@inweb/viewer-visualize 25.3.15 → 25.3.18
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 +70 -59
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +83 -67
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/Viewer/Loaders/VsfXLoader.ts +13 -5
- package/src/Viewer/Loaders/VsfXPartialLoader.ts +70 -48
- package/src/Viewer/Loaders/VsfXStreamingLoader.ts +5 -5
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaCloud.ts +1 -1
- package/src/Viewer/Viewer.ts +4 -4
- package/src/index.ts +1 -1
|
@@ -2673,9 +2673,9 @@ class VsfXStreamingLoader extends BaseLoader {
|
|
|
2673
2673
|
updaterController.initialize(this.viewer);
|
|
2674
2674
|
this.viewer._abortController = abortController;
|
|
2675
2675
|
let isFireDatabaseChunk = false;
|
|
2676
|
-
const chunkLoadHandler = (progress,
|
|
2676
|
+
const chunkLoadHandler = (progress, chunk) => {
|
|
2677
2677
|
if (!this.viewer.visualizeJs) return;
|
|
2678
|
-
const status = visViewer.parseVsfx(
|
|
2678
|
+
const status = visViewer.parseVsfx(chunk);
|
|
2679
2679
|
updaterController.update(UpdateType.kDelay);
|
|
2680
2680
|
this.viewer.emitEvent({
|
|
2681
2681
|
type: "geometryprogress",
|
|
@@ -2694,13 +2694,13 @@ class VsfXStreamingLoader extends BaseLoader {
|
|
|
2694
2694
|
this.viewer.resize();
|
|
2695
2695
|
this.viewer.emitEvent({
|
|
2696
2696
|
type: "databasechunk",
|
|
2697
|
-
data:
|
|
2697
|
+
data: chunk,
|
|
2698
2698
|
model: this.model
|
|
2699
2699
|
});
|
|
2700
2700
|
} else {
|
|
2701
2701
|
this.viewer.emitEvent({
|
|
2702
2702
|
type: "geometrychunk",
|
|
2703
|
-
data:
|
|
2703
|
+
data: chunk,
|
|
2704
2704
|
model: this.model
|
|
2705
2705
|
});
|
|
2706
2706
|
}
|
|
@@ -2711,7 +2711,7 @@ class VsfXStreamingLoader extends BaseLoader {
|
|
|
2711
2711
|
type: "geometrystart",
|
|
2712
2712
|
model: this.model
|
|
2713
2713
|
});
|
|
2714
|
-
await this.model.
|
|
2714
|
+
await this.model.downloadResource(this.model.database, chunkLoadHandler, abortController.signal);
|
|
2715
2715
|
console.timeEnd("File load time");
|
|
2716
2716
|
updaterController.update(UpdateType.kNormal);
|
|
2717
2717
|
this.viewer.emitEvent({
|
|
@@ -2729,6 +2729,10 @@ class VsfXStreamingLoader extends BaseLoader {
|
|
|
2729
2729
|
}
|
|
2730
2730
|
}
|
|
2731
2731
|
|
|
2732
|
+
const PENDING_REQUESTS_SIZE = 50;
|
|
2733
|
+
|
|
2734
|
+
const PENDING_REQUESTS_TIMEOUT = 250;
|
|
2735
|
+
|
|
2732
2736
|
class VsfXPartialLoader extends BaseLoader {
|
|
2733
2737
|
async load() {
|
|
2734
2738
|
if (!this.viewer.visualizeJs) return;
|
|
@@ -2738,8 +2742,6 @@ class VsfXPartialLoader extends BaseLoader {
|
|
|
2738
2742
|
const abortControllerForRequestMap = new Map;
|
|
2739
2743
|
let servicePartAborted = false;
|
|
2740
2744
|
const pendingRequestsMap = new Map;
|
|
2741
|
-
const PENDING_REQUESTS_SIZE = 50;
|
|
2742
|
-
const PENDING_REQUESTS_TIMEOUT = 250;
|
|
2743
2745
|
let pendingRequestsTimerId = 0;
|
|
2744
2746
|
const pendingRequestsAbortHandler = () => clearTimeout(pendingRequestsTimerId);
|
|
2745
2747
|
const pendingRequestsAbortController = new AbortController;
|
|
@@ -2749,9 +2751,9 @@ class VsfXPartialLoader extends BaseLoader {
|
|
|
2749
2751
|
this.viewer._abortController = abortController;
|
|
2750
2752
|
this.viewer._abortControllerForRequestMap = abortControllerForRequestMap;
|
|
2751
2753
|
visViewer.memoryLimit = this.options.memoryLimit;
|
|
2752
|
-
const
|
|
2754
|
+
const chunkLoadHandler = (progress, chunk, requestId = 0) => {
|
|
2753
2755
|
if (!this.viewer.visualizeJs) return;
|
|
2754
|
-
const state = visViewer.parseVsfxInPartialMode(requestId,
|
|
2756
|
+
const state = visViewer.parseVsfxInPartialMode(requestId, chunk);
|
|
2755
2757
|
updaterController.update(UpdateType.kDelay);
|
|
2756
2758
|
this.viewer.emitEvent({
|
|
2757
2759
|
type: "geometryprogress",
|
|
@@ -2765,114 +2767,125 @@ class VsfXPartialLoader extends BaseLoader {
|
|
|
2765
2767
|
this.viewer.resize();
|
|
2766
2768
|
this.viewer.emitEvent({
|
|
2767
2769
|
type: "databasechunk",
|
|
2768
|
-
data:
|
|
2770
|
+
data: chunk,
|
|
2769
2771
|
model: this.model
|
|
2770
2772
|
});
|
|
2771
2773
|
} else {
|
|
2772
2774
|
this.viewer.emitEvent({
|
|
2773
2775
|
type: "geometrychunk",
|
|
2774
|
-
data:
|
|
2776
|
+
data: chunk,
|
|
2775
2777
|
model: this.model
|
|
2776
2778
|
});
|
|
2777
2779
|
}
|
|
2778
2780
|
};
|
|
2779
|
-
const
|
|
2781
|
+
const downloadResourceRange = async (dataId, requestId, ranges) => {
|
|
2782
|
+
console.log("--- VsfXPartialLoader.downloadResourceRange", dataId, requestId, ranges);
|
|
2780
2783
|
const abortCtrl = new AbortController;
|
|
2781
2784
|
abortControllerForRequestMap.set(requestId, abortCtrl);
|
|
2782
2785
|
try {
|
|
2783
|
-
await this.model.
|
|
2786
|
+
await this.model.downloadResourceRange(dataId, ranges, requestId, chunkLoadHandler, abortCtrl.signal);
|
|
2784
2787
|
} catch (error) {
|
|
2788
|
+
console.log("--- VsfXPartialLoader.downloadResourceRange error", dataId, requestId, error);
|
|
2785
2789
|
this.viewer.emitEvent({
|
|
2786
2790
|
type: "geometryerror",
|
|
2787
2791
|
data: error,
|
|
2788
2792
|
model: this.model
|
|
2789
2793
|
});
|
|
2790
2794
|
} finally {
|
|
2791
|
-
|
|
2792
|
-
requests.forEach((requestId => visViewer.onRequestResponseComplete(requestId)));
|
|
2795
|
+
ranges.forEach((range => visViewer.onRequestResponseComplete(range.requestId)));
|
|
2793
2796
|
abortControllerForRequestMap.delete(requestId);
|
|
2794
2797
|
updaterController.update(UpdateType.kNormal);
|
|
2795
2798
|
}
|
|
2796
2799
|
};
|
|
2797
|
-
const
|
|
2798
|
-
const
|
|
2800
|
+
const requestRecordsToRanges = (requestId, records) => {
|
|
2801
|
+
const ranges = [];
|
|
2799
2802
|
for (let i = 0; i < records.size(); i++) {
|
|
2800
2803
|
const record = records.get(i);
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
begin: record.begin,
|
|
2804
|
-
end: record.end
|
|
2805
|
-
size: parseInt(record.end, 10) - parseInt(record.begin, 10)
|
|
2804
|
+
ranges.push({
|
|
2805
|
+
requestId: requestId,
|
|
2806
|
+
begin: Number(record.begin),
|
|
2807
|
+
end: Number(record.end)
|
|
2806
2808
|
});
|
|
2807
2809
|
record.delete();
|
|
2808
2810
|
}
|
|
2809
|
-
return
|
|
2811
|
+
return ranges;
|
|
2810
2812
|
};
|
|
2811
2813
|
const objectHandler = {
|
|
2812
2814
|
onServicePartReceived: bHasIndex => {
|
|
2815
|
+
console.log("--- VsfXPartialLoader.onServicePartReceived", bHasIndex);
|
|
2813
2816
|
if (bHasIndex) {
|
|
2814
2817
|
servicePartAborted = true;
|
|
2815
2818
|
abortController.abort();
|
|
2816
2819
|
}
|
|
2817
2820
|
},
|
|
2818
2821
|
onRequest: (requestId, records) => {
|
|
2819
|
-
|
|
2822
|
+
const ranges = requestRecordsToRanges(requestId, records);
|
|
2823
|
+
console.log("--- VsfXPartialLoader.onRequest", this.model.database, requestId, ranges);
|
|
2824
|
+
downloadResourceRange(this.model.database, requestId, ranges);
|
|
2820
2825
|
},
|
|
2821
2826
|
onFullLoaded: () => {
|
|
2827
|
+
console.log("--- VsfXPartialLoader.onFullLoaded");
|
|
2822
2828
|
updaterController.update(UpdateType.kNormal);
|
|
2823
|
-
console.timeEnd("File load time");
|
|
2824
2829
|
},
|
|
2825
2830
|
onRequestResponseParsed: requestId => {
|
|
2831
|
+
console.log("--- VsfXPartialLoader.onRequestResponseParsed", requestId);
|
|
2826
2832
|
abortControllerForRequestMap.delete(requestId);
|
|
2827
2833
|
updaterController.update(UpdateType.kNormal);
|
|
2828
2834
|
},
|
|
2829
2835
|
onRequestAborted: requestId => {
|
|
2836
|
+
console.log("--- VsfXPartialLoader.onRequestAborted", requestId);
|
|
2830
2837
|
const abortCtrl = abortControllerForRequestMap.get(requestId);
|
|
2831
2838
|
if (abortCtrl) abortCtrl.abort();
|
|
2832
2839
|
},
|
|
2833
|
-
onRequestResourceFile:
|
|
2834
|
-
const
|
|
2835
|
-
|
|
2836
|
-
let
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2840
|
+
onRequestResourceFile: (requestId, dataId, records) => {
|
|
2841
|
+
const ranges = requestRecordsToRanges(requestId, records);
|
|
2842
|
+
console.log("--- VsfXPartialLoader.onRequestResourceFile", dataId, requestId, ranges);
|
|
2843
|
+
let pendingRanges = [];
|
|
2844
|
+
let requestNumber = 0;
|
|
2845
|
+
const pendingRequest = pendingRequestsMap.get(dataId);
|
|
2846
|
+
if (pendingRequest) {
|
|
2847
|
+
pendingRanges = pendingRequest.ranges;
|
|
2848
|
+
requestNumber = pendingRequest.number;
|
|
2841
2849
|
}
|
|
2842
|
-
if (
|
|
2850
|
+
if (requestNumber <= 5) {
|
|
2851
|
+
console.log("--- VsfXPartialLoader.onRequestResourceFile: requestNumber <= 5");
|
|
2843
2852
|
pendingRequestsMap.set(dataId, {
|
|
2844
|
-
|
|
2845
|
-
number:
|
|
2853
|
+
ranges: [],
|
|
2854
|
+
number: requestNumber + 1
|
|
2846
2855
|
});
|
|
2847
|
-
|
|
2856
|
+
downloadResourceRange(dataId, requestId, ranges);
|
|
2848
2857
|
return;
|
|
2849
2858
|
}
|
|
2850
|
-
|
|
2859
|
+
pendingRanges = pendingRanges.concat(ranges);
|
|
2860
|
+
if (pendingRanges.length >= PENDING_REQUESTS_SIZE) {
|
|
2861
|
+
console.log("--- VsfXPartialLoader.onRequestResourceFile: pendingRanges.length >", PENDING_REQUESTS_SIZE);
|
|
2851
2862
|
if (pendingRequestsTimerId) {
|
|
2852
2863
|
window.clearTimeout(pendingRequestsTimerId);
|
|
2853
2864
|
pendingRequestsTimerId = 0;
|
|
2854
2865
|
}
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2866
|
+
pendingRequestsMap.set(dataId, {
|
|
2867
|
+
ranges: [],
|
|
2868
|
+
number: requestNumber + 1
|
|
2869
|
+
});
|
|
2870
|
+
downloadResourceRange(dataId, requestId, pendingRanges);
|
|
2871
|
+
return;
|
|
2859
2872
|
}
|
|
2860
2873
|
pendingRequestsMap.set(dataId, {
|
|
2861
|
-
|
|
2862
|
-
number:
|
|
2874
|
+
ranges: pendingRanges,
|
|
2875
|
+
number: requestNumber + 1
|
|
2863
2876
|
});
|
|
2864
2877
|
if (pendingRequestsTimerId === 0) {
|
|
2865
2878
|
pendingRequestsTimerId = window.setTimeout((() => {
|
|
2879
|
+
console.log("--- VsfXPartialLoader.onRequestResourceFile: timer", PENDING_REQUESTS_SIZE);
|
|
2866
2880
|
pendingRequestsAbortController.signal.removeEventListener("abort", pendingRequestsAbortHandler);
|
|
2867
2881
|
pendingRequestsTimerId = 0;
|
|
2868
|
-
pendingRequestsMap.forEach(((
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
array: [],
|
|
2874
|
-
number: requestsRecord.number + 1
|
|
2882
|
+
pendingRequestsMap.forEach(((request, dataId) => {
|
|
2883
|
+
if (request.ranges.length > 0) {
|
|
2884
|
+
pendingRequestsMap.set(dataId, {
|
|
2885
|
+
ranges: [],
|
|
2886
|
+
number: request.number + 1
|
|
2875
2887
|
});
|
|
2888
|
+
downloadResourceRange(dataId, requestId, request.ranges);
|
|
2876
2889
|
}
|
|
2877
2890
|
}));
|
|
2878
2891
|
}), PENDING_REQUESTS_TIMEOUT);
|
|
@@ -2883,13 +2896,12 @@ class VsfXPartialLoader extends BaseLoader {
|
|
|
2883
2896
|
}
|
|
2884
2897
|
};
|
|
2885
2898
|
visViewer.attachPartialResolver(objectHandler);
|
|
2886
|
-
console.time("File load time");
|
|
2887
2899
|
try {
|
|
2888
2900
|
this.viewer.emitEvent({
|
|
2889
2901
|
type: "geometrystart",
|
|
2890
2902
|
model: this.model
|
|
2891
2903
|
});
|
|
2892
|
-
await this.model.
|
|
2904
|
+
await this.model.downloadResource(this.model.database, chunkLoadHandler, abortController.signal).catch((error => {
|
|
2893
2905
|
if (!servicePartAborted) throw error;
|
|
2894
2906
|
}));
|
|
2895
2907
|
this.viewer.emitEvent({
|
|
@@ -2918,29 +2930,36 @@ class VsfXLoader extends BaseLoader {
|
|
|
2918
2930
|
const visViewer = visLib.getViewer();
|
|
2919
2931
|
const abortController = new AbortController;
|
|
2920
2932
|
this.viewer._abortController = abortController;
|
|
2933
|
+
const chunkLoadHandler = progress => {
|
|
2934
|
+
this.viewer.emitEvent({
|
|
2935
|
+
type: "geometryprogress",
|
|
2936
|
+
data: progress,
|
|
2937
|
+
model: this.model
|
|
2938
|
+
});
|
|
2939
|
+
};
|
|
2921
2940
|
console.time("File load time");
|
|
2922
2941
|
try {
|
|
2923
2942
|
this.viewer.emitEvent({
|
|
2924
2943
|
type: "geometrystart",
|
|
2925
2944
|
model: this.model
|
|
2926
2945
|
});
|
|
2927
|
-
const
|
|
2928
|
-
type: "geometryprogress",
|
|
2929
|
-
data: progress,
|
|
2930
|
-
model: this.model
|
|
2931
|
-
});
|
|
2932
|
-
const arrayBuffer = await this.model.downloadResource(this.model.database, progressCb, abortController.signal);
|
|
2946
|
+
const arrayBuffer = await this.model.downloadResource(this.model.database, chunkLoadHandler, abortController.signal);
|
|
2933
2947
|
if (abortController.signal.aborted) {
|
|
2934
2948
|
await Promise.reject(new Error(`Open model aborted ${this.model.name}`));
|
|
2935
2949
|
}
|
|
2950
|
+
const data = new Uint8Array(arrayBuffer);
|
|
2936
2951
|
if (this.viewer.visualizeJs) {
|
|
2937
|
-
visViewer.parseVsfx(
|
|
2938
|
-
this.viewer.update(true);
|
|
2952
|
+
visViewer.parseVsfx(data);
|
|
2939
2953
|
this.viewer.syncOpenCloudVisualStyle(false);
|
|
2940
2954
|
this.viewer.syncOptions();
|
|
2941
2955
|
this.viewer.resize();
|
|
2942
2956
|
}
|
|
2943
2957
|
console.timeEnd("File load time");
|
|
2958
|
+
this.viewer.emitEvent({
|
|
2959
|
+
type: "databasechunk",
|
|
2960
|
+
data: data,
|
|
2961
|
+
model: this.model
|
|
2962
|
+
});
|
|
2944
2963
|
this.viewer.emitEvent({
|
|
2945
2964
|
type: "geometryend",
|
|
2946
2965
|
model: this.model
|
|
@@ -3569,7 +3588,7 @@ class KonvaCloud {
|
|
|
3569
3588
|
width: (_a = params.width) !== null && _a !== void 0 ? _a : 200,
|
|
3570
3589
|
height: (_b = params.height) !== null && _b !== void 0 ? _b : 200,
|
|
3571
3590
|
stroke: (_c = params.color) !== null && _c !== void 0 ? _c : "#ff0000",
|
|
3572
|
-
strokeWidth: (_d = params.lineWidth) !== null && _d !== void 0 ? _d :
|
|
3591
|
+
strokeWidth: (_d = params.lineWidth) !== null && _d !== void 0 ? _d : 4,
|
|
3573
3592
|
draggable: true,
|
|
3574
3593
|
strokeScaleEnabled: false,
|
|
3575
3594
|
globalCompositeOperation: "source-over",
|
|
@@ -5108,9 +5127,6 @@ class Viewer extends EventEmitter2 {
|
|
|
5108
5127
|
try {
|
|
5109
5128
|
visualStyleId = visViewer.findVisualStyle("OpenCloud");
|
|
5110
5129
|
} catch (e) {
|
|
5111
|
-
if (!isInitializing) {
|
|
5112
|
-
console.log("OpenCloud visual style not found, creating it on client side");
|
|
5113
|
-
}
|
|
5114
5130
|
visualStyleId = visViewer.createVisualStyle("OpenCloud");
|
|
5115
5131
|
const colorDef = new visLib.OdTvColorDef(66, 66, 66);
|
|
5116
5132
|
const shadedVsId = visViewer.findVisualStyle("Realistic");
|
|
@@ -5355,7 +5371,7 @@ class Viewer extends EventEmitter2 {
|
|
|
5355
5371
|
if (!model) throw new Error("No default model found");
|
|
5356
5372
|
const overrideOptions = new Options;
|
|
5357
5373
|
overrideOptions.data = this.options.data;
|
|
5358
|
-
if (file.type === ".rcs") {
|
|
5374
|
+
if (file.type === ".rcs" && !overrideOptions.enablePartialMode) {
|
|
5359
5375
|
console.log("Partial load mode is forced for RCS file");
|
|
5360
5376
|
overrideOptions.enablePartialMode = true;
|
|
5361
5377
|
}
|
|
@@ -5591,5 +5607,5 @@ class Viewer extends EventEmitter2 {
|
|
|
5591
5607
|
}
|
|
5592
5608
|
}
|
|
5593
5609
|
|
|
5594
|
-
export { OdBaseDragger, Viewer, commands };
|
|
5610
|
+
export { OdBaseDragger, Options, Viewer, commands };
|
|
5595
5611
|
//# sourceMappingURL=viewer-visualize.module.js.map
|