@inweb/viewer-three 26.12.0 → 26.12.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/viewer-three",
3
- "version": "26.12.0",
3
+ "version": "26.12.2",
4
4
  "description": "JavaScript library for rendering CAD and BIM files in a browser using Three.js",
5
5
  "homepage": "https://cloud.opendesign.com/docs/index.html",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -35,10 +35,10 @@
35
35
  "docs": "typedoc"
36
36
  },
37
37
  "dependencies": {
38
- "@inweb/client": "~26.12.0",
39
- "@inweb/eventemitter2": "~26.12.0",
40
- "@inweb/markup": "~26.12.0",
41
- "@inweb/viewer-core": "~26.12.0"
38
+ "@inweb/client": "~26.12.2",
39
+ "@inweb/eventemitter2": "~26.12.2",
40
+ "@inweb/markup": "~26.12.2",
41
+ "@inweb/viewer-core": "~26.12.2"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/three": "^0.180.0",
@@ -24,11 +24,11 @@
24
24
  import {
25
25
  Box3,
26
26
  LinearSRGBColorSpace,
27
- // LinearToneMapping,
28
27
  Object3D,
29
28
  OrthographicCamera,
30
29
  PerspectiveCamera,
31
30
  Plane,
31
+ Raycaster,
32
32
  Scene,
33
33
  Sphere,
34
34
  Vector2,
@@ -832,7 +832,11 @@ export class Viewer
832
832
  }
833
833
 
834
834
  // IWorldTransform
835
-
835
+ // ===================== AI-CODE-START ======================
836
+ // Source: Claude Sonnet 4.5
837
+ // Date: 2025-11-25
838
+ // Reviewer: vitaly.ivanov@opendesign.com
839
+ // Issue: CLOUD-5990
836
840
  screenToWorld(position: { x: number; y: number }): { x: number; y: number; z: number } {
837
841
  if (!this.renderer) return { x: position.x, y: position.y, z: 0 };
838
842
 
@@ -840,11 +844,36 @@ export class Viewer
840
844
  const x = position.x / (rect.width / 2) - 1;
841
845
  const y = -position.y / (rect.height / 2) + 1;
842
846
 
843
- const point = new Vector3(x, y, -1);
844
- point.unproject(this.camera);
847
+ if (this.camera["isPerspectiveCamera"]) {
848
+ // Create a raycaster from the screen position
849
+ const raycaster = new Raycaster();
850
+ const mouse = new Vector2(x, y);
851
+ raycaster.setFromCamera(mouse, this.camera);
852
+
853
+ // Create a plane perpendicular to the camera direction at the target point
854
+ const cameraDirection = new Vector3();
855
+ this.camera.getWorldDirection(cameraDirection);
856
+ const targetPlane = new Plane().setFromNormalAndCoplanarPoint(cameraDirection, this.target);
857
+
858
+ // Intersect the ray with the target plane
859
+ const intersectionPoint = new Vector3();
860
+ raycaster.ray.intersectPlane(targetPlane, intersectionPoint);
861
+
862
+ // If intersection fails (ray parallel to plane), fallback to near plane unprojection
863
+ if (!intersectionPoint) {
864
+ const point = new Vector3(x, y, -1);
865
+ point.unproject(this.camera);
866
+ return { x: point.x, y: point.y, z: point.z };
867
+ }
868
+ return { x: intersectionPoint.x, y: intersectionPoint.y, z: intersectionPoint.z };
869
+ } else {
870
+ const point = new Vector3(x, y, -1);
871
+ point.unproject(this.camera);
845
872
 
846
- return { x: point.x, y: point.y, z: point.z };
873
+ return { x: point.x, y: point.y, z: point.z };
874
+ }
847
875
  }
876
+ // ===================== AI-CODE-END ======================
848
877
 
849
878
  worldToScreen(position: { x: number; y: number; z: number }): { x: number; y: number } {
850
879
  if (!this.renderer) return { x: position.x, y: position.y };