-
-
Save ELI7VH/17097cab0270df74a5ca6c999a45392a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const starCount = 2000 | |
const starInstances = new app.THREE.InstancedMesh(this.starGeometry, this.starMaterial, starCount) | |
this.stars = mapI(starCount, (i) => { | |
const r = 425 + rand(120) | |
const xyAngle = rand(Math.PI * 2) | |
const zAngle = rand(Math.PI * 2) | |
const x = Math.cos(xyAngle) * Math.sin(zAngle) * r | |
const y = Math.sin(xyAngle) * Math.sin(zAngle) * r + 2 | |
const z = Math.cos(zAngle) * r | |
const n = simplex.noise3D(x * 20, y * 20, z * 20) * 0.001 | |
// const star = new app.THREE.Mesh(this.starGeometry, this.starMaterial, starCount) | |
const dummyStar = new app.THREE.Object3D() | |
dummyStar.position.set(x, y, z) | |
dummyStar.lookAt(0, 0, 0) | |
starInstances.setMatrixAt(i, dummyStar.matrix) | |
starInstances.instanceMatrix.needsUpdate = true | |
return { x, y, z, n, r } | |
}) | |
this.el.object3D.add(starInstances) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment