@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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Model } from "@inweb/client";
|
|
2
2
|
import { IOptions } from "@inweb/viewer-core";
|
|
3
3
|
import { TCSLoader } from "./TCSLoader";
|
|
4
|
+
import { VsfXLoader } from "./VsfXLoader";
|
|
4
5
|
import { VsfXStreamingLoader } from "./VsfXStreamingLoader";
|
|
5
6
|
import { VsfXPartialLoader } from "./VsfXPartialLoader";
|
|
6
7
|
import { Viewer } from "../Viewer";
|
|
7
|
-
import { VsfXLoader } from "./VsfXLoader";
|
|
8
8
|
export declare class LoaderFactory {
|
|
9
|
-
create(viewer: Viewer, model: Model, options: IOptions): TCSLoader |
|
|
9
|
+
create(viewer: Viewer, model: Model, options: IOptions): TCSLoader | VsfXLoader | VsfXStreamingLoader | VsfXPartialLoader;
|
|
10
10
|
}
|
package/lib/Viewer/Viewer.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventM
|
|
|
28
28
|
visualizeJs: any;
|
|
29
29
|
_abortController: AbortController | undefined;
|
|
30
30
|
_abortControllerForRequestMap: Map<string, AbortController> | undefined;
|
|
31
|
-
client: Client;
|
|
31
|
+
client: Client | undefined;
|
|
32
32
|
/**
|
|
33
33
|
* @param client - The `Client` instance that provides access to a server. Do not specify
|
|
34
34
|
* `Client` if you need a standalone viewer instance without access to server models.
|
package/lib/Viewer/utils.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export declare function loadScript(url: string): Promise<
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const loadVisualizeJs: (url: string, onprogress: any) => Promise<unknown>;
|
|
1
|
+
export declare function loadScript(url: string): Promise<HTMLScriptElement>;
|
|
2
|
+
export declare const loadVisualizeJs: (url: string, onprogress: any) => Promise<any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-visualize",
|
|
3
|
-
"version": "25.3.
|
|
3
|
+
"version": "25.3.21",
|
|
4
4
|
"description": "3D CAD and BIM data Viewer powered by Visualize",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"test": "karma start karma.conf.js"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@inweb/client": "^25.3.
|
|
32
|
-
"@inweb/eventemitter2": "^25.3.
|
|
33
|
-
"@inweb/viewer-core": "^25.3.
|
|
31
|
+
"@inweb/client": "^25.3.19",
|
|
32
|
+
"@inweb/eventemitter2": "^25.3.19",
|
|
33
|
+
"@inweb/viewer-core": "^25.3.19"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"canvas": "^2.11.2",
|
package/src/ConvetMath.ts
CHANGED
|
@@ -172,7 +172,7 @@ export function worldToScreen(
|
|
|
172
172
|
worldPoint: [x: number, y: number, z: number],
|
|
173
173
|
screenWidth: number,
|
|
174
174
|
screenHeight: number
|
|
175
|
-
) {
|
|
175
|
+
): number[] {
|
|
176
176
|
const widthHalf = screenWidth / 2;
|
|
177
177
|
const heightHalf = screenHeight / 2;
|
|
178
178
|
|
|
@@ -188,6 +188,7 @@ export function worldToScreen(
|
|
|
188
188
|
function lengthVector(a: { x: number; y: number; z: number }): number {
|
|
189
189
|
return Math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z);
|
|
190
190
|
}
|
|
191
|
+
|
|
191
192
|
function normalizeVector(a: { x: number; y: number; z: number }): { x: number; y: number; z: number } {
|
|
192
193
|
const len = lengthVector(a);
|
|
193
194
|
if (len === 0) return a;
|
|
@@ -25,10 +25,10 @@ import { Model } from "@inweb/client";
|
|
|
25
25
|
import { IOptions } from "@inweb/viewer-core";
|
|
26
26
|
|
|
27
27
|
import { TCSLoader } from "./TCSLoader";
|
|
28
|
+
import { VsfXLoader } from "./VsfXLoader";
|
|
28
29
|
import { VsfXStreamingLoader } from "./VsfXStreamingLoader";
|
|
29
30
|
import { VsfXPartialLoader } from "./VsfXPartialLoader";
|
|
30
31
|
import { Viewer } from "../Viewer";
|
|
31
|
-
import { VsfXLoader } from "./VsfXLoader";
|
|
32
32
|
|
|
33
33
|
export class LoaderFactory {
|
|
34
34
|
create(viewer: Viewer, model: Model, options: IOptions) {
|
|
@@ -31,25 +31,23 @@ export class TCSLoader extends BaseLoader {
|
|
|
31
31
|
const visViewer = visLib.getViewer();
|
|
32
32
|
const abortController = new AbortController();
|
|
33
33
|
|
|
34
|
-
const
|
|
35
|
-
const chunksProgress = listFileForDownload.map(() => 0);
|
|
36
|
-
|
|
37
|
-
const calcProgress = (index: number, progress: number) => {
|
|
38
|
-
chunksProgress[index] = progress;
|
|
39
|
-
const fileProgress = chunksProgress.reduce((acc, progress) => (acc += progress)) / (chunksProgress.length || 1);
|
|
40
|
-
this.viewer.emitEvent({ type: "geometryprogress", data: fileProgress, model: this.model });
|
|
41
|
-
};
|
|
34
|
+
const filesToDownload = [this.model.database, ...this.model.geometry];
|
|
42
35
|
|
|
43
36
|
this.viewer._abortController = abortController;
|
|
44
37
|
|
|
38
|
+
console.time("File load time");
|
|
45
39
|
try {
|
|
46
40
|
this.viewer.emitEvent({ type: "geometrystart", model: this.model });
|
|
47
41
|
|
|
48
|
-
for (let i = 0; i <
|
|
49
|
-
const
|
|
42
|
+
for (let i = 0; i < filesToDownload.length; i++) {
|
|
43
|
+
const dataId = filesToDownload[i];
|
|
44
|
+
|
|
45
|
+
const chunkLoadHandler = (progress: number) => {
|
|
46
|
+
const data = (i + progress) / filesToDownload.length;
|
|
47
|
+
this.viewer.emitEvent({ type: "geometryprogress", data, model: this.model });
|
|
48
|
+
};
|
|
50
49
|
|
|
51
|
-
const
|
|
52
|
-
const arrayBuffer = await this.model.downloadResource(chunk, progressCb, abortController.signal);
|
|
50
|
+
const arrayBuffer = await this.model.downloadResource(dataId, chunkLoadHandler, abortController.signal);
|
|
53
51
|
|
|
54
52
|
if (abortController.signal.aborted) {
|
|
55
53
|
await Promise.reject(new Error(`Open model aborted ${this.model.name}`));
|
|
@@ -73,6 +71,8 @@ export class TCSLoader extends BaseLoader {
|
|
|
73
71
|
}
|
|
74
72
|
}
|
|
75
73
|
|
|
74
|
+
console.timeEnd("File load time");
|
|
75
|
+
|
|
76
76
|
this.viewer.emitEvent({ type: "geometryend", model: this.model });
|
|
77
77
|
} catch (error) {
|
|
78
78
|
this.viewer.emitEvent({ type: "geometryerror", data: error, model: this.model });
|
|
@@ -65,7 +65,7 @@ export class VsfXLoader extends BaseLoader {
|
|
|
65
65
|
|
|
66
66
|
this.viewer.emitEvent({ type: "databasechunk", data, model: this.model });
|
|
67
67
|
this.viewer.emitEvent({ type: "geometryend", model: this.model });
|
|
68
|
-
} catch (error) {
|
|
68
|
+
} catch (error: any) {
|
|
69
69
|
this.viewer.emitEvent({ type: "geometryerror", data: error, model: this.model });
|
|
70
70
|
throw error;
|
|
71
71
|
}
|
|
@@ -77,8 +77,8 @@ export class VsfXPartialLoader extends BaseLoader {
|
|
|
77
77
|
const abortCtrl = new AbortController();
|
|
78
78
|
abortControllerForRequestMap.set(requestId, abortCtrl);
|
|
79
79
|
try {
|
|
80
|
-
await this.model.downloadResourceRange(dataId,
|
|
81
|
-
} catch (error) {
|
|
80
|
+
await this.model.downloadResourceRange(dataId, requestId, ranges, chunkLoadHandler, abortCtrl.signal);
|
|
81
|
+
} catch (error: any) {
|
|
82
82
|
this.viewer.emitEvent({ type: "geometryerror", data: error, model: this.model });
|
|
83
83
|
} finally {
|
|
84
84
|
ranges.forEach((range) => visViewer.onRequestResponseComplete(range.requestId));
|
|
@@ -194,7 +194,7 @@ export class VsfXPartialLoader extends BaseLoader {
|
|
|
194
194
|
});
|
|
195
195
|
|
|
196
196
|
this.viewer.emitEvent({ type: "geometryend", model: this.model });
|
|
197
|
-
} catch (error) {
|
|
197
|
+
} catch (error: any) {
|
|
198
198
|
if (pendingRequestsTimerId) {
|
|
199
199
|
window.clearTimeout(pendingRequestsTimerId);
|
|
200
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
|
@@ -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);
|
|
@@ -140,7 +140,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
140
140
|
this.registerDragger(key, value);
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
-
this.canvasEvents = CANVAS_EVENTS;
|
|
143
|
+
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
144
144
|
this.canvaseventlistener = (event: Event) => this.emit(event);
|
|
145
145
|
|
|
146
146
|
this._enableAutoUpdate = params.enableAutoUpdate ?? true;
|
|
@@ -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();
|
|
@@ -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];
|
|
@@ -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"]({
|