From cbadda19b1f97d348a3d762e57fbab1fe3d04c23 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 20 Mar 2022 00:58:19 -0400 Subject: [PATCH] animate scene --- .../src/pages/index/Scene.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/storyteller-home/src/pages/index/Scene.tsx b/packages/storyteller-home/src/pages/index/Scene.tsx index 2c961e532d..777f251721 100644 --- a/packages/storyteller-home/src/pages/index/Scene.tsx +++ b/packages/storyteller-home/src/pages/index/Scene.tsx @@ -11,6 +11,7 @@ interface Props { function Scene(props: Props) { const mountRef = useRef(null); + const pointCloudRef = useRef(null); /*const [isPlaying, setIsPlaying] = useState(false); @@ -33,6 +34,7 @@ function Scene(props: Props) { useEffect(() => { if (mountRef.current === null) { + // NB: This is just to satisfy TypeScript. return; } @@ -77,8 +79,12 @@ function Scene(props: Props) { const animate = function () { requestAnimationFrame(animate); - //cube.rotation.x += 0.01; - //cube.rotation.y += 0.01; + + if (pointCloudRef.current !== null) { + (pointCloudRef.current as any).rotation.x += 0.0005; + (pointCloudRef.current as any).rotation.y += 0.001; + } + renderer.render(scene, camera); }; @@ -92,13 +98,18 @@ function Scene(props: Props) { // resource URL '/assets/temp.pcd', // called when the resource is loaded - function ( mesh : any ) { + function (mesh : any) { mesh.geometry.center(); mesh.geometry.rotateX( Math.PI ); - scene.add( mesh ); + mesh.scale.x = 2; + mesh.scale.y = 2; + mesh.scale.z = 2; mesh.material.color.setHex( 0xffffff ); //mesh.scale.x = 3; //mesh.position.x = 0; + scene.add( mesh ); + + pointCloudRef.current = mesh; }, // called when loading is in progresses function ( xhr : any ) {