@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
package/dist/viewer-visualize.js
CHANGED
|
@@ -365,7 +365,9 @@
|
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
-
const
|
|
368
|
+
const CanvasEvents = [ "click", "contextmenu", "dblclick", "mousedown", "mouseleave", "mousemove", "mouseup", "pointercancel", "pointerdown", "pointerleave", "pointermove", "pointerup", "touchcancel", "touchend", "touchmove", "touchstart", "wheel" ];
|
|
369
|
+
|
|
370
|
+
const CANVAS_EVENTS = CanvasEvents;
|
|
369
371
|
|
|
370
372
|
///////////////////////////////////////////////////////////////////////////////
|
|
371
373
|
const composeMatrixFromTransform = (translate, rotate, scale, modelCenter, matrix) => {
|
|
@@ -680,27 +682,24 @@
|
|
|
680
682
|
|
|
681
683
|
class EventEmitter2 {
|
|
682
684
|
constructor() {
|
|
683
|
-
this._listeners =
|
|
685
|
+
this._listeners = {};
|
|
684
686
|
}
|
|
685
687
|
addEventListener(type, listener) {
|
|
686
|
-
if (this._listeners === undefined) this._listeners = {};
|
|
687
688
|
if (this._listeners[type] === undefined) this._listeners[type] = [];
|
|
688
689
|
this._listeners[type].push(listener);
|
|
689
690
|
return this;
|
|
690
691
|
}
|
|
691
692
|
removeEventListener(type, listener) {
|
|
692
|
-
if (this._listeners === undefined) return this;
|
|
693
693
|
if (this._listeners[type] === undefined) return this;
|
|
694
694
|
const listeners = this._listeners[type].filter((x => x !== listener));
|
|
695
|
-
this._listeners[type] = listeners
|
|
695
|
+
if (listeners.length !== 0) this._listeners[type] = listeners; else delete this._listeners[type];
|
|
696
696
|
return this;
|
|
697
697
|
}
|
|
698
698
|
removeAllListeners(type) {
|
|
699
|
-
if (type) this._listeners[type]
|
|
699
|
+
if (type) delete this._listeners[type]; else this._listeners = {};
|
|
700
700
|
return this;
|
|
701
701
|
}
|
|
702
702
|
emitEvent(event) {
|
|
703
|
-
if (this._listeners === undefined) return false;
|
|
704
703
|
if (this._listeners[event.type] === undefined) return false;
|
|
705
704
|
const invoke = this._listeners[event.type].slice();
|
|
706
705
|
invoke.forEach((listener => listener.call(this, event)));
|
|
@@ -2709,20 +2708,18 @@
|
|
|
2709
2708
|
const visLib = this.viewer.visLib();
|
|
2710
2709
|
const visViewer = visLib.getViewer();
|
|
2711
2710
|
const abortController = new AbortController();
|
|
2712
|
-
const
|
|
2713
|
-
const chunksProgress = listFileForDownload.map(() => 0);
|
|
2714
|
-
const calcProgress = (index, progress) => {
|
|
2715
|
-
chunksProgress[index] = progress;
|
|
2716
|
-
const fileProgress = chunksProgress.reduce((acc, progress) => (acc += progress)) / (chunksProgress.length || 1);
|
|
2717
|
-
this.viewer.emitEvent({ type: "geometryprogress", data: fileProgress, model: this.model });
|
|
2718
|
-
};
|
|
2711
|
+
const filesToDownload = [this.model.database, ...this.model.geometry];
|
|
2719
2712
|
this.viewer._abortController = abortController;
|
|
2713
|
+
console.time("File load time");
|
|
2720
2714
|
try {
|
|
2721
2715
|
this.viewer.emitEvent({ type: "geometrystart", model: this.model });
|
|
2722
|
-
for (let i = 0; i <
|
|
2723
|
-
const
|
|
2724
|
-
const
|
|
2725
|
-
|
|
2716
|
+
for (let i = 0; i < filesToDownload.length; i++) {
|
|
2717
|
+
const dataId = filesToDownload[i];
|
|
2718
|
+
const chunkLoadHandler = (progress) => {
|
|
2719
|
+
const data = (i + progress) / filesToDownload.length;
|
|
2720
|
+
this.viewer.emitEvent({ type: "geometryprogress", data, model: this.model });
|
|
2721
|
+
};
|
|
2722
|
+
const arrayBuffer = await this.model.downloadResource(dataId, chunkLoadHandler, abortController.signal);
|
|
2726
2723
|
if (abortController.signal.aborted) {
|
|
2727
2724
|
await Promise.reject(new Error(`Open model aborted ${this.model.name}`));
|
|
2728
2725
|
}
|
|
@@ -2740,6 +2737,44 @@
|
|
|
2740
2737
|
this.viewer.emitEvent({ type: "geometrychunk", data, model: this.model });
|
|
2741
2738
|
}
|
|
2742
2739
|
}
|
|
2740
|
+
console.timeEnd("File load time");
|
|
2741
|
+
this.viewer.emitEvent({ type: "geometryend", model: this.model });
|
|
2742
|
+
}
|
|
2743
|
+
catch (error) {
|
|
2744
|
+
this.viewer.emitEvent({ type: "geometryerror", data: error, model: this.model });
|
|
2745
|
+
throw error;
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2751
|
+
class VsfXLoader extends BaseLoader {
|
|
2752
|
+
async load() {
|
|
2753
|
+
if (!this.viewer.visualizeJs)
|
|
2754
|
+
return;
|
|
2755
|
+
const visLib = this.viewer.visLib();
|
|
2756
|
+
const visViewer = visLib.getViewer();
|
|
2757
|
+
const abortController = new AbortController();
|
|
2758
|
+
this.viewer._abortController = abortController;
|
|
2759
|
+
const chunkLoadHandler = (progress) => {
|
|
2760
|
+
this.viewer.emitEvent({ type: "geometryprogress", data: progress, model: this.model });
|
|
2761
|
+
};
|
|
2762
|
+
console.time("File load time");
|
|
2763
|
+
try {
|
|
2764
|
+
this.viewer.emitEvent({ type: "geometrystart", model: this.model });
|
|
2765
|
+
const arrayBuffer = await this.model.downloadResource(this.model.database, chunkLoadHandler, abortController.signal);
|
|
2766
|
+
if (abortController.signal.aborted) {
|
|
2767
|
+
await Promise.reject(new Error(`Open model aborted ${this.model.name}`));
|
|
2768
|
+
}
|
|
2769
|
+
const data = new Uint8Array(arrayBuffer);
|
|
2770
|
+
if (this.viewer.visualizeJs) {
|
|
2771
|
+
visViewer.parseVsfx(data);
|
|
2772
|
+
this.viewer.syncOpenCloudVisualStyle(false);
|
|
2773
|
+
this.viewer.syncOptions();
|
|
2774
|
+
this.viewer.resize();
|
|
2775
|
+
}
|
|
2776
|
+
console.timeEnd("File load time");
|
|
2777
|
+
this.viewer.emitEvent({ type: "databasechunk", data, model: this.model });
|
|
2743
2778
|
this.viewer.emitEvent({ type: "geometryend", model: this.model });
|
|
2744
2779
|
}
|
|
2745
2780
|
catch (error) {
|
|
@@ -2759,6 +2794,7 @@
|
|
|
2759
2794
|
})(UpdateType || (UpdateType = {}));
|
|
2760
2795
|
class UpdaterController {
|
|
2761
2796
|
constructor() {
|
|
2797
|
+
this.lastUpdate = 0;
|
|
2762
2798
|
this.delayUpdateTime = START_UPDATE_TIME;
|
|
2763
2799
|
}
|
|
2764
2800
|
initialize(viewer) {
|
|
@@ -2869,7 +2905,7 @@
|
|
|
2869
2905
|
const abortCtrl = new AbortController();
|
|
2870
2906
|
abortControllerForRequestMap.set(requestId, abortCtrl);
|
|
2871
2907
|
try {
|
|
2872
|
-
await this.model.downloadResourceRange(dataId,
|
|
2908
|
+
await this.model.downloadResourceRange(dataId, requestId, ranges, chunkLoadHandler, abortCtrl.signal);
|
|
2873
2909
|
}
|
|
2874
2910
|
catch (error) {
|
|
2875
2911
|
this.viewer.emitEvent({ type: "geometryerror", data: error, model: this.model });
|
|
@@ -2982,43 +3018,6 @@
|
|
|
2982
3018
|
}
|
|
2983
3019
|
}
|
|
2984
3020
|
|
|
2985
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2986
|
-
class VsfXLoader extends BaseLoader {
|
|
2987
|
-
async load() {
|
|
2988
|
-
if (!this.viewer.visualizeJs)
|
|
2989
|
-
return;
|
|
2990
|
-
const visLib = this.viewer.visLib();
|
|
2991
|
-
const visViewer = visLib.getViewer();
|
|
2992
|
-
const abortController = new AbortController();
|
|
2993
|
-
this.viewer._abortController = abortController;
|
|
2994
|
-
const chunkLoadHandler = (progress) => {
|
|
2995
|
-
this.viewer.emitEvent({ type: "geometryprogress", data: progress, model: this.model });
|
|
2996
|
-
};
|
|
2997
|
-
console.time("File load time");
|
|
2998
|
-
try {
|
|
2999
|
-
this.viewer.emitEvent({ type: "geometrystart", model: this.model });
|
|
3000
|
-
const arrayBuffer = await this.model.downloadResource(this.model.database, chunkLoadHandler, abortController.signal);
|
|
3001
|
-
if (abortController.signal.aborted) {
|
|
3002
|
-
await Promise.reject(new Error(`Open model aborted ${this.model.name}`));
|
|
3003
|
-
}
|
|
3004
|
-
const data = new Uint8Array(arrayBuffer);
|
|
3005
|
-
if (this.viewer.visualizeJs) {
|
|
3006
|
-
visViewer.parseVsfx(data);
|
|
3007
|
-
this.viewer.syncOpenCloudVisualStyle(false);
|
|
3008
|
-
this.viewer.syncOptions();
|
|
3009
|
-
this.viewer.resize();
|
|
3010
|
-
}
|
|
3011
|
-
console.timeEnd("File load time");
|
|
3012
|
-
this.viewer.emitEvent({ type: "databasechunk", data, model: this.model });
|
|
3013
|
-
this.viewer.emitEvent({ type: "geometryend", model: this.model });
|
|
3014
|
-
}
|
|
3015
|
-
catch (error) {
|
|
3016
|
-
this.viewer.emitEvent({ type: "geometryerror", data: error, model: this.model });
|
|
3017
|
-
throw error;
|
|
3018
|
-
}
|
|
3019
|
-
}
|
|
3020
|
-
}
|
|
3021
|
-
|
|
3022
3021
|
///////////////////////////////////////////////////////////////////////////////
|
|
3023
3022
|
class LoaderFactory {
|
|
3024
3023
|
create(viewer, model, options) {
|
|
@@ -16401,15 +16400,17 @@
|
|
|
16401
16400
|
* the auto-update is disabled, you need to update the `VisualizeJS` viewer and the active
|
|
16402
16401
|
* dragger manually using the `update` event. Default is `true`.
|
|
16403
16402
|
*/
|
|
16404
|
-
constructor(client, params = {
|
|
16405
|
-
markupType: MarkupType.Konva,
|
|
16406
|
-
}) {
|
|
16403
|
+
constructor(client, params = {}) {
|
|
16407
16404
|
var _a, _b;
|
|
16408
16405
|
super();
|
|
16406
|
+
this._visualizeJsUrl = "";
|
|
16407
|
+
this.frameId = 0;
|
|
16409
16408
|
this.configure(params);
|
|
16410
16409
|
this._options = new Options(this);
|
|
16411
16410
|
this.client = client;
|
|
16412
16411
|
this._activeDragger = null;
|
|
16412
|
+
this._zoomWheelDragger = null;
|
|
16413
|
+
this._gestureManager = null;
|
|
16413
16414
|
this._renderTime = 0;
|
|
16414
16415
|
this.markup = MarkupFactory.createMarkup((_a = params.markupType) !== null && _a !== void 0 ? _a : MarkupType.Konva);
|
|
16415
16416
|
this.draggerFactory = new Map();
|
|
@@ -16427,7 +16428,7 @@
|
|
|
16427
16428
|
markupDraggers === null || markupDraggers === void 0 ? void 0 : markupDraggers.forEach((value, key) => {
|
|
16428
16429
|
this.registerDragger(key, value);
|
|
16429
16430
|
});
|
|
16430
|
-
this.canvasEvents = CANVAS_EVENTS;
|
|
16431
|
+
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
16431
16432
|
this.canvaseventlistener = (event) => this.emit(event);
|
|
16432
16433
|
this._enableAutoUpdate = (_b = params.enableAutoUpdate) !== null && _b !== void 0 ? _b : true;
|
|
16433
16434
|
this._isNeedRender = false;
|
|
@@ -16586,7 +16587,7 @@
|
|
|
16586
16587
|
* @param force - If `true` updates the viewer immidietly. Otherwise updates on next
|
|
16587
16588
|
* animation frame. Default is `false`.
|
|
16588
16589
|
*/
|
|
16589
|
-
update(force) {
|
|
16590
|
+
update(force = false) {
|
|
16590
16591
|
var _a, _b;
|
|
16591
16592
|
if (this._enableAutoUpdate) {
|
|
16592
16593
|
if (force) {
|
|
@@ -16961,6 +16962,8 @@
|
|
|
16961
16962
|
var _a;
|
|
16962
16963
|
if (!this.visualizeJs)
|
|
16963
16964
|
return this;
|
|
16965
|
+
if (!this.client)
|
|
16966
|
+
return this;
|
|
16964
16967
|
const abortController = new AbortController();
|
|
16965
16968
|
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
16966
16969
|
this._abortControllerForReferences = abortController;
|
|
@@ -17024,7 +17027,7 @@
|
|
|
17024
17027
|
this.cancel();
|
|
17025
17028
|
this.clear();
|
|
17026
17029
|
this.emitEvent({ type: "open", file, model: file });
|
|
17027
|
-
let model;
|
|
17030
|
+
let model = undefined;
|
|
17028
17031
|
if (file) {
|
|
17029
17032
|
const models = (await file.getModels()) || [];
|
|
17030
17033
|
model = models.find((model) => model.default) || models[0];
|
|
@@ -17294,6 +17297,7 @@
|
|
|
17294
17297
|
}
|
|
17295
17298
|
|
|
17296
17299
|
exports.CANVAS_EVENTS = CANVAS_EVENTS;
|
|
17300
|
+
exports.CanvasEvents = CanvasEvents;
|
|
17297
17301
|
exports.OdBaseDragger = OdBaseDragger;
|
|
17298
17302
|
exports.Options = Options;
|
|
17299
17303
|
exports.Viewer = Viewer;
|