|
@ -47,7 +47,7 @@ import { randFloat } from 'three/src/math/MathUtils.js'; |
|
|
const cubeMaterial = new THREE.MeshPhongMaterial({ map: texture }); |
|
|
const cubeMaterial = new THREE.MeshPhongMaterial({ map: texture }); |
|
|
|
|
|
|
|
|
// Create an InstancedMesh
|
|
|
// Create an InstancedMesh
|
|
|
count = 100; |
|
|
count = 80; |
|
|
instancedMesh = new THREE.InstancedMesh(cubeGeometry, cubeMaterial, count); |
|
|
instancedMesh = new THREE.InstancedMesh(cubeGeometry, cubeMaterial, count); |
|
|
scene.add(instancedMesh) |
|
|
scene.add(instancedMesh) |
|
|
dummy = new THREE.Object3D(); |
|
|
dummy = new THREE.Object3D(); |
|
@ -55,7 +55,7 @@ import { randFloat } from 'three/src/math/MathUtils.js'; |
|
|
for (let i = 0; i < count; i++) { |
|
|
for (let i = 0; i < count; i++) { |
|
|
let size = randFloat(5, 8); |
|
|
let size = randFloat(5, 8); |
|
|
dummy.scale.set(size, size, size); |
|
|
dummy.scale.set(size, size, size); |
|
|
dummy.position.set(randFloat(-10, 10), randFloat(-6, 3), 0); |
|
|
dummy.position.set(randFloat(-10, 10), randFloat(-8, 8), 0); |
|
|
dummy.updateMatrix(); |
|
|
dummy.updateMatrix(); |
|
|
instancedMesh.setMatrixAt(i, dummy.matrix); |
|
|
instancedMesh.setMatrixAt(i, dummy.matrix); |
|
|
} |
|
|
} |
|
|