@inweb/viewer-core 25.3.18 → 25.3.19

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.
@@ -22,220 +22,30 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import { EventEmitter2 } from "@inweb/eventemitter2";
25
+ import { IOptions, RGB, defaultOptions } from "./IOptions";
25
26
 
26
- export interface RGB {
27
- red: number;
28
- green: number;
29
- blue: number;
30
- }
31
-
32
- /**
33
- * `VisualizeJS` parameters.
34
- */
35
- export interface OptionsData {
36
- /**
37
- * Show WCS
38
- *
39
- * @defaultValue true
40
- */
41
- showWCS?: boolean;
42
-
43
- /**
44
- * Enable camera animation
45
- *
46
- * @defaultValue true
47
- */
48
- cameraAnimation?: boolean;
49
-
50
- /**
51
- * Enable antialiasing use FXAA
52
- *
53
- * @defaultValue true
54
- */
55
- antialiasing?: boolean;
56
-
57
- /**
58
- * Enable ground shadows
59
- *
60
- * @defaultValue false
61
- */
62
- groundShadow?: boolean;
63
-
64
- /**
65
- * Enable shadows
66
- *
67
- * @defaultValue false
68
- */
69
- shadows?: boolean;
70
-
71
- /**
72
- * Camera speed on X axis
73
- *
74
- * @defaultValue 4
75
- */
76
- cameraAxisXSpeed?: number;
77
-
78
- /**
79
- * Camera speed on Y axis
80
- *
81
- * @defaultValue 1
82
- */
83
- cameraAxisYSpeed?: number;
84
-
85
- /**
86
- * Ambient occlusion
87
- *
88
- * @defaultValue false
89
- */
90
- ambientOcclusion?: boolean;
91
-
92
- /**
93
- * Enable streaming mode
94
- *
95
- * If enableStreamingMode is true then enablePartialMode will be used, otherwise -
96
- * enablePartialMode will be ignored and file / assembly will be loaded in one go
97
- *
98
- * @defaultValue true
99
- */
100
- enableStreamingMode?: boolean;
101
-
102
- /**
103
- * Enable partial load mode to be able open large drawing If enablePartialMode enabled, then
104
- * sceneGraph will be switched off
105
- *
106
- * @defaultValue false
107
- */
108
- enablePartialMode?: boolean;
109
-
110
- /**
111
- * The size of the memory buffer that the Viewer can use for graphics data
112
- *
113
- * @defaultValue 3294967296
114
- */
115
- memoryLimit?: number;
116
-
117
- /**
118
- * Cutting plane fill color
119
- *
120
- * @defaultValue { red: 0xff, green: 0x98, blue: 0x00 }
121
- */
122
- cuttingPlaneFillColor?: RGB;
123
-
124
- /**
125
- * Outline edges color in RGB format.
126
- */
127
- edgesColor?: { r: number; g: number; b: number };
128
-
129
- /**
130
- * Faces color in the RGB format.
131
- */
132
- facesColor?: { r: number; g: number; b: number };
133
-
134
- /**
135
- * Show or hide edges.
136
- */
137
- edgesVisibility?: boolean;
138
-
139
- /**
140
- * Show edges over drawing.
141
- */
142
- edgesOverlap?: boolean;
143
-
144
- /**
145
- * Show faces over drawing.
146
- */
147
- facesOverlap?: boolean;
148
-
149
- /**
150
- * Faces transparency value from 0 to 255.
151
- */
152
- facesTransparancy?: number;
153
-
154
- /**
155
- * Enable custom highlight settings.
156
- */
157
- enableCustomHighlight?: boolean;
158
-
159
- /**
160
- * Enable or disable scene graph, it increases perfomance improvement, but consumes memory
161
- * Large drawings can take up a lot of memory. If sceneGraph enabled, then enablePartialMode
162
- * will be switched off
163
- */
164
- sceneGraph: boolean;
165
-
166
- /**
167
- * Edge display models. No edges is usefull for less memory consumption: `false` - no edges
168
- * are displayed, `true` - display isolines.
169
- */
170
- edgeModel: boolean;
171
-
172
- /**
173
- * Reverse the mouse wheel direction for zooming: false - moving the wheel up zooms in,
174
- * moving down zooms out, `true` - moving the wheel up zooms out, moving down zooms in.
175
- */
176
- reverseZoomWheel: boolean;
177
-
178
- /**
179
- * Enable mouse wheel zooming.
180
- */
181
- enableZoomWheel: boolean;
182
-
183
- /**
184
- * Enable touch gestures. This option will be ignored when enableZoomWheel is disabled, since
185
- * gestures contains touch zoom.
186
- */
187
- enableGestures: boolean;
188
-
189
- /**
190
- * Default file geometry data type. Can be one of:
191
- *
192
- * - `vsfx` - `VSFX` (default), for opening a file in `VisualizeJS` viewer.
193
- * - `gltf` - `glTF`, for opening a file in `Three.js` viewer.
194
- */
195
- geometryType?: string;
196
- }
197
-
198
- export class Options {
27
+ export class Options implements IOptions {
199
28
  protected _emitter?: EventEmitter2;
200
- protected _data: OptionsData;
29
+ protected _data: IOptions;
201
30
 
202
31
  constructor(emitter?: EventEmitter2) {
203
32
  this._emitter = emitter;
204
- this._data = Options.defaults();
33
+ this._data = defaultOptions();
205
34
  this.loadFromStorage();
206
35
  }
207
36
 
208
- static defaults(): OptionsData {
209
- return {
210
- showWCS: true,
211
- cameraAnimation: true,
212
- antialiasing: true,
213
- groundShadow: false,
214
- shadows: false,
215
- cameraAxisXSpeed: 4,
216
- cameraAxisYSpeed: 1,
217
- ambientOcclusion: false,
218
- enableStreamingMode: true,
219
- enablePartialMode: false,
220
- memoryLimit: 3294967296,
221
- cuttingPlaneFillColor: { red: 0xff, green: 0x98, blue: 0x00 },
222
- edgesColor: { r: 0xff, g: 0x98, b: 0x00 },
223
- facesColor: { r: 0xff, g: 0x98, b: 0x00 },
224
- edgesVisibility: true,
225
- edgesOverlap: true,
226
- facesOverlap: false,
227
- facesTransparancy: 200,
228
- enableCustomHighlight: true,
229
- sceneGraph: false,
230
- edgeModel: true,
231
- reverseZoomWheel: false,
232
- enableZoomWheel: true,
233
- enableGestures: true,
234
- geometryType: "vsfx",
235
- };
37
+ static defaults(): IOptions {
38
+ return defaultOptions();
236
39
  }
237
40
 
238
41
  notifierChangeEvent(): void {
42
+ console.warn(
43
+ "Options.notifierChangeEvent() has been deprecated since 25.3 and will be removed in a future release, use Options.change() instead."
44
+ );
45
+ this.change();
46
+ }
47
+
48
+ change(): void {
239
49
  if (this._emitter !== undefined) {
240
50
  this.saveToStorage();
241
51
  this._emitter.emit({ type: "optionschange", data: this });
@@ -283,14 +93,15 @@ export class Options {
283
93
  }
284
94
  }
285
95
 
286
- get data(): OptionsData {
96
+ get data(): IOptions {
287
97
  return this._data;
288
98
  }
289
99
 
290
- set data(value: OptionsData) {
291
- const sceneGraph = value.enablePartialMode ? false : value.sceneGraph;
292
- this._data = { ...Options.defaults(), ...this._data, ...value, sceneGraph };
293
- this.notifierChangeEvent();
100
+ set data(value: IOptions) {
101
+ const enablePartialMode = value.enableStreamingMode ? value.enablePartialMode : false;
102
+ const sceneGraph = enablePartialMode ? false : value.sceneGraph;
103
+ this._data = { ...Options.defaults(), ...this._data, ...value, enablePartialMode, sceneGraph };
104
+ this.change();
294
105
  }
295
106
 
296
107
  get showWCS(): boolean {
@@ -299,7 +110,7 @@ export class Options {
299
110
 
300
111
  set showWCS(value: boolean) {
301
112
  this._data.showWCS = value;
302
- this.notifierChangeEvent();
113
+ this.change();
303
114
  }
304
115
 
305
116
  get cameraAnimation(): boolean {
@@ -308,7 +119,7 @@ export class Options {
308
119
 
309
120
  set cameraAnimation(value: boolean) {
310
121
  this._data.cameraAnimation = value;
311
- this.notifierChangeEvent();
122
+ this.change();
312
123
  }
313
124
 
314
125
  get antialiasing(): boolean {
@@ -317,7 +128,7 @@ export class Options {
317
128
 
318
129
  set antialiasing(value: boolean) {
319
130
  this._data.antialiasing = value;
320
- this.notifierChangeEvent();
131
+ this.change();
321
132
  }
322
133
 
323
134
  get groundShadow(): boolean {
@@ -326,7 +137,7 @@ export class Options {
326
137
 
327
138
  set groundShadow(value: boolean) {
328
139
  this._data.groundShadow = value;
329
- this.notifierChangeEvent();
140
+ this.change();
330
141
  }
331
142
 
332
143
  get shadows(): boolean {
@@ -335,7 +146,7 @@ export class Options {
335
146
 
336
147
  set shadows(value: boolean) {
337
148
  this._data.shadows = value;
338
- this.notifierChangeEvent();
149
+ this.change();
339
150
  }
340
151
 
341
152
  get cameraAxisXSpeed(): number {
@@ -344,7 +155,7 @@ export class Options {
344
155
 
345
156
  set cameraAxisXSpeed(value: number) {
346
157
  this._data.cameraAxisXSpeed = value;
347
- this.notifierChangeEvent();
158
+ this.change();
348
159
  }
349
160
 
350
161
  get cameraAxisYSpeed(): number {
@@ -353,7 +164,7 @@ export class Options {
353
164
 
354
165
  set cameraAxisYSpeed(value: number) {
355
166
  this.cameraAxisYSpeed = value;
356
- this.notifierChangeEvent();
167
+ this.change();
357
168
  }
358
169
 
359
170
  get ambientOcclusion(): boolean {
@@ -362,7 +173,7 @@ export class Options {
362
173
 
363
174
  set ambientOcclusion(value: boolean) {
364
175
  this._data.ambientOcclusion = value;
365
- this.notifierChangeEvent();
176
+ this.change();
366
177
  }
367
178
 
368
179
  get enableStreamingMode(): boolean {
@@ -371,12 +182,8 @@ export class Options {
371
182
 
372
183
  set enableStreamingMode(value: boolean) {
373
184
  this._data.enableStreamingMode = value;
374
-
375
- if (this._data.enableStreamingMode) {
376
- this._data.enablePartialMode = false;
377
- }
378
-
379
- this.notifierChangeEvent();
185
+ if (!value) this._data.enablePartialMode = false;
186
+ this.change();
380
187
  }
381
188
 
382
189
  get enablePartialMode(): boolean {
@@ -385,8 +192,11 @@ export class Options {
385
192
 
386
193
  set enablePartialMode(value: boolean) {
387
194
  this._data.enablePartialMode = value;
388
- if (value) this._data.sceneGraph = false;
389
- this.notifierChangeEvent();
195
+ if (value) {
196
+ this._data.enableStreamingMode = true;
197
+ this._data.sceneGraph = false;
198
+ }
199
+ this.change();
390
200
  }
391
201
 
392
202
  get memoryLimit(): number {
@@ -395,7 +205,7 @@ export class Options {
395
205
 
396
206
  set memoryLimit(value: number) {
397
207
  this._data.memoryLimit = value;
398
- this.notifierChangeEvent();
208
+ this.change();
399
209
  }
400
210
 
401
211
  get cuttingPlaneFillColor(): RGB {
@@ -404,7 +214,7 @@ export class Options {
404
214
 
405
215
  set cuttingPlaneFillColor(value: RGB) {
406
216
  this._data.cuttingPlaneFillColor = value;
407
- this.notifierChangeEvent();
217
+ this.change();
408
218
  }
409
219
 
410
220
  get edgesColor() {
@@ -413,7 +223,7 @@ export class Options {
413
223
 
414
224
  set edgesColor(value) {
415
225
  this._data.edgesColor = value;
416
- this.notifierChangeEvent();
226
+ this.change();
417
227
  }
418
228
 
419
229
  get facesColor() {
@@ -422,7 +232,7 @@ export class Options {
422
232
 
423
233
  set facesColor(value) {
424
234
  this._data.facesColor = value;
425
- this.notifierChangeEvent();
235
+ this.change();
426
236
  }
427
237
 
428
238
  get edgesVisibility() {
@@ -431,7 +241,7 @@ export class Options {
431
241
 
432
242
  set edgesVisibility(value) {
433
243
  this._data.edgesVisibility = value;
434
- this.notifierChangeEvent();
244
+ this.change();
435
245
  }
436
246
 
437
247
  get edgesOverlap() {
@@ -440,7 +250,7 @@ export class Options {
440
250
 
441
251
  set edgesOverlap(value) {
442
252
  this._data.edgesOverlap = value;
443
- this.notifierChangeEvent();
253
+ this.change();
444
254
  }
445
255
 
446
256
  get facesOverlap() {
@@ -449,7 +259,7 @@ export class Options {
449
259
 
450
260
  set facesOverlap(value) {
451
261
  this._data.facesOverlap = value;
452
- this.notifierChangeEvent();
262
+ this.change();
453
263
  }
454
264
 
455
265
  get facesTransparancy() {
@@ -458,7 +268,7 @@ export class Options {
458
268
 
459
269
  set facesTransparancy(value) {
460
270
  this._data.facesTransparancy = value;
461
- this.notifierChangeEvent();
271
+ this.change();
462
272
  }
463
273
 
464
274
  get enableCustomHighlight() {
@@ -467,7 +277,7 @@ export class Options {
467
277
 
468
278
  set enableCustomHighlight(value) {
469
279
  this._data.enableCustomHighlight = value;
470
- this.notifierChangeEvent();
280
+ this.change();
471
281
  }
472
282
 
473
283
  get sceneGraph() {
@@ -477,7 +287,7 @@ export class Options {
477
287
  set sceneGraph(value) {
478
288
  this._data.sceneGraph = value;
479
289
  if (value) this._data.enablePartialMode = false;
480
- this.notifierChangeEvent();
290
+ this.change();
481
291
  }
482
292
 
483
293
  get edgeModel() {
@@ -486,7 +296,7 @@ export class Options {
486
296
 
487
297
  set edgeModel(value) {
488
298
  this._data.edgeModel = Boolean(value);
489
- this.notifierChangeEvent();
299
+ this.change();
490
300
  }
491
301
 
492
302
  get reverseZoomWheel() {
@@ -495,7 +305,7 @@ export class Options {
495
305
 
496
306
  set reverseZoomWheel(value: boolean) {
497
307
  this._data.reverseZoomWheel = !!value;
498
- this.notifierChangeEvent();
308
+ this.change();
499
309
  }
500
310
 
501
311
  get enableZoomWheel() {
@@ -504,7 +314,7 @@ export class Options {
504
314
 
505
315
  set enableZoomWheel(value: boolean) {
506
316
  this._data.enableZoomWheel = !!value;
507
- this.notifierChangeEvent();
317
+ this.change();
508
318
  }
509
319
 
510
320
  get enableGestures() {
@@ -513,7 +323,7 @@ export class Options {
513
323
 
514
324
  set enableGestures(value: boolean) {
515
325
  this._data.enableGestures = !!value;
516
- this.notifierChangeEvent();
326
+ this.change();
517
327
  }
518
328
 
519
329
  get geometryType() {
@@ -522,6 +332,6 @@ export class Options {
522
332
 
523
333
  set geometryType(value: string) {
524
334
  this._data.geometryType = value;
525
- this.notifierChangeEvent();
335
+ this.change();
526
336
  }
527
337
  }
@@ -1,4 +1,4 @@
1
- import { Options } from "./Options";
1
+ import { IOptions } from "./IOptions";
2
2
 
3
3
  /**
4
4
  * An event that fires when options has been changed.
@@ -14,7 +14,7 @@ export interface OptionsChangeEvent {
14
14
  /**
15
15
  * New parameters.
16
16
  */
17
- data: Options;
17
+ data: IOptions;
18
18
  }
19
19
 
20
20
  /**
@@ -24,12 +24,12 @@
24
24
  import { IEventEmitter } from "@inweb/eventemitter2";
25
25
  import { Assembly, Client, File, Model } from "@inweb/client";
26
26
  import { ICommandService } from "../commands/ICommands";
27
- import { Options } from "../options/Options";
27
+ import { IOptions } from "../options/IOptions";
28
28
  import { IViewpoint } from "./IViewpoint";
29
29
 
30
30
  export interface IViewer extends IEventEmitter, ICommandService {
31
31
  client: Client | undefined;
32
- options: Options;
32
+ options: IOptions;
33
33
  canvas: HTMLCanvasElement | undefined;
34
34
  canvasEvents: string[];
35
35
  draggers: string[];