MCPcopy Create free account
hub / github.com/SuboptimalEng/three-js-tutorials / App

Function App

05-lighting/src/App.jsx:8–168  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import SceneInit from './lib/SceneInit';
7
8function App() {
9 useEffect(() => {
10 const test = new SceneInit('myThreeJsCanvas');
11 test.initialize();
12 test.animate();
13
14 // initialize gui
15 const gui = new GUI();
16
17 // main group
18 const mainGroup = new THREE.Group();
19 mainGroup.position.y = 0.5;
20 test.scene.add(mainGroup);
21
22 // normal box
23 // const bg0 = new THREE.BoxGeometry(1, 1, 1);
24 // const bm0 = new THREE.MeshNormalMaterial();
25 // const boxMesh0 = new THREE.Mesh(bg0, bm0);
26 // test.scene.add(boxMesh0);
27
28 // set up ground
29 const groundGeometry = new THREE.BoxGeometry(8, 0.5, 8);
30 const groundMaterial = new THREE.MeshPhongMaterial({ color: 0xfafafa });
31 const groundMesh = new THREE.Mesh(groundGeometry, groundMaterial);
32 groundMesh.receiveShadow = true;
33 groundMesh.position.y = -2;
34 mainGroup.add(groundMesh);
35
36 // set up torus for youtube thumbnail
37 // const bg1 = new THREE.TorusGeometry(1.5, 0.75, 64, 64);
38 // const bm1 = new THREE.MeshNormalMaterial({ color: 0xff0000 });
39 // const boxMesh1 = new THREE.Mesh(bg1, bm1);
40 // boxMesh1.castShadow = true;
41 // boxMesh1.position.y = 1;
42 // boxMesh1.position.z = 1;
43 // boxMesh1.rotation.x = -Math.PI / 3;
44 // mainGroup.add(boxMesh1);
45
46 // set up red box mesh
47 const bg1 = new THREE.BoxGeometry(1, 1, 1);
48 const bm1 = new THREE.MeshPhongMaterial({ color: 0xff0000 });
49 const boxMesh1 = new THREE.Mesh(bg1, bm1);
50 boxMesh1.castShadow = true;
51 boxMesh1.position.x = -2;
52 mainGroup.add(boxMesh1);
53
54 // set up green box mesh
55 const bg2 = new THREE.BoxGeometry(1, 1, 1);
56 const bm2 = new THREE.MeshPhongMaterial({ color: 0x00ff00 });
57 const boxMesh2 = new THREE.Mesh(bg2, bm2);
58 boxMesh2.castShadow = true;
59 boxMesh2.position.x = 0;
60 mainGroup.add(boxMesh2);
61
62 // set up blue box mesh
63 const bg3 = new THREE.BoxGeometry(1, 1, 1);
64 const bm3 = new THREE.MeshPhongMaterial({ color: 0x0000ff });
65 const boxMesh3 = new THREE.Mesh(bg3, bm3);

Callers

nothing calls this directly

Calls 2

initializeMethod · 0.95
animateMethod · 0.95

Tested by

no test coverage detected