From 3b16e392c3a726e710b04c9b3354128ad262585c Mon Sep 17 00:00:00 2001 From: zda9250 Date: Tue, 18 Nov 2025 01:05:54 -0500 Subject: [PATCH] Update bg.js --- js/bg.js | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/js/bg.js b/js/bg.js index eb601a9..3e5e7c3 100644 --- a/js/bg.js +++ b/js/bg.js @@ -1,6 +1,33 @@ import * as THREE from 'three'; import { randFloat } from '/node_modules/three/src/math/MathUtils.js'; + + +const baseGeometry = new THREE.SphereGeometry(3,5,5); +class Star extends THREE.Mesh +{ + constructor(distance = 0.0, geometry = baseGeometry) + { + super( + geometry, + new THREE.MeshBasicMaterial({ + color: new THREE.Color(randFloat(0.2, 0.7), randFloat(0.2, 0.7), randFloat(0.2, 0.7)), + + })); + + this.distance = distance; + + this.p = new THREE.Vector3(); + this.p.randomDirection(); + this.p.multiplyScalar(distance); + + //this.rotation.set(new THREE.Vector3().randomDirection()); + + this.position.set(this.p.x, this.p.y, this.p.z); + } +} + + const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); //camera.position.z = 5; @@ -62,27 +89,3 @@ document.addEventListener( 'pointermove', onMouseMove ); renderer.setAnimationLoop( animate ); - -const baseGeometry = new THREE.SphereGeometry(3,5,5); -class Star extends THREE.Mesh -{ - constructor(distance = 0.0, geometry = baseGeometry) - { - super( - geometry, - new THREE.MeshBasicMaterial({ - color: new THREE.Color(randFloat(0.2, 0.7), randFloat(0.2, 0.7), randFloat(0.2, 0.7)), - - })); - - this.distance = distance; - - this.p = new THREE.Vector3(); - this.p.randomDirection(); - this.p.multiplyScalar(distance); - - //this.rotation.set(new THREE.Vector3().randomDirection()); - - this.position.set(this.p.x, this.p.y, this.p.z); - } -} \ No newline at end of file