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

Function App

03-geometry/src/App.jsx:9–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7import SceneInit from './lib/SceneInit';
8
9function App() {
10 useEffect(() => {
11 const test = new SceneInit('myThreeJsCanvas');
12 test.initialize();
13 test.animate();
14
15 // PART 1
16 // Adding geometries to a three.js scene.
17 // const boxGeometry = new THREE.BoxGeometry(1, 1, 1, 1, 1, 16);
18 // const boxMaterial = new THREE.MeshNormalMaterial({ wireframe: true });
19 // const boxMesh = new THREE.Mesh(boxGeometry, boxMaterial);
20 // boxMesh.position.x = -1;
21 // test.scene.add(boxMesh);
22
23 // const cylinderGeometry = new THREE.CylinderGeometry(0.5, 0.5, 1, 32, 16);
24 // const cylinderMaterial = new THREE.MeshNormalMaterial({ wireframe: true });
25 // const cylinderMesh = new THREE.Mesh(cylinderGeometry, cylinderMaterial);
26 // cylinderMesh.position.x = 1;
27 // test.scene.add(cylinderMesh);
28
29 // const torusGeometry = new THREE.TorusGeometry(0.5, 0.25, 20, 20);
30 // const torusMaterial = new THREE.MeshNormalMaterial({ wireframe: true });
31 // const torusMesh = new THREE.Mesh(torusGeometry, torusMaterial);
32 // test.scene.add(torusMesh);
33
34 // PART 2
35 // Why add width/height segments for a geometry?
36 // function vertexShader() {
37 // return `
38 // varying float z;
39 // uniform float u_time;
40 // void main() {
41 // z = (cos(position.y + u_time) + sin(position.x + u_time)) / 4.0;
42 // gl_Position = projectionMatrix * modelViewMatrix * vec4(position.x, position.y, z + position.z, 1.0);
43 // }
44 // `;
45 // }
46 // function fragmentShader() {
47 // return `
48 // void main() {
49 // gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
50 // }
51 // `;
52 // }
53 // const geometry = new THREE.BoxGeometry(1, 1, 1, 1, 1, 1);
54 // const material = new THREE.ShaderMaterial({
55 // uniforms: test.uniforms,
56 // fragmentShader: fragmentShader(),
57 // vertexShader: vertexShader(),
58 // wireframe: true,
59 // });
60 // const mesh = new THREE.Mesh(geometry, material);
61 // mesh.rotation.x = Math.PI / 2;
62 // test.scene.add(mesh);
63
64 // PART 3
65 // Showcase "hidden" geometries.
66 const roundedBoxGeometry = new RoundedBoxGeometry(1, 1, 1, 4, 0.1);

Callers

nothing calls this directly

Calls 2

initializeMethod · 0.95
animateMethod · 0.95

Tested by

no test coverage detected