@inweb/viewer-visualize 25.8.20 → 25.8.22

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.
@@ -11,7 +11,7 @@ export declare class VisualizeMarkup implements IMarkup {
11
11
  lineWidth: number;
12
12
  lineType: "solid";
13
13
  fontSize: number;
14
- initialize(canvas: HTMLCanvasElement, canvasEvents: string[], viewer?: IEventEmitter, worldTransformer?: IWorldTransform): void;
14
+ initialize(container: HTMLElement, containerEvents: string[], viewer?: IEventEmitter, worldTransformer?: IWorldTransform): void;
15
15
  dispose(): void;
16
16
  syncOverlay(): void;
17
17
  clearOverlay(): void;
@@ -31,9 +31,9 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
31
31
  _abortControllerForReferences: AbortController | undefined;
32
32
  client: Client | undefined;
33
33
  /**
34
- * @param client - The `Client` instance that provides access to a Open Cloud Server. Do not
35
- * specify `Client` if you need a standalone viewer instance to view `VSFX` files from the
36
- * web or from local computer.
34
+ * @param client - The `Client` instance that is used to load model reference files from the
35
+ * Open Cloud Server. Do not specify `Client` if you need a standalone viewer instance to
36
+ * view `VSFX` files from the web or from local computer.
37
37
  * @param params - An object containing viewer configuration parameters.
38
38
  * @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own
39
39
  * library instance, or specify `undefined` or blank to use the default URL defined by
@@ -251,9 +251,12 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
251
251
  applyModelTransformMatrix(model: Model | Assembly): void;
252
252
  applySceneGraphSettings(options?: IOptions): void;
253
253
  /**
254
- * Loads a model/file/assembly into the viewer.
254
+ * Loads a file from Open Cloud Server into the viewer.
255
255
  *
256
- * This method requires a {@link Client} instance to work. For standalone viewer instance use
256
+ * The file geometry data on the server must be converted to `VSFX` format.
257
+ *
258
+ * This method requires a `Client` instance to be specified when creating the viewer to load
259
+ * model reference files from the Open Cloud Server. For a standalone viewer instance use
257
260
  * {@link openVsfFile | openVsfFile()} or {@link openVsfxFile | openVsfxFile()}.
258
261
  *
259
262
  * Fires:
@@ -266,9 +269,9 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
266
269
  * - {@link GeometryEndEvent | geometryend}
267
270
  * - {@link GeometryErrorEvent | geometryerror}
268
271
  *
269
- * @param file - File or Assembly or Model instance to load. If a `File` instance with
270
- * multiple models is specified, the default model will be loaded. If there is no default
271
- * model, first availiable model will be loaded.
272
+ * @param file - File, assembly or specific model to load. If a `File` instance with multiple
273
+ * models is specified, the default model will be loaded. If there is no default model,
274
+ * first availiable model will be loaded.
272
275
  */
273
276
  open(file: File | Assembly | Model): Promise<this>;
274
277
  /**
@@ -324,21 +327,21 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
324
327
  *
325
328
  * - {@link ChangeMarkupColorEvent | changemarkupcolor}
326
329
  *
327
- * @param r - `Red` part of color.
328
- * @param g - `Green` part of color.
329
- * @param b - `Blue` part of color.
330
+ * @param r - The `red` component of the color, as a number between 0 and 255.
331
+ * @param g - The `green` component of the color, as a number between 0 and 255.
332
+ * @param b - The `blue` component of the color, as a number between 0 and 255.
330
333
  */
331
334
  setMarkupColor(r?: number, g?: number, b?: number): void;
332
335
  /**
333
336
  * Colors all markup objects with the specified color.
334
337
  *
335
- * @param r - `Red` part of color.
336
- * @param g - `Green` part of color.
337
- * @param b - `Blue` part of color.
338
+ * @param r - The `red` component of the color, as a number between 0 and 255.
339
+ * @param g - The `green` component of the color, as a number between 0 and 255.
340
+ * @param b - The `blue` component of the color, as a number between 0 and 255.
338
341
  */
339
342
  colorizeAllMarkup(r?: number, g?: number, b?: number): void;
340
343
  /**
341
- * Colors selected markup objects with the specified color.
344
+ * Colors the selected markup objects with the specified color.
342
345
  *
343
346
  * @param r - `Red` part of color.
344
347
  * @param g - `Green` part of color.
@@ -352,7 +355,8 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
352
355
  /**
353
356
  * Sets the viewer state to the specified viewpoint.
354
357
  *
355
- * To get a list of available model viewpoints, use the `File.getViewpoints()`.
358
+ * To get a list of available viewpoints from the server for a specific file, use the
359
+ * `File.getViewpoints()`.
356
360
  *
357
361
  * @param viewpoint - Viewpoint data.
358
362
  */
@@ -360,7 +364,7 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
360
364
  /**
361
365
  * Saves the viewer state at the viewpoint.
362
366
  *
363
- * To save a viewpoint to a model on the server, use the `File.saveViewpoint()`.
367
+ * To save a viewpoint to the server for a specific file, use the `File.saveViewpoint()`.
364
368
  */
365
369
  createViewpoint(): IViewpoint;
366
370
  private getPoint3dFromArray;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/viewer-visualize",
3
- "version": "25.8.20",
3
+ "version": "25.8.22",
4
4
  "description": "3D viewer powered by 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": "~25.8.20",
33
- "@inweb/eventemitter2": "~25.8.20",
34
- "@inweb/markup": "~25.8.20",
35
- "@inweb/viewer-core": "~25.8.20"
32
+ "@inweb/client": "~25.8.22",
33
+ "@inweb/eventemitter2": "~25.8.22",
34
+ "@inweb/markup": "~25.8.22",
35
+ "@inweb/viewer-core": "~25.8.22"
36
36
  },
37
37
  "visualizeJS": "https://opencloud.azureedge.net/libs/visualizejs/master/Visualize.js"
38
38
  }
@@ -14,8 +14,8 @@ export class VisualizeMarkup implements IMarkup {
14
14
  public fontSize = 34;
15
15
 
16
16
  initialize(
17
- canvas: HTMLCanvasElement,
18
- canvasEvents: string[],
17
+ container: HTMLElement,
18
+ containerEvents: string[],
19
19
  viewer?: IEventEmitter,
20
20
  worldTransformer?: IWorldTransform
21
21
  ): void {
@@ -98,9 +98,9 @@ export class Viewer
98
98
  public client: Client | undefined;
99
99
 
100
100
  /**
101
- * @param client - The `Client` instance that provides access to a Open Cloud Server. Do not
102
- * specify `Client` if you need a standalone viewer instance to view `VSFX` files from the
103
- * web or from local computer.
101
+ * @param client - The `Client` instance that is used to load model reference files from the
102
+ * Open Cloud Server. Do not specify `Client` if you need a standalone viewer instance to
103
+ * view `VSFX` files from the web or from local computer.
104
104
  * @param params - An object containing viewer configuration parameters.
105
105
  * @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own
106
106
  * library instance, or specify `undefined` or blank to use the default URL defined by
@@ -331,6 +331,9 @@ export class Viewer
331
331
  if (!this.visualizeJs) return this;
332
332
 
333
333
  const { clientWidth, clientHeight } = this.canvas;
334
+
335
+ if (!clientWidth || !clientHeight) return this; // <- invisible viewer, or viewer with parent removed
336
+
334
337
  this.canvas.width = clientWidth * window.devicePixelRatio;
335
338
  this.canvas.height = clientHeight * window.devicePixelRatio;
336
339
 
@@ -899,9 +902,12 @@ export class Viewer
899
902
  }
900
903
 
901
904
  /**
902
- * Loads a model/file/assembly into the viewer.
905
+ * Loads a file from Open Cloud Server into the viewer.
906
+ *
907
+ * The file geometry data on the server must be converted to `VSFX` format.
903
908
  *
904
- * This method requires a {@link Client} instance to work. For standalone viewer instance use
909
+ * This method requires a `Client` instance to be specified when creating the viewer to load
910
+ * model reference files from the Open Cloud Server. For a standalone viewer instance use
905
911
  * {@link openVsfFile | openVsfFile()} or {@link openVsfxFile | openVsfxFile()}.
906
912
  *
907
913
  * Fires:
@@ -914,9 +920,9 @@ export class Viewer
914
920
  * - {@link GeometryEndEvent | geometryend}
915
921
  * - {@link GeometryErrorEvent | geometryerror}
916
922
  *
917
- * @param file - File or Assembly or Model instance to load. If a `File` instance with
918
- * multiple models is specified, the default model will be loaded. If there is no default
919
- * model, first availiable model will be loaded.
923
+ * @param file - File, assembly or specific model to load. If a `File` instance with multiple
924
+ * models is specified, the default model will be loaded. If there is no default model,
925
+ * first availiable model will be loaded.
920
926
  */
921
927
  async open(file: File | Assembly | Model): Promise<this> {
922
928
  if (!this.visualizeJs) return this;
@@ -1101,9 +1107,9 @@ export class Viewer
1101
1107
  *
1102
1108
  * - {@link ChangeMarkupColorEvent | changemarkupcolor}
1103
1109
  *
1104
- * @param r - `Red` part of color.
1105
- * @param g - `Green` part of color.
1106
- * @param b - `Blue` part of color.
1110
+ * @param r - The `red` component of the color, as a number between 0 and 255.
1111
+ * @param g - The `green` component of the color, as a number between 0 and 255.
1112
+ * @param b - The `blue` component of the color, as a number between 0 and 255.
1107
1113
  */
1108
1114
  setMarkupColor(r = 255, g = 0, b = 0): void {
1109
1115
  this._markup.setMarkupColor(r, g, b);
@@ -1114,16 +1120,16 @@ export class Viewer
1114
1120
  /**
1115
1121
  * Colors all markup objects with the specified color.
1116
1122
  *
1117
- * @param r - `Red` part of color.
1118
- * @param g - `Green` part of color.
1119
- * @param b - `Blue` part of color.
1123
+ * @param r - The `red` component of the color, as a number between 0 and 255.
1124
+ * @param g - The `green` component of the color, as a number between 0 and 255.
1125
+ * @param b - The `blue` component of the color, as a number between 0 and 255.
1120
1126
  */
1121
1127
  colorizeAllMarkup(r = 255, g = 0, b = 0): void {
1122
1128
  this._markup.colorizeAllMarkup(r, g, b);
1123
1129
  }
1124
1130
 
1125
1131
  /**
1126
- * Colors selected markup objects with the specified color.
1132
+ * Colors the selected markup objects with the specified color.
1127
1133
  *
1128
1134
  * @param r - `Red` part of color.
1129
1135
  * @param g - `Green` part of color.
@@ -1159,7 +1165,8 @@ export class Viewer
1159
1165
  /**
1160
1166
  * Sets the viewer state to the specified viewpoint.
1161
1167
  *
1162
- * To get a list of available model viewpoints, use the `File.getViewpoints()`.
1168
+ * To get a list of available viewpoints from the server for a specific file, use the
1169
+ * `File.getViewpoints()`.
1163
1170
  *
1164
1171
  * @param viewpoint - Viewpoint data.
1165
1172
  */
@@ -1172,7 +1179,7 @@ export class Viewer
1172
1179
  /**
1173
1180
  * Saves the viewer state at the viewpoint.
1174
1181
  *
1175
- * To save a viewpoint to a model on the server, use the `File.saveViewpoint()`.
1182
+ * To save a viewpoint to the server for a specific file, use the `File.saveViewpoint()`.
1176
1183
  */
1177
1184
  createViewpoint(): IViewpoint {
1178
1185
  const vp = this._markup.getViewpoint();