diff --git a/template/package.json b/template/package.json new file mode 100644 index 0000000..c5b7d2c --- /dev/null +++ b/template/package.json @@ -0,0 +1,20 @@ +{ + "name": "threejs-template", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build" + }, + "devDependencies": { + "@vitejs/plugin-react": "4.1", + "vite": "^4.5.0" + }, + "dependencies": { + "react": "18.2", + "react-dom": "18.2", + "@react-three/fiber": "^8.15.8", + "three": "^0.158.0" + } +} \ No newline at end of file diff --git a/template/public/bangers-v20-latin-regular.woff b/template/public/bangers-v20-latin-regular.woff new file mode 100644 index 0000000..a84dbc4 Binary files /dev/null and b/template/public/bangers-v20-latin-regular.woff differ diff --git a/template/src/Experience.jsx b/template/src/Experience.jsx new file mode 100644 index 0000000..b5bebc1 --- /dev/null +++ b/template/src/Experience.jsx @@ -0,0 +1,28 @@ +import { useThree, extend } from '@react-three/fiber' +import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js' + +extend({ OrbitControls }) + +export default function Experience() +{ + const { camera, gl } = useThree() + + return <> + + + + + + + + + + + + + + + + + +} \ No newline at end of file diff --git a/template/src/index.html b/template/src/index.html new file mode 100644 index 0000000..4510fa6 --- /dev/null +++ b/template/src/index.html @@ -0,0 +1,12 @@ + + + + + + + R3F + + +
+ + \ No newline at end of file diff --git a/template/src/index.jsx b/template/src/index.jsx new file mode 100644 index 0000000..2977d5b --- /dev/null +++ b/template/src/index.jsx @@ -0,0 +1,19 @@ +import './style.css' +import ReactDOM from 'react-dom/client' +import { Canvas } from '@react-three/fiber' +import Experience from './Experience.jsx' + +const root = ReactDOM.createRoot(document.querySelector('#root')) + +root.render( + + + +) \ No newline at end of file diff --git a/template/src/style.css b/template/src/style.css new file mode 100644 index 0000000..19cd416 --- /dev/null +++ b/template/src/style.css @@ -0,0 +1,11 @@ +html, +body, +#root +{ + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: ivory; +} \ No newline at end of file diff --git a/template/vite.config.js b/template/vite.config.js new file mode 100644 index 0000000..5b278ef --- /dev/null +++ b/template/vite.config.js @@ -0,0 +1,39 @@ +import react from '@vitejs/plugin-react' +import { transformWithEsbuild } from 'vite' + +export default { + root: 'src/', + publicDir: '../public/', + base: './', + plugins: + [ + // React support + react(), + + // .js file support as if it was JSX + { + name: 'load+transform-js-files-as-jsx', + async transform(code, id) + { + if (!id.match(/src\/.*\.js$/)) + return null + + return transformWithEsbuild(code, id, { + loader: 'jsx', + jsx: 'automatic', + }); + }, + }, + ], + server: + { + host: true, // Open to local network and display URL + open: !('SANDBOX_URL' in process.env || 'CODESANDBOX_HOST' in process.env) // Open if it's not a CodeSandbox + }, + build: + { + outDir: '../dist', // Output in the dist/ folder + emptyOutDir: true, // Empty the folder first + sourcemap: true // Add sourcemap + }, +} \ No newline at end of file