()
| 6 | import SceneInit from './lib/SceneInit'; |
| 7 | |
| 8 | function App() { |
| 9 | useEffect(() => { |
| 10 | const test = new SceneInit('myThreeJsCanvas'); |
| 11 | test.initialize(); |
| 12 | test.animate(); |
| 13 | |
| 14 | // part 0 - add axis helper |
| 15 | const axesHelper = new THREE.AxesHelper(8); |
| 16 | test.scene.add(axesHelper); |
| 17 | |
| 18 | // part 0 - add box mesh which will be tweened |
| 19 | const boxGeometry = new THREE.BoxGeometry(4, 4, 4); |
| 20 | const boxMaterial = new THREE.MeshNormalMaterial(); |
| 21 | const boxMesh = new THREE.Mesh(boxGeometry, boxMaterial); |
| 22 | test.scene.add(boxMesh); |
| 23 | |
| 24 | // part 0 - add ground mesh for reference |
| 25 | const groundGeometry = new THREE.BoxGeometry(24, 1, 24); |
| 26 | const groundMaterial = new THREE.MeshNormalMaterial(); |
| 27 | const groundMesh = new THREE.Mesh(groundGeometry, groundMaterial); |
| 28 | groundMesh.position.y = -4; |
| 29 | test.scene.add(groundMesh); |
| 30 | |
| 31 | // part 0 - ensure that tween.js is running |
| 32 | const animate = (t) => { |
| 33 | TWEEN.update(t); |
| 34 | window.requestAnimationFrame(animate); |
| 35 | }; |
| 36 | animate(); |
| 37 | |
| 38 | // part 1 - set up basic tween.js examples |
| 39 | // const tween = new TWEEN.Tween({ x: 0 }) |
| 40 | // .to({ x: 5 }, 2000) |
| 41 | // .onUpdate((coords) => { |
| 42 | // boxMesh.position.x = coords.x; |
| 43 | // }); |
| 44 | // tween.start(); |
| 45 | |
| 46 | // const tween = new TWEEN.Tween({ x: 0, xRotation: 0 }) |
| 47 | // .to({ x: 5, xRotation: Math.PI / 2 }, 2000) |
| 48 | // .onUpdate((coords) => { |
| 49 | // boxMesh.position.x = coords.x; |
| 50 | // boxMesh.rotation.x = coords.xRotation; |
| 51 | // }); |
| 52 | // tween.start(); |
| 53 | |
| 54 | // part 2 - tween.js functions (repeat, delay) |
| 55 | // const tween = new TWEEN.Tween({ x: 0, y: 0, xRotation: 0 }) |
| 56 | // .to({ x: 5, y: 8, xRotation: Math.PI / 2 }, 2000) |
| 57 | // .onUpdate((coords) => { |
| 58 | // boxMesh.position.x = coords.x; |
| 59 | // boxMesh.position.y = coords.y; |
| 60 | // boxMesh.rotation.x = coords.xRotation; |
| 61 | // }) |
| 62 | // .repeat(Infinity) |
| 63 | // .delay(500); |
| 64 | // tween.start(); |
| 65 |
nothing calls this directly
no test coverage detected