Skip to content

Commit

Permalink
cleaning things
Browse files Browse the repository at this point in the history
  • Loading branch information
abernier committed Jul 21, 2024
1 parent e1a7245 commit ee8c5fd
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 47 deletions.
1 change: 0 additions & 1 deletion apps/aquarium/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react'
import { useLayoutEffect, useEffect, useRef } from 'react'
import { Canvas, useFrame } from '@react-three/fiber'
import { useMask, useGLTF, useAnimations, Float, Instance, Instances, CameraControls } from '@react-three/drei'
Expand Down
13 changes: 2 additions & 11 deletions apps/aquarium/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig(async ({ command, mode }) => {
const plugins = [react()]

if (process.env.CHEESY_CANVAS) {
const cheesyCanvas = (await import('@pmndrs/examples/vite-plugin-cheesy-canvas')).default
plugins.push(cheesyCanvas())
}

return {
plugins
}
export default defineConfig({
plugins: [react()]
})
5 changes: 3 additions & 2 deletions apps/baking-soft-shadows/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as THREE from 'three'
import { useLayoutEffect, useEffect } from 'react'
import { Canvas, useThree } from '@react-three/fiber'
import { useLayoutEffect } from 'react'
import { Canvas } from '@react-three/fiber'
import { Center, AccumulativeShadows, RandomizedLight, OrbitControls, Environment, useGLTF } from '@react-three/drei'
import { FlakesTexture } from 'three-stdlib'

import suziModel from './suzi-model.gltf?url'

//
export default function App() {
return (
<Canvas shadows camera={{ position: [4, 2.5, 8], fov: 35 }}>
Expand Down
5 changes: 3 additions & 2 deletions apps/basic-demo/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useRef, useState, useEffect } from 'react'
import { Canvas, useFrame, useThree } from '@react-three/fiber'
import { useRef, useState } from 'react'
import { Canvas, useFrame } from '@react-three/fiber'
import { OrbitControls } from '@react-three/drei'

//
function Box(props) {
// This reference gives us direct access to the THREE.Mesh object
const ref = useRef()
Expand Down
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions packages/examples/bin/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env node

import { spawn } from "node:child_process";
import minimist from "minimist";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";

var argv = minimist(process.argv.slice(2));
// console.log("argv=", argv);

const name = argv._[0];
if (!name) {
console.error("Please provide the app name as the first argument.");
process.exit(1);
}

const __filename = fileURLToPath(import.meta.url); // Converts the URL to a file path
const __dirname = dirname(__filename); // Gets the directory name
const viteConfigPath = resolve(__dirname, "../src/vite.config.ts");
// console.log("viteConfigPath=", viteConfigPath);

const cmd = spawn(
"npx",
["vite", "build", "--config", viteConfigPath, "--base", `/examples/${name}`],
{
stdio: "inherit",
env: process.env,
}
);

cmd.on("exit", (code) => {
if (code !== 0) {
console.error("Build failed with error");
process.exit(1);
}

console.log("Build completed successfully.");
});
21 changes: 0 additions & 21 deletions packages/examples/bin/build.sh

This file was deleted.

9 changes: 4 additions & 5 deletions packages/examples/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
{
"name": "@pmndrs/examples",
"private": true,
"type": "module",
"version": "0.0.0",
"version": "0.0.1",
"exports": {
"./CheesyCanvas": "./src/CheesyCanvas.jsx",
"./vite-plugin-cheesy-canvas": "./src/vite-plugin-cheesy-canvas.js"
"./CheesyCanvas": "./src/CheesyCanvas.jsx"
},
"bin": {
"vite-build": "./bin/build.sh"
"vite-build": "./bin/build.mjs"
},
"dependencies": {
"@babel/parser": "^7.24.8",
"@babel/traverse": "^7.24.8",
"@babel/types": "^7.24.9",
"ast-types": "^0.16.1",
"minimist": "^1.2.8",
"recast": "^0.23.9"
}
}
2 changes: 1 addition & 1 deletion packages/examples/src/CheesyCanvas.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function ({ children, ...props }) {

const props2 = {
...props,
style: { border: "2px solid red", ...props.style },
// style: { border: "2px solid red", ...props.style },
};

const sayCheeseParam = new URLSearchParams(window.location.search).has(
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/vite-plugin-cheesy-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function vitePluginCheesyCanvas() {

// If we found a Canvas import just before, we want to add:
// ```
// import CheesyCanvas from './CheesyCanvas'; // (I)
// import CheesyCanvas from '@pmndrs/examples/CheesyCanvas'; // (I)
// const Canvas = CheesyCanvas; // (II)
// ```

Expand Down
8 changes: 8 additions & 0 deletions packages/examples/src/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

import cheesyCanvas from "./vite-plugin-cheesy-canvas";

export default defineConfig({
plugins: [react(), cheesyCanvas()],
});
2 changes: 1 addition & 1 deletion test/e2e/snapshot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function getDemoNames() {
});
}
// const demoNames = getDemoNames();
const demoNames = ["baking-soft-shadows", "basic-demo"];
const demoNames = ["aquarium", "baking-soft-shadows", "basic-demo"];
console.log("demoNames", demoNames);

demoNames.forEach((demoName) => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ee8c5fd

Please sign in to comment.