i need to form a custom model by particles.What i want is this https://youtu.be/R4XtWEMrwe0?si=JFgc4Vqdv4Md5vfC .see this
const sphereGeometry = new THREE.SphereGeometry(0.003, 16, 16);
const particles = [];
const originalPositions = [];
const originalMaterials = [];
const highlightMaterial = new THREE.MeshStandardMaterial({ color: 0x00ff00 });
loader.load('/mesh3.glb', (gltf) => {
const model = gltf.scene;
model.scale.set(0.8, 0.8, 0.8);
model.position.set(0, -0.7, -1);
if (model) {
model.traverse((child) => {
if (child.isMesh) {
const vertices = child.geometry.attributes.position;
for (let i = 0; i < vertices.count; i++) {
const x = vertices.getX(i);
const y = vertices.getY(i);
const z = vertices.getZ(i);
const randomX = x + (Math.random() - 0.5) * 0.1;
const randomY = y + (Math.random() - 0.5) * 0.1;
const randomZ = z + (Math.random() - 0.5) * 0.1;
const particle = new THREE.Mesh(sphereGeometry, new THREE.MeshStandardMaterial());
particle.position.set(randomX, randomY, randomZ);
particle.position.copy(child.localToWorld(particle.position));
particles.push(particle);
originalPositions.push(new THREE.Vector3(randomX, randomY, randomZ));
originalMaterials.push(particle.material.clone());
}
}
});
scene.add(...particles);
}
});
this is what i have now. but it looks bad.
please help if anyone know this.