cant scale this particles See this video
please help if anyone knows
const sphereGeometry = new THREE.SphereGeometry(0.004, 16, 16);
const particles = new THREE.InstancedMesh(
sphereGeometry,
new THREE.MeshStandardMaterial(),
5000 // Number of instances
);
particles.instanceMatrix.setUsage(THREE.DynamicDrawUsage); // Set usage for dynamic updates
let sampler;
let model;
loader.load('/earth.glb', (gltf) => {
model = gltf.scene;
model.scale.set(0.4, 0.4, 0.4);
model.position.set(0, -0.1, -1);
gltf.scene.traverse((obj) => {
if (obj.isMesh) {
sampler = new MeshSurfaceSampler(obj).build();
const matrix = new THREE.Matrix4();
for (let i = 0; i < 30000; i++) {
const sample = new THREE.Vector3();
sampler.sample(sample);
// Set the position of each instance
matrix.compose(sample, new THREE.Quaternion(), new THREE.Vector3(0.4, 0.4, 0.4));
matrix.makeTranslation(sample.x, sample.y, sample.z);
particles.setMatrixAt(i, matrix);
}
model.scale.set(0.4, 0.4, 0.4);
scene.add(particles);
scene.add(model);
}
});