Skip to content

Commit cf0b8fc

Browse files
fix: correct raycasting frustum calculation for orthographic cameras (#136)
1 parent b34fc77 commit cf0b8fc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/fragments/src/FragmentsModels/src/model/raycast-manager.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,14 @@ export class RaycastManager {
154154
}
155155

156156
private setEnds(camera: THREE.Camera) {
157-
this._n.constant = camera.position.length();
157+
if (camera instanceof THREE.OrthographicCamera) {
158+
this._n.constant = camera.near;
159+
this._f.constant = camera.far;
160+
} else {
161+
this._n.constant = camera.position.length();
162+
this._f.constant = Infinity;
163+
}
158164
this._f.normal = this._n.normal;
159-
this._f.constant = Infinity;
160165
}
161166

162167
private screenToCast(p: Point, element: any, result = new THREE.Vector2()) {

0 commit comments

Comments
 (0)