@inweb/viewer-visualize 25.3.19 → 25.3.21
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 +66 -62
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +84 -82
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Loaders/LoaderFactory.d.ts +2 -2
- package/lib/Viewer/Viewer.d.ts +1 -1
- package/lib/Viewer/utils.d.ts +2 -3
- package/package.json +4 -4
- package/src/ConvetMath.ts +2 -1
- package/src/Viewer/Loaders/LoaderFactory.ts +1 -1
- package/src/Viewer/Loaders/TCSLoader.ts +12 -12
- package/src/Viewer/Loaders/UpdaterController.ts +1 -0
- package/src/Viewer/Loaders/VsfXLoader.ts +1 -1
- package/src/Viewer/Loaders/VsfXPartialLoader.ts +3 -3
- package/src/Viewer/Loaders/VsfXStreamingLoader.ts +1 -1
- package/src/Viewer/Viewer.ts +13 -13
- package/src/Viewer/utils.ts +3 -12
|
@@ -361,7 +361,9 @@ class Options {
|
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
const
|
|
364
|
+
const CanvasEvents = [ "click", "contextmenu", "dblclick", "mousedown", "mouseleave", "mousemove", "mouseup", "pointercancel", "pointerdown", "pointerleave", "pointermove", "pointerup", "touchcancel", "touchend", "touchmove", "touchstart", "wheel" ];
|
|
365
|
+
|
|
366
|
+
const CANVAS_EVENTS = CanvasEvents;
|
|
365
367
|
|
|
366
368
|
const composeMatrixFromTransform = (translate, rotate, scale, modelCenter, matrix) => {
|
|
367
369
|
const translateMatrix = matrix.setTranslation([ translate.x, translate.y, translate.z ]);
|
|
@@ -693,27 +695,24 @@ commands("VisualizeJS").registerCommand("zoomToSelected", zoomToSelected);
|
|
|
693
695
|
|
|
694
696
|
class EventEmitter2 {
|
|
695
697
|
constructor() {
|
|
696
|
-
this._listeners =
|
|
698
|
+
this._listeners = {};
|
|
697
699
|
}
|
|
698
700
|
addEventListener(type, listener) {
|
|
699
|
-
if (this._listeners === undefined) this._listeners = {};
|
|
700
701
|
if (this._listeners[type] === undefined) this._listeners[type] = [];
|
|
701
702
|
this._listeners[type].push(listener);
|
|
702
703
|
return this;
|
|
703
704
|
}
|
|
704
705
|
removeEventListener(type, listener) {
|
|
705
|
-
if (this._listeners === undefined) return this;
|
|
706
706
|
if (this._listeners[type] === undefined) return this;
|
|
707
707
|
const listeners = this._listeners[type].filter((x => x !== listener));
|
|
708
|
-
this._listeners[type] = listeners
|
|
708
|
+
if (listeners.length !== 0) this._listeners[type] = listeners; else delete this._listeners[type];
|
|
709
709
|
return this;
|
|
710
710
|
}
|
|
711
711
|
removeAllListeners(type) {
|
|
712
|
-
if (type) this._listeners[type]
|
|
712
|
+
if (type) delete this._listeners[type]; else this._listeners = {};
|
|
713
713
|
return this;
|
|
714
714
|
}
|
|
715
715
|
emitEvent(event) {
|
|
716
|
-
if (this._listeners === undefined) return false;
|
|
717
716
|
if (this._listeners[event.type] === undefined) return false;
|
|
718
717
|
const invoke = this._listeners[event.type].slice();
|
|
719
718
|
invoke.forEach((listener => listener.call(this, event)));
|
|
@@ -2583,27 +2582,25 @@ class TCSLoader extends BaseLoader {
|
|
|
2583
2582
|
const visLib = this.viewer.visLib();
|
|
2584
2583
|
const visViewer = visLib.getViewer();
|
|
2585
2584
|
const abortController = new AbortController;
|
|
2586
|
-
const
|
|
2587
|
-
const chunksProgress = listFileForDownload.map((() => 0));
|
|
2588
|
-
const calcProgress = (index, progress) => {
|
|
2589
|
-
chunksProgress[index] = progress;
|
|
2590
|
-
const fileProgress = chunksProgress.reduce(((acc, progress) => acc += progress)) / (chunksProgress.length || 1);
|
|
2591
|
-
this.viewer.emitEvent({
|
|
2592
|
-
type: "geometryprogress",
|
|
2593
|
-
data: fileProgress,
|
|
2594
|
-
model: this.model
|
|
2595
|
-
});
|
|
2596
|
-
};
|
|
2585
|
+
const filesToDownload = [ this.model.database, ...this.model.geometry ];
|
|
2597
2586
|
this.viewer._abortController = abortController;
|
|
2587
|
+
console.time("File load time");
|
|
2598
2588
|
try {
|
|
2599
2589
|
this.viewer.emitEvent({
|
|
2600
2590
|
type: "geometrystart",
|
|
2601
2591
|
model: this.model
|
|
2602
2592
|
});
|
|
2603
|
-
for (let i = 0; i <
|
|
2604
|
-
const
|
|
2605
|
-
const
|
|
2606
|
-
|
|
2593
|
+
for (let i = 0; i < filesToDownload.length; i++) {
|
|
2594
|
+
const dataId = filesToDownload[i];
|
|
2595
|
+
const chunkLoadHandler = progress => {
|
|
2596
|
+
const data = (i + progress) / filesToDownload.length;
|
|
2597
|
+
this.viewer.emitEvent({
|
|
2598
|
+
type: "geometryprogress",
|
|
2599
|
+
data: data,
|
|
2600
|
+
model: this.model
|
|
2601
|
+
});
|
|
2602
|
+
};
|
|
2603
|
+
const arrayBuffer = await this.model.downloadResource(dataId, chunkLoadHandler, abortController.signal);
|
|
2607
2604
|
if (abortController.signal.aborted) {
|
|
2608
2605
|
await Promise.reject(new Error(`Open model aborted ${this.model.name}`));
|
|
2609
2606
|
}
|
|
@@ -2628,6 +2625,59 @@ class TCSLoader extends BaseLoader {
|
|
|
2628
2625
|
});
|
|
2629
2626
|
}
|
|
2630
2627
|
}
|
|
2628
|
+
console.timeEnd("File load time");
|
|
2629
|
+
this.viewer.emitEvent({
|
|
2630
|
+
type: "geometryend",
|
|
2631
|
+
model: this.model
|
|
2632
|
+
});
|
|
2633
|
+
} catch (error) {
|
|
2634
|
+
this.viewer.emitEvent({
|
|
2635
|
+
type: "geometryerror",
|
|
2636
|
+
data: error,
|
|
2637
|
+
model: this.model
|
|
2638
|
+
});
|
|
2639
|
+
throw error;
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
class VsfXLoader extends BaseLoader {
|
|
2645
|
+
async load() {
|
|
2646
|
+
if (!this.viewer.visualizeJs) return;
|
|
2647
|
+
const visLib = this.viewer.visLib();
|
|
2648
|
+
const visViewer = visLib.getViewer();
|
|
2649
|
+
const abortController = new AbortController;
|
|
2650
|
+
this.viewer._abortController = abortController;
|
|
2651
|
+
const chunkLoadHandler = progress => {
|
|
2652
|
+
this.viewer.emitEvent({
|
|
2653
|
+
type: "geometryprogress",
|
|
2654
|
+
data: progress,
|
|
2655
|
+
model: this.model
|
|
2656
|
+
});
|
|
2657
|
+
};
|
|
2658
|
+
console.time("File load time");
|
|
2659
|
+
try {
|
|
2660
|
+
this.viewer.emitEvent({
|
|
2661
|
+
type: "geometrystart",
|
|
2662
|
+
model: this.model
|
|
2663
|
+
});
|
|
2664
|
+
const arrayBuffer = await this.model.downloadResource(this.model.database, chunkLoadHandler, abortController.signal);
|
|
2665
|
+
if (abortController.signal.aborted) {
|
|
2666
|
+
await Promise.reject(new Error(`Open model aborted ${this.model.name}`));
|
|
2667
|
+
}
|
|
2668
|
+
const data = new Uint8Array(arrayBuffer);
|
|
2669
|
+
if (this.viewer.visualizeJs) {
|
|
2670
|
+
visViewer.parseVsfx(data);
|
|
2671
|
+
this.viewer.syncOpenCloudVisualStyle(false);
|
|
2672
|
+
this.viewer.syncOptions();
|
|
2673
|
+
this.viewer.resize();
|
|
2674
|
+
}
|
|
2675
|
+
console.timeEnd("File load time");
|
|
2676
|
+
this.viewer.emitEvent({
|
|
2677
|
+
type: "databasechunk",
|
|
2678
|
+
data: data,
|
|
2679
|
+
model: this.model
|
|
2680
|
+
});
|
|
2631
2681
|
this.viewer.emitEvent({
|
|
2632
2682
|
type: "geometryend",
|
|
2633
2683
|
model: this.model
|
|
@@ -2657,6 +2707,7 @@ var UpdateType;
|
|
|
2657
2707
|
|
|
2658
2708
|
class UpdaterController {
|
|
2659
2709
|
constructor() {
|
|
2710
|
+
this.lastUpdate = 0;
|
|
2660
2711
|
this.delayUpdateTime = START_UPDATE_TIME;
|
|
2661
2712
|
}
|
|
2662
2713
|
initialize(viewer) {
|
|
@@ -2793,7 +2844,7 @@ class VsfXPartialLoader extends BaseLoader {
|
|
|
2793
2844
|
const abortCtrl = new AbortController;
|
|
2794
2845
|
abortControllerForRequestMap.set(requestId, abortCtrl);
|
|
2795
2846
|
try {
|
|
2796
|
-
await this.model.downloadResourceRange(dataId,
|
|
2847
|
+
await this.model.downloadResourceRange(dataId, requestId, ranges, chunkLoadHandler, abortCtrl.signal);
|
|
2797
2848
|
} catch (error) {
|
|
2798
2849
|
this.viewer.emitEvent({
|
|
2799
2850
|
type: "geometryerror",
|
|
@@ -2924,58 +2975,6 @@ class VsfXPartialLoader extends BaseLoader {
|
|
|
2924
2975
|
}
|
|
2925
2976
|
}
|
|
2926
2977
|
|
|
2927
|
-
class VsfXLoader extends BaseLoader {
|
|
2928
|
-
async load() {
|
|
2929
|
-
if (!this.viewer.visualizeJs) return;
|
|
2930
|
-
const visLib = this.viewer.visLib();
|
|
2931
|
-
const visViewer = visLib.getViewer();
|
|
2932
|
-
const abortController = new AbortController;
|
|
2933
|
-
this.viewer._abortController = abortController;
|
|
2934
|
-
const chunkLoadHandler = progress => {
|
|
2935
|
-
this.viewer.emitEvent({
|
|
2936
|
-
type: "geometryprogress",
|
|
2937
|
-
data: progress,
|
|
2938
|
-
model: this.model
|
|
2939
|
-
});
|
|
2940
|
-
};
|
|
2941
|
-
console.time("File load time");
|
|
2942
|
-
try {
|
|
2943
|
-
this.viewer.emitEvent({
|
|
2944
|
-
type: "geometrystart",
|
|
2945
|
-
model: this.model
|
|
2946
|
-
});
|
|
2947
|
-
const arrayBuffer = await this.model.downloadResource(this.model.database, chunkLoadHandler, abortController.signal);
|
|
2948
|
-
if (abortController.signal.aborted) {
|
|
2949
|
-
await Promise.reject(new Error(`Open model aborted ${this.model.name}`));
|
|
2950
|
-
}
|
|
2951
|
-
const data = new Uint8Array(arrayBuffer);
|
|
2952
|
-
if (this.viewer.visualizeJs) {
|
|
2953
|
-
visViewer.parseVsfx(data);
|
|
2954
|
-
this.viewer.syncOpenCloudVisualStyle(false);
|
|
2955
|
-
this.viewer.syncOptions();
|
|
2956
|
-
this.viewer.resize();
|
|
2957
|
-
}
|
|
2958
|
-
console.timeEnd("File load time");
|
|
2959
|
-
this.viewer.emitEvent({
|
|
2960
|
-
type: "databasechunk",
|
|
2961
|
-
data: data,
|
|
2962
|
-
model: this.model
|
|
2963
|
-
});
|
|
2964
|
-
this.viewer.emitEvent({
|
|
2965
|
-
type: "geometryend",
|
|
2966
|
-
model: this.model
|
|
2967
|
-
});
|
|
2968
|
-
} catch (error) {
|
|
2969
|
-
this.viewer.emitEvent({
|
|
2970
|
-
type: "geometryerror",
|
|
2971
|
-
data: error,
|
|
2972
|
-
model: this.model
|
|
2973
|
-
});
|
|
2974
|
-
throw error;
|
|
2975
|
-
}
|
|
2976
|
-
}
|
|
2977
|
-
}
|
|
2978
|
-
|
|
2979
2978
|
class LoaderFactory {
|
|
2980
2979
|
create(viewer, model, options) {
|
|
2981
2980
|
const geometryType = model.database.split(".").pop();
|
|
@@ -4918,15 +4917,17 @@ const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
|
|
|
4918
4917
|
const isExist = value => value !== undefined && value !== null;
|
|
4919
4918
|
|
|
4920
4919
|
class Viewer extends EventEmitter2 {
|
|
4921
|
-
constructor(client, params = {
|
|
4922
|
-
markupType: MarkupType.Konva
|
|
4923
|
-
}) {
|
|
4920
|
+
constructor(client, params = {}) {
|
|
4924
4921
|
var _a, _b;
|
|
4925
4922
|
super();
|
|
4923
|
+
this._visualizeJsUrl = "";
|
|
4924
|
+
this.frameId = 0;
|
|
4926
4925
|
this.configure(params);
|
|
4927
4926
|
this._options = new Options(this);
|
|
4928
4927
|
this.client = client;
|
|
4929
4928
|
this._activeDragger = null;
|
|
4929
|
+
this._zoomWheelDragger = null;
|
|
4930
|
+
this._gestureManager = null;
|
|
4930
4931
|
this._renderTime = 0;
|
|
4931
4932
|
this.markup = MarkupFactory.createMarkup((_a = params.markupType) !== null && _a !== void 0 ? _a : MarkupType.Konva);
|
|
4932
4933
|
this.draggerFactory = new Map;
|
|
@@ -4944,7 +4945,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4944
4945
|
markupDraggers === null || markupDraggers === void 0 ? void 0 : markupDraggers.forEach(((value, key) => {
|
|
4945
4946
|
this.registerDragger(key, value);
|
|
4946
4947
|
}));
|
|
4947
|
-
this.canvasEvents = CANVAS_EVENTS;
|
|
4948
|
+
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
4948
4949
|
this.canvaseventlistener = event => this.emit(event);
|
|
4949
4950
|
this._enableAutoUpdate = (_b = params.enableAutoUpdate) !== null && _b !== void 0 ? _b : true;
|
|
4950
4951
|
this._isNeedRender = false;
|
|
@@ -5064,7 +5065,7 @@ class Viewer extends EventEmitter2 {
|
|
|
5064
5065
|
});
|
|
5065
5066
|
return this;
|
|
5066
5067
|
}
|
|
5067
|
-
update(force) {
|
|
5068
|
+
update(force = false) {
|
|
5068
5069
|
var _a, _b;
|
|
5069
5070
|
if (this._enableAutoUpdate) {
|
|
5070
5071
|
if (force) {
|
|
@@ -5328,6 +5329,7 @@ class Viewer extends EventEmitter2 {
|
|
|
5328
5329
|
async loadReferences(model) {
|
|
5329
5330
|
var _a;
|
|
5330
5331
|
if (!this.visualizeJs) return this;
|
|
5332
|
+
if (!this.client) return this;
|
|
5331
5333
|
const abortController = new AbortController;
|
|
5332
5334
|
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
5333
5335
|
this._abortControllerForReferences = abortController;
|
|
@@ -5364,7 +5366,7 @@ class Viewer extends EventEmitter2 {
|
|
|
5364
5366
|
file: file,
|
|
5365
5367
|
model: file
|
|
5366
5368
|
});
|
|
5367
|
-
let model;
|
|
5369
|
+
let model = undefined;
|
|
5368
5370
|
if (file) {
|
|
5369
5371
|
const models = await file.getModels() || [];
|
|
5370
5372
|
model = models.find((model => model.default)) || models[0];
|
|
@@ -5608,5 +5610,5 @@ class Viewer extends EventEmitter2 {
|
|
|
5608
5610
|
}
|
|
5609
5611
|
}
|
|
5610
5612
|
|
|
5611
|
-
export { CANVAS_EVENTS, OdBaseDragger, Options, Viewer, commands, defaultOptions };
|
|
5613
|
+
export { CANVAS_EVENTS, CanvasEvents, OdBaseDragger, Options, Viewer, commands, defaultOptions };
|
|
5612
5614
|
//# sourceMappingURL=viewer-visualize.module.js.map
|