@inweb/viewer-visualize 26.12.6 → 26.12.7

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-visualize",
3
- "version": "26.12.6",
3
+ "version": "26.12.7",
4
4
  "description": "JavaScript library for rendering CAD and BIM files in a browser using VisualizeJS",
5
5
  "homepage": "https://cloud.opendesign.com/docs/index.html",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -29,10 +29,10 @@
29
29
  "docs": "typedoc"
30
30
  },
31
31
  "dependencies": {
32
- "@inweb/client": "~26.12.6",
33
- "@inweb/eventemitter2": "~26.12.6",
34
- "@inweb/markup": "~26.12.6",
35
- "@inweb/viewer-core": "~26.12.6"
32
+ "@inweb/client": "~26.12.7",
33
+ "@inweb/eventemitter2": "~26.12.7",
34
+ "@inweb/markup": "~26.12.7",
35
+ "@inweb/viewer-core": "~26.12.7"
36
36
  },
37
37
  "visualizeJS": "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js"
38
38
  }
@@ -167,7 +167,7 @@ export class VisualizeMarkup implements IMarkup {
167
167
  const visLib = this._viewer.visLib();
168
168
  const visViewer = this._viewer.visViewer();
169
169
 
170
- if (!viewpoint) viewpoint = {};
170
+ if (!viewpoint) viewpoint = { custom_fields: {} };
171
171
 
172
172
  viewpoint.lines = [];
173
173
  viewpoint.texts = [];
@@ -219,13 +219,8 @@ export class VisualizeMarkup implements IMarkup {
219
219
  }
220
220
  itr.delete();
221
221
 
222
- viewpoint.snapshot = {
223
- data: visLib.canvas.toDataURL("image/jpeg", 0.25),
224
- };
225
-
226
- viewpoint.custom_fields = {
227
- markup_color: this.getMarkupColor(),
228
- };
222
+ viewpoint.snapshot = { data: visLib.canvas.toDataURL("image/jpeg", 0.25) };
223
+ viewpoint.custom_fields.markup_color = this.getMarkupColor();
229
224
 
230
225
  return viewpoint;
231
226
  }
@@ -1021,12 +1021,49 @@ export class Viewer
1021
1021
  true
1022
1022
  );
1023
1023
 
1024
- this.syncOverlay();
1024
+ this.options.cameraMode = "orthographic";
1025
1025
  this.emitEvent({ type: "changecameramode", mode: "orthographic" });
1026
1026
  }
1027
1027
  };
1028
1028
 
1029
- const setPerspectiveCamera = (perspective_camera: IPerspectiveCamera) => {};
1029
+ const setPerspectiveCamera = (perspective_camera: IPerspectiveCamera) => {
1030
+ if (perspective_camera) {
1031
+ // ===================== AI-CODE-START ======================
1032
+ // Source: Claude Sonnet 4.5
1033
+ // Date: 2025-12-03
1034
+ // Reviewer: roman.mochalov@opendesign.com
1035
+ // Issue: CLOUD-5997
1036
+ // Notes: Originally AI-generated, modified manually
1037
+
1038
+ const aspectRatio = this.canvas.width / this.canvas.height;
1039
+
1040
+ const position = perspective_camera.view_point;
1041
+ const target = perspective_camera.direction;
1042
+ const fov = (perspective_camera.field_of_view * Math.PI) / 180;
1043
+
1044
+ const dx = target.x - position.x;
1045
+ const dy = target.y - position.y;
1046
+ const dz = target.z - position.z;
1047
+ const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
1048
+
1049
+ const fieldHeight = 2 * distance * Math.tan(fov / 2);
1050
+ const fieldWidth = fieldHeight * aspectRatio;
1051
+
1052
+ // ===================== AI-CODE-END ======================
1053
+
1054
+ activeView.setView(
1055
+ getPoint3dAsArray(perspective_camera.view_point),
1056
+ getPoint3dAsArray(perspective_camera.direction),
1057
+ getPoint3dAsArray(perspective_camera.up_vector),
1058
+ fieldWidth,
1059
+ fieldHeight,
1060
+ false
1061
+ );
1062
+
1063
+ this.options.cameraMode = "perspective";
1064
+ this.emitEvent({ type: "changecameramode", mode: "perspective" });
1065
+ }
1066
+ };
1030
1067
 
1031
1068
  const setClippingPlanes = (clipping_planes: IClippingPlane[]) => {
1032
1069
  if (clipping_planes) {
@@ -1060,6 +1097,8 @@ export class Viewer
1060
1097
  setSelection(viewpoint.custom_fields?.selection2 || viewpoint.selection);
1061
1098
  this._markup.setViewpoint(viewpoint);
1062
1099
 
1100
+ this.syncOverlay();
1101
+
1063
1102
  this.setActiveDragger(draggerName);
1064
1103
  this.emitEvent({ type: "drawviewpoint", data: viewpoint });
1065
1104
  this.update();
@@ -1076,18 +1115,47 @@ export class Viewer
1076
1115
  };
1077
1116
 
1078
1117
  const getOrthogonalCamera = (): IOrthogonalCamera => {
1079
- return {
1080
- view_point: getPoint3dFromArray(activeView.viewPosition),
1081
- direction: getPoint3dFromArray(activeView.viewTarget),
1082
- up_vector: getPoint3dFromArray(activeView.upVector),
1083
- field_width: activeView.viewFieldWidth,
1084
- field_height: activeView.viewFieldHeight,
1085
- view_to_world_scale: 1,
1086
- };
1118
+ if (!activeView.perspective)
1119
+ return {
1120
+ view_point: getPoint3dFromArray(activeView.viewPosition),
1121
+ direction: getPoint3dFromArray(activeView.viewTarget),
1122
+ up_vector: getPoint3dFromArray(activeView.upVector),
1123
+ field_width: activeView.viewFieldWidth,
1124
+ field_height: activeView.viewFieldHeight,
1125
+ view_to_world_scale: 1,
1126
+ };
1127
+ else return undefined;
1087
1128
  };
1088
1129
 
1089
1130
  const getPerspectiveCamera = (): IPerspectiveCamera => {
1090
- return undefined;
1131
+ if (activeView.perspective) {
1132
+ // ===================== AI-CODE-START ======================
1133
+ // Source: Claude Sonnet 4.5
1134
+ // Date: 2025-12-03
1135
+ // Reviewer: roman.mochalov@opendesign.com
1136
+ // Issue: CLOUD-5997
1137
+ // Notes: Originally AI-generated, modified manually
1138
+
1139
+ const position = activeView.viewPosition;
1140
+ const target = activeView.viewTarget;
1141
+ const fieldHeight = activeView.viewFieldHeight;
1142
+
1143
+ const dx = target[0] - position[0];
1144
+ const dy = target[1] - position[1];
1145
+ const dz = target[2] - position[2];
1146
+ const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
1147
+
1148
+ const fov = 2 * Math.atan(fieldHeight / (2 * distance));
1149
+
1150
+ // ===================== AI-CODE-END ======================
1151
+
1152
+ return {
1153
+ view_point: getPoint3dFromArray(activeView.viewPosition),
1154
+ direction: getPoint3dFromArray(activeView.viewTarget),
1155
+ up_vector: getPoint3dFromArray(activeView.upVector),
1156
+ field_of_view: (fov * 180) / Math.PI,
1157
+ };
1158
+ } else return undefined;
1091
1159
  };
1092
1160
 
1093
1161
  const getClippingPlanes = (): IClippingPlane[] => {