Skip to content

Commit

Permalink
remove example
Browse files Browse the repository at this point in the history
  • Loading branch information
agargaro committed Jan 15, 2025
1 parent 61da9c9 commit 7634920
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions examples/remove.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Main, PerspectiveCameraAuto } from '@three.ez/main';
import { BoxGeometry, DirectionalLight, MeshLambertMaterial, Scene } from 'three';
import { OrbitControls } from 'three/examples/jsm/Addons.js';
import { InstancedMesh2 } from '../src/index.js';

const camera = new PerspectiveCameraAuto().translateZ(10);
camera.add(new DirectionalLight('white', 3));
const scene = new Scene();
const main = new Main(); // init renderer and other stuff
main.createView({ scene, camera, backgroundColor: 'skyblue' });
const controls = new OrbitControls(camera, main.renderer.domElement);
controls.update();

const boxes = new InstancedMesh2(new BoxGeometry(), new MeshLambertMaterial());
scene.add(boxes);

boxes.addInstances(20, (obj, index) => {
obj.position.randomDirection().multiplyScalar(Math.random() * 5);
obj.quaternion.random();
obj.color = Math.random() * 0xfffff;
});

boxes.computeBVH();

boxes.on('click', (e) => {
boxes.removeInstances(e.intersection.instanceId);
});
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/overrideMaterial.ts"></script>
<script type="module" src="./examples/remove.ts"></script>
<span class="info" id="count"></span>
</body>

Expand Down

0 comments on commit 7634920

Please sign in to comment.