@inweb/viewer-visualize 25.3.18 → 25.3.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/dist/viewer-visualize.js +150 -147
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +167 -166
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/ConvetMath.d.ts +28 -0
- package/lib/Viewer/Loaders/BaseLoader.d.ts +3 -3
- package/lib/Viewer/Loaders/LoaderFactory.d.ts +3 -3
- package/lib/Viewer/Viewer.d.ts +4 -4
- package/lib/Viewer/utils.d.ts +2 -3
- package/lib/index.d.ts +1 -1
- package/package.json +4 -4
- package/src/ConvetMath.ts +373 -0
- package/src/Viewer/Loaders/BaseLoader.ts +3 -3
- package/src/Viewer/Loaders/LoaderFactory.ts +4 -3
- 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 +5 -28
- package/src/Viewer/Loaders/VsfXStreamingLoader.ts +1 -1
- package/src/Viewer/Viewer.ts +16 -16
- package/src/Viewer/utils.ts +3 -12
- package/src/index.ts +1 -1
|
@@ -74,15 +74,11 @@ export class VsfXPartialLoader extends BaseLoader {
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
const downloadResourceRange = async (dataId: string, requestId: number, ranges: any) => {
|
|
77
|
-
console.log("--- VsfXPartialLoader.downloadResourceRange", dataId, requestId, ranges);
|
|
78
|
-
|
|
79
77
|
const abortCtrl = new AbortController();
|
|
80
78
|
abortControllerForRequestMap.set(requestId, abortCtrl);
|
|
81
79
|
try {
|
|
82
|
-
await this.model.downloadResourceRange(dataId,
|
|
83
|
-
} catch (error) {
|
|
84
|
-
console.log("--- VsfXPartialLoader.downloadResourceRange error", dataId, requestId, error);
|
|
85
|
-
|
|
80
|
+
await this.model.downloadResourceRange(dataId, requestId, ranges, chunkLoadHandler, abortCtrl.signal);
|
|
81
|
+
} catch (error: any) {
|
|
86
82
|
this.viewer.emitEvent({ type: "geometryerror", data: error, model: this.model });
|
|
87
83
|
} finally {
|
|
88
84
|
ranges.forEach((range) => visViewer.onRequestResponseComplete(range.requestId));
|
|
@@ -107,8 +103,6 @@ export class VsfXPartialLoader extends BaseLoader {
|
|
|
107
103
|
|
|
108
104
|
const objectHandler = {
|
|
109
105
|
onServicePartReceived: (bHasIndex: boolean) => {
|
|
110
|
-
console.log("--- VsfXPartialLoader.onServicePartReceived", bHasIndex);
|
|
111
|
-
|
|
112
106
|
if (bHasIndex) {
|
|
113
107
|
servicePartAborted = true;
|
|
114
108
|
abortController.abort();
|
|
@@ -117,38 +111,27 @@ export class VsfXPartialLoader extends BaseLoader {
|
|
|
117
111
|
|
|
118
112
|
onRequest: (requestId: number, records: any) => {
|
|
119
113
|
const ranges = requestRecordsToRanges(requestId, records);
|
|
120
|
-
|
|
121
|
-
console.log("--- VsfXPartialLoader.onRequest", this.model.database, requestId, ranges);
|
|
122
|
-
|
|
123
114
|
downloadResourceRange(this.model.database, requestId, ranges);
|
|
124
115
|
},
|
|
125
116
|
|
|
126
117
|
onFullLoaded: () => {
|
|
127
|
-
console.log("--- VsfXPartialLoader.onFullLoaded");
|
|
128
|
-
|
|
129
118
|
updaterController.update(UpdateType.kNormal);
|
|
130
119
|
},
|
|
131
120
|
|
|
132
121
|
onRequestResponseParsed: (requestId: number) => {
|
|
133
|
-
console.log("--- VsfXPartialLoader.onRequestResponseParsed", requestId);
|
|
134
|
-
|
|
135
122
|
abortControllerForRequestMap.delete(requestId);
|
|
136
123
|
updaterController.update(UpdateType.kNormal);
|
|
137
124
|
},
|
|
138
125
|
|
|
139
126
|
onRequestAborted: (requestId: number) => {
|
|
140
|
-
console.log("--- VsfXPartialLoader.onRequestAborted", requestId);
|
|
141
|
-
|
|
142
127
|
const abortCtrl = abortControllerForRequestMap.get(requestId);
|
|
143
128
|
if (abortCtrl) abortCtrl.abort();
|
|
144
129
|
},
|
|
145
130
|
|
|
146
|
-
onRequestResourceFile: (requestId: number,
|
|
147
|
-
|
|
131
|
+
onRequestResourceFile: (requestId: number, _: string, records: any) => {
|
|
132
|
+
const dataId = `${this.model.fileId}${this.model.file.type}`;
|
|
148
133
|
const ranges = requestRecordsToRanges(requestId, records);
|
|
149
134
|
|
|
150
|
-
console.log("--- VsfXPartialLoader.onRequestResourceFile", dataId, requestId, ranges);
|
|
151
|
-
|
|
152
135
|
let pendingRanges = [];
|
|
153
136
|
let requestNumber = 0;
|
|
154
137
|
const pendingRequest = pendingRequestsMap.get(dataId);
|
|
@@ -159,8 +142,6 @@ export class VsfXPartialLoader extends BaseLoader {
|
|
|
159
142
|
|
|
160
143
|
// first several records of each file are processed without grouping (they usually require to be processed sequentially)
|
|
161
144
|
if (requestNumber <= 5) {
|
|
162
|
-
console.log("--- VsfXPartialLoader.onRequestResourceFile: requestNumber <= 5");
|
|
163
|
-
|
|
164
145
|
pendingRequestsMap.set(dataId, { ranges: [], number: requestNumber + 1 });
|
|
165
146
|
downloadResourceRange(dataId, requestId, ranges);
|
|
166
147
|
return;
|
|
@@ -170,8 +151,6 @@ export class VsfXPartialLoader extends BaseLoader {
|
|
|
170
151
|
|
|
171
152
|
// group requests to each file to launch a combined server request
|
|
172
153
|
if (pendingRanges.length >= PENDING_REQUESTS_SIZE) {
|
|
173
|
-
console.log("--- VsfXPartialLoader.onRequestResourceFile: pendingRanges.length >", PENDING_REQUESTS_SIZE);
|
|
174
|
-
|
|
175
154
|
if (pendingRequestsTimerId) {
|
|
176
155
|
window.clearTimeout(pendingRequestsTimerId);
|
|
177
156
|
pendingRequestsTimerId = 0;
|
|
@@ -187,8 +166,6 @@ export class VsfXPartialLoader extends BaseLoader {
|
|
|
187
166
|
// set timeout to wait for the new requests, after that process the remaining requests
|
|
188
167
|
if (pendingRequestsTimerId === 0) {
|
|
189
168
|
pendingRequestsTimerId = window.setTimeout(() => {
|
|
190
|
-
console.log("--- VsfXPartialLoader.onRequestResourceFile: timer", PENDING_REQUESTS_SIZE);
|
|
191
|
-
|
|
192
169
|
pendingRequestsAbortController.signal.removeEventListener("abort", pendingRequestsAbortHandler);
|
|
193
170
|
pendingRequestsTimerId = 0;
|
|
194
171
|
|
|
@@ -217,7 +194,7 @@ export class VsfXPartialLoader extends BaseLoader {
|
|
|
217
194
|
});
|
|
218
195
|
|
|
219
196
|
this.viewer.emitEvent({ type: "geometryend", model: this.model });
|
|
220
|
-
} catch (error) {
|
|
197
|
+
} catch (error: any) {
|
|
221
198
|
if (pendingRequestsTimerId) {
|
|
222
199
|
window.clearTimeout(pendingRequestsTimerId);
|
|
223
200
|
pendingRequestsTimerId = 0;
|
|
@@ -79,7 +79,7 @@ export class VsfXStreamingLoader extends BaseLoader {
|
|
|
79
79
|
updaterController.update(UpdateType.kNormal);
|
|
80
80
|
|
|
81
81
|
this.viewer.emitEvent({ type: "geometryend", model: this.model });
|
|
82
|
-
} catch (error) {
|
|
82
|
+
} catch (error: any) {
|
|
83
83
|
this.viewer.emitEvent({ type: "geometryerror", data: error, model: this.model });
|
|
84
84
|
throw error;
|
|
85
85
|
}
|
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -27,11 +27,11 @@ import {
|
|
|
27
27
|
CANVAS_EVENTS,
|
|
28
28
|
commands,
|
|
29
29
|
IClippingPlane,
|
|
30
|
+
IOptions,
|
|
30
31
|
IOrthogonalCamera,
|
|
31
32
|
IViewpoint,
|
|
32
33
|
IViewer,
|
|
33
34
|
Options,
|
|
34
|
-
OptionsData,
|
|
35
35
|
OptionsEventMap,
|
|
36
36
|
ViewerEventMap,
|
|
37
37
|
} from "@inweb/viewer-core";
|
|
@@ -74,14 +74,14 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
74
74
|
private _renderTime: DOMHighResTimeStamp;
|
|
75
75
|
|
|
76
76
|
protected _options: Options;
|
|
77
|
-
protected _visualizeJsUrl
|
|
77
|
+
protected _visualizeJsUrl = "";
|
|
78
78
|
protected _abortControllerForReferences: AbortController | undefined;
|
|
79
79
|
|
|
80
80
|
private canvaseventlistener: (event: Event) => void;
|
|
81
81
|
|
|
82
82
|
public draggerFactory: Map<string, typeof OdBaseDragger>;
|
|
83
83
|
public canvasEvents: string[];
|
|
84
|
-
private frameId
|
|
84
|
+
private frameId = 0;
|
|
85
85
|
private _resizeObserver: ResizeObserver | undefined;
|
|
86
86
|
public canvas: HTMLCanvasElement | undefined;
|
|
87
87
|
public markup: IMarkup;
|
|
@@ -89,7 +89,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
89
89
|
public visualizeJs: any;
|
|
90
90
|
public _abortController: AbortController | undefined;
|
|
91
91
|
public _abortControllerForRequestMap: Map<string, AbortController> | undefined;
|
|
92
|
-
public client: Client;
|
|
92
|
+
public client: Client | undefined;
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* @param client - The `Client` instance that provides access to a server. Do not specify
|
|
@@ -107,9 +107,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
107
107
|
*/
|
|
108
108
|
constructor(
|
|
109
109
|
client?: Client,
|
|
110
|
-
params: { visualizeJsUrl?: string; enableAutoUpdate?: boolean; markupType?: MarkupType } = {
|
|
111
|
-
markupType: MarkupType.Konva,
|
|
112
|
-
}
|
|
110
|
+
params: { visualizeJsUrl?: string; enableAutoUpdate?: boolean; markupType?: MarkupType } = {}
|
|
113
111
|
) {
|
|
114
112
|
super();
|
|
115
113
|
this.configure(params);
|
|
@@ -119,6 +117,8 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
119
117
|
this.client = client;
|
|
120
118
|
|
|
121
119
|
this._activeDragger = null;
|
|
120
|
+
this._zoomWheelDragger = null;
|
|
121
|
+
this._gestureManager = null;
|
|
122
122
|
this._renderTime = 0;
|
|
123
123
|
|
|
124
124
|
this.markup = MarkupFactory.createMarkup(params.markupType ?? MarkupType.Konva);
|
|
@@ -335,7 +335,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
335
335
|
* @param force - If `true` updates the viewer immidietly. Otherwise updates on next
|
|
336
336
|
* animation frame. Default is `false`.
|
|
337
337
|
*/
|
|
338
|
-
update(force
|
|
338
|
+
update(force = false) {
|
|
339
339
|
if (this._enableAutoUpdate) {
|
|
340
340
|
if (force) {
|
|
341
341
|
this.visViewer()?.update();
|
|
@@ -455,7 +455,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
455
455
|
return this;
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
-
syncOptions(options:
|
|
458
|
+
syncOptions(options: IOptions = this.options): this {
|
|
459
459
|
if (!this.visualizeJs) return this;
|
|
460
460
|
|
|
461
461
|
const visLib = this.visLib();
|
|
@@ -526,7 +526,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
526
526
|
return this;
|
|
527
527
|
}
|
|
528
528
|
|
|
529
|
-
syncHighlightingOptions(options:
|
|
529
|
+
syncHighlightingOptions(options: IOptions = this.options): this {
|
|
530
530
|
if (!this.visualizeJs) return this;
|
|
531
531
|
|
|
532
532
|
const params = options.enableCustomHighlight ? options : Options.defaults();
|
|
@@ -774,12 +774,13 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
774
774
|
*/
|
|
775
775
|
async loadReferences(model: Model | File | Assembly): Promise<this> {
|
|
776
776
|
if (!this.visualizeJs) return this;
|
|
777
|
+
if (!this.client) return this;
|
|
777
778
|
|
|
778
779
|
const abortController = new AbortController();
|
|
779
780
|
this._abortControllerForReferences?.abort();
|
|
780
781
|
this._abortControllerForReferences = abortController;
|
|
781
782
|
|
|
782
|
-
let references = [];
|
|
783
|
+
let references: any[] = [];
|
|
783
784
|
await model
|
|
784
785
|
.getReferences(abortController.signal)
|
|
785
786
|
.then((data) => (references = data.references))
|
|
@@ -849,8 +850,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
849
850
|
|
|
850
851
|
this.emitEvent({ type: "open", file, model: file });
|
|
851
852
|
|
|
852
|
-
let model: Model;
|
|
853
|
-
|
|
853
|
+
let model: Model | undefined = undefined;
|
|
854
854
|
if (file) {
|
|
855
855
|
const models = (await file.getModels()) || [];
|
|
856
856
|
model = models.find((model: Model) => model.default) || models[0];
|
|
@@ -865,7 +865,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
865
865
|
}
|
|
866
866
|
|
|
867
867
|
const loaderFactory = new LoaderFactory();
|
|
868
|
-
const loader = loaderFactory.create(this, model, overrideOptions
|
|
868
|
+
const loader = loaderFactory.create(this, model, overrideOptions);
|
|
869
869
|
|
|
870
870
|
await this.loadReferences(model);
|
|
871
871
|
await loader.load();
|
|
@@ -916,7 +916,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
916
916
|
this.emitEvent({ type: "geometryprogress", data: 1, buffer });
|
|
917
917
|
this.emitEvent({ type: "databasechunk", data, buffer });
|
|
918
918
|
this.emitEvent({ type: "geometryend", buffer });
|
|
919
|
-
} catch (error) {
|
|
919
|
+
} catch (error: any) {
|
|
920
920
|
this.emitEvent({ type: "geometryerror", data: error, buffer });
|
|
921
921
|
throw error;
|
|
922
922
|
}
|
|
@@ -962,7 +962,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
962
962
|
this.emitEvent({ type: "geometryprogress", data: 1, buffer });
|
|
963
963
|
this.emitEvent({ type: "databasechunk", data, buffer });
|
|
964
964
|
this.emitEvent({ type: "geometryend", buffer });
|
|
965
|
-
} catch (error) {
|
|
965
|
+
} catch (error: any) {
|
|
966
966
|
this.emitEvent({ type: "geometryerror", data: error, buffer });
|
|
967
967
|
throw error;
|
|
968
968
|
}
|
package/src/Viewer/utils.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
export function loadScript(url: string) {
|
|
24
|
+
export function loadScript(url: string): Promise<HTMLScriptElement> {
|
|
25
25
|
return new Promise((resolve, reject) => {
|
|
26
26
|
const script = document.createElement("script");
|
|
27
27
|
script.src = url;
|
|
@@ -35,16 +35,7 @@ export function loadScript(url: string) {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
const cache = {};
|
|
40
|
-
return (...args) => {
|
|
41
|
-
const argStr = JSON.stringify(args);
|
|
42
|
-
cache[argStr] = cache[argStr] || f(...args);
|
|
43
|
-
return cache[argStr];
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
function loadVisuazlizeJsScript(url) {
|
|
38
|
+
function loadVisuazlizeJsScript(url: string): Promise<HTMLScriptElement> {
|
|
48
39
|
if (window["getVisualizeLibInst"]) {
|
|
49
40
|
const script = window["getVisualizeLibInst"].script;
|
|
50
41
|
if (script) {
|
|
@@ -56,7 +47,7 @@ function loadVisuazlizeJsScript(url) {
|
|
|
56
47
|
return loadScript(url);
|
|
57
48
|
}
|
|
58
49
|
|
|
59
|
-
export const loadVisualizeJs = (url: string, onprogress) => {
|
|
50
|
+
export const loadVisualizeJs = (url: string, onprogress): Promise<any> => {
|
|
60
51
|
return loadVisuazlizeJsScript(url).then((script) => {
|
|
61
52
|
return new Promise((resolve, reject) => {
|
|
62
53
|
const instance = window["getVisualizeLibInst"]({
|
package/src/index.ts
CHANGED