From 3a376800e096580fc4cecee7f0a027c7e6fe94bf Mon Sep 17 00:00:00 2001 From: Nils Date: Wed, 16 Oct 2024 22:02:04 +0200 Subject: [PATCH] Added some spheres --- .gitignore | 3 ++- src/index.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f3f691e..c087876 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,5 @@ dist .yarn/install-state.gz .pnp.* -.DS_Store \ No newline at end of file +.DS_Store +.idea/ diff --git a/src/index.js b/src/index.js index 16f58fe..4fea285 100644 --- a/src/index.js +++ b/src/index.js @@ -68,6 +68,37 @@ function setupScene({ scene, camera, renderer, player, controllers }) { scoreText.rotateX(-Math.PI / 3.3); updateScoreDisplay(); + + // Spheres and lines + const spheres = []; + const sphereMaterial = new THREE.MeshBasicMaterial({ color: 0xff0000 }); + const lineMaterial = new THREE.LineBasicMaterial({ color: 0x00ff00 }); + + for (let i = 0; i < 5; i++) { + const sphere = new THREE.Mesh( + new THREE.SphereGeometry(0.2, 32, 32), + sphereMaterial, + ); + sphere.position.set( + Math.random() * 10 - 5, + Math.random() * 3 + 1, + -Math.random() * 5 - 5, + ); + scene.add(sphere); + spheres.push(sphere); + + // If this is not the first sphere, create a line connecting to the previous sphere + if (i > 0) { + const points = []; + points.push(spheres[i - 1].position); + points.push(sphere.position); + const geometry = new THREE.BufferGeometry().setFromPoints(points); + const line = new THREE.Line(geometry, lineMaterial); + scene.add(line); + } + } + + // Load and set up positional audio const listener = new THREE.AudioListener(); camera.add(listener);