@inweb/viewer-visualize 25.11.0 → 25.11.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.
@@ -24,7 +24,7 @@ export declare class VisualizeMarkup implements IMarkup {
24
24
  colorizeAllMarkup(r?: number, g?: number, b?: number): void;
25
25
  colorizeSelectedMarkups(r?: number, g?: number, b?: number): void;
26
26
  setViewpoint(viewpoint: IViewpoint): void;
27
- getViewpoint(): IViewpoint;
27
+ getViewpoint(viewpoint: IViewpoint): IViewpoint;
28
28
  enableEditMode(mode: MarkupMode | false): this;
29
29
  createObject(type: string, params: any): IMarkupObject;
30
30
  getObjects(): IMarkupObject[];
@@ -148,9 +148,9 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
148
148
  syncOptions(options?: IOptions): this;
149
149
  syncHighlightingOptions(options?: IOptions): this;
150
150
  /**
151
- * List of names of registered draggers.
151
+ * List of names of available draggers.
152
152
  *
153
- * The following draggers are registered by default:
153
+ * The following draggers are available by default:
154
154
  *
155
155
  * - `Line`
156
156
  * - `Text`
@@ -181,18 +181,9 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
181
181
  activeDragger(): IDragger | null;
182
182
  setActiveDragger(name?: string): IDragger | null;
183
183
  resetActiveDragger(): void;
184
- /**
185
- * Removes all cutting planes.
186
- */
187
184
  clearSlices(): void;
188
- /**
189
- * Clears the overlay view.
190
- */
191
185
  clearOverlay(): void;
192
- /**
193
- * Creates an overlay view. Overlay view is used to draw cutting planes and `Visualize` markups.
194
- */
195
- syncOverlay(): any;
186
+ syncOverlay(): void;
196
187
  is3D(): boolean;
197
188
  screenToWorld(position: {
198
189
  x: number;
@@ -321,20 +312,7 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
321
312
  * Adds an empty `Visualize` markup entity to the overlay.
322
313
  */
323
314
  addMarkupEntity(entityName: string): any;
324
- /**
325
- * Sets the viewer state to the specified viewpoint.
326
- *
327
- * To get a list of available viewpoints from the server for a specific file, use the
328
- * `File.getViewpoints()`.
329
- *
330
- * @param viewpoint - Viewpoint data.
331
- */
332
315
  drawViewpoint(viewpoint: IViewpoint): void;
333
- /**
334
- * Saves the viewer state at the viewpoint.
335
- *
336
- * To save a viewpoint to the server for a specific file, use the `File.saveViewpoint()`.
337
- */
338
316
  createViewpoint(): IViewpoint;
339
317
  private getPoint3dFromArray;
340
318
  private getLogicalPoint3dAsArray;
@@ -342,6 +320,8 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
342
320
  private setOrthogonalCameraSettings;
343
321
  private getClippingPlanes;
344
322
  private setClippingPlanes;
323
+ private getSelection;
324
+ private setSelection;
345
325
  /**
346
326
  * Executes the command denoted by the given command. If the command is not found, tries to
347
327
  * set active dragger with the specified name.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inweb/viewer-visualize",
3
- "version": "25.11.0",
4
- "description": "3D viewer powered by VisualizeJS",
3
+ "version": "25.11.2",
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",
7
7
  "author": "Open Design Alliance",
@@ -29,10 +29,10 @@
29
29
  "docs": "typedoc"
30
30
  },
31
31
  "dependencies": {
32
- "@inweb/client": "~25.11.0",
33
- "@inweb/eventemitter2": "~25.11.0",
34
- "@inweb/markup": "~25.11.0",
35
- "@inweb/viewer-core": "~25.11.0"
32
+ "@inweb/client": "~25.11.2",
33
+ "@inweb/eventemitter2": "~25.11.2",
34
+ "@inweb/markup": "~25.11.2",
35
+ "@inweb/viewer-core": "~25.11.2"
36
36
  },
37
37
  "visualizeJS": "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js"
38
38
  }
@@ -27,7 +27,7 @@ import { Viewer } from "../Viewer";
27
27
  function resetView(viewer: Viewer): void {
28
28
  if (!viewer.visualizeJs) return;
29
29
 
30
- viewer.executeCommand("setActiveDragger", "");
30
+ viewer.executeCommand("setActiveDragger");
31
31
  viewer.executeCommand("clearSlices");
32
32
  viewer.executeCommand("clearOverlay");
33
33
  viewer.executeCommand("setMarkupColor");
@@ -133,7 +133,8 @@ export class OdaWalkDragger extends OdBaseDragger {
133
133
  avp.delete();
134
134
  }
135
135
 
136
- this.subject.update();
136
+ // CLOUD-5359 Demo Viewer crashes after the Walk Mode
137
+ this.subject.update(true);
137
138
  this.subject.options.enableZoomWheel = this.enableZoomWheelPreviousValue;
138
139
  }
139
140
 
@@ -63,6 +63,7 @@ export class TCSLoader extends BaseLoader {
63
63
 
64
64
  this.viewer.syncOpenCloudVisualStyle(false);
65
65
  this.viewer.syncOptions();
66
+ this.viewer.syncOverlay();
66
67
  this.viewer.resize();
67
68
 
68
69
  this.viewer.emitEvent({ type: "databasechunk", data, model: this.model });
@@ -58,6 +58,7 @@ export class VsfXLoader extends BaseLoader {
58
58
 
59
59
  this.viewer.syncOpenCloudVisualStyle(false);
60
60
  this.viewer.syncOptions();
61
+ this.viewer.syncOverlay();
61
62
  this.viewer.resize();
62
63
  }
63
64
 
@@ -65,6 +65,7 @@ export class VsfXPartialLoader extends BaseLoader {
65
65
 
66
66
  this.viewer.syncOpenCloudVisualStyle(false);
67
67
  this.viewer.syncOptions();
68
+ this.viewer.syncOverlay();
68
69
  this.viewer.resize();
69
70
 
70
71
  this.viewer.emitEvent({ type: "databasechunk", data: chunk, model: this.model });
@@ -61,6 +61,7 @@ export class VsfXStreamingLoader extends BaseLoader {
61
61
 
62
62
  this.viewer.syncOpenCloudVisualStyle(false);
63
63
  this.viewer.syncOptions();
64
+ this.viewer.syncOverlay();
64
65
  this.viewer.resize();
65
66
 
66
67
  this.viewer.emitEvent({ type: "databasechunk", data: chunk, model: this.model });
@@ -134,20 +134,20 @@ export class VisualizeMarkup implements IMarkup {
134
134
  this._viewer.update();
135
135
  }
136
136
 
137
- getViewpoint(): IViewpoint {
137
+ getViewpoint(viewpoint: IViewpoint): IViewpoint {
138
+ if (!this._viewer.visualizeJs) return {};
139
+
138
140
  function getLogicalPoint3dFromArray(array) {
139
141
  return { x: array[0], y: array[1], z: array[2] };
140
142
  }
141
143
 
142
- if (!this._viewer.visualizeJs) return {};
143
-
144
144
  const visLib = this._viewer.visLib();
145
145
  const visViewer = visLib.getViewer();
146
146
 
147
- const viewpoint: IViewpoint = {
148
- lines: [],
149
- texts: [],
150
- };
147
+ if (!viewpoint) viewpoint = {};
148
+
149
+ viewpoint.lines = [];
150
+ viewpoint.texts = [];
151
151
 
152
152
  const model = visViewer.getMarkupModel();
153
153
  const itr = model.getEntitiesIterator();
@@ -204,7 +204,6 @@ export class VisualizeMarkup implements IMarkup {
204
204
  markup_color: this.getMarkupColor(),
205
205
  };
206
206
 
207
- viewpoint.description = new Date().toDateString();
208
207
  return viewpoint;
209
208
  }
210
209
 
@@ -29,9 +29,11 @@ import {
29
29
  commands,
30
30
  Dragger,
31
31
  IClippingPlane,
32
+ IComponent,
32
33
  IDragger,
33
34
  IOrthogonalCamera,
34
35
  IOptions,
36
+ IPoint,
35
37
  IViewer,
36
38
  IViewpoint,
37
39
  Options,
@@ -253,6 +255,7 @@ export class Viewer
253
255
 
254
256
  this.syncOpenCloudVisualStyle(true);
255
257
  this.syncOptions();
258
+ this.syncOverlay();
256
259
 
257
260
  this._renderTime = performance.now();
258
261
  this.render(this._renderTime);
@@ -619,9 +622,9 @@ export class Viewer
619
622
  }
620
623
 
621
624
  /**
622
- * List of names of registered draggers.
625
+ * List of names of available draggers.
623
626
  *
624
- * The following draggers are registered by default:
627
+ * The following draggers are available by default:
625
628
  *
626
629
  * - `Line`
627
630
  * - `Text`
@@ -683,6 +686,7 @@ export class Viewer
683
686
  .join(" ");
684
687
  }
685
688
  this.emitEvent({ type: "changeactivedragger", data: name });
689
+ this.update();
686
690
  }
687
691
  return this._activeDragger;
688
692
  }
@@ -695,9 +699,6 @@ export class Viewer
695
699
  }
696
700
  }
697
701
 
698
- /**
699
- * Removes all cutting planes.
700
- */
701
702
  clearSlices(): void {
702
703
  if (!this.visualizeJs) return;
703
704
 
@@ -709,9 +710,6 @@ export class Viewer
709
710
  this.update();
710
711
  }
711
712
 
712
- /**
713
- * Clears the overlay view.
714
- */
715
713
  clearOverlay(): void {
716
714
  if (!this.visualizeJs) return;
717
715
 
@@ -719,10 +717,7 @@ export class Viewer
719
717
  this.update();
720
718
  }
721
719
 
722
- /**
723
- * Creates an overlay view. Overlay view is used to draw cutting planes and `Visualize` markups.
724
- */
725
- syncOverlay(): any {
720
+ syncOverlay(): void {
726
721
  if (!this.visualizeJs) return;
727
722
 
728
723
  const visViewer = this.visViewer();
@@ -998,6 +993,7 @@ export class Viewer
998
993
 
999
994
  this.syncOpenCloudVisualStyle(false);
1000
995
  this.syncOptions();
996
+ this.syncOverlay();
1001
997
  this.resize();
1002
998
 
1003
999
  this.emitEvent({ type: "geometryprogress", data: 1, buffer });
@@ -1047,6 +1043,7 @@ export class Viewer
1047
1043
 
1048
1044
  this.syncOpenCloudVisualStyle(false);
1049
1045
  this.syncOptions();
1046
+ this.syncOverlay();
1050
1047
  this.resize();
1051
1048
 
1052
1049
  this.emitEvent({ type: "geometryprogress", data: 1, buffer });
@@ -1082,6 +1079,7 @@ export class Viewer
1082
1079
  const visViewer = visLib.getViewer();
1083
1080
 
1084
1081
  this.setActiveDragger();
1082
+ this.clearSlices();
1085
1083
  this.clearOverlay();
1086
1084
 
1087
1085
  visViewer.clear();
@@ -1089,6 +1087,7 @@ export class Viewer
1089
1087
 
1090
1088
  this.syncOpenCloudVisualStyle(true);
1091
1089
  this.syncOptions();
1090
+ this.syncOverlay();
1092
1091
  this.resize();
1093
1092
 
1094
1093
  this.emitEvent({ type: "clear" });
@@ -1157,38 +1156,50 @@ export class Viewer
1157
1156
  return entityId;
1158
1157
  }
1159
1158
 
1160
- /**
1161
- * Sets the viewer state to the specified viewpoint.
1162
- *
1163
- * To get a list of available viewpoints from the server for a specific file, use the
1164
- * `File.getViewpoints()`.
1165
- *
1166
- * @param viewpoint - Viewpoint data.
1167
- */
1168
1159
  drawViewpoint(viewpoint: IViewpoint): void {
1160
+ if (!this.visualizeJs) return;
1161
+
1162
+ const draggerName = this._activeDragger?.name;
1163
+
1164
+ this.setActiveDragger();
1165
+ this.clearSlices();
1166
+ this.clearOverlay();
1167
+
1168
+ this.clearSelected();
1169
+ this.showAll();
1170
+ this.explode();
1171
+
1169
1172
  this.setOrthogonalCameraSettings(viewpoint.orthogonal_camera);
1170
1173
  this.setClippingPlanes(viewpoint.clipping_planes);
1174
+ this.setSelection(viewpoint.selection);
1171
1175
  this._markup.setViewpoint(viewpoint);
1176
+
1177
+ this.setActiveDragger(draggerName);
1178
+ this.emitEvent({ type: "drawviewpoint", data: viewpoint });
1179
+ this.update();
1172
1180
  }
1173
1181
 
1174
- /**
1175
- * Saves the viewer state at the viewpoint.
1176
- *
1177
- * To save a viewpoint to the server for a specific file, use the `File.saveViewpoint()`.
1178
- */
1179
1182
  createViewpoint(): IViewpoint {
1180
- const viewpoint = this._markup.getViewpoint();
1183
+ if (!this.visualizeJs) return {};
1184
+
1185
+ const viewpoint: IViewpoint = {};
1186
+
1181
1187
  viewpoint.orthogonal_camera = this.getOrthogonalCameraSettings();
1182
1188
  viewpoint.clipping_planes = this.getClippingPlanes();
1189
+ viewpoint.selection = this.getSelection();
1190
+ viewpoint.description = new Date().toDateString();
1191
+ this._markup.getViewpoint(viewpoint);
1192
+
1193
+ this.emitEvent({ type: "createviewpoint", data: viewpoint });
1183
1194
 
1184
1195
  return viewpoint;
1185
1196
  }
1186
1197
 
1187
- private getPoint3dFromArray(array) {
1198
+ private getPoint3dFromArray(array: number[]) {
1188
1199
  return { x: array[0], y: array[1], z: array[2] };
1189
1200
  }
1190
1201
 
1191
- private getLogicalPoint3dAsArray(point3d) {
1202
+ private getLogicalPoint3dAsArray(point3d: IPoint) {
1192
1203
  return [point3d.x, point3d.y, point3d.z];
1193
1204
  }
1194
1205
 
@@ -1209,10 +1220,6 @@ export class Viewer
1209
1220
  const visViewer = this.visViewer();
1210
1221
  const activeView = visViewer.activeView;
1211
1222
 
1212
- this.resetActiveDragger();
1213
- this.clearSlices();
1214
- this.clearOverlay();
1215
-
1216
1223
  if (settings) {
1217
1224
  activeView.setView(
1218
1225
  this.getLogicalPoint3dAsArray(settings.view_point),
@@ -1222,9 +1229,8 @@ export class Viewer
1222
1229
  settings.field_height,
1223
1230
  true
1224
1231
  );
1232
+ this.syncOverlay();
1225
1233
  }
1226
-
1227
- this.syncOverlay();
1228
1234
  }
1229
1235
 
1230
1236
  private getClippingPlanes(): IClippingPlane[] {
@@ -1235,25 +1241,28 @@ export class Viewer
1235
1241
  for (let i = 0; i < activeView.numCuttingPlanes(); i++) {
1236
1242
  const cuttingPlane = activeView.getCuttingPlane(i);
1237
1243
 
1238
- const plane = {
1244
+ const clipping_plane = {
1239
1245
  location: this.getPoint3dFromArray(cuttingPlane.getOrigin()),
1240
1246
  direction: this.getPoint3dFromArray(cuttingPlane.normal()),
1241
1247
  };
1242
1248
 
1243
- clipping_planes.push(plane);
1249
+ clipping_planes.push(clipping_plane);
1244
1250
  }
1245
1251
 
1246
1252
  return clipping_planes;
1247
1253
  }
1248
1254
 
1249
- private setClippingPlanes(clippingPlanes: IClippingPlane[]) {
1250
- if (clippingPlanes) {
1255
+ private setClippingPlanes(clipping_planes: IClippingPlane[]) {
1256
+ if (clipping_planes) {
1251
1257
  const visViewer = this.visViewer();
1252
1258
  const activeView = visViewer.activeView;
1253
1259
 
1254
- for (const plane of clippingPlanes) {
1260
+ for (const clipping_plane of clipping_planes) {
1255
1261
  const cuttingPlane = new (this.visLib().OdTvPlane)();
1256
- cuttingPlane.set(this.getLogicalPoint3dAsArray(plane.location), this.getLogicalPoint3dAsArray(plane.direction));
1262
+ cuttingPlane.set(
1263
+ this.getLogicalPoint3dAsArray(clipping_plane.location),
1264
+ this.getLogicalPoint3dAsArray(clipping_plane.direction)
1265
+ );
1257
1266
 
1258
1267
  activeView.addCuttingPlane(cuttingPlane);
1259
1268
  activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
@@ -1261,6 +1270,14 @@ export class Viewer
1261
1270
  }
1262
1271
  }
1263
1272
 
1273
+ private getSelection(): IComponent[] {
1274
+ return this.getSelected().map((handle) => ({ handle }));
1275
+ }
1276
+
1277
+ private setSelection(selection: IComponent[]) {
1278
+ this.setSelected(selection?.map((component) => component.handle));
1279
+ }
1280
+
1264
1281
  /**
1265
1282
  * Executes the command denoted by the given command. If the command is not found, tries to
1266
1283
  * set active dragger with the specified name.