the custom model is not rotating when it comes with particle. See this to understand the situation.
const sphereGeometry = new THREE.SphereGeometry(0.004, 16, 16);
const particles = [];
const originalPositions = [];
const originalMaterials = [];
const highlightMaterial = new THREE.MeshStandardMaterial({ color: 0x00ff00 });
let sampler;
let model;
loader.load('/earth.glb', (gltf) => {
model = gltf.scene;
model.scale.set(0.7, 0.7, 0.7)
// model.position.set(0, -0.7, -1);
model.position.set(0, -0.1, -1);
gltf.scene.traverse((obj) => {
if (obj.isMesh) {
sampler = new MeshSurfaceSampler(obj).build();
const numParticles = 3000;
for (let i = 0; i < numParticles; i++) {
const sample = new THREE.Vector3();
sampler.sample(sample);
const particle = new THREE.Mesh(sphereGeometry, new THREE.MeshStandardMaterial());
particle.position.copy(sample);
particle.position.copy(obj.localToWorld(particle.position));
particle.rotation.copy(obj.rotation);
particles.push(particle);
originalPositions.push(sample.clone());
originalMaterials.push(particle.material.clone());
scene.add(particle)
}
}
});
});
const tick = () => {
const elapsedTime = clock.getElapsedTime();
// updateCameraPosition();
if (model) {
model.rotation.y += 0.005
}
// updateParticles();
window.requestAnimationFrame(tick)
composer.render()
}
tick()
}, [])