From e11ef1045d92f6b192efcfafcd008de46fb35b46 Mon Sep 17 00:00:00 2001 From: diarmidmackenzie Date: Tue, 21 Nov 2023 11:45:22 +0000 Subject: [PATCH] Set instancedMesh count correctly when adjusting capacity --- src/instanced-mesh.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/instanced-mesh.js b/src/instanced-mesh.js index 477d375..5ba6b96 100644 --- a/src/instanced-mesh.js +++ b/src/instanced-mesh.js @@ -256,7 +256,9 @@ AFRAME.registerComponent('instanced-mesh', { var newMesh = new THREE.InstancedMesh(node.geometry, node.material, this.data.capacity); + newMesh.count = this.members; newMeshes.push(newMesh); + for (ii = 0; ii < Math.min(oldMesh.count, this.data.capacity); ii ++ ) { oldMesh.getMatrixAt(ii, this.matrix) newMesh.setMatrixAt(ii, this.matrix);