I created a custom mesh using the WebGPURenderer, and later on, I needed to update the attributes of this custom mesh because the number of vertices changed. I recreated a geometry and then reassigned the geometry properties, but the attribute update did not take effect at that time; it still used the original attribute for rendering. The update only took effect after the material was updated. Why is that?
pseudo code
// init object
const geometry = new BufferGeometry();
const array = [
[0.5, 0],
[0, 0],
[0, 0.5]
];
geometry.setAttribute('position', new Float32ArrayAttribute(new Float32Array(array), 3));
const mesh = new Mesh(geometry, material);
...
// wait a moment, then update
setTimeout(() => {
mesh.geometry.dispose();
const newGeometry = new BufferGeometry();
const array = [
[0, -0.5],
[0, 0],
[0.5, 0].
[0.5, -0.5]
];
newGeometry.setAttribute('position', new Float32ArrayAttribute(new Float32Array(array), 3));
mesh.geometry = newGeometry;
}, 3000);
This problem has been bothering me for a long time recently. I would be grateful for any help.