Skip to content

Commit

Permalink
Merge pull request #140 from lewibs/maintenance/raycaster
Browse files Browse the repository at this point in the history
Raycaster refactoring
  • Loading branch information
HoyosJuan authored Nov 29, 2023
2 parents 925ca79 + 2bb68e7 commit 1c16724
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/core/SimpleRaycaster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ export class SimpleRaycaster extends BaseRaycaster implements Disposable {
): THREE.Intersection | null {
const camera = this.components.camera.get();
this._raycaster.setFromCamera(this.mouse.position, camera);
const result = this._raycaster.intersectObjects(items);
const filtered = this.filterClippingPlanes(result);
return filtered.length > 0 ? filtered[0] : null;
return this.intersect(items)
}

castRayFromVector(
Expand All @@ -59,6 +57,12 @@ export class SimpleRaycaster extends BaseRaycaster implements Disposable {
items = this.components.meshes
) {
this._raycaster.set(origin, direction);
return this.intersect(items);
}

private intersect(
items: THREE.Mesh[] = this.components.meshes
) {
const result = this._raycaster.intersectObjects(items);
const filtered = this.filterClippingPlanes(result);
return filtered.length > 0 ? filtered[0] : null;
Expand Down

0 comments on commit 1c16724

Please sign in to comment.