@inweb/viewer-core 26.9.3 → 26.9.5
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-core.js +23 -225
- package/dist/viewer-core.js.map +1 -1
- package/dist/viewer-core.module.js +106 -100
- package/dist/viewer-core.module.js.map +1 -1
- package/package.json +3 -3
- package/src/loaders/ILoader.ts +2 -2
- package/src/loaders/Loader.ts +2 -2
- package/src/loaders/Loaders.ts +2 -2
|
@@ -1,14 +1,32 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
1
24
|
class CommandsRegistry {
|
|
2
25
|
constructor() {
|
|
3
|
-
this._commands = new Map;
|
|
26
|
+
this._commands = new Map();
|
|
4
27
|
}
|
|
5
28
|
registerCommand(id, handler, description, thisArg) {
|
|
6
|
-
this._commands.set(id, {
|
|
7
|
-
id: id,
|
|
8
|
-
handler: handler,
|
|
9
|
-
thisArg: thisArg,
|
|
10
|
-
description: description
|
|
11
|
-
});
|
|
29
|
+
this._commands.set(id, { id, handler, thisArg, description });
|
|
12
30
|
}
|
|
13
31
|
registerCommandAlias(id, alias) {
|
|
14
32
|
this.registerCommand(alias, (viewer, ...args) => this.executeCommand(id, viewer, ...args));
|
|
@@ -17,7 +35,7 @@ class CommandsRegistry {
|
|
|
17
35
|
return this._commands.get(id);
|
|
18
36
|
}
|
|
19
37
|
getCommands() {
|
|
20
|
-
const map = new Map;
|
|
38
|
+
const map = new Map();
|
|
21
39
|
this._commands.forEach((value, key) => map.set(key, value));
|
|
22
40
|
return map;
|
|
23
41
|
}
|
|
@@ -26,28 +44,23 @@ class CommandsRegistry {
|
|
|
26
44
|
if (!command) {
|
|
27
45
|
if (viewer) {
|
|
28
46
|
const isDraggerCommand = viewer.draggers.includes(id);
|
|
29
|
-
if (isDraggerCommand)
|
|
47
|
+
if (isDraggerCommand)
|
|
48
|
+
return viewer.setActiveDragger(id);
|
|
30
49
|
}
|
|
31
50
|
console.warn(`Command '${id}' not found`);
|
|
32
51
|
return undefined;
|
|
33
52
|
}
|
|
34
|
-
const {
|
|
35
|
-
const result = handler.apply(thisArg, [
|
|
36
|
-
viewer === null || viewer === void 0 ? void 0 : viewer.emit({
|
|
37
|
-
type: "command",
|
|
38
|
-
data: id,
|
|
39
|
-
args: args
|
|
40
|
-
});
|
|
53
|
+
const { handler, thisArg } = command;
|
|
54
|
+
const result = handler.apply(thisArg, [viewer, ...args]);
|
|
55
|
+
viewer === null || viewer === void 0 ? void 0 : viewer.emit({ type: "command", data: id, args });
|
|
41
56
|
return result;
|
|
42
57
|
}
|
|
43
58
|
}
|
|
44
|
-
|
|
45
|
-
const _commandsRegistry = new Map;
|
|
46
|
-
|
|
59
|
+
const _commandsRegistry = new Map();
|
|
47
60
|
function commandsRegistry(viewerType = "") {
|
|
48
61
|
let result = _commandsRegistry.get(viewerType);
|
|
49
62
|
if (!result) {
|
|
50
|
-
result = new CommandsRegistry;
|
|
63
|
+
result = new CommandsRegistry();
|
|
51
64
|
_commandsRegistry.set(viewerType, result);
|
|
52
65
|
}
|
|
53
66
|
return result;
|
|
@@ -57,40 +70,40 @@ class Dragger {
|
|
|
57
70
|
constructor(viewer) {
|
|
58
71
|
this.name = "";
|
|
59
72
|
}
|
|
60
|
-
dispose() {}
|
|
73
|
+
dispose() { }
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
class DraggersRegistry {
|
|
64
77
|
constructor() {
|
|
65
|
-
this._providers = new Map;
|
|
78
|
+
this._providers = new Map();
|
|
66
79
|
}
|
|
67
80
|
registerDragger(name, provider) {
|
|
68
81
|
this._providers.set(name, provider);
|
|
69
82
|
}
|
|
70
83
|
registerDraggerAlias(name, alias) {
|
|
71
84
|
const provider = this._providers.get(name);
|
|
72
|
-
if (provider)
|
|
85
|
+
if (provider)
|
|
86
|
+
this.registerDragger(alias, (viewer) => provider(viewer));
|
|
73
87
|
}
|
|
74
88
|
getDraggers() {
|
|
75
|
-
const map = new Map;
|
|
89
|
+
const map = new Map();
|
|
76
90
|
this._providers.forEach((value, key) => map.set(key, value));
|
|
77
91
|
return map;
|
|
78
92
|
}
|
|
79
93
|
createDragger(name, viewer) {
|
|
80
94
|
const provider = this._providers.get(name);
|
|
81
|
-
if (!provider)
|
|
95
|
+
if (!provider)
|
|
96
|
+
return null;
|
|
82
97
|
const dragger = provider(viewer);
|
|
83
98
|
dragger.name = name;
|
|
84
99
|
return dragger;
|
|
85
100
|
}
|
|
86
101
|
}
|
|
87
|
-
|
|
88
|
-
const _draggersRegistry = new Map;
|
|
89
|
-
|
|
102
|
+
const _draggersRegistry = new Map();
|
|
90
103
|
function draggersRegistry(viewerType = "") {
|
|
91
104
|
let result = _draggersRegistry.get(viewerType);
|
|
92
105
|
if (!result) {
|
|
93
|
-
result = new DraggersRegistry;
|
|
106
|
+
result = new DraggersRegistry();
|
|
94
107
|
_draggersRegistry.set(viewerType, result);
|
|
95
108
|
}
|
|
96
109
|
return result;
|
|
@@ -100,40 +113,40 @@ class Component {
|
|
|
100
113
|
constructor(viewer) {
|
|
101
114
|
this.name = "";
|
|
102
115
|
}
|
|
103
|
-
dispose() {}
|
|
116
|
+
dispose() { }
|
|
104
117
|
}
|
|
105
118
|
|
|
106
119
|
class Components {
|
|
107
120
|
constructor() {
|
|
108
|
-
this._providers = new Map;
|
|
121
|
+
this._providers = new Map();
|
|
109
122
|
}
|
|
110
123
|
registerComponent(name, provider) {
|
|
111
124
|
this._providers.set(name, provider);
|
|
112
125
|
}
|
|
113
126
|
registerComponentAlias(name, alias) {
|
|
114
127
|
const provider = this._providers.get(name);
|
|
115
|
-
if (provider)
|
|
128
|
+
if (provider)
|
|
129
|
+
this.registerComponent(alias, (viewer) => provider(viewer));
|
|
116
130
|
}
|
|
117
131
|
getComponents() {
|
|
118
|
-
const map = new Map;
|
|
132
|
+
const map = new Map();
|
|
119
133
|
this._providers.forEach((value, key) => map.set(key, value));
|
|
120
134
|
return map;
|
|
121
135
|
}
|
|
122
136
|
createComponent(name, viewer) {
|
|
123
137
|
const provider = this._providers.get(name);
|
|
124
|
-
if (!provider)
|
|
138
|
+
if (!provider)
|
|
139
|
+
return null;
|
|
125
140
|
const component = provider(viewer);
|
|
126
141
|
component.name = name;
|
|
127
142
|
return component;
|
|
128
143
|
}
|
|
129
144
|
}
|
|
130
|
-
|
|
131
|
-
const _components = new Map;
|
|
132
|
-
|
|
145
|
+
const _components = new Map();
|
|
133
146
|
function componentsRegistry(viewerType = "") {
|
|
134
147
|
let result = _components.get(viewerType);
|
|
135
148
|
if (!result) {
|
|
136
|
-
result = new Components;
|
|
149
|
+
result = new Components();
|
|
137
150
|
_components.set(viewerType, result);
|
|
138
151
|
}
|
|
139
152
|
return result;
|
|
@@ -142,7 +155,7 @@ function componentsRegistry(viewerType = "") {
|
|
|
142
155
|
class Loader {
|
|
143
156
|
constructor() {
|
|
144
157
|
this.name = "";
|
|
145
|
-
this.abortController = new AbortController;
|
|
158
|
+
this.abortController = new AbortController();
|
|
146
159
|
}
|
|
147
160
|
dispose() {
|
|
148
161
|
this.abortController.abort();
|
|
@@ -161,7 +174,7 @@ class Loader {
|
|
|
161
174
|
|
|
162
175
|
class Loaders {
|
|
163
176
|
constructor() {
|
|
164
|
-
this._providers = new Map;
|
|
177
|
+
this._providers = new Map();
|
|
165
178
|
}
|
|
166
179
|
registerLoader(name, provider) {
|
|
167
180
|
this._providers.set(name, provider);
|
|
@@ -170,7 +183,7 @@ class Loaders {
|
|
|
170
183
|
return this._providers.get(name);
|
|
171
184
|
}
|
|
172
185
|
getLoaders() {
|
|
173
|
-
const map = new Map;
|
|
186
|
+
const map = new Map();
|
|
174
187
|
this._providers.forEach((value, key) => map.set(key, value));
|
|
175
188
|
return map;
|
|
176
189
|
}
|
|
@@ -186,13 +199,11 @@ class Loaders {
|
|
|
186
199
|
return result;
|
|
187
200
|
}
|
|
188
201
|
}
|
|
189
|
-
|
|
190
|
-
const _loaders = new Map;
|
|
191
|
-
|
|
202
|
+
const _loaders = new Map();
|
|
192
203
|
function loadersRegistry(viewerType = "") {
|
|
193
204
|
let result = _loaders.get(viewerType);
|
|
194
205
|
if (!result) {
|
|
195
|
-
result = new Loaders;
|
|
206
|
+
result = new Loaders();
|
|
196
207
|
_loaders.set(viewerType, result);
|
|
197
208
|
}
|
|
198
209
|
return result;
|
|
@@ -211,21 +222,9 @@ function defaultOptions() {
|
|
|
211
222
|
enableStreamingMode: true,
|
|
212
223
|
enablePartialMode: false,
|
|
213
224
|
memoryLimit: 3294967296,
|
|
214
|
-
cuttingPlaneFillColor: {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
blue: 0
|
|
218
|
-
},
|
|
219
|
-
edgesColor: {
|
|
220
|
-
r: 255,
|
|
221
|
-
g: 152,
|
|
222
|
-
b: 0
|
|
223
|
-
},
|
|
224
|
-
facesColor: {
|
|
225
|
-
r: 255,
|
|
226
|
-
g: 152,
|
|
227
|
-
b: 0
|
|
228
|
-
},
|
|
225
|
+
cuttingPlaneFillColor: { red: 0xff, green: 0x98, blue: 0x00 },
|
|
226
|
+
edgesColor: { r: 0xff, g: 0x98, b: 0x00 },
|
|
227
|
+
facesColor: { r: 0xff, g: 0x98, b: 0x00 },
|
|
229
228
|
edgesVisibility: true,
|
|
230
229
|
edgesOverlap: true,
|
|
231
230
|
facesOverlap: false,
|
|
@@ -237,7 +236,7 @@ function defaultOptions() {
|
|
|
237
236
|
enableZoomWheel: true,
|
|
238
237
|
enableGestures: true,
|
|
239
238
|
geometryType: "vsfx",
|
|
240
|
-
rulerUnit: "Default"
|
|
239
|
+
rulerUnit: "Default",
|
|
241
240
|
};
|
|
242
241
|
}
|
|
243
242
|
|
|
@@ -257,31 +256,30 @@ class Options {
|
|
|
257
256
|
change() {
|
|
258
257
|
if (this._emitter !== undefined) {
|
|
259
258
|
this.saveToStorage();
|
|
260
|
-
this._emitter.emit({
|
|
261
|
-
type: "optionschange",
|
|
262
|
-
data: this
|
|
263
|
-
});
|
|
259
|
+
this._emitter.emit({ type: "optionschange", data: this });
|
|
264
260
|
}
|
|
265
261
|
}
|
|
266
262
|
saveToStorage() {
|
|
267
|
-
if (typeof window !== "undefined")
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
263
|
+
if (typeof window !== "undefined")
|
|
264
|
+
try {
|
|
265
|
+
localStorage.setItem("od-client-settings", JSON.stringify(this.data));
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
console.error("Cannot save client settings.", error);
|
|
269
|
+
}
|
|
272
270
|
}
|
|
273
271
|
loadFromStorage() {
|
|
274
|
-
if (typeof window !== "undefined")
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
...data
|
|
280
|
-
}
|
|
272
|
+
if (typeof window !== "undefined")
|
|
273
|
+
try {
|
|
274
|
+
const item = localStorage.getItem("od-client-settings");
|
|
275
|
+
if (item) {
|
|
276
|
+
const data = JSON.parse(item);
|
|
277
|
+
this.data = { ...data };
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
console.error("Cannot load client settings.", error);
|
|
281
282
|
}
|
|
282
|
-
} catch (error) {
|
|
283
|
-
console.error("Cannot load client settings.", error);
|
|
284
|
-
}
|
|
285
283
|
}
|
|
286
284
|
resetToDefaults(fields) {
|
|
287
285
|
if (fields !== undefined) {
|
|
@@ -290,15 +288,10 @@ class Options {
|
|
|
290
288
|
acc[field] = defaults[field];
|
|
291
289
|
return acc;
|
|
292
290
|
}, {});
|
|
293
|
-
this.data = {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
};
|
|
297
|
-
} else {
|
|
298
|
-
this.data = {
|
|
299
|
-
...this.data,
|
|
300
|
-
...Options.defaults()
|
|
301
|
-
};
|
|
291
|
+
this.data = { ...this.data, ...resetData };
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
this.data = { ...this.data, ...Options.defaults() };
|
|
302
295
|
}
|
|
303
296
|
}
|
|
304
297
|
get data() {
|
|
@@ -307,13 +300,7 @@ class Options {
|
|
|
307
300
|
set data(value) {
|
|
308
301
|
const enablePartialMode = value.enableStreamingMode ? value.enablePartialMode : false;
|
|
309
302
|
const sceneGraph = enablePartialMode ? false : value.sceneGraph;
|
|
310
|
-
this._data = {
|
|
311
|
-
...Options.defaults(),
|
|
312
|
-
...this._data,
|
|
313
|
-
...value,
|
|
314
|
-
enablePartialMode: enablePartialMode,
|
|
315
|
-
sceneGraph: sceneGraph
|
|
316
|
-
};
|
|
303
|
+
this._data = { ...Options.defaults(), ...this._data, ...value, enablePartialMode, sceneGraph };
|
|
317
304
|
this.change();
|
|
318
305
|
}
|
|
319
306
|
get showWCS() {
|
|
@@ -377,7 +364,8 @@ class Options {
|
|
|
377
364
|
}
|
|
378
365
|
set enableStreamingMode(value) {
|
|
379
366
|
this._data.enableStreamingMode = value;
|
|
380
|
-
if (!value)
|
|
367
|
+
if (!value)
|
|
368
|
+
this._data.enablePartialMode = false;
|
|
381
369
|
this.change();
|
|
382
370
|
}
|
|
383
371
|
get enablePartialMode() {
|
|
@@ -459,7 +447,8 @@ class Options {
|
|
|
459
447
|
}
|
|
460
448
|
set sceneGraph(value) {
|
|
461
449
|
this._data.sceneGraph = value;
|
|
462
|
-
if (value)
|
|
450
|
+
if (value)
|
|
451
|
+
this._data.enablePartialMode = false;
|
|
463
452
|
this.change();
|
|
464
453
|
}
|
|
465
454
|
get edgeModel() {
|
|
@@ -506,8 +495,25 @@ class Options {
|
|
|
506
495
|
}
|
|
507
496
|
}
|
|
508
497
|
|
|
509
|
-
const CanvasEvents = [
|
|
510
|
-
|
|
498
|
+
const CanvasEvents = [
|
|
499
|
+
"click",
|
|
500
|
+
"contextmenu",
|
|
501
|
+
"dblclick",
|
|
502
|
+
"mousedown",
|
|
503
|
+
"mouseleave",
|
|
504
|
+
"mousemove",
|
|
505
|
+
"mouseup",
|
|
506
|
+
"pointercancel",
|
|
507
|
+
"pointerdown",
|
|
508
|
+
"pointerleave",
|
|
509
|
+
"pointermove",
|
|
510
|
+
"pointerup",
|
|
511
|
+
"touchcancel",
|
|
512
|
+
"touchend",
|
|
513
|
+
"touchmove",
|
|
514
|
+
"touchstart",
|
|
515
|
+
"wheel",
|
|
516
|
+
];
|
|
511
517
|
const CANVAS_EVENTS = CanvasEvents;
|
|
512
518
|
|
|
513
519
|
export { CANVAS_EVENTS, CanvasEvents, Component, Dragger, Loader, Options, commandsRegistry, componentsRegistry, defaultOptions, draggersRegistry, loadersRegistry };
|