I’m trying to create a cloth simulation using @react-three/fiber
and @react-three/cannon
.
I created particles that respond to physics. However, I would like to reproduce this behavior on cloth. However, I can’t get the effect.
useFrame(() => {
if (particles.current[0][0]) {
const geom = meshRef.current.geometry;
const positions = geom.attributes.position.array;
positions.forEach((v, vi) => {
let x = vi % RESOLUTIONX
let y = Math.floor(vi / RESOLUTIONX)
if (particles.current[y] && particles.current[y][x].current) {
geom.attributes.position.setXYZ(vi, ... particles.current[y][x].current.particle.current.position.toArray())
}
})
geom.attributes.position.needsUpdate = true;
geom.computeVertexNormals();
}
});