├── .gitignore ├── 03-basic-scene ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 05-transforms-objects ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 06-animations ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 07-cameras ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 08-fullscreen-and-resizing ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 09-geometries ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 10-debug-ui ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 11-textures ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ ├── robots.txt │ └── textures │ │ ├── checkerboard-1024x1024.png │ │ ├── checkerboard-8x8.png │ │ ├── door │ │ ├── alpha.jpg │ │ ├── ambientOcclusion.jpg │ │ ├── color.jpg │ │ ├── height.jpg │ │ ├── metalness.jpg │ │ ├── normal.jpg │ │ └── roughness.jpg │ │ └── minecraft.png ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 12-materials ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ ├── robots.txt │ └── textures │ │ ├── door │ │ ├── alpha.jpg │ │ ├── ambientOcclusion.jpg │ │ ├── color.jpg │ │ ├── height.jpg │ │ ├── metalness.jpg │ │ ├── normal.jpg │ │ └── roughness.jpg │ │ ├── environmentMaps │ │ ├── 0 │ │ │ ├── nx.jpg │ │ │ ├── ny.jpg │ │ │ ├── nz.jpg │ │ │ ├── px.jpg │ │ │ ├── py.jpg │ │ │ └── pz.jpg │ │ ├── 1 │ │ │ ├── nx.jpg │ │ │ ├── ny.jpg │ │ │ ├── nz.jpg │ │ │ ├── px.jpg │ │ │ ├── py.jpg │ │ │ └── pz.jpg │ │ ├── 2 │ │ │ ├── nx.jpg │ │ │ ├── ny.jpg │ │ │ ├── nz.jpg │ │ │ ├── px.jpg │ │ │ ├── py.jpg │ │ │ └── pz.jpg │ │ └── 3 │ │ │ ├── nx.jpg │ │ │ ├── ny.jpg │ │ │ ├── nz.jpg │ │ │ ├── px.jpg │ │ │ ├── py.jpg │ │ │ └── pz.jpg │ │ ├── gradients │ │ ├── 3.jpg │ │ └── 5.jpg │ │ └── matcaps │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── 6.png │ │ ├── 7.png │ │ └── 8.png ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 13-3d-text ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── fonts │ │ ├── LICENSE │ │ └── helvetiker_regular.typeface.json │ ├── index.html │ ├── manifest.json │ ├── robots.txt │ └── textures │ │ └── matcaps │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── 6.png │ │ ├── 7.png │ │ └── 8.png ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 14-lights ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 15-shadows ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ ├── robots.txt │ └── textures │ │ ├── bakedShadow.jpg │ │ └── simpleShadow.jpg ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 16-haunted-house ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ ├── robots.txt │ └── textures │ │ ├── bricks │ │ ├── ambientOcclusion.jpg │ │ ├── color.jpg │ │ ├── normal.jpg │ │ └── roughness.jpg │ │ ├── door │ │ ├── alpha.jpg │ │ ├── ambientOcclusion.jpg │ │ ├── color.jpg │ │ ├── height.jpg │ │ ├── metalness.jpg │ │ ├── normal.jpg │ │ └── roughness.jpg │ │ └── grass │ │ ├── ambientOcclusion.jpg │ │ ├── color.jpg │ │ ├── normal.jpg │ │ └── roughness.jpg ├── src │ ├── App.tsx │ ├── components │ │ ├── Bushes.tsx │ │ ├── Door.tsx │ │ ├── Floor.tsx │ │ ├── Ghosts.tsx │ │ ├── Graves.tsx │ │ ├── Lights.tsx │ │ ├── Roof.tsx │ │ └── Walls.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 17-particles ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ ├── robots.txt │ └── textures │ │ └── particles │ │ ├── 1.png │ │ ├── 10.png │ │ ├── 11.png │ │ ├── 12.png │ │ ├── 13.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── 6.png │ │ ├── 7.png │ │ ├── 8.png │ │ └── 9.png ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 18-galaxy-generator ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 19-raycaster ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── 20-physics ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | **/node_modules/** 5 | **/.pnp/** 6 | .pnp.js 7 | 8 | # testing 9 | **/coverage/** 10 | 11 | # production 12 | **/build/** 13 | 14 | # misc 15 | **/.DS_Store 16 | .DS_Store 17 | **/.env.local 18 | .env.local 19 | **/.env.development.local 20 | .env.development.local 21 | **/.env.test.local 22 | .env.test.local 23 | **/.env.production.local 24 | .env.production.local 25 | 26 | npm-debug.log* 27 | yarn-debug.log* 28 | yarn-error.log* 29 | 30 | .vscode/ 31 | **/.vscode/** 32 | **/.eslintcache 33 | .eslintcache 34 | 35 | .prettierrc 36 | **/.prettierrc/** -------------------------------------------------------------------------------- /03-basic-scene/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /03-basic-scene/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.9", 7 | "@testing-library/react": "^11.2.3", 8 | "@testing-library/user-event": "^12.6.0", 9 | "@types/jest": "^26.0.20", 10 | "@types/node": "^12.19.14", 11 | "@types/react": "^16.14.2", 12 | "@types/react-dom": "^16.9.10", 13 | "react": "^17.0.1", 14 | "react-dom": "^17.0.1", 15 | "react-scripts": "4.0.1", 16 | "react-three-fiber": "^5.3.14", 17 | "three": "^0.124.0", 18 | "typescript": "^4.1.3", 19 | "web-vitals": "^0.2.4" 20 | }, 21 | "scripts": { 22 | "start": "react-scripts start", 23 | "build": "react-scripts build", 24 | "test": "react-scripts test", 25 | "eject": "react-scripts eject" 26 | }, 27 | "eslintConfig": { 28 | "extends": [ 29 | "react-app", 30 | "react-app/jest" 31 | ] 32 | }, 33 | "browserslist": { 34 | "production": [ 35 | ">0.2%", 36 | "not dead", 37 | "not op_mini all" 38 | ], 39 | "development": [ 40 | "last 1 chrome version", 41 | "last 1 firefox version", 42 | "last 1 safari version" 43 | ] 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /03-basic-scene/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/03-basic-scene/public/favicon.ico -------------------------------------------------------------------------------- /03-basic-scene/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 03 - Basic Scene - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /03-basic-scene/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /03-basic-scene/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /03-basic-scene/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Canvas } from 'react-three-fiber'; 3 | 4 | const sizes = { 5 | width: 800, 6 | height: 600, 7 | }; 8 | 9 | const Box: React.FC = () => { 10 | return ( 11 | 12 | 13 | 14 | 15 | ); 16 | }; 17 | 18 | function App() { 19 | return ( 20 | 28 | 29 | 30 | ); 31 | } 32 | 33 | export default App; 34 | -------------------------------------------------------------------------------- /03-basic-scene/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 3 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /03-basic-scene/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /03-basic-scene/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /03-basic-scene/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /03-basic-scene/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /03-basic-scene/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /05-transforms-objects/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.9", 7 | "@testing-library/react": "^11.2.3", 8 | "@testing-library/user-event": "^12.6.0", 9 | "@types/jest": "^26.0.20", 10 | "@types/node": "^12.19.14", 11 | "@types/react": "^16.14.2", 12 | "@types/react-dom": "^16.9.10", 13 | "react": "^17.0.1", 14 | "react-dom": "^17.0.1", 15 | "react-scripts": "4.0.1", 16 | "react-three-fiber": "^5.3.14", 17 | "three": "^0.124.0", 18 | "typescript": "^4.1.3", 19 | "web-vitals": "^0.2.4" 20 | }, 21 | "scripts": { 22 | "start": "react-scripts start", 23 | "build": "react-scripts build", 24 | "test": "react-scripts test", 25 | "eject": "react-scripts eject" 26 | }, 27 | "eslintConfig": { 28 | "extends": [ 29 | "react-app", 30 | "react-app/jest" 31 | ] 32 | }, 33 | "browserslist": { 34 | "production": [ 35 | ">0.2%", 36 | "not dead", 37 | "not op_mini all" 38 | ], 39 | "development": [ 40 | "last 1 chrome version", 41 | "last 1 firefox version", 42 | "last 1 safari version" 43 | ] 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /05-transforms-objects/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/05-transforms-objects/public/favicon.ico -------------------------------------------------------------------------------- /05-transforms-objects/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 05 - Transforms Objects - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /05-transforms-objects/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /05-transforms-objects/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /05-transforms-objects/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Canvas, MeshBasicMaterialProps } from 'react-three-fiber'; 3 | 4 | const sizes = { 5 | width: 800, 6 | height: 600, 7 | }; 8 | 9 | interface CubeProps { 10 | posX: number; 11 | } 12 | const Cube: React.FC & CubeProps> = ({ 13 | posX, 14 | color, 15 | }) => { 16 | return ( 17 | 18 | 19 | 20 | 21 | ); 22 | }; 23 | 24 | const Cubes: React.FC = () => { 25 | return ( 26 | 27 | 28 | 29 | 30 | 31 | ); 32 | }; 33 | 34 | const App: React.FC = () => { 35 | return ( 36 | 45 | 46 | 47 | ); 48 | }; 49 | 50 | export default App; 51 | -------------------------------------------------------------------------------- /05-transforms-objects/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 3 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /05-transforms-objects/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /05-transforms-objects/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /05-transforms-objects/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /05-transforms-objects/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /05-transforms-objects/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /06-animations/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /06-animations/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-spring/three": "^9.0.0-rc.3", 7 | "@testing-library/jest-dom": "^5.11.9", 8 | "@testing-library/react": "^11.2.3", 9 | "@testing-library/user-event": "^12.6.0", 10 | "@types/jest": "^26.0.20", 11 | "@types/node": "^12.19.14", 12 | "@types/react": "^16.14.2", 13 | "@types/react-dom": "^16.9.10", 14 | "react": "^17.0.1", 15 | "react-dom": "^17.0.1", 16 | "react-scripts": "4.0.1", 17 | "react-three-fiber": "^5.3.14", 18 | "three": "^0.124.0", 19 | "typescript": "^4.1.3", 20 | "web-vitals": "^0.2.4" 21 | }, 22 | "scripts": { 23 | "start": "react-scripts start", 24 | "build": "react-scripts build", 25 | "test": "react-scripts test", 26 | "eject": "react-scripts eject" 27 | }, 28 | "eslintConfig": { 29 | "extends": [ 30 | "react-app", 31 | "react-app/jest" 32 | ] 33 | }, 34 | "browserslist": { 35 | "production": [ 36 | ">0.2%", 37 | "not dead", 38 | "not op_mini all" 39 | ], 40 | "development": [ 41 | "last 1 chrome version", 42 | "last 1 firefox version", 43 | "last 1 safari version" 44 | ] 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /06-animations/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/06-animations/public/favicon.ico -------------------------------------------------------------------------------- /06-animations/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 05 - Transforms Objects - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /06-animations/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /06-animations/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /06-animations/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Canvas, MeshBasicMaterialProps } from 'react-three-fiber'; 3 | import { a, useSpring } from '@react-spring/three'; 4 | 5 | const sizes = { 6 | width: 800, 7 | height: 600, 8 | }; 9 | 10 | const Cube: React.FC> = ({ color }) => { 11 | const { position } = useSpring({ 12 | loop: { 13 | reverse: true, 14 | }, 15 | from: { 16 | position: [0, 0, 0], 17 | }, 18 | to: { 19 | position: [2, 0, 0], 20 | }, 21 | }); 22 | 23 | return ( 24 | //@ts-ignore - Vector3 type isn't supported by @react-spring/three yet... 25 | 26 | 27 | 28 | 29 | ); 30 | }; 31 | 32 | const App: React.FC = () => { 33 | return ( 34 | 43 | 44 | 45 | ); 46 | }; 47 | 48 | export default App; 49 | -------------------------------------------------------------------------------- /06-animations/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 3 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /06-animations/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /06-animations/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /06-animations/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /06-animations/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /06-animations/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /07-cameras/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /07-cameras/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.9", 7 | "@testing-library/react": "^11.2.3", 8 | "@testing-library/user-event": "^12.6.0", 9 | "@types/jest": "^26.0.20", 10 | "@types/node": "^12.19.14", 11 | "@types/react": "^16.14.2", 12 | "@types/react-dom": "^16.9.10", 13 | "drei": "^2.2.17", 14 | "react": "^17.0.1", 15 | "react-dom": "^17.0.1", 16 | "react-scripts": "4.0.1", 17 | "react-three-fiber": "^5.3.14", 18 | "three": "^0.124.0", 19 | "typescript": "^4.1.3", 20 | "web-vitals": "^0.2.4" 21 | }, 22 | "scripts": { 23 | "start": "react-scripts start", 24 | "build": "react-scripts build", 25 | "test": "react-scripts test", 26 | "eject": "react-scripts eject" 27 | }, 28 | "eslintConfig": { 29 | "extends": [ 30 | "react-app", 31 | "react-app/jest" 32 | ] 33 | }, 34 | "browserslist": { 35 | "production": [ 36 | ">0.2%", 37 | "not dead", 38 | "not op_mini all" 39 | ], 40 | "development": [ 41 | "last 1 chrome version", 42 | "last 1 firefox version", 43 | "last 1 safari version" 44 | ] 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /07-cameras/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/07-cameras/public/favicon.ico -------------------------------------------------------------------------------- /07-cameras/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 07 - Cameras - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /07-cameras/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /07-cameras/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /07-cameras/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Canvas, MeshBasicMaterialProps } from 'react-three-fiber'; 3 | import { OrbitControls } from 'drei'; 4 | 5 | const sizes = { 6 | width: 800, 7 | height: 600, 8 | }; 9 | 10 | const Cube: React.FC> = ({ color }) => { 11 | return ( 12 | 13 | 14 | 15 | 16 | ); 17 | }; 18 | 19 | const App: React.FC = () => { 20 | return ( 21 | 30 | 31 | 32 | 33 | ); 34 | }; 35 | 36 | export default App; 37 | -------------------------------------------------------------------------------- /07-cameras/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /07-cameras/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import "./index.css"; 4 | import App from "./App"; 5 | import reportWebVitals from "./reportWebVitals"; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById("root") 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /07-cameras/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /07-cameras/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from "web-vitals"; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /07-cameras/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import "@testing-library/jest-dom"; 6 | -------------------------------------------------------------------------------- /07-cameras/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /08-fullscreen-and-resizing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.9", 7 | "@testing-library/react": "^11.2.3", 8 | "@testing-library/user-event": "^12.6.0", 9 | "@types/jest": "^26.0.20", 10 | "@types/node": "^12.19.14", 11 | "@types/react": "^16.14.2", 12 | "@types/react-dom": "^16.9.10", 13 | "drei": "^2.2.17", 14 | "react": "^17.0.1", 15 | "react-dom": "^17.0.1", 16 | "react-scripts": "4.0.1", 17 | "react-three-fiber": "^5.3.14", 18 | "three": "^0.124.0", 19 | "typescript": "^4.1.3", 20 | "web-vitals": "^0.2.4" 21 | }, 22 | "scripts": { 23 | "start": "react-scripts start", 24 | "build": "react-scripts build", 25 | "test": "react-scripts test", 26 | "eject": "react-scripts eject" 27 | }, 28 | "eslintConfig": { 29 | "extends": [ 30 | "react-app", 31 | "react-app/jest" 32 | ] 33 | }, 34 | "browserslist": { 35 | "production": [ 36 | ">0.2%", 37 | "not dead", 38 | "not op_mini all" 39 | ], 40 | "development": [ 41 | "last 1 chrome version", 42 | "last 1 firefox version", 43 | "last 1 safari version" 44 | ] 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /08-fullscreen-and-resizing/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/08-fullscreen-and-resizing/public/favicon.ico -------------------------------------------------------------------------------- /08-fullscreen-and-resizing/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 07 - Cameras - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /08-fullscreen-and-resizing/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /08-fullscreen-and-resizing/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /08-fullscreen-and-resizing/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Canvas, MeshBasicMaterialProps } from 'react-three-fiber'; 3 | import { OrbitControls } from 'drei'; 4 | 5 | const Cube: React.FC> = ({ color }) => { 6 | return ( 7 | 8 | 9 | 10 | 11 | ); 12 | }; 13 | 14 | const App: React.FC = () => { 15 | const [isFullscreen, setIsFullscreen] = React.useState(false); 16 | const canvasRef = React.useRef(null); 17 | React.useEffect(() => { 18 | if (canvasRef.current && document) { 19 | if (isFullscreen) { 20 | canvasRef.current?.requestFullscreen(); 21 | } else { 22 | if (document.exitFullscreen) { 23 | document?.exitFullscreen(); 24 | } 25 | } 26 | } 27 | }, [isFullscreen]); 28 | return ( 29 | setIsFullscreen(!isFullscreen)} 31 | colorManagement 32 | onCreated={(state) => { 33 | canvasRef.current = state.gl.domElement; 34 | }} 35 | camera={{ 36 | position: [0, 0, 3], 37 | fov: 75, 38 | }} 39 | pixelRatio={Math.min(window.devicePixelRatio, 2)} 40 | > 41 | 42 | 43 | 44 | 45 | ); 46 | }; 47 | 48 | export default App; 49 | -------------------------------------------------------------------------------- /08-fullscreen-and-resizing/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /08-fullscreen-and-resizing/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /08-fullscreen-and-resizing/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /08-fullscreen-and-resizing/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /08-fullscreen-and-resizing/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /08-fullscreen-and-resizing/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /09-geometries/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /09-geometries/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.9", 7 | "@testing-library/react": "^11.2.3", 8 | "@testing-library/user-event": "^12.6.0", 9 | "@types/jest": "^26.0.20", 10 | "@types/node": "^12.19.14", 11 | "@types/react": "^16.14.2", 12 | "@types/react-dom": "^16.9.10", 13 | "drei": "^2.2.17", 14 | "react": "^17.0.1", 15 | "react-dom": "^17.0.1", 16 | "react-scripts": "4.0.1", 17 | "react-three-fiber": "^5.3.14", 18 | "three": "^0.124.0", 19 | "typescript": "^4.1.3", 20 | "web-vitals": "^0.2.4" 21 | }, 22 | "scripts": { 23 | "start": "react-scripts start", 24 | "build": "react-scripts build", 25 | "test": "react-scripts test", 26 | "eject": "react-scripts eject" 27 | }, 28 | "eslintConfig": { 29 | "extends": [ 30 | "react-app", 31 | "react-app/jest" 32 | ] 33 | }, 34 | "browserslist": { 35 | "production": [ 36 | ">0.2%", 37 | "not dead", 38 | "not op_mini all" 39 | ], 40 | "development": [ 41 | "last 1 chrome version", 42 | "last 1 firefox version", 43 | "last 1 safari version" 44 | ] 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /09-geometries/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/09-geometries/public/favicon.ico -------------------------------------------------------------------------------- /09-geometries/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 09 - Geometries - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /09-geometries/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /09-geometries/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /09-geometries/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Canvas } from 'react-three-fiber'; 3 | import { OrbitControls } from 'drei'; 4 | 5 | const CustomBufferGeometry: React.FC = () => { 6 | const count = 100; 7 | const positionsArray = React.useMemo(() => { 8 | return new Float32Array(count * 3 * 3).map(() => (Math.random() - 0.5) * 4); 9 | }, [count]); 10 | return ( 11 | 12 | 13 | 19 | 20 | 21 | 22 | ); 23 | }; 24 | 25 | const App: React.FC = () => { 26 | return ( 27 | 34 | 35 | 36 | 37 | 38 | ); 39 | }; 40 | 41 | export default App; 42 | -------------------------------------------------------------------------------- /09-geometries/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /09-geometries/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /09-geometries/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /09-geometries/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /09-geometries/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /09-geometries/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /10-debug-ui/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /10-debug-ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-spring/three": "^9.0.0-rc.3", 7 | "@testing-library/jest-dom": "^5.11.9", 8 | "@testing-library/react": "^11.2.3", 9 | "@testing-library/user-event": "^12.6.0", 10 | "@types/jest": "^26.0.20", 11 | "@types/node": "^12.19.14", 12 | "@types/react": "^16.14.2", 13 | "@types/react-dom": "^16.9.10", 14 | "drei": "^2.2.17", 15 | "react": "^17.0.1", 16 | "react-dom": "^17.0.1", 17 | "react-scripts": "4.0.1", 18 | "react-three-fiber": "^5.3.14", 19 | "three": "^0.124.0", 20 | "tweakpane": "^1.5.7", 21 | "typescript": "^4.1.3", 22 | "use-tweaks": "^0.3.1", 23 | "web-vitals": "^0.2.4" 24 | }, 25 | "scripts": { 26 | "start": "react-scripts start", 27 | "build": "react-scripts build", 28 | "test": "react-scripts test", 29 | "eject": "react-scripts eject" 30 | }, 31 | "eslintConfig": { 32 | "extends": [ 33 | "react-app", 34 | "react-app/jest" 35 | ] 36 | }, 37 | "browserslist": { 38 | "production": [ 39 | ">0.2%", 40 | "not dead", 41 | "not op_mini all" 42 | ], 43 | "development": [ 44 | "last 1 chrome version", 45 | "last 1 firefox version", 46 | "last 1 safari version" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /10-debug-ui/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/10-debug-ui/public/favicon.ico -------------------------------------------------------------------------------- /10-debug-ui/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 10 - Debug-UI - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /10-debug-ui/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /10-debug-ui/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /10-debug-ui/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Canvas } from 'react-three-fiber'; 3 | import { OrbitControls } from 'drei'; 4 | import { a, useSpring } from '@react-spring/three'; 5 | import { useTweaks, makeButton, makeSeparator } from 'use-tweaks'; 6 | 7 | const Cube: React.FC = () => { 8 | const [rotationY, setRotationY] = React.useState(0); 9 | const CUBE_GROUP = 'Cube'; 10 | 11 | const { x, y, wireframe, visibility, color: c } = useTweaks(CUBE_GROUP, { 12 | x: { 13 | value: 0, 14 | min: -3, 15 | max: 3, 16 | }, 17 | y: { 18 | value: 0, 19 | min: -3, 20 | max: 3, 21 | }, 22 | color: '#ff0000', 23 | wireframe: false, 24 | visibility: true, 25 | ...makeSeparator(), 26 | ...makeButton('Spin', () => setRotationY((y) => y + Math.PI * 2)), 27 | }); 28 | 29 | const { rotation } = useSpring({ 30 | to: { 31 | rotation: rotationY, 32 | }, 33 | config: { mass: 5, tension: 500, friction: 80 }, 34 | }); 35 | 36 | return ( 37 | 38 | 39 | 45 | 46 | ); 47 | }; 48 | 49 | const App: React.FC = () => { 50 | return ( 51 | 57 | 58 | 59 | 60 | 61 | ); 62 | }; 63 | 64 | export default App; 65 | -------------------------------------------------------------------------------- /10-debug-ui/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /10-debug-ui/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /10-debug-ui/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /10-debug-ui/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /10-debug-ui/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /10-debug-ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /11-textures/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /11-textures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-spring/three": "^9.0.0-rc.3", 7 | "@react-three/drei": "^2.2.19", 8 | "@testing-library/jest-dom": "^5.11.9", 9 | "@testing-library/react": "^11.2.3", 10 | "@testing-library/user-event": "^12.6.0", 11 | "@types/jest": "^26.0.20", 12 | "@types/node": "^12.19.14", 13 | "@types/react": "^16.14.2", 14 | "@types/react-dom": "^16.9.10", 15 | "drei": "^2.2.17", 16 | "react": "^17.0.1", 17 | "react-dom": "^17.0.1", 18 | "react-scripts": "4.0.1", 19 | "react-three-fiber": "^5.3.14", 20 | "react-three-gui": "^0.4.2", 21 | "three": "^0.124.0", 22 | "tweakpane": "^1.5.7", 23 | "typescript": "^4.1.3", 24 | "use-tweaks": "^0.3.1", 25 | "web-vitals": "^0.2.4" 26 | }, 27 | "scripts": { 28 | "start": "react-scripts start", 29 | "build": "react-scripts build", 30 | "test": "react-scripts test", 31 | "eject": "react-scripts eject" 32 | }, 33 | "eslintConfig": { 34 | "extends": [ 35 | "react-app", 36 | "react-app/jest" 37 | ] 38 | }, 39 | "browserslist": { 40 | "production": [ 41 | ">0.2%", 42 | "not dead", 43 | "not op_mini all" 44 | ], 45 | "development": [ 46 | "last 1 chrome version", 47 | "last 1 firefox version", 48 | "last 1 safari version" 49 | ] 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /11-textures/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/11-textures/public/favicon.ico -------------------------------------------------------------------------------- /11-textures/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 11 - Textures - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /11-textures/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /11-textures/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /11-textures/public/textures/checkerboard-1024x1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/11-textures/public/textures/checkerboard-1024x1024.png -------------------------------------------------------------------------------- /11-textures/public/textures/checkerboard-8x8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/11-textures/public/textures/checkerboard-8x8.png -------------------------------------------------------------------------------- /11-textures/public/textures/door/alpha.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/11-textures/public/textures/door/alpha.jpg -------------------------------------------------------------------------------- /11-textures/public/textures/door/ambientOcclusion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/11-textures/public/textures/door/ambientOcclusion.jpg -------------------------------------------------------------------------------- /11-textures/public/textures/door/color.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/11-textures/public/textures/door/color.jpg -------------------------------------------------------------------------------- /11-textures/public/textures/door/height.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/11-textures/public/textures/door/height.jpg -------------------------------------------------------------------------------- /11-textures/public/textures/door/metalness.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/11-textures/public/textures/door/metalness.jpg -------------------------------------------------------------------------------- /11-textures/public/textures/door/normal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/11-textures/public/textures/door/normal.jpg -------------------------------------------------------------------------------- /11-textures/public/textures/door/roughness.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/11-textures/public/textures/door/roughness.jpg -------------------------------------------------------------------------------- /11-textures/public/textures/minecraft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/11-textures/public/textures/minecraft.png -------------------------------------------------------------------------------- /11-textures/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React, { Suspense } from 'react'; 2 | import { Canvas } from 'react-three-fiber'; 3 | import * as THREE from 'three'; 4 | import { OrbitControls } from 'drei'; 5 | import { a, useSpring } from '@react-spring/three'; 6 | import { useTweaks, makeButton } from 'use-tweaks'; 7 | 8 | const Cube: React.FC = () => { 9 | const [rotationY, setRotationY] = React.useState(0); 10 | const CUBE_GROUP = 'Cube'; 11 | 12 | const [texture] = React.useState(() => { 13 | const loader = new THREE.TextureLoader(); 14 | const t = loader.load('/textures/minecraft.png'); 15 | t.generateMipmaps = false; 16 | t.minFilter = THREE.NearestFilter; 17 | t.magFilter = THREE.NearestFilter; 18 | 19 | return t; 20 | }); 21 | 22 | useTweaks(CUBE_GROUP, { 23 | ...makeButton('Spin', () => setRotationY((y) => y + Math.PI * 2)), 24 | }); 25 | 26 | const { rotation } = useSpring({ 27 | to: { 28 | rotation: rotationY, 29 | }, 30 | config: { mass: 5, tension: 500, friction: 80 }, 31 | }); 32 | 33 | return ( 34 | 35 | 36 | 37 | 38 | ); 39 | }; 40 | 41 | const App: React.FC = () => { 42 | return ( 43 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | ); 60 | }; 61 | 62 | export default App; 63 | -------------------------------------------------------------------------------- /11-textures/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /11-textures/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /11-textures/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /11-textures/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /11-textures/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /11-textures/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /12-materials/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /12-materials/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-spring/three": "^9.0.0-rc.3", 7 | "@react-three/drei": "^2.2.21", 8 | "@testing-library/jest-dom": "^5.11.9", 9 | "@testing-library/react": "^11.2.3", 10 | "@testing-library/user-event": "^12.6.0", 11 | "@types/jest": "^26.0.20", 12 | "@types/node": "^12.19.14", 13 | "@types/react": "^16.14.2", 14 | "@types/react-dom": "^16.9.10", 15 | "react": "^17.0.1", 16 | "react-dom": "^17.0.1", 17 | "react-scripts": "4.0.1", 18 | "react-three-fiber": "^5.3.17", 19 | "three": "^0.124.0", 20 | "tweakpane": "^1.5.7", 21 | "typescript": "^4.1.3", 22 | "use-tweaks": "^0.3.1", 23 | "web-vitals": "^0.2.4" 24 | }, 25 | "scripts": { 26 | "start": "react-scripts start", 27 | "build": "react-scripts build", 28 | "test": "react-scripts test", 29 | "eject": "react-scripts eject" 30 | }, 31 | "eslintConfig": { 32 | "extends": [ 33 | "react-app", 34 | "react-app/jest" 35 | ] 36 | }, 37 | "browserslist": { 38 | "production": [ 39 | ">0.2%", 40 | "not dead", 41 | "not op_mini all" 42 | ], 43 | "development": [ 44 | "last 1 chrome version", 45 | "last 1 firefox version", 46 | "last 1 safari version" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /12-materials/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/favicon.ico -------------------------------------------------------------------------------- /12-materials/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 12 - Materials - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /12-materials/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /12-materials/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /12-materials/public/textures/door/alpha.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/door/alpha.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/door/ambientOcclusion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/door/ambientOcclusion.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/door/color.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/door/color.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/door/height.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/door/height.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/door/metalness.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/door/metalness.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/door/normal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/door/normal.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/door/roughness.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/door/roughness.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/0/nx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/0/nx.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/0/ny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/0/ny.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/0/nz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/0/nz.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/0/px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/0/px.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/0/py.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/0/py.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/0/pz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/0/pz.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/1/nx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/1/nx.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/1/ny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/1/ny.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/1/nz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/1/nz.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/1/px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/1/px.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/1/py.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/1/py.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/1/pz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/1/pz.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/2/nx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/2/nx.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/2/ny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/2/ny.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/2/nz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/2/nz.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/2/px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/2/px.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/2/py.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/2/py.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/2/pz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/2/pz.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/3/nx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/3/nx.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/3/ny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/3/ny.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/3/nz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/3/nz.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/3/px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/3/px.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/3/py.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/3/py.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/environmentMaps/3/pz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/environmentMaps/3/pz.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/gradients/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/gradients/3.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/gradients/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/gradients/5.jpg -------------------------------------------------------------------------------- /12-materials/public/textures/matcaps/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/matcaps/1.png -------------------------------------------------------------------------------- /12-materials/public/textures/matcaps/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/matcaps/2.png -------------------------------------------------------------------------------- /12-materials/public/textures/matcaps/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/matcaps/3.png -------------------------------------------------------------------------------- /12-materials/public/textures/matcaps/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/matcaps/4.png -------------------------------------------------------------------------------- /12-materials/public/textures/matcaps/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/matcaps/5.png -------------------------------------------------------------------------------- /12-materials/public/textures/matcaps/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/matcaps/6.png -------------------------------------------------------------------------------- /12-materials/public/textures/matcaps/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/matcaps/7.png -------------------------------------------------------------------------------- /12-materials/public/textures/matcaps/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/12-materials/public/textures/matcaps/8.png -------------------------------------------------------------------------------- /12-materials/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /12-materials/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /12-materials/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /12-materials/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /12-materials/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /12-materials/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /13-3d-text/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /13-3d-text/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-spring/three": "^9.0.0-rc.3", 7 | "@react-three/drei": "^2.2.19", 8 | "@testing-library/jest-dom": "^5.11.9", 9 | "@testing-library/react": "^11.2.3", 10 | "@testing-library/user-event": "^12.6.0", 11 | "@types/jest": "^26.0.20", 12 | "@types/node": "^12.19.14", 13 | "@types/react": "^16.14.2", 14 | "@types/react-dom": "^16.9.10", 15 | "react": "^17.0.1", 16 | "react-dom": "^17.0.1", 17 | "react-scripts": "4.0.1", 18 | "react-three-fiber": "^5.3.15", 19 | "three": "^0.124.0", 20 | "tweakpane": "^1.5.7", 21 | "typescript": "^4.1.3", 22 | "use-tweaks": "^0.3.1", 23 | "web-vitals": "^0.2.4" 24 | }, 25 | "scripts": { 26 | "start": "react-scripts start", 27 | "build": "react-scripts build", 28 | "test": "react-scripts test", 29 | "eject": "react-scripts eject" 30 | }, 31 | "eslintConfig": { 32 | "extends": [ 33 | "react-app", 34 | "react-app/jest" 35 | ] 36 | }, 37 | "browserslist": { 38 | "production": [ 39 | ">0.2%", 40 | "not dead", 41 | "not op_mini all" 42 | ], 43 | "development": [ 44 | "last 1 chrome version", 45 | "last 1 firefox version", 46 | "last 1 safari version" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /13-3d-text/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/13-3d-text/public/favicon.ico -------------------------------------------------------------------------------- /13-3d-text/public/fonts/LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/13-3d-text/public/fonts/LICENSE -------------------------------------------------------------------------------- /13-3d-text/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 13 - 3d-Text - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /13-3d-text/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /13-3d-text/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /13-3d-text/public/textures/matcaps/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/13-3d-text/public/textures/matcaps/1.png -------------------------------------------------------------------------------- /13-3d-text/public/textures/matcaps/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/13-3d-text/public/textures/matcaps/2.png -------------------------------------------------------------------------------- /13-3d-text/public/textures/matcaps/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/13-3d-text/public/textures/matcaps/3.png -------------------------------------------------------------------------------- /13-3d-text/public/textures/matcaps/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/13-3d-text/public/textures/matcaps/4.png -------------------------------------------------------------------------------- /13-3d-text/public/textures/matcaps/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/13-3d-text/public/textures/matcaps/5.png -------------------------------------------------------------------------------- /13-3d-text/public/textures/matcaps/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/13-3d-text/public/textures/matcaps/6.png -------------------------------------------------------------------------------- /13-3d-text/public/textures/matcaps/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/13-3d-text/public/textures/matcaps/7.png -------------------------------------------------------------------------------- /13-3d-text/public/textures/matcaps/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/13-3d-text/public/textures/matcaps/8.png -------------------------------------------------------------------------------- /13-3d-text/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /13-3d-text/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /13-3d-text/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /13-3d-text/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /13-3d-text/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /13-3d-text/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /14-lights/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /14-lights/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-spring/three": "^9.0.0-rc.3", 7 | "@react-three/drei": "^2.2.19", 8 | "@testing-library/jest-dom": "^5.11.9", 9 | "@testing-library/react": "^11.2.3", 10 | "@testing-library/user-event": "^12.6.0", 11 | "@types/jest": "^26.0.20", 12 | "@types/node": "^12.19.14", 13 | "@types/react": "^16.14.2", 14 | "@types/react-dom": "^16.9.10", 15 | "react": "^17.0.1", 16 | "react-dom": "^17.0.1", 17 | "react-scripts": "4.0.1", 18 | "react-three-fiber": "^5.3.15", 19 | "three": "^0.124.0", 20 | "tweakpane": "^1.5.7", 21 | "typescript": "^4.1.3", 22 | "use-tweaks": "^0.3.1", 23 | "web-vitals": "^0.2.4" 24 | }, 25 | "scripts": { 26 | "start": "react-scripts start", 27 | "build": "react-scripts build", 28 | "test": "react-scripts test", 29 | "eject": "react-scripts eject" 30 | }, 31 | "eslintConfig": { 32 | "extends": [ 33 | "react-app", 34 | "react-app/jest" 35 | ] 36 | }, 37 | "browserslist": { 38 | "production": [ 39 | ">0.2%", 40 | "not dead", 41 | "not op_mini all" 42 | ], 43 | "development": [ 44 | "last 1 chrome version", 45 | "last 1 firefox version", 46 | "last 1 safari version" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /14-lights/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/14-lights/public/favicon.ico -------------------------------------------------------------------------------- /14-lights/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 14 - Lights - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /14-lights/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /14-lights/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /14-lights/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /14-lights/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /14-lights/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /14-lights/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /14-lights/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /14-lights/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /15-shadows/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /15-shadows/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-spring/three": "^9.0.0-rc.3", 7 | "@react-three/drei": "^2.2.19", 8 | "@testing-library/jest-dom": "^5.11.9", 9 | "@testing-library/react": "^11.2.3", 10 | "@testing-library/user-event": "^12.6.0", 11 | "@types/jest": "^26.0.20", 12 | "@types/node": "^12.19.14", 13 | "@types/react": "^16.14.2", 14 | "@types/react-dom": "^16.9.10", 15 | "react": "^17.0.1", 16 | "react-dom": "^17.0.1", 17 | "react-scripts": "4.0.1", 18 | "react-three-fiber": "^5.3.15", 19 | "three": "^0.124.0", 20 | "tweakpane": "^1.5.7", 21 | "typescript": "^4.1.3", 22 | "use-tweaks": "^0.3.1", 23 | "web-vitals": "^0.2.4" 24 | }, 25 | "scripts": { 26 | "start": "react-scripts start", 27 | "build": "react-scripts build", 28 | "test": "react-scripts test", 29 | "eject": "react-scripts eject" 30 | }, 31 | "eslintConfig": { 32 | "extends": [ 33 | "react-app", 34 | "react-app/jest" 35 | ] 36 | }, 37 | "browserslist": { 38 | "production": [ 39 | ">0.2%", 40 | "not dead", 41 | "not op_mini all" 42 | ], 43 | "development": [ 44 | "last 1 chrome version", 45 | "last 1 firefox version", 46 | "last 1 safari version" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /15-shadows/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/15-shadows/public/favicon.ico -------------------------------------------------------------------------------- /15-shadows/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 14 - Lights - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /15-shadows/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /15-shadows/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /15-shadows/public/textures/bakedShadow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/15-shadows/public/textures/bakedShadow.jpg -------------------------------------------------------------------------------- /15-shadows/public/textures/simpleShadow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/15-shadows/public/textures/simpleShadow.jpg -------------------------------------------------------------------------------- /15-shadows/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /15-shadows/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /15-shadows/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /15-shadows/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /15-shadows/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /15-shadows/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /16-haunted-house/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-spring/three": "^9.0.0-rc.3", 7 | "@react-three/drei": "^2.2.19", 8 | "@testing-library/jest-dom": "^5.11.9", 9 | "@testing-library/react": "^11.2.3", 10 | "@testing-library/user-event": "^12.6.0", 11 | "@types/jest": "^26.0.20", 12 | "@types/node": "^12.19.14", 13 | "@types/react": "^16.14.2", 14 | "@types/react-dom": "^16.9.10", 15 | "react": "^17.0.1", 16 | "react-dom": "^17.0.1", 17 | "react-scripts": "4.0.1", 18 | "react-three-fiber": "^5.3.15", 19 | "three": "^0.124.0", 20 | "tweakpane": "^1.5.7", 21 | "typescript": "^4.1.3", 22 | "use-tweaks": "^0.3.1", 23 | "web-vitals": "^0.2.4" 24 | }, 25 | "scripts": { 26 | "start": "react-scripts start", 27 | "build": "react-scripts build", 28 | "test": "react-scripts test", 29 | "eject": "react-scripts eject" 30 | }, 31 | "eslintConfig": { 32 | "extends": [ 33 | "react-app", 34 | "react-app/jest" 35 | ] 36 | }, 37 | "browserslist": { 38 | "production": [ 39 | ">0.2%", 40 | "not dead", 41 | "not op_mini all" 42 | ], 43 | "development": [ 44 | "last 1 chrome version", 45 | "last 1 firefox version", 46 | "last 1 safari version" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /16-haunted-house/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/favicon.ico -------------------------------------------------------------------------------- /16-haunted-house/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 14 - Lights - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /16-haunted-house/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /16-haunted-house/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /16-haunted-house/public/textures/bricks/ambientOcclusion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/bricks/ambientOcclusion.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/bricks/color.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/bricks/color.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/bricks/normal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/bricks/normal.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/bricks/roughness.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/bricks/roughness.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/door/alpha.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/door/alpha.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/door/ambientOcclusion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/door/ambientOcclusion.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/door/color.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/door/color.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/door/height.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/door/height.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/door/metalness.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/door/metalness.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/door/normal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/door/normal.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/door/roughness.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/door/roughness.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/grass/ambientOcclusion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/grass/ambientOcclusion.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/grass/color.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/grass/color.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/grass/normal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/grass/normal.jpg -------------------------------------------------------------------------------- /16-haunted-house/public/textures/grass/roughness.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/16-haunted-house/public/textures/grass/roughness.jpg -------------------------------------------------------------------------------- /16-haunted-house/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React, { Suspense } from 'react'; 2 | import { Canvas } from 'react-three-fiber'; 3 | import * as THREE from 'three'; 4 | import { OrbitControls } from '@react-three/drei'; 5 | import { Floor } from './components/Floor'; 6 | import { Walls } from './components/Walls'; 7 | import { Roof } from './components/Roof'; 8 | import { Door } from './components/Door'; 9 | import { Bushes } from './components/Bushes'; 10 | import { Graves } from './components/Graves'; 11 | import { Lights } from './components/Lights'; 12 | 13 | const House: React.FC = () => { 14 | return ( 15 | 16 | 17 | 18 | 19 | 20 | 21 | ); 22 | }; 23 | 24 | const Objects: React.FC = () => { 25 | return ( 26 | <> 27 | 28 | 29 | 30 | 31 | ); 32 | }; 33 | 34 | const App: React.FC = () => { 35 | return ( 36 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | ); 57 | }; 58 | 59 | export default App; 60 | -------------------------------------------------------------------------------- /16-haunted-house/src/components/Bushes.tsx: -------------------------------------------------------------------------------- 1 | import * as THREE from 'three'; 2 | export const Bushes: React.FC = () => { 3 | const bushes: { 4 | scale: number; 5 | position: Parameters; 6 | }[] = [ 7 | { scale: 0.5, position: [0.8, 0.2, 2.2] }, 8 | { scale: 0.25, position: [1.4, 0.1, 2.1] }, 9 | { scale: 0.4, position: [-0.8, 0.1, 2.2] }, 10 | { scale: 0.15, position: [-1, 0.05, 2.6] }, 11 | ]; 12 | return ( 13 | <> 14 | {bushes.map((bush, idx) => { 15 | const { scale, position } = bush; 16 | return ( 17 | 23 | 24 | 25 | 26 | ); 27 | })} 28 | 29 | ); 30 | }; 31 | -------------------------------------------------------------------------------- /16-haunted-house/src/components/Door.tsx: -------------------------------------------------------------------------------- 1 | import { useTexture } from '@react-three/drei'; 2 | import { useResource, useUpdate } from 'react-three-fiber'; 3 | import * as THREE from 'three'; 4 | 5 | export const Door: React.FC = () => { 6 | const doorRef = useResource< 7 | THREE.Mesh 8 | >(); 9 | 10 | const [ 11 | doorColorTexture, 12 | doorAlphaTexture, 13 | doorAmbientOcclusionTexture, 14 | doorHeightTexture, 15 | doorNormalTexture, 16 | doorMetalnessTexture, 17 | doorRoughnessTexture, 18 | ] = useTexture([ 19 | 'textures/door/color.jpg', 20 | 'textures/door/alpha.jpg', 21 | 'textures/door/ambientOcclusion.jpg', 22 | 'textures/door/height.jpg', 23 | 'textures/door/normal.jpg', 24 | 'textures/door/metalness.jpg', 25 | 'textures/door/roughness.jpg', 26 | ]); 27 | 28 | useUpdate( 29 | (self) => { 30 | self.geometry.setAttribute( 31 | 'uv2', 32 | new THREE.Float32BufferAttribute(self.geometry.attributes.uv.array, 2) 33 | ); 34 | }, 35 | [], 36 | doorRef 37 | ); 38 | return ( 39 | 40 | 41 | 52 | 53 | ); 54 | }; 55 | -------------------------------------------------------------------------------- /16-haunted-house/src/components/Floor.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import * as THREE from 'three'; 3 | import { useTexture } from '@react-three/drei'; 4 | import { useResource, useUpdate } from 'react-three-fiber'; 5 | 6 | export const Floor: React.FC = () => { 7 | const floorRef = useResource< 8 | THREE.Mesh 9 | >(); 10 | 11 | const [ 12 | grassColorTexture, 13 | grassAmbientOcclusionTexture, 14 | grassNormalTexture, 15 | grassRoughnessTexture, 16 | ] = useTexture([ 17 | 'textures/grass/color.jpg', 18 | 'textures/grass/ambientOcclusion.jpg', 19 | 'textures/grass/normal.jpg', 20 | 'textures/grass/roughness.jpg', 21 | ]); 22 | 23 | useUpdate( 24 | (self) => { 25 | self.geometry.setAttribute( 26 | 'uv2', 27 | new THREE.Float32BufferAttribute(self.geometry.attributes.uv.array, 2) 28 | ); 29 | }, 30 | [], 31 | floorRef 32 | ); 33 | 34 | function setRepeatXY(texture: THREE.Texture | null): THREE.Texture | null { 35 | const t = texture; 36 | t?.repeat.set(8, 8); 37 | 38 | return t; 39 | } 40 | 41 | function assignWrappingMode(texture: THREE.Texture | null): void { 42 | const t = texture; 43 | t?.wrapS && (t.wrapS = THREE.RepeatWrapping); 44 | t?.wrapT && (t.wrapT = THREE.RepeatWrapping); 45 | } 46 | 47 | const grassMaterialRef = useUpdate((self) => { 48 | const textures = [self.map, self.aoMap, self.normalMap, self.roughnessMap]; 49 | // Repeating textures 50 | textures.forEach((t) => assignWrappingMode(setRepeatXY(t))); 51 | }, []); 52 | 53 | return ( 54 | 60 | 61 | 68 | 69 | ); 70 | }; 71 | -------------------------------------------------------------------------------- /16-haunted-house/src/components/Ghosts.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useFrame, useThree } from 'react-three-fiber'; 3 | 4 | const Ghost = React.forwardRef( 5 | ({ color }, ref) => { 6 | return ( 7 | 15 | ); 16 | } 17 | ); 18 | 19 | export const Ghosts: React.FC = () => { 20 | const ghost1Ref = React.useRef(); 21 | const ghost2Ref = React.useRef(); 22 | const ghost3Ref = React.useRef(); 23 | 24 | const { clock } = useThree(); 25 | 26 | useFrame(() => { 27 | const { elapsedTime } = clock; 28 | 29 | if (ghost1Ref.current) { 30 | const ghost1Angle = elapsedTime * 0.5; 31 | ghost1Ref.current.position.x = Math.cos(ghost1Angle) * 4; 32 | ghost1Ref.current.position.z = Math.sin(ghost1Angle) * 4; 33 | ghost1Ref.current.position.y = Math.sin(elapsedTime * 3); 34 | } 35 | 36 | if (ghost2Ref.current) { 37 | const ghost2Angle = -elapsedTime * 0.32; 38 | ghost2Ref.current.position.x = Math.cos(ghost2Angle) * 5; 39 | ghost2Ref.current.position.z = Math.sin(ghost2Angle) * 5; 40 | ghost2Ref.current.position.y = 41 | Math.sin(elapsedTime * 4) + Math.sin(elapsedTime * 2.5); 42 | } 43 | 44 | if (ghost3Ref.current) { 45 | const ghost3Angle = -elapsedTime * 0.18; 46 | ghost3Ref.current.position.x = 47 | Math.cos(ghost3Angle) * (7 + Math.sin(elapsedTime * 0.32)); 48 | ghost3Ref.current.position.z = 49 | Math.cos(ghost3Angle) * (7 + Math.sin(elapsedTime * 0.5)); 50 | ghost3Ref.current.position.y = 51 | Math.sin(elapsedTime * 5) + Math.sin(elapsedTime * 2); 52 | } 53 | }); 54 | return ( 55 | <> 56 | 57 | 58 | 59 | 60 | ); 61 | }; 62 | -------------------------------------------------------------------------------- /16-haunted-house/src/components/Graves.tsx: -------------------------------------------------------------------------------- 1 | export const Graves: React.FC = () => { 2 | return ( 3 | 4 | {Array(50) 5 | .fill(null) 6 | .map((_, idx) => { 7 | const angle = Math.random() * Math.PI * 2; 8 | const radius = 4 + Math.random() * 5; 9 | const x = Math.sin(angle) * radius; 10 | const z = Math.cos(angle) * radius; 11 | 12 | return ( 13 | 20 | 21 | 22 | 23 | ); 24 | })} 25 | 26 | ); 27 | }; 28 | -------------------------------------------------------------------------------- /16-haunted-house/src/components/Lights.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import * as THREE from 'three'; 3 | import { useResource, useThree } from 'react-three-fiber'; 4 | import { Ghosts } from './Ghosts'; 5 | 6 | export const Lights: React.FC = () => { 7 | // * Refs 8 | const directionalLightRef = useResource(); 9 | const pointLightRef = useResource(); 10 | 11 | const { scene, gl } = useThree(); 12 | 13 | // Adding fog to the scene 14 | React.useEffect(() => { 15 | scene.fog = new THREE.Fog('#262837', 1, 15); 16 | }, [scene]); 17 | 18 | React.useEffect(() => { 19 | gl.setClearColor('#262837'); 20 | }, [gl]); 21 | 22 | return ( 23 | <> 24 | 25 | 34 | 40 | 41 | 42 | ); 43 | }; 44 | -------------------------------------------------------------------------------- /16-haunted-house/src/components/Roof.tsx: -------------------------------------------------------------------------------- 1 | export const Roof: React.FC = () => { 2 | return ( 3 | 4 | 5 | 6 | 7 | ); 8 | }; 9 | -------------------------------------------------------------------------------- /16-haunted-house/src/components/Walls.tsx: -------------------------------------------------------------------------------- 1 | import { useTexture } from '@react-three/drei'; 2 | import { useResource, useUpdate } from 'react-three-fiber'; 3 | import * as THREE from 'three'; 4 | 5 | export const Walls: React.FC = () => { 6 | const wallsRef = useResource< 7 | THREE.Mesh 8 | >(); 9 | 10 | const [ 11 | bricksColorTexture, 12 | bricksAmbientOcclusionTexture, 13 | bricksNormalTexture, 14 | bricksRoughnessTexture, 15 | ] = useTexture([ 16 | 'textures/bricks/color.jpg', 17 | 'textures/bricks/ambientOcclusion.jpg', 18 | 'textures/bricks/normal.jpg', 19 | 'textures/bricks/roughness.jpg', 20 | ]); 21 | 22 | useUpdate( 23 | (self) => { 24 | self.geometry.setAttribute( 25 | 'uv2', 26 | new THREE.Float32BufferAttribute(self.geometry.attributes.uv.array, 2) 27 | ); 28 | }, 29 | [], 30 | wallsRef 31 | ); 32 | return ( 33 | 34 | 35 | 41 | 42 | ); 43 | }; 44 | -------------------------------------------------------------------------------- /16-haunted-house/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /16-haunted-house/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /16-haunted-house/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /16-haunted-house/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /16-haunted-house/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /16-haunted-house/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /17-particles/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /17-particles/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-spring/three": "^9.0.0-rc.3", 7 | "@react-three/drei": "^2.2.19", 8 | "@testing-library/jest-dom": "^5.11.9", 9 | "@testing-library/react": "^11.2.3", 10 | "@testing-library/user-event": "^12.6.0", 11 | "@types/jest": "^26.0.20", 12 | "@types/node": "^12.19.14", 13 | "@types/react": "^16.14.2", 14 | "@types/react-dom": "^16.9.10", 15 | "react": "^17.0.1", 16 | "react-dom": "^17.0.1", 17 | "react-scripts": "4.0.1", 18 | "react-three-fiber": "^5.3.15", 19 | "three": "^0.124.0", 20 | "tweakpane": "^1.5.7", 21 | "typescript": "^4.1.3", 22 | "use-tweaks": "^0.3.1", 23 | "web-vitals": "^0.2.4" 24 | }, 25 | "scripts": { 26 | "start": "react-scripts start", 27 | "build": "react-scripts build", 28 | "test": "react-scripts test", 29 | "eject": "react-scripts eject" 30 | }, 31 | "eslintConfig": { 32 | "extends": [ 33 | "react-app", 34 | "react-app/jest" 35 | ] 36 | }, 37 | "browserslist": { 38 | "production": [ 39 | ">0.2%", 40 | "not dead", 41 | "not op_mini all" 42 | ], 43 | "development": [ 44 | "last 1 chrome version", 45 | "last 1 firefox version", 46 | "last 1 safari version" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /17-particles/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/favicon.ico -------------------------------------------------------------------------------- /17-particles/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 14 - Lights - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /17-particles/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /17-particles/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /17-particles/public/textures/particles/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/1.png -------------------------------------------------------------------------------- /17-particles/public/textures/particles/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/10.png -------------------------------------------------------------------------------- /17-particles/public/textures/particles/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/11.png -------------------------------------------------------------------------------- /17-particles/public/textures/particles/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/12.png -------------------------------------------------------------------------------- /17-particles/public/textures/particles/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/13.png -------------------------------------------------------------------------------- /17-particles/public/textures/particles/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/2.png -------------------------------------------------------------------------------- /17-particles/public/textures/particles/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/3.png -------------------------------------------------------------------------------- /17-particles/public/textures/particles/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/4.png -------------------------------------------------------------------------------- /17-particles/public/textures/particles/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/5.png -------------------------------------------------------------------------------- /17-particles/public/textures/particles/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/6.png -------------------------------------------------------------------------------- /17-particles/public/textures/particles/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/7.png -------------------------------------------------------------------------------- /17-particles/public/textures/particles/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/8.png -------------------------------------------------------------------------------- /17-particles/public/textures/particles/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/17-particles/public/textures/particles/9.png -------------------------------------------------------------------------------- /17-particles/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /17-particles/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /17-particles/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /17-particles/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /17-particles/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /17-particles/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /18-galaxy-generator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-spring/three": "^9.0.0-rc.3", 7 | "@react-three/drei": "^2.2.19", 8 | "@testing-library/jest-dom": "^5.11.9", 9 | "@testing-library/react": "^11.2.3", 10 | "@testing-library/user-event": "^12.6.0", 11 | "@types/jest": "^26.0.20", 12 | "@types/node": "^12.19.14", 13 | "@types/react": "^16.14.2", 14 | "@types/react-dom": "^16.9.10", 15 | "lerp": "^1.0.3", 16 | "react": "^17.0.1", 17 | "react-dom": "^17.0.1", 18 | "react-scripts": "4.0.1", 19 | "react-three-fiber": "^5.3.15", 20 | "three": "^0.124.0", 21 | "tweakpane": "^1.5.7", 22 | "typescript": "^4.1.3", 23 | "use-tweaks": "^0.3.1", 24 | "web-vitals": "^0.2.4" 25 | }, 26 | "scripts": { 27 | "start": "react-scripts start", 28 | "build": "react-scripts build", 29 | "test": "react-scripts test", 30 | "eject": "react-scripts eject" 31 | }, 32 | "eslintConfig": { 33 | "extends": [ 34 | "react-app", 35 | "react-app/jest" 36 | ] 37 | }, 38 | "browserslist": { 39 | "production": [ 40 | ">0.2%", 41 | "not dead", 42 | "not op_mini all" 43 | ], 44 | "development": [ 45 | "last 1 chrome version", 46 | "last 1 firefox version", 47 | "last 1 safari version" 48 | ] 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /18-galaxy-generator/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/18-galaxy-generator/public/favicon.ico -------------------------------------------------------------------------------- /18-galaxy-generator/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 18 - Galaxy - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /18-galaxy-generator/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /18-galaxy-generator/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /18-galaxy-generator/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /18-galaxy-generator/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /18-galaxy-generator/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /18-galaxy-generator/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /18-galaxy-generator/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /18-galaxy-generator/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /19-raycaster/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /19-raycaster/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-spring/three": "^9.0.0-rc.3", 7 | "@react-three/drei": "^2.2.19", 8 | "@testing-library/jest-dom": "^5.11.9", 9 | "@testing-library/react": "^11.2.3", 10 | "@testing-library/user-event": "^12.6.0", 11 | "@types/jest": "^26.0.20", 12 | "@types/node": "^12.19.14", 13 | "@types/react": "^16.14.2", 14 | "@types/react-dom": "^16.9.10", 15 | "lerp": "^1.0.3", 16 | "react": "^17.0.1", 17 | "react-dom": "^17.0.1", 18 | "react-scripts": "4.0.1", 19 | "react-three-fiber": "^5.3.15", 20 | "three": "^0.124.0", 21 | "tweakpane": "^1.5.7", 22 | "typescript": "^4.1.3", 23 | "use-tweaks": "^0.3.1", 24 | "web-vitals": "^0.2.4" 25 | }, 26 | "scripts": { 27 | "start": "react-scripts start", 28 | "build": "react-scripts build", 29 | "test": "react-scripts test", 30 | "eject": "react-scripts eject" 31 | }, 32 | "eslintConfig": { 33 | "extends": [ 34 | "react-app", 35 | "react-app/jest" 36 | ] 37 | }, 38 | "browserslist": { 39 | "production": [ 40 | ">0.2%", 41 | "not dead", 42 | "not op_mini all" 43 | ], 44 | "development": [ 45 | "last 1 chrome version", 46 | "last 1 firefox version", 47 | "last 1 safari version" 48 | ] 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /19-raycaster/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/19-raycaster/public/favicon.ico -------------------------------------------------------------------------------- /19-raycaster/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 19 - Raycaster - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /19-raycaster/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /19-raycaster/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /19-raycaster/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React, { Suspense } from 'react'; 2 | import { Canvas, MeshProps, useFrame, useThree } from 'react-three-fiber'; 3 | import * as THREE from 'three'; 4 | import { OrbitControls, Stats } from '@react-three/drei'; 5 | 6 | const Obj = React.forwardRef((props, ref) => { 7 | const [isHovered, set] = React.useState(false); 8 | 9 | return ( 10 | set(true)} 13 | onPointerOut={() => set(false)} 14 | {...props} 15 | > 16 | 17 | 18 | 19 | ); 20 | }); 21 | 22 | const Objs: React.FC = () => { 23 | const obj1 = React.useRef(); 24 | const obj2 = React.useRef(); 25 | const obj3 = React.useRef(); 26 | 27 | const { clock } = useThree(); 28 | 29 | useFrame(() => { 30 | const { elapsedTime } = clock; 31 | 32 | // Animating objects 33 | obj1.current && 34 | (obj1.current.position.y = Math.sin(elapsedTime * 0.3) * 1.5); 35 | obj2.current && 36 | (obj2.current.position.y = Math.sin(elapsedTime * 0.8) * 1.5); 37 | obj3.current && 38 | (obj3.current.position.y = Math.sin(elapsedTime * 1.4) * 1.5); 39 | }); 40 | return ( 41 | 42 | 43 | 44 | 45 | 46 | ); 47 | }; 48 | 49 | const App: React.FC = () => { 50 | return ( 51 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | ); 69 | }; 70 | 71 | export default App; 72 | -------------------------------------------------------------------------------- /19-raycaster/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /19-raycaster/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /19-raycaster/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /19-raycaster/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /19-raycaster/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /19-raycaster/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /20-physics/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threejs-journey-r3f-and-typescript", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-spring/three": "^9.0.0-rc.3", 7 | "@react-three/cannon": "^0.5.4", 8 | "@react-three/drei": "^2.2.19", 9 | "@testing-library/jest-dom": "^5.11.9", 10 | "@testing-library/react": "^11.2.3", 11 | "@testing-library/user-event": "^12.6.0", 12 | "@types/jest": "^26.0.20", 13 | "@types/node": "^12.19.14", 14 | "@types/react": "^16.14.2", 15 | "@types/react-dom": "^16.9.10", 16 | "lerp": "^1.0.3", 17 | "react": "^17.0.1", 18 | "react-dom": "^17.0.1", 19 | "react-scripts": "4.0.1", 20 | "react-three-fiber": "^5.3.18", 21 | "three": "^0.124.0", 22 | "tweakpane": "^1.5.7", 23 | "typescript": "^4.1.3", 24 | "use-asset": "^1.0.2", 25 | "use-tweaks": "^0.3.1", 26 | "uuid": "^8.3.2", 27 | "web-vitals": "^0.2.4" 28 | }, 29 | "scripts": { 30 | "start": "react-scripts start", 31 | "build": "react-scripts build", 32 | "test": "react-scripts test", 33 | "eject": "react-scripts eject" 34 | }, 35 | "eslintConfig": { 36 | "extends": [ 37 | "react-app", 38 | "react-app/jest" 39 | ] 40 | }, 41 | "browserslist": { 42 | "production": [ 43 | ">0.2%", 44 | "not dead", 45 | "not op_mini all" 46 | ], 47 | "development": [ 48 | "last 1 chrome version", 49 | "last 1 firefox version", 50 | "last 1 safari version" 51 | ] 52 | }, 53 | "devDependencies": { 54 | "@types/uuid": "^8.3.0" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /20-physics/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h-jennings/threejs-journey-r3f-and-typescript/85a664068c75a521d44ae5e90790627177e62e30/20-physics/public/favicon.ico -------------------------------------------------------------------------------- /20-physics/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 20 - Physics - R3F 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /20-physics/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /20-physics/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /20-physics/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #root { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | -webkit-touch-callout: none; 9 | -webkit-user-select: none; 10 | -khtml-user-select: none; 11 | -moz-user-select: none; 12 | -ms-user-select: none; 13 | user-select: none; 14 | overflow: hidden; 15 | } 16 | 17 | *, 18 | *::after, 19 | *::before { 20 | box-sizing: border-box; 21 | } 22 | 23 | body { 24 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 25 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 26 | sans-serif; 27 | -webkit-font-smoothing: antialiased; 28 | -moz-osx-font-smoothing: grayscale; 29 | margin: 0; 30 | padding: 0; 31 | overflow: hidden; 32 | } 33 | 34 | code { 35 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 36 | monospace; 37 | } 38 | -------------------------------------------------------------------------------- /20-physics/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root'), 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /20-physics/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /20-physics/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /20-physics/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /20-physics/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # threejs-journey-r3f-and-typescript 2 | [threejsjourney.xyz](https://threejs-journey.xyz/) is a course by [Bruno Simon](https://bruno-simon.com/) on [Three.js](https://threejs.org/) 3 | 4 | The course itself is taught in vanilla JS. This repo contains (will contain) all of the lessons implemented using [react-three-fiber](https://github.com/pmndrs/react-three-fiber) and TypeScript. 5 | 6 | React and TypeScript are my front end tools of choice, building this repo helped me learn how to implement the concepts and techniques Bruno taught, but in a declarative, React environment. 7 | --------------------------------------------------------------------------------