I create a BufferGeometry and set its attributes like so:
this.clearGroups();
this.addGroup(groupStart, groupCount, 0);
const indexAttribute = new BufferAttribute(new Uint32Array(indices), 1);
this.setIndex(indexAttribute);
const positionAttribute = new BufferAttribute(new Float32Array(verticesCount * 3), 3);
this.setAttribute('position', positionAttribute);
Now occasionally I recall this setup code if the number of vertices changes. The strange thing is that the mesh using this BufferGeometry will disappear if the number of vertices INCREASES to be more than the initial number. Even more strangely so, it will still be visible in shadow-maps and only the direct rendering will disappear.
However, if I add
for (const key of Object.keys(this.attributes)) {
this.deleteAttribute(key);
}
next to the
this.clearGroups();
call, effectively removing all attributes first before setting a new one, it will work properly.
What I suspect is, that the new position-buffer-attribute never gets re-set (that’s why it works when the number of vertices DECREASES (still working on the original buffer), but won’t work when INCREASING them.
Is this intended behaviour ?