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

Function App

07-import-model/src/App.jsx:11–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9import SceneInit from './lib/SceneInit';
10
11function App() {
12 useEffect(() => {
13 const test = new SceneInit('myThreeJsCanvas');
14 test.initialize();
15 test.animate();
16
17 // const boxGeometry = new THREE.BoxGeometry(8, 8, 8);
18 // const boxMaterial = new THREE.MeshNormalMaterial();
19 // const boxMesh = new THREE.Mesh(boxGeometry, boxMaterial);
20 // test.scene.add(boxMesh);
21
22 let loadedModel;
23 const glftLoader = new GLTFLoader();
24 glftLoader.load('./assets/shiba/scene.gltf', (gltfScene) => {
25 loadedModel = gltfScene;
26 // console.log(loadedModel);
27
28 gltfScene.scene.rotation.y = Math.PI / 8;
29 gltfScene.scene.position.y = 3;
30 gltfScene.scene.scale.set(10, 10, 10);
31 test.scene.add(gltfScene.scene);
32 });
33
34 const animate = () => {
35 if (loadedModel) {
36 loadedModel.scene.rotation.x += 0.01;
37 loadedModel.scene.rotation.y += 0.01;
38 loadedModel.scene.rotation.z += 0.01;
39 }
40 requestAnimationFrame(animate);
41 };
42 animate();
43 }, []);
44
45 return (
46 <div>
47 <canvas id="myThreeJsCanvas" />
48 </div>
49 );
50}
51
52export default App;

Callers

nothing calls this directly

Calls 3

initializeMethod · 0.95
animateMethod · 0.95
animateFunction · 0.70

Tested by

no test coverage detected