Skip to content

Commit

Permalink
feat(core): allow to override raycaster mouse position
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Oct 20, 2024
1 parent ac32b51 commit 59916b4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thatopen/components",
"description": "Collection of core functionalities to author BIM apps.",
"version": "2.4.0-alpha.8",
"version": "2.4.0-alpha.9",
"author": "That Open Company",
"contributors": [
"Antonio Gonzalez Viegas (https://github.com/agviegas)",
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/core/Raycasters/src/simple-raycaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@ export class SimpleRaycaster implements Disposable {
* @param items - the [meshes](https://threejs.org/docs/#api/en/objects/Mesh)
* to query. If not provided, it will query all the meshes stored in
* {@link Components.meshes}.
* @param position - the screen position to use for raycasting. If not provided,
* the last pointer (mouse/touch) position will be used.
*/
castRay(
items: THREE.Object3D[] = Array.from(this.world.meshes),
position = this.mouse.position,
): THREE.Intersection | null {
if (!this.world) {
throw new Error("A world is needed to cast rays!");
}
const camera = this.world.camera.three;
this.three.setFromCamera(this.mouse.position, camera);
this.three.setFromCamera(position, camera);
return this.intersect(items);
}

Expand Down
6 changes: 0 additions & 6 deletions packages/front/src/fragments/Highlighter/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ stats.dom.style.zIndex = "unset";
world.renderer.onBeforeUpdate.add(() => stats.begin());
world.renderer.onAfterUpdate.add(() => stats.end());

window.addEventListener("keydown", (e) => {
if(e.code === "KeyP") {
components.dispose();
}
})

/* MD
### 🎉 Wrap up
---
Expand Down

0 comments on commit 59916b4

Please sign in to comment.