Skip to content

Commit

Permalink
example
Browse files Browse the repository at this point in the history
  • Loading branch information
agargaro committed Nov 29, 2024
1 parent 55123f7 commit 4940c4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions examples/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ main.createView({
}
});

const instancedMesh = new InstancedMesh2(new BoxGeometry(), new MeshNormalMaterial(), { capacity: undefined });
const instancedMesh = new InstancedMesh2(new BoxGeometry(), new MeshNormalMaterial()); // capacity is optional
instancedMesh.on('click', (e) => instancedMesh.setVisibilityAt(e.intersection.instanceId, false));
scene.add(instancedMesh);

scene.on('animate', () => {
if (instancedMesh.instancesCount >= 1000000) return;
if (instancedMesh.instancesCount >= 10000000) return;

instancedMesh.addInstances(625, (obj, index) => {
obj.position.randomDirection().multiplyScalar(Math.random() * 100000 + 200);
obj.position.randomDirection().multiplyScalar(Math.random() * 1000000 + 200);
obj.scale.random().multiplyScalar(Math.random() * 5 + 1);
obj.quaternion.random();
});

if (instancedMesh.instancesCount === 625) { // FIX
if (instancedMesh.instancesCount === 625) {
instancedMesh.computeBVH({ getBBoxFromBSphere: true }); // fix if count is 0
}
});
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</head>

<body>
<script type="module" src="./examples/morph.ts"></script>
<script type="module" src="./examples/test.ts"></script>
<span class="info" id="count"></span>
</body>

Expand Down

0 comments on commit 4940c4a

Please sign in to comment.