@inweb/viewer-three 26.12.0 → 26.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6965,9 +6965,27 @@ class Viewer extends EventEmitter2 {
6965
6965
  const rect = this.canvas.getBoundingClientRect();
6966
6966
  const x = position.x / (rect.width / 2) - 1;
6967
6967
  const y = -position.y / (rect.height / 2) + 1;
6968
- const point = new Vector3(x, y, -1);
6969
- point.unproject(this.camera);
6970
- return { x: point.x, y: point.y, z: point.z };
6968
+ if (this.camera["isPerspectiveCamera"]) {
6969
+ const raycaster = new Raycaster();
6970
+ const mouse = new Vector2(x, y);
6971
+ raycaster.setFromCamera(mouse, this.camera);
6972
+ const cameraDirection = new Vector3();
6973
+ this.camera.getWorldDirection(cameraDirection);
6974
+ const targetPlane = new Plane().setFromNormalAndCoplanarPoint(cameraDirection, this.target);
6975
+ const intersectionPoint = new Vector3();
6976
+ raycaster.ray.intersectPlane(targetPlane, intersectionPoint);
6977
+ if (!intersectionPoint) {
6978
+ const point = new Vector3(x, y, -1);
6979
+ point.unproject(this.camera);
6980
+ return { x: point.x, y: point.y, z: point.z };
6981
+ }
6982
+ return { x: intersectionPoint.x, y: intersectionPoint.y, z: intersectionPoint.z };
6983
+ }
6984
+ else {
6985
+ const point = new Vector3(x, y, -1);
6986
+ point.unproject(this.camera);
6987
+ return { x: point.x, y: point.y, z: point.z };
6988
+ }
6971
6989
  }
6972
6990
  worldToScreen(position) {
6973
6991
  if (!this.renderer)