@inweb/viewer-visualize 26.1.0 → 26.1.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.
@@ -55,8 +55,8 @@ const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
55
55
  const isExist = (value) => value !== undefined && value !== null;
56
56
 
57
57
  /**
58
- * 3D viewer powered by
59
- * {@link https://cloud.opendesign.com/docs/index.html#/visualizejs | VisualizeJS} library.
58
+ * 3D viewer powered by {@link https://cloud.opendesign.com/docs/index.html#/visualizejs | VisualizeJS}
59
+ * library.
60
60
  */
61
61
  export class Viewer
62
62
  extends EventEmitter2<ViewerEventMap & CanvasEventMap & OptionsEventMap>
@@ -86,18 +86,18 @@ export class Viewer
86
86
  public client: Client | undefined;
87
87
 
88
88
  /**
89
- * @param client - The `Client` instance that is used to load model reference files from the
90
- * Open Cloud Server. Do not specify `Client` if you need a standalone viewer instance to
91
- * view `VSFX` files from the web or from local computer.
89
+ * @param client - The `Client` instance that is used to load model reference files from the Open Cloud
90
+ * Server. Do not specify `Client` if you need a standalone viewer instance to view `VSFX` files from
91
+ * the web or from local computer.
92
92
  * @param params - An object containing viewer configuration parameters.
93
- * @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own
94
- * library instance, or specify `undefined` or blank to use the default URL defined by
95
- * `Viewer.visualize` library you are using.
96
- * @param params.enableAutoUpdate - Enable auto-update of the viewer after any changes. If
97
- * the auto-update is disabled, you need to register an `update` event handler and update
98
- * the `VisualizeJS` viewer and active dragger manually. Default is `true`.
99
- * @param params.markupType - The type of the markup core: `Visualize` (deprecated) or
100
- * `Konva`. Default is `Konva`.
93
+ * @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own library
94
+ * instance, or specify `undefined` or blank to use the default URL defined by `Viewer.visualize`
95
+ * library you are using.
96
+ * @param params.enableAutoUpdate - Enable auto-update of the viewer after any changes. If the
97
+ * auto-update is disabled, you need to register an `update` event handler and update the
98
+ * `VisualizeJS` viewer and active dragger manually. Default is `true`.
99
+ * @param params.markupType - The type of the markup core: `Visualize` (deprecated) or `Konva`. Default
100
+ * is `Konva`.
101
101
  */
102
102
  constructor(
103
103
  client?: Client,
@@ -157,9 +157,9 @@ export class Viewer
157
157
  * Changes the viewer parameters.
158
158
  *
159
159
  * @param params - An object containing new parameters.
160
- * @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own
161
- * library instance or specify `undefined` or blank to use the default URL defined by
162
- * `Viewer.visualize` library you are using.
160
+ * @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own library
161
+ * instance or specify `undefined` or blank to use the default URL defined by `Viewer.visualize`
162
+ * library you are using.
163
163
  */
164
164
  configure(params: { visualizeJsUrl?: string }): this {
165
165
  this._visualizeJsUrl = params.visualizeJsUrl || "VISUALIZE_JS_URL";
@@ -176,10 +176,10 @@ export class Viewer
176
176
  * - {@link InitializeProgressEvent | initializeprogress}
177
177
  *
178
178
  * @param canvas -
179
- * {@link https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement | HTMLCanvasElement}
180
- * for `VisualizeJS`.
181
- * @param onProgress - A callback function that handles events measuring progress of loading
182
- * of the `VisualizeJS` library.
179
+ * {@link https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement | HTMLCanvasElement} for
180
+ * `VisualizeJS`.
181
+ * @param onProgress - A callback function that handles events measuring progress of loading of the
182
+ * `VisualizeJS` library.
183
183
  */
184
184
  async initialize(canvas: HTMLCanvasElement, onProgress?: (event: ProgressEvent) => void): Promise<this> {
185
185
  this.addEventListener("optionschange", (event) => this.syncOptions(event.data));
@@ -218,7 +218,7 @@ export class Viewer
218
218
 
219
219
  this._markup.initialize(this.canvas, this.canvasEvents, this, this);
220
220
 
221
- for (let name of components.getComponents().keys()) {
221
+ for (const name of components.getComponents().keys()) {
222
222
  this._components.push(components.createComponent(name, this));
223
223
  }
224
224
 
@@ -306,15 +306,15 @@ export class Viewer
306
306
  /**
307
307
  * Updates the viewer.
308
308
  *
309
- * Do nothing if the auto-update mode is disabled in the constructor. In this case, register
310
- * an `update` event handler and update the `Visualize` viewer and active dragger manually.
309
+ * Do nothing if the auto-update mode is disabled in the constructor. In this case, register an
310
+ * `update` event handler and update the `Visualize` viewer and active dragger manually.
311
311
  *
312
312
  * Fires:
313
313
  *
314
314
  * - {@link UpdateEvent | update}
315
315
  *
316
- * @param force - If `true` updates the viewer immidietly. Otherwise updates on next
317
- * animation frame. Default is `false`.
316
+ * @param force - If `true` updates the viewer immidietly. Otherwise updates on next animation frame.
317
+ * Default is `false`.
318
318
  */
319
319
  update(force = false) {
320
320
  if (this._enableAutoUpdate) {
@@ -347,11 +347,11 @@ export class Viewer
347
347
  }
348
348
 
349
349
  /**
350
- * Updates the viewer asynchronously without locking the user interface. Used to update the
351
- * viewer after changes that require a long rendering time.
350
+ * Updates the viewer asynchronously without locking the user interface. Used to update the viewer
351
+ * after changes that require a long rendering time.
352
352
  *
353
- * Do nothing if the auto-update mode is disabled in the constructor. In this case, register
354
- * an `update` event handler and update the `VisualizeJS` viewer and active dragger manually.
353
+ * Do nothing if the auto-update mode is disabled in the constructor. In this case, register an
354
+ * `update` event handler and update the `VisualizeJS` viewer and active dragger manually.
355
355
  *
356
356
  * Fires:
357
357
  *
@@ -376,24 +376,24 @@ export class Viewer
376
376
  }
377
377
 
378
378
  /**
379
- * Returns `VisualizeJS`
380
- * {@link https://cloud.opendesign.com/docs/index.html#/visualizejs_api | module} instance.
379
+ * Returns `VisualizeJS` {@link https://cloud.opendesign.com/docs/index.html#/visualizejs_api | module}
380
+ * instance.
381
381
  */
382
382
  get visualizeJs(): any {
383
383
  return this._visualizeJs;
384
384
  }
385
385
 
386
386
  /**
387
- * Returns `VisualizeJS`
388
- * {@link https://cloud.opendesign.com/docs/index.html#/visualizejs_api | module} instance.
387
+ * Returns `VisualizeJS` {@link https://cloud.opendesign.com/docs/index.html#/visualizejs_api | module}
388
+ * instance.
389
389
  */
390
390
  visLib(): any {
391
391
  return this.visualizeJs;
392
392
  }
393
393
 
394
394
  /**
395
- * Returns `VisualizeJS`
396
- * {@link https://cloud.opendesign.com/docs/index.html#/vis/Viewer | Viewer} instance.
395
+ * Returns `VisualizeJS` {@link https://cloud.opendesign.com/docs/index.html#/vis/Viewer | Viewer}
396
+ * instance.
397
397
  */
398
398
  visViewer(): any {
399
399
  return this.visualizeJs?.getViewer();
@@ -836,15 +836,15 @@ export class Viewer
836
836
  *
837
837
  * The file geometry data on the server must be converted to `VSFX` format.
838
838
  *
839
- * To open a large file, enable {@link IOptions.enablePartialMode | partial streaming} mode
840
- * before opening (see example below).
839
+ * To open a large file, enable {@link IOptions.enablePartialMode | partial streaming} mode before
840
+ * opening (see example below).
841
841
  *
842
- * This method requires a `Client` instance to be specified when creating the viewer to load
843
- * model reference files from the Open Cloud Server. For a standalone viewer instance use
842
+ * This method requires a `Client` instance to be specified when creating the viewer to load model
843
+ * reference files from the Open Cloud Server. For a standalone viewer instance use
844
844
  * {@link openVsfFile | openVsfFile()} or {@link openVsfxFile | openVsfxFile()}.
845
845
  *
846
- * If there was an active dragger before opening the file, it will be deactivated. After
847
- * opening the file, you must manually activate the required dragger.
846
+ * If there was an active dragger before opening the file, it will be deactivated. After opening the
847
+ * file, you must manually activate the required dragger.
848
848
  *
849
849
  * Fires:
850
850
  *
@@ -856,14 +856,17 @@ export class Viewer
856
856
  * - {@link GeometryEndEvent | geometryend}
857
857
  * - {@link GeometryErrorEvent | geometryerror}
858
858
  *
859
- * @example <caption>Using partial streaming mode to open a large file from a server.</caption>
860
- * viewer.options.enableStreamingMode = true;
861
- * viewer.options.enablePartialMode = true;
862
- * await viewer.open(file);
859
+ * @example Using partial streaming mode to open a large file from a server.
863
860
  *
864
- * @param file - File, assembly or specific model to load. If a `File` instance with multiple
865
- * models is specified, the default model will be loaded. If there is no default model,
866
- * first availiable model will be loaded.
861
+ * ```javascript
862
+ * viewer.options.enableStreamingMode = true;
863
+ * viewer.options.enablePartialMode = true;
864
+ * await viewer.open(file);
865
+ * ```
866
+ *
867
+ * @param file - File, assembly or specific model to load. If a `File` instance with multiple models is
868
+ * specified, the default model will be loaded. If there is no default model, first availiable model
869
+ * will be loaded.
867
870
  */
868
871
  async open(file: File | Assembly | Model): Promise<this> {
869
872
  if (!this.visualizeJs) return this;
@@ -908,8 +911,8 @@ export class Viewer
908
911
  * This method does not support {@link IOptions.enableStreamingMode | streaming} or
909
912
  * {@link IOptions.enablePartialMode | partial streaming} mode.
910
913
  *
911
- * If there was an active dragger before opening the file, it will be deactivated. After
912
- * opening the file, you must manually activate the required dragger.
914
+ * If there was an active dragger before opening the file, it will be deactivated. After opening the
915
+ * file, you must manually activate the required dragger.
913
916
  *
914
917
  * Fires:
915
918
  *
@@ -961,8 +964,8 @@ export class Viewer
961
964
  * This method does not support {@link IOptions.enableStreamingMode | streaming} or
962
965
  * {@link IOptions.enablePartialMode | partial streaming} mode.
963
966
  *
964
- * If there was an active dragger before opening the file, it will be deactivated. After
965
- * opening the file, you must manually activate the required dragger.
967
+ * If there was an active dragger before opening the file, it will be deactivated. After opening the
968
+ * file, you must manually activate the required dragger.
966
969
  *
967
970
  * Fires:
968
971
  *
@@ -1165,6 +1168,7 @@ export class Viewer
1165
1168
  up_vector: this.getPoint3dFromArray(activeView.upVector),
1166
1169
  field_width: activeView.viewFieldWidth,
1167
1170
  field_height: activeView.viewFieldHeight,
1171
+ view_to_world_scale: 1,
1168
1172
  };
1169
1173
  }
1170
1174
 
@@ -1231,8 +1235,8 @@ export class Viewer
1231
1235
  }
1232
1236
 
1233
1237
  /**
1234
- * Executes the command denoted by the given command. If the command is not found, tries to
1235
- * set active dragger with the specified name.
1238
+ * Executes the command denoted by the given command. If the command is not found, tries to set active
1239
+ * dragger with the specified name.
1236
1240
  *
1237
1241
  * The following commands are available by default:
1238
1242
  *
@@ -1264,8 +1268,8 @@ export class Viewer
1264
1268
  *
1265
1269
  * @param id - Command ID or dragger name.
1266
1270
  * @param args - Parameters passed to the command handler function.
1267
- * @returns Returns the result of the command handler function or new active dragger
1268
- * instance. Returns `undefined` if neither the command nor the dragger exists.
1271
+ * @returns Returns the result of the command handler function or new active dragger instance. Returns
1272
+ * `undefined` if neither the command nor the dragger exists.
1269
1273
  */
1270
1274
  executeCommand(id: string, ...args: any[]): any {
1271
1275
  return commands.executeCommand(id, this, ...args);