Skip to content

Commit

Permalink
quick optimization to use tmp ray and plane for pan calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
kpal81xd committed May 1, 2024
1 parent a71ff92 commit 1e4a1e2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cameras/multi-camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type PointerMoveEvent = PointerEvent & {
const tmpVa = new Vec2();
const tmpV1 = new Vec3();
const tmpV2 = new Vec3();
const tmpR1 = new Ray();
const tmpP1 = new Plane();

const PASSIVE: any = { passive: false };

Expand Down Expand Up @@ -262,8 +264,8 @@ class MultiCamera extends BaseCamera {
const focalPos = tmpV2.add2(cameraPos, focusDirScaled);
const planeNormal = focusDirScaled.mulScalar(-1).normalize();

const plane = new Plane(planeNormal, -planeNormal.dot(focalPos));
const ray = new Ray(cameraPos, mouseW.sub(cameraPos).normalize());
const plane = tmpP1.setFromPointNormal(focalPos, planeNormal);
const ray = tmpR1.set(cameraPos, mouseW.sub(cameraPos).normalize());

plane.intersectsRay(ray, point);
}
Expand Down

0 comments on commit 1e4a1e2

Please sign in to comment.