@inweb/viewer-visualize 25.8.16 → 25.8.20
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/README.md +41 -19
- package/dist/viewer-visualize.js +158 -95
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +95 -31
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Markup/MarkupFactory.d.ts +2 -6
- package/lib/Viewer/Viewer.d.ts +66 -63
- package/package.json +6 -6
- package/src/Viewer/Draggers/OdZoomDragger.ts +1 -1
- package/src/Viewer/Markup/MarkupFactory.ts +5 -9
- package/src/Viewer/Viewer.ts +75 -70
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -62,7 +62,7 @@ const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
|
|
|
62
62
|
const isExist = (value) => value !== undefined && value !== null;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* 3D viewer powered by
|
|
66
66
|
* {@link https://cloud.opendesign.com/docs/index.html#/visualizejs | VisualizeJS} library.
|
|
67
67
|
*/
|
|
68
68
|
|
|
@@ -98,19 +98,17 @@ export class Viewer
|
|
|
98
98
|
public client: Client | undefined;
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
* @param client - The `Client` instance that provides access to a
|
|
102
|
-
* `Client` if you need a standalone viewer instance
|
|
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.
|
|
103
104
|
* @param params - An object containing viewer configuration parameters.
|
|
104
105
|
* @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own
|
|
105
|
-
* library instance, or
|
|
106
|
-
* `
|
|
107
|
-
*
|
|
108
|
-
* _Note: Your own `VisualizeJS` library version must match the version of the `Client.js`
|
|
109
|
-
* you are using._
|
|
106
|
+
* library instance, or specify `undefined` or blank to use the default URL defined by
|
|
107
|
+
* `Viewer.visualize` library you are using.
|
|
110
108
|
* @param params.enableAutoUpdate - Enable auto-update of the viewer after any changes. If
|
|
111
|
-
* the auto-update is disabled, you need to register
|
|
112
|
-
* the viewer and
|
|
113
|
-
* @param params.markupType -
|
|
109
|
+
* the auto-update is disabled, you need to register an `update` event handler and update
|
|
110
|
+
* the `VisualizeJS` viewer and active dragger manually. Default is `true`.
|
|
111
|
+
* @param params.markupType - The type of the markup core: `Visualize` (deprecated) or
|
|
114
112
|
* `Konva`. Default is `Konva`.
|
|
115
113
|
*/
|
|
116
114
|
constructor(
|
|
@@ -157,7 +155,7 @@ export class Viewer
|
|
|
157
155
|
/**
|
|
158
156
|
* Viewer options.
|
|
159
157
|
*/
|
|
160
|
-
get options():
|
|
158
|
+
get options(): IOptions {
|
|
161
159
|
return this._options;
|
|
162
160
|
}
|
|
163
161
|
|
|
@@ -171,7 +169,7 @@ export class Viewer
|
|
|
171
169
|
}
|
|
172
170
|
|
|
173
171
|
/**
|
|
174
|
-
* 2D markup core.
|
|
172
|
+
* 2D markup core instance used to create markups.
|
|
175
173
|
*
|
|
176
174
|
* @readonly
|
|
177
175
|
*/
|
|
@@ -180,11 +178,12 @@ export class Viewer
|
|
|
180
178
|
}
|
|
181
179
|
|
|
182
180
|
/**
|
|
183
|
-
*
|
|
181
|
+
* Changes the viewer parameters.
|
|
184
182
|
*
|
|
185
|
-
* @param params - An object containing new
|
|
183
|
+
* @param params - An object containing new parameters.
|
|
186
184
|
* @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own
|
|
187
|
-
* library instance or
|
|
185
|
+
* library instance or specify `undefined` or blank to use the default URL defined by
|
|
186
|
+
* `Viewer.visualize` library you are using.
|
|
188
187
|
*/
|
|
189
188
|
configure(params: { visualizeJsUrl?: string }): this {
|
|
190
189
|
this._visualizeJsUrl = params.visualizeJsUrl || "VISUALIZE_JS_URL";
|
|
@@ -192,7 +191,7 @@ export class Viewer
|
|
|
192
191
|
}
|
|
193
192
|
|
|
194
193
|
/**
|
|
195
|
-
*
|
|
194
|
+
* Loads the `VisualizeJS` module and initialize it with the specified canvas. Call
|
|
196
195
|
* {@link dispose | dispose()} to release allocated resources.
|
|
197
196
|
*
|
|
198
197
|
* Fires:
|
|
@@ -264,8 +263,8 @@ export class Viewer
|
|
|
264
263
|
}
|
|
265
264
|
|
|
266
265
|
/**
|
|
267
|
-
* Releases all resources allocated by this
|
|
268
|
-
*
|
|
266
|
+
* Releases all resources allocated by this viewer instance. Call this method before release
|
|
267
|
+
* the `Viewer` instance.
|
|
269
268
|
*/
|
|
270
269
|
dispose(): this {
|
|
271
270
|
this.cancel();
|
|
@@ -301,7 +300,7 @@ export class Viewer
|
|
|
301
300
|
}
|
|
302
301
|
|
|
303
302
|
/**
|
|
304
|
-
* Returns `true` if `VisualizeJS` module has been loaded
|
|
303
|
+
* Returns `true` if `VisualizeJS` module has been loaded and initialized.
|
|
305
304
|
*/
|
|
306
305
|
isInitialized(): boolean {
|
|
307
306
|
return !!this.visualizeJs;
|
|
@@ -345,8 +344,10 @@ export class Viewer
|
|
|
345
344
|
}
|
|
346
345
|
|
|
347
346
|
/**
|
|
348
|
-
* Updates the viewer.
|
|
349
|
-
*
|
|
347
|
+
* Updates the viewer.
|
|
348
|
+
*
|
|
349
|
+
* Do nothing if the auto-update mode is disabled in the constructor. In this case, register
|
|
350
|
+
* an `update` event handler and update the `Visualize` viewer and active dragger manually.
|
|
350
351
|
*
|
|
351
352
|
* Fires:
|
|
352
353
|
*
|
|
@@ -367,21 +368,15 @@ export class Viewer
|
|
|
367
368
|
this.emitEvent({ type: "update", data: force });
|
|
368
369
|
}
|
|
369
370
|
|
|
370
|
-
/**
|
|
371
|
-
* Update with internal schedule, need after change operation when have long update for
|
|
372
|
-
* update without lock UI
|
|
373
|
-
*
|
|
374
|
-
* @param maxScheduleUpdateTimeInMs - Maximum time for one update, by default 30 ms
|
|
375
|
-
* @param maxScheduleUpdateCount - Maximum count of schedule update
|
|
376
|
-
* @returns return void Promise
|
|
377
|
-
*/
|
|
378
|
-
|
|
379
371
|
private scheduleUpdateAsync(maxScheduleUpdateTimeInMs = 50): Promise<void> {
|
|
380
372
|
return new Promise<void>((resolve, reject) => {
|
|
381
373
|
setTimeout(() => {
|
|
382
374
|
try {
|
|
383
|
-
this.
|
|
384
|
-
|
|
375
|
+
if (this._enableAutoUpdate) {
|
|
376
|
+
this.visViewer()?.update(maxScheduleUpdateTimeInMs);
|
|
377
|
+
this.activeDragger()?.updatePreview();
|
|
378
|
+
}
|
|
379
|
+
this.emitEvent({ type: "update", data: false });
|
|
385
380
|
resolve();
|
|
386
381
|
} catch (e) {
|
|
387
382
|
console.error(e);
|
|
@@ -391,6 +386,20 @@ export class Viewer
|
|
|
391
386
|
});
|
|
392
387
|
}
|
|
393
388
|
|
|
389
|
+
/**
|
|
390
|
+
* Updates the viewer asynchronously without locking the user interface. Used to update the
|
|
391
|
+
* viewer after changes that require a long rendering time.
|
|
392
|
+
*
|
|
393
|
+
* Do nothing if the auto-update mode is disabled in the constructor. In this case, register
|
|
394
|
+
* an `update` event handler and update the `VisualizeJS` viewer and active dragger manually.
|
|
395
|
+
*
|
|
396
|
+
* Fires:
|
|
397
|
+
*
|
|
398
|
+
* - {@link UpdateEvent | update}
|
|
399
|
+
*
|
|
400
|
+
* @param maxScheduleUpdateTimeInMs - Maximum time for one update, default 30 ms.
|
|
401
|
+
* @param maxScheduleUpdateCount - Maximum count of scheduled updates.
|
|
402
|
+
*/
|
|
394
403
|
async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50): Promise<void> {
|
|
395
404
|
this._isRunAsyncUpdate = true;
|
|
396
405
|
const device = this.visViewer().getActiveDevice();
|
|
@@ -611,7 +620,7 @@ export class Viewer
|
|
|
611
620
|
}
|
|
612
621
|
|
|
613
622
|
/**
|
|
614
|
-
* List of names of
|
|
623
|
+
* List of names of registered draggers. By default, the following draggers are registered:
|
|
615
624
|
*
|
|
616
625
|
* - `Line`
|
|
617
626
|
* - `Text`
|
|
@@ -633,7 +642,8 @@ export class Viewer
|
|
|
633
642
|
}
|
|
634
643
|
|
|
635
644
|
/**
|
|
636
|
-
*
|
|
645
|
+
* Registers a dragger for the viewer. Dragger is an object that received mouse/keyboard
|
|
646
|
+
* events and does something to the viewer.
|
|
637
647
|
*
|
|
638
648
|
* @param name - Dragger name.
|
|
639
649
|
* @param dragger - Dragger class.
|
|
@@ -650,7 +660,7 @@ export class Viewer
|
|
|
650
660
|
}
|
|
651
661
|
|
|
652
662
|
/**
|
|
653
|
-
*
|
|
663
|
+
* Changes the active dragger. Viewer must be initialized before enable dragger or exception is thrown.
|
|
654
664
|
*
|
|
655
665
|
* Fires:
|
|
656
666
|
*
|
|
@@ -688,7 +698,7 @@ export class Viewer
|
|
|
688
698
|
}
|
|
689
699
|
|
|
690
700
|
/**
|
|
691
|
-
*
|
|
701
|
+
* Resets the state of the active dragger.
|
|
692
702
|
*/
|
|
693
703
|
resetActiveDragger(): void {
|
|
694
704
|
const dragger = this._activeDragger;
|
|
@@ -699,7 +709,7 @@ export class Viewer
|
|
|
699
709
|
}
|
|
700
710
|
|
|
701
711
|
/**
|
|
702
|
-
*
|
|
712
|
+
* Removes all cutting planes.
|
|
703
713
|
*/
|
|
704
714
|
clearSlices(): void {
|
|
705
715
|
if (!this.visualizeJs) return;
|
|
@@ -713,7 +723,7 @@ export class Viewer
|
|
|
713
723
|
}
|
|
714
724
|
|
|
715
725
|
/**
|
|
716
|
-
*
|
|
726
|
+
* Clears the overlay view.
|
|
717
727
|
*/
|
|
718
728
|
clearOverlay(): void {
|
|
719
729
|
if (!this.visualizeJs) return;
|
|
@@ -723,7 +733,7 @@ export class Viewer
|
|
|
723
733
|
}
|
|
724
734
|
|
|
725
735
|
/**
|
|
726
|
-
*
|
|
736
|
+
* Creates an overlay view. Overlay view is used to draw cutting planes and `Visualize` markups.
|
|
727
737
|
*/
|
|
728
738
|
syncOverlay(): any {
|
|
729
739
|
if (!this.visualizeJs) return;
|
|
@@ -758,7 +768,7 @@ export class Viewer
|
|
|
758
768
|
}
|
|
759
769
|
|
|
760
770
|
/**
|
|
761
|
-
* Returns `true` if current
|
|
771
|
+
* Returns `true` if current model is 3D model.
|
|
762
772
|
*/
|
|
763
773
|
is3D(): boolean {
|
|
764
774
|
if (!this.visualizeJs) return false;
|
|
@@ -821,16 +831,14 @@ export class Viewer
|
|
|
821
831
|
}
|
|
822
832
|
|
|
823
833
|
/**
|
|
824
|
-
* Returns a list of original handles for the selected
|
|
834
|
+
* Returns a list of original handles for the selected objects.
|
|
825
835
|
*/
|
|
826
836
|
getSelected(): string[] {
|
|
827
837
|
return this.executeCommand("getSelected");
|
|
828
838
|
}
|
|
829
839
|
|
|
830
840
|
/**
|
|
831
|
-
*
|
|
832
|
-
* {@link File.getProperties | File.getProperties()} or
|
|
833
|
-
* {@link File.searchProperties | File.searchProperties()} methods.
|
|
841
|
+
* Selects the model objects by original handles that are obtained using `File.searchProperties()`.
|
|
834
842
|
*
|
|
835
843
|
* Fires:
|
|
836
844
|
*
|
|
@@ -842,13 +850,8 @@ export class Viewer
|
|
|
842
850
|
this.executeCommand("setSelected", handles);
|
|
843
851
|
}
|
|
844
852
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
* correct rendering of the model.
|
|
848
|
-
*
|
|
849
|
-
* @param model - Instance of model with references. If a `File` instance is specified
|
|
850
|
-
* instead of a model, the file references will be loaded.
|
|
851
|
-
*/
|
|
853
|
+
// Internal loading routines
|
|
854
|
+
|
|
852
855
|
async loadReferences(model: Model | File | Assembly): Promise<this> {
|
|
853
856
|
if (!this.visualizeJs) return this;
|
|
854
857
|
if (!this.client) return this;
|
|
@@ -873,8 +876,6 @@ export class Viewer
|
|
|
873
876
|
return this;
|
|
874
877
|
}
|
|
875
878
|
|
|
876
|
-
// Internal loading routines
|
|
877
|
-
|
|
878
879
|
applyModelTransformMatrix(model: Model | Assembly) {
|
|
879
880
|
this.executeCommand("applyModelTransform", model);
|
|
880
881
|
}
|
|
@@ -898,7 +899,7 @@ export class Viewer
|
|
|
898
899
|
}
|
|
899
900
|
|
|
900
901
|
/**
|
|
901
|
-
* Loads a model
|
|
902
|
+
* Loads a model/file/assembly into the viewer.
|
|
902
903
|
*
|
|
903
904
|
* This method requires a {@link Client} instance to work. For standalone viewer instance use
|
|
904
905
|
* {@link openVsfFile | openVsfFile()} or {@link openVsfxFile | openVsfxFile()}.
|
|
@@ -933,7 +934,7 @@ export class Viewer
|
|
|
933
934
|
if (!model) throw new Error("No default model found");
|
|
934
935
|
|
|
935
936
|
const overrideOptions = new Options();
|
|
936
|
-
overrideOptions.data = this.
|
|
937
|
+
overrideOptions.data = this._options.data;
|
|
937
938
|
if (file.type === ".rcs" && !overrideOptions.enablePartialMode) {
|
|
938
939
|
console.log("Partial load mode is forced for RCS file");
|
|
939
940
|
overrideOptions.enablePartialMode = true;
|
|
@@ -954,7 +955,7 @@ export class Viewer
|
|
|
954
955
|
}
|
|
955
956
|
|
|
956
957
|
/**
|
|
957
|
-
* Loads a VSF file into the viewer.
|
|
958
|
+
* Loads a `VSF` file into the viewer.
|
|
958
959
|
*
|
|
959
960
|
* Fires:
|
|
960
961
|
*
|
|
@@ -1000,7 +1001,7 @@ export class Viewer
|
|
|
1000
1001
|
}
|
|
1001
1002
|
|
|
1002
1003
|
/**
|
|
1003
|
-
* Loads a VSFX file into the viewer.
|
|
1004
|
+
* Loads a `VSFX` file into the viewer.
|
|
1004
1005
|
*
|
|
1005
1006
|
* Fires:
|
|
1006
1007
|
*
|
|
@@ -1064,7 +1065,7 @@ export class Viewer
|
|
|
1064
1065
|
}
|
|
1065
1066
|
|
|
1066
1067
|
/**
|
|
1067
|
-
* Unloads the model and clears the viewer.
|
|
1068
|
+
* Unloads the model and clears the viewer and markups.
|
|
1068
1069
|
*/
|
|
1069
1070
|
clear(): this {
|
|
1070
1071
|
if (!this.visualizeJs) return this;
|
|
@@ -1087,16 +1088,18 @@ export class Viewer
|
|
|
1087
1088
|
}
|
|
1088
1089
|
|
|
1089
1090
|
/**
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
-
* @returns Color with `RGB` values.
|
|
1091
|
+
* Returns the color of new markup objects.
|
|
1093
1092
|
*/
|
|
1094
1093
|
getMarkupColor(): { r: number; g: number; b: number } {
|
|
1095
1094
|
return this._markup.getMarkupColor();
|
|
1096
1095
|
}
|
|
1097
1096
|
|
|
1098
1097
|
/**
|
|
1099
|
-
*
|
|
1098
|
+
* Sets the color of new markup objects.
|
|
1099
|
+
*
|
|
1100
|
+
* Fires:
|
|
1101
|
+
*
|
|
1102
|
+
* - {@link ChangeMarkupColorEvent | changemarkupcolor}
|
|
1100
1103
|
*
|
|
1101
1104
|
* @param r - `Red` part of color.
|
|
1102
1105
|
* @param g - `Green` part of color.
|
|
@@ -1109,7 +1112,7 @@ export class Viewer
|
|
|
1109
1112
|
}
|
|
1110
1113
|
|
|
1111
1114
|
/**
|
|
1112
|
-
*
|
|
1115
|
+
* Colors all markup objects with the specified color.
|
|
1113
1116
|
*
|
|
1114
1117
|
* @param r - `Red` part of color.
|
|
1115
1118
|
* @param g - `Green` part of color.
|
|
@@ -1120,7 +1123,7 @@ export class Viewer
|
|
|
1120
1123
|
}
|
|
1121
1124
|
|
|
1122
1125
|
/**
|
|
1123
|
-
*
|
|
1126
|
+
* Colors selected markup objects with the specified color.
|
|
1124
1127
|
*
|
|
1125
1128
|
* @param r - `Red` part of color.
|
|
1126
1129
|
* @param g - `Green` part of color.
|
|
@@ -1131,7 +1134,7 @@ export class Viewer
|
|
|
1131
1134
|
}
|
|
1132
1135
|
|
|
1133
1136
|
/**
|
|
1134
|
-
*
|
|
1137
|
+
* Adds an empty `Visualize` markup entity to the overlay.
|
|
1135
1138
|
*/
|
|
1136
1139
|
addMarkupEntity(entityName: string) {
|
|
1137
1140
|
if (!this.visualizeJs) return null;
|
|
@@ -1154,8 +1157,9 @@ export class Viewer
|
|
|
1154
1157
|
}
|
|
1155
1158
|
|
|
1156
1159
|
/**
|
|
1157
|
-
*
|
|
1158
|
-
*
|
|
1160
|
+
* Sets the viewer state to the specified viewpoint.
|
|
1161
|
+
*
|
|
1162
|
+
* To get a list of available model viewpoints, use the `File.getViewpoints()`.
|
|
1159
1163
|
*
|
|
1160
1164
|
* @param viewpoint - Viewpoint data.
|
|
1161
1165
|
*/
|
|
@@ -1166,8 +1170,9 @@ export class Viewer
|
|
|
1166
1170
|
}
|
|
1167
1171
|
|
|
1168
1172
|
/**
|
|
1169
|
-
*
|
|
1170
|
-
*
|
|
1173
|
+
* Saves the viewer state at the viewpoint.
|
|
1174
|
+
*
|
|
1175
|
+
* To save a viewpoint to a model on the server, use the `File.saveViewpoint()`.
|
|
1171
1176
|
*/
|
|
1172
1177
|
createViewpoint(): IViewpoint {
|
|
1173
1178
|
const vp = this._markup.getViewpoint();
|