@inweb/viewer-visualize 27.4.7 → 27.6.0
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/dist/viewer-visualize.js +239 -136
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +72 -48
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Components/CameraComponent.d.ts +1 -1
- package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +1 -1
- package/lib/Viewer/Draggers/OdaLineDragger.d.ts +0 -1
- package/lib/Viewer/Markup/Visualize/VisualizeMarkup.d.ts +1 -1
- package/lib/Viewer/Viewer.d.ts +5 -5
- package/package.json +6 -6
- package/src/Viewer/Commands/SetSelected2.ts +1 -1
- package/src/Viewer/Commands/index.ts +21 -10
- package/src/Viewer/Components/CameraComponent.ts +5 -5
- package/src/Viewer/Components/CanvasRemoveComponent.ts +0 -1
- package/src/Viewer/Components/GestureManagerComponent.ts +0 -1
- package/src/Viewer/Components/ZoomWheelComponent.ts +0 -1
- package/src/Viewer/Draggers/Common/OdBaseDragger.ts +3 -1
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureUtils.ts +2 -2
- package/src/Viewer/Draggers/MeasureLineDragger/index.ts +4 -4
- package/src/Viewer/Draggers/OdBaseCuttingPlaneDragger.ts +6 -3
- package/src/Viewer/Draggers/OdCuttingPlaneZAxisDragger.ts +1 -1
- package/src/Viewer/Draggers/OdaLineDragger.ts +4 -5
- package/src/Viewer/Loaders/FileLoader.ts +6 -4
- package/src/Viewer/Loaders/VSFFileLoader.ts +1 -1
- package/src/Viewer/Loaders/VSFXCloudPartialLoader.ts +7 -5
- package/src/Viewer/Loaders/VSFXCloudStreamingLoader.ts +1 -1
- package/src/Viewer/Loaders/VSFXFileLoader.ts +1 -1
- package/src/Viewer/Markup/Visualize/VisualizeMarkup.ts +1 -1
- package/src/Viewer/Models/ModelImpl.ts +1 -1
- package/src/Viewer/Viewer.ts +44 -23
- package/src/Viewer/utils.ts +1 -1
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -85,7 +85,6 @@ export class Viewer
|
|
|
85
85
|
private _activeDragger: IDragger | null;
|
|
86
86
|
private _components: IComponent[];
|
|
87
87
|
|
|
88
|
-
private _updateDelay: number;
|
|
89
88
|
private _renderNeeded: boolean;
|
|
90
89
|
private _renderTime: DOMHighResTimeStamp;
|
|
91
90
|
private _enableAutoUpdate: boolean;
|
|
@@ -128,10 +127,10 @@ export class Viewer
|
|
|
128
127
|
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
129
128
|
this.canvaseventlistener = (event: Event) => this.emit(event);
|
|
130
129
|
|
|
130
|
+
this._visualizeTimestamp = 0;
|
|
131
131
|
this._activeDragger = null;
|
|
132
132
|
this._components = [];
|
|
133
133
|
|
|
134
|
-
this._updateDelay = 1000;
|
|
135
134
|
this._renderNeeded = false;
|
|
136
135
|
this._renderTime = 0;
|
|
137
136
|
this._enableAutoUpdate = params.enableAutoUpdate ?? true;
|
|
@@ -276,7 +275,8 @@ export class Viewer
|
|
|
276
275
|
this._markup.initialize(this.canvas, this.canvasEvents, this, this);
|
|
277
276
|
|
|
278
277
|
for (const name of components.getComponents().keys()) {
|
|
279
|
-
|
|
278
|
+
const component = components.createComponent(name, this);
|
|
279
|
+
if (component) this._components.push(component);
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
this.syncOptions();
|
|
@@ -300,7 +300,7 @@ export class Viewer
|
|
|
300
300
|
this.setActiveDragger();
|
|
301
301
|
|
|
302
302
|
this._components.forEach((component: IComponent) => component.dispose());
|
|
303
|
-
this._components =
|
|
303
|
+
this._components.length = 0;
|
|
304
304
|
|
|
305
305
|
this._markup.dispose();
|
|
306
306
|
|
|
@@ -312,7 +312,7 @@ export class Viewer
|
|
|
312
312
|
if (this._viewer) this._viewer.clear();
|
|
313
313
|
|
|
314
314
|
this._visualizeJs = undefined;
|
|
315
|
-
this._visualizeTimestamp =
|
|
315
|
+
this._visualizeTimestamp = 0;
|
|
316
316
|
this._viewer = undefined;
|
|
317
317
|
|
|
318
318
|
return this;
|
|
@@ -353,19 +353,20 @@ export class Viewer
|
|
|
353
353
|
* - {@link UpdateEvent | update}
|
|
354
354
|
* - {@link RenderEvent | render}
|
|
355
355
|
*
|
|
356
|
-
* @param force - If `true` updates the viewer immidietly.
|
|
357
|
-
*
|
|
356
|
+
* @param force - If `true` updates the viewer immidietly. If a `number` is specified and more than the
|
|
357
|
+
* given amount of milliseconds has elapsed since the last rendering, the update is performed
|
|
358
|
+
* immediately as well. Otherwise updates on next animation frame. Default is `false`.
|
|
358
359
|
*/
|
|
359
|
-
update(force = false) {
|
|
360
|
+
update(force: boolean | number = false) {
|
|
360
361
|
const time = performance.now();
|
|
361
|
-
|
|
362
|
+
if (typeof force === "number" && time - this._renderTime >= force) force = true;
|
|
362
363
|
|
|
363
364
|
if (this._enableAutoUpdate) {
|
|
364
365
|
this._renderNeeded = true;
|
|
365
366
|
if (force) this.render(time);
|
|
366
367
|
}
|
|
367
368
|
|
|
368
|
-
this.emitEvent({ type: "update", force });
|
|
369
|
+
this.emitEvent({ type: "update", force: !!force });
|
|
369
370
|
}
|
|
370
371
|
|
|
371
372
|
// Internal render routines
|
|
@@ -577,10 +578,10 @@ export class Viewer
|
|
|
577
578
|
this.clearSelected();
|
|
578
579
|
|
|
579
580
|
this.loaders.forEach((loader) => loader.dispose());
|
|
580
|
-
this.loaders =
|
|
581
|
+
this.loaders.length = 0;
|
|
581
582
|
|
|
582
583
|
this.models.forEach((model) => model.dispose());
|
|
583
|
-
this.models =
|
|
584
|
+
this.models.length = 0;
|
|
584
585
|
|
|
585
586
|
visViewer.clear();
|
|
586
587
|
visViewer.createLocalDatabase();
|
|
@@ -712,6 +713,23 @@ export class Viewer
|
|
|
712
713
|
activeView.delete();
|
|
713
714
|
}
|
|
714
715
|
|
|
716
|
+
// sync cutting plane fill options
|
|
717
|
+
|
|
718
|
+
view.setEnableCuttingPlaneFill(
|
|
719
|
+
options.enableSectionFill,
|
|
720
|
+
options.sectionFillColor.r,
|
|
721
|
+
options.sectionFillColor.g,
|
|
722
|
+
options.sectionFillColor.b
|
|
723
|
+
);
|
|
724
|
+
|
|
725
|
+
view.setCuttingPlaneFillPatternEnabled(
|
|
726
|
+
options.enableSectionHatch,
|
|
727
|
+
visLib.CuttingPlaneFillStyle.kSlantRight,
|
|
728
|
+
options.sectionHatchColor.r,
|
|
729
|
+
options.sectionHatchColor.g,
|
|
730
|
+
options.sectionHatchColor.b
|
|
731
|
+
);
|
|
732
|
+
|
|
715
733
|
// sync highlighting options
|
|
716
734
|
|
|
717
735
|
const params = options.enableCustomHighlight ? options : Options.defaults();
|
|
@@ -814,6 +832,7 @@ export class Viewer
|
|
|
814
832
|
activeView.removeCuttingPlanes();
|
|
815
833
|
activeView.delete();
|
|
816
834
|
|
|
835
|
+
this.emitEvent({ type: "changecuttingplanes" });
|
|
817
836
|
this.emitEvent({ type: "clearslices" });
|
|
818
837
|
this.update();
|
|
819
838
|
}
|
|
@@ -864,8 +883,8 @@ export class Viewer
|
|
|
864
883
|
|
|
865
884
|
setActiveDragger(name = ""): IDragger | null {
|
|
866
885
|
if (!this._activeDragger || this._activeDragger.name !== name) {
|
|
867
|
-
const oldDragger = this._activeDragger;
|
|
868
|
-
let newDragger = null;
|
|
886
|
+
const oldDragger: IDragger | null = this._activeDragger;
|
|
887
|
+
let newDragger: IDragger | null = null;
|
|
869
888
|
|
|
870
889
|
if (this._activeDragger) {
|
|
871
890
|
this._activeDragger.dispose();
|
|
@@ -895,8 +914,8 @@ export class Viewer
|
|
|
895
914
|
}
|
|
896
915
|
}
|
|
897
916
|
|
|
898
|
-
getComponent(name: string): IComponent {
|
|
899
|
-
return this._components.find((component) => component.name === name);
|
|
917
|
+
getComponent(name: string): IComponent | null {
|
|
918
|
+
return this._components.find((component) => component.name === name) || null;
|
|
900
919
|
}
|
|
901
920
|
|
|
902
921
|
drawViewpoint(viewpoint: IViewpoint): void {
|
|
@@ -909,7 +928,7 @@ export class Viewer
|
|
|
909
928
|
return [point3d.x, point3d.y, point3d.z];
|
|
910
929
|
};
|
|
911
930
|
|
|
912
|
-
const setOrthogonalCamera = (orthogonal_camera
|
|
931
|
+
const setOrthogonalCamera = (orthogonal_camera?: IOrthogonalCamera) => {
|
|
913
932
|
if (orthogonal_camera) {
|
|
914
933
|
activeView.setView(
|
|
915
934
|
getPoint3dAsArray(orthogonal_camera.view_point),
|
|
@@ -925,7 +944,7 @@ export class Viewer
|
|
|
925
944
|
}
|
|
926
945
|
};
|
|
927
946
|
|
|
928
|
-
const setPerspectiveCamera = (perspective_camera
|
|
947
|
+
const setPerspectiveCamera = (perspective_camera?: IPerspectiveCamera) => {
|
|
929
948
|
if (perspective_camera) {
|
|
930
949
|
// ===================== AI-CODE-START ======================
|
|
931
950
|
// Source: Claude Sonnet 4.5
|
|
@@ -964,7 +983,7 @@ export class Viewer
|
|
|
964
983
|
}
|
|
965
984
|
};
|
|
966
985
|
|
|
967
|
-
const setClippingPlanes = (clipping_planes
|
|
986
|
+
const setClippingPlanes = (clipping_planes?: IClippingPlane[]) => {
|
|
968
987
|
if (clipping_planes) {
|
|
969
988
|
for (const clipping_plane of clipping_planes) {
|
|
970
989
|
const cuttingPlane = new (this.visLib().OdTvPlane)();
|
|
@@ -973,6 +992,8 @@ export class Viewer
|
|
|
973
992
|
activeView.addCuttingPlane(cuttingPlane);
|
|
974
993
|
activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
|
|
975
994
|
}
|
|
995
|
+
|
|
996
|
+
this.emitEvent({ type: "changecuttingplanes" });
|
|
976
997
|
}
|
|
977
998
|
};
|
|
978
999
|
|
|
@@ -985,8 +1006,8 @@ export class Viewer
|
|
|
985
1006
|
this.setActiveDragger();
|
|
986
1007
|
this.clearSlices();
|
|
987
1008
|
this.clearOverlay();
|
|
988
|
-
|
|
989
1009
|
this.clearSelected();
|
|
1010
|
+
|
|
990
1011
|
this.showAll();
|
|
991
1012
|
this.explode();
|
|
992
1013
|
|
|
@@ -1013,7 +1034,7 @@ export class Viewer
|
|
|
1013
1034
|
return { x: array[0], y: array[1], z: array[2] };
|
|
1014
1035
|
};
|
|
1015
1036
|
|
|
1016
|
-
const getOrthogonalCamera = (): IOrthogonalCamera => {
|
|
1037
|
+
const getOrthogonalCamera = (): IOrthogonalCamera | undefined => {
|
|
1017
1038
|
if (!activeView.perspective)
|
|
1018
1039
|
return {
|
|
1019
1040
|
view_point: getPoint3dFromArray(activeView.viewPosition),
|
|
@@ -1026,7 +1047,7 @@ export class Viewer
|
|
|
1026
1047
|
else return undefined;
|
|
1027
1048
|
};
|
|
1028
1049
|
|
|
1029
|
-
const getPerspectiveCamera = (): IPerspectiveCamera => {
|
|
1050
|
+
const getPerspectiveCamera = (): IPerspectiveCamera | undefined => {
|
|
1030
1051
|
if (activeView.perspective) {
|
|
1031
1052
|
// ===================== AI-CODE-START ======================
|
|
1032
1053
|
// Source: Claude Sonnet 4.5
|
|
@@ -1058,7 +1079,7 @@ export class Viewer
|
|
|
1058
1079
|
};
|
|
1059
1080
|
|
|
1060
1081
|
const getClippingPlanes = (): IClippingPlane[] => {
|
|
1061
|
-
const clipping_planes = [];
|
|
1082
|
+
const clipping_planes: IClippingPlane[] = [];
|
|
1062
1083
|
for (let i = 0; i < activeView.numCuttingPlanes(); i++) {
|
|
1063
1084
|
const cuttingPlane = activeView.getCuttingPlane(i);
|
|
1064
1085
|
|
package/src/Viewer/utils.ts
CHANGED
|
@@ -30,7 +30,7 @@ export function loadScript(url: string, params: LoadParams = {}): Promise<HTMLSc
|
|
|
30
30
|
const script = document.createElement("script");
|
|
31
31
|
script.src = url;
|
|
32
32
|
script.async = true;
|
|
33
|
-
script.crossOrigin = params.crossOrigin;
|
|
33
|
+
script.crossOrigin = params.crossOrigin || null;
|
|
34
34
|
script.onload = () => resolve(script);
|
|
35
35
|
script.onerror = () => {
|
|
36
36
|
script.remove();
|