@inweb/viewer-core 27.6.0 → 27.6.2
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 +111 -57
- package/dist/viewer-core.js.map +1 -1
- package/dist/viewer-core.module.js +111 -57
- package/dist/viewer-core.module.js.map +1 -1
- package/lib/options/IOptions.d.ts +5 -5
- package/lib/options/Options.d.ts +7 -2
- package/package.json +3 -3
- package/src/options/IOptions.ts +5 -5
- package/src/options/Options.ts +121 -65
package/dist/viewer-core.js
CHANGED
|
@@ -271,21 +271,44 @@
|
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
+
function isColorRGB(value) {
|
|
275
|
+
return (typeof value === "object" &&
|
|
276
|
+
value !== null &&
|
|
277
|
+
typeof value.r === "number" &&
|
|
278
|
+
typeof value.g === "number" &&
|
|
279
|
+
typeof value.b === "number");
|
|
280
|
+
}
|
|
281
|
+
function isLegacyRGB(value) {
|
|
282
|
+
return (typeof value === "object" &&
|
|
283
|
+
value !== null &&
|
|
284
|
+
typeof value.red === "number" &&
|
|
285
|
+
typeof value.green === "number" &&
|
|
286
|
+
typeof value.blue === "number");
|
|
287
|
+
}
|
|
274
288
|
class Options {
|
|
275
289
|
constructor(emitter) {
|
|
290
|
+
this._updateCount = 0;
|
|
276
291
|
this._emitter = emitter;
|
|
277
|
-
this._data =
|
|
292
|
+
this._data = Options.defaults();
|
|
293
|
+
this._defaults = Options.defaults();
|
|
278
294
|
this.loadFromStorage();
|
|
279
295
|
}
|
|
280
296
|
static defaults() {
|
|
281
297
|
return defaultOptions();
|
|
282
298
|
}
|
|
283
299
|
change() {
|
|
284
|
-
if (this._emitter !== undefined) {
|
|
300
|
+
if (this._emitter !== undefined && this._updateCount === 0) {
|
|
285
301
|
this.saveToStorage();
|
|
286
302
|
this._emitter.emit({ type: "optionschange", data: this });
|
|
287
303
|
}
|
|
288
304
|
}
|
|
305
|
+
beginUpdate() {
|
|
306
|
+
this._updateCount++;
|
|
307
|
+
}
|
|
308
|
+
endUpdate() {
|
|
309
|
+
this._updateCount--;
|
|
310
|
+
this.change();
|
|
311
|
+
}
|
|
289
312
|
saveToStorage() {
|
|
290
313
|
if (typeof window !== "undefined")
|
|
291
314
|
try {
|
|
@@ -299,18 +322,15 @@
|
|
|
299
322
|
if (typeof window !== "undefined")
|
|
300
323
|
try {
|
|
301
324
|
const item = localStorage.getItem("od-client-settings");
|
|
302
|
-
if (item)
|
|
303
|
-
|
|
304
|
-
this.data = { ...data };
|
|
305
|
-
}
|
|
325
|
+
if (item)
|
|
326
|
+
this.data = JSON.parse(item);
|
|
306
327
|
}
|
|
307
328
|
catch (error) {
|
|
308
329
|
console.error("Cannot load client settings.", error);
|
|
309
330
|
}
|
|
310
331
|
}
|
|
311
|
-
resetToDefaults(fields) {
|
|
312
|
-
|
|
313
|
-
if (fields !== undefined) {
|
|
332
|
+
resetToDefaults(fields, defaults = this._defaults) {
|
|
333
|
+
if (Array.isArray(fields)) {
|
|
314
334
|
const resetData = {};
|
|
315
335
|
for (const field of fields) {
|
|
316
336
|
if (field in defaults)
|
|
@@ -322,34 +342,41 @@
|
|
|
322
342
|
this.data = defaults;
|
|
323
343
|
}
|
|
324
344
|
}
|
|
325
|
-
setProperty(key, value =
|
|
345
|
+
setProperty(key, value = this._defaults[key], accept = this.isValidValue(key, value)) {
|
|
346
|
+
if (!accept) {
|
|
347
|
+
console.warn(`Options.${key}: Invalid value`, value);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
326
350
|
if (this._data[key] !== value) {
|
|
327
351
|
this._data[key] = value;
|
|
328
352
|
this.change();
|
|
329
353
|
}
|
|
330
354
|
}
|
|
355
|
+
isValidValue(key, value) {
|
|
356
|
+
return typeof value === typeof this._defaults[key];
|
|
357
|
+
}
|
|
331
358
|
get data() {
|
|
332
359
|
return this._data;
|
|
333
360
|
}
|
|
334
361
|
set data(value) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
362
|
+
this.beginUpdate();
|
|
363
|
+
try {
|
|
364
|
+
for (const key of Object.keys(value)) {
|
|
365
|
+
if (key in this._defaults)
|
|
366
|
+
this[key] = value[key];
|
|
367
|
+
else
|
|
368
|
+
this._data[key] = value[key];
|
|
369
|
+
}
|
|
370
|
+
if ("enablePartialMode" in value) {
|
|
371
|
+
this.enablePartialMode = value.enablePartialMode;
|
|
372
|
+
}
|
|
373
|
+
if ("sectionFillColor" in value) {
|
|
374
|
+
this.sectionFillColor = value.sectionFillColor;
|
|
375
|
+
}
|
|
340
376
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
this._data.enableStreamingMode = true;
|
|
344
|
-
this._data.sceneGraph = false;
|
|
377
|
+
finally {
|
|
378
|
+
this.endUpdate();
|
|
345
379
|
}
|
|
346
|
-
if (!value.sectionFillColor && value.cuttingPlaneFillColor)
|
|
347
|
-
this._data.sectionFillColor = {
|
|
348
|
-
r: value.cuttingPlaneFillColor.red,
|
|
349
|
-
g: value.cuttingPlaneFillColor.green,
|
|
350
|
-
b: value.cuttingPlaneFillColor.blue,
|
|
351
|
-
};
|
|
352
|
-
this.change();
|
|
353
380
|
}
|
|
354
381
|
get showWCS() {
|
|
355
382
|
return this._data.showWCS;
|
|
@@ -367,7 +394,7 @@
|
|
|
367
394
|
return this._data.antialiasing;
|
|
368
395
|
}
|
|
369
396
|
set antialiasing(value) {
|
|
370
|
-
this.setProperty("antialiasing", value);
|
|
397
|
+
this.setProperty("antialiasing", value, typeof value === "boolean" || typeof value === "string");
|
|
371
398
|
}
|
|
372
399
|
get groundShadow() {
|
|
373
400
|
return this._data.groundShadow;
|
|
@@ -403,19 +430,27 @@
|
|
|
403
430
|
return this._data.enableStreamingMode;
|
|
404
431
|
}
|
|
405
432
|
set enableStreamingMode(value) {
|
|
406
|
-
this.
|
|
407
|
-
|
|
408
|
-
this.setProperty("
|
|
433
|
+
this.beginUpdate();
|
|
434
|
+
try {
|
|
435
|
+
this.setProperty("enableStreamingMode", value);
|
|
436
|
+
this.setProperty("enablePartialMode", this.enablePartialMode && this.enableStreamingMode);
|
|
437
|
+
}
|
|
438
|
+
finally {
|
|
439
|
+
this.endUpdate();
|
|
409
440
|
}
|
|
410
441
|
}
|
|
411
442
|
get enablePartialMode() {
|
|
412
443
|
return this._data.enablePartialMode;
|
|
413
444
|
}
|
|
414
445
|
set enablePartialMode(value) {
|
|
415
|
-
this.
|
|
416
|
-
|
|
417
|
-
this.setProperty("
|
|
418
|
-
this.setProperty("
|
|
446
|
+
this.beginUpdate();
|
|
447
|
+
try {
|
|
448
|
+
this.setProperty("enablePartialMode", value);
|
|
449
|
+
this.setProperty("enableStreamingMode", this.enableStreamingMode || this.enablePartialMode);
|
|
450
|
+
this.setProperty("sceneGraph", this.sceneGraph && !this.enablePartialMode);
|
|
451
|
+
}
|
|
452
|
+
finally {
|
|
453
|
+
this.endUpdate();
|
|
419
454
|
}
|
|
420
455
|
}
|
|
421
456
|
get memoryLimit() {
|
|
@@ -425,20 +460,24 @@
|
|
|
425
460
|
this.setProperty("memoryLimit", value);
|
|
426
461
|
}
|
|
427
462
|
get cuttingPlaneFillColor() {
|
|
428
|
-
|
|
429
|
-
return {
|
|
430
|
-
red: this._data.sectionFillColor.r,
|
|
431
|
-
green: this._data.sectionFillColor.g,
|
|
432
|
-
blue: this._data.sectionFillColor.b,
|
|
433
|
-
};
|
|
463
|
+
return this._data.cuttingPlaneFillColor;
|
|
434
464
|
}
|
|
435
465
|
set cuttingPlaneFillColor(value) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
466
|
+
if (this._updateCount === 0) {
|
|
467
|
+
console.warn("Options.cuttingPlaneFillColor has been deprecated since 27.5 and will be removed in a future release, use sectionFillColor instead");
|
|
468
|
+
}
|
|
469
|
+
this.beginUpdate();
|
|
470
|
+
try {
|
|
471
|
+
this.setProperty("cuttingPlaneFillColor", value, isLegacyRGB(value));
|
|
472
|
+
this.setProperty("sectionFillColor", {
|
|
473
|
+
r: this._data.cuttingPlaneFillColor.red,
|
|
474
|
+
g: this._data.cuttingPlaneFillColor.green,
|
|
475
|
+
b: this._data.cuttingPlaneFillColor.blue,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
finally {
|
|
479
|
+
this.endUpdate();
|
|
480
|
+
}
|
|
442
481
|
}
|
|
443
482
|
get enableSectionFill() {
|
|
444
483
|
return this._data.enableSectionFill;
|
|
@@ -450,7 +489,18 @@
|
|
|
450
489
|
return this._data.sectionFillColor;
|
|
451
490
|
}
|
|
452
491
|
set sectionFillColor(value) {
|
|
453
|
-
this.
|
|
492
|
+
this.beginUpdate();
|
|
493
|
+
try {
|
|
494
|
+
this.setProperty("sectionFillColor", value, isColorRGB(value));
|
|
495
|
+
this.setProperty("cuttingPlaneFillColor", {
|
|
496
|
+
red: this._data.sectionFillColor.r,
|
|
497
|
+
green: this._data.sectionFillColor.g,
|
|
498
|
+
blue: this._data.sectionFillColor.b,
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
finally {
|
|
502
|
+
this.endUpdate();
|
|
503
|
+
}
|
|
454
504
|
}
|
|
455
505
|
get sectionUseObjectColor() {
|
|
456
506
|
return this._data.sectionUseObjectColor;
|
|
@@ -468,7 +518,7 @@
|
|
|
468
518
|
return this._data.sectionHatchColor;
|
|
469
519
|
}
|
|
470
520
|
set sectionHatchColor(value) {
|
|
471
|
-
this.setProperty("sectionHatchColor", value);
|
|
521
|
+
this.setProperty("sectionHatchColor", value, isColorRGB(value));
|
|
472
522
|
}
|
|
473
523
|
get sectionHatchScale() {
|
|
474
524
|
return this._data.sectionHatchScale;
|
|
@@ -486,7 +536,7 @@
|
|
|
486
536
|
return this._data.sectionOutlineColor;
|
|
487
537
|
}
|
|
488
538
|
set sectionOutlineColor(value) {
|
|
489
|
-
this.setProperty("sectionOutlineColor", value);
|
|
539
|
+
this.setProperty("sectionOutlineColor", value, isColorRGB(value));
|
|
490
540
|
}
|
|
491
541
|
get sectionOutlineWidth() {
|
|
492
542
|
return this._data.sectionOutlineWidth;
|
|
@@ -498,13 +548,13 @@
|
|
|
498
548
|
return this._data.edgesColor;
|
|
499
549
|
}
|
|
500
550
|
set edgesColor(value) {
|
|
501
|
-
this.setProperty("edgesColor", value);
|
|
551
|
+
this.setProperty("edgesColor", value, isColorRGB(value));
|
|
502
552
|
}
|
|
503
553
|
get facesColor() {
|
|
504
554
|
return this._data.facesColor;
|
|
505
555
|
}
|
|
506
556
|
set facesColor(value) {
|
|
507
|
-
this.setProperty("facesColor", value);
|
|
557
|
+
this.setProperty("facesColor", value, isColorRGB(value));
|
|
508
558
|
}
|
|
509
559
|
get edgesVisibility() {
|
|
510
560
|
return this._data.edgesVisibility;
|
|
@@ -540,9 +590,13 @@
|
|
|
540
590
|
return this._data.sceneGraph;
|
|
541
591
|
}
|
|
542
592
|
set sceneGraph(value) {
|
|
543
|
-
this.
|
|
544
|
-
|
|
545
|
-
this.setProperty("
|
|
593
|
+
this.beginUpdate();
|
|
594
|
+
try {
|
|
595
|
+
this.setProperty("sceneGraph", value);
|
|
596
|
+
this.setProperty("enablePartialMode", this.enablePartialMode && !this.sceneGraph);
|
|
597
|
+
}
|
|
598
|
+
finally {
|
|
599
|
+
this.endUpdate();
|
|
546
600
|
}
|
|
547
601
|
}
|
|
548
602
|
get edgeModel() {
|
|
@@ -585,13 +639,13 @@
|
|
|
585
639
|
return this._data.rulerPrecision;
|
|
586
640
|
}
|
|
587
641
|
set rulerPrecision(value) {
|
|
588
|
-
this.setProperty("rulerPrecision", value);
|
|
642
|
+
this.setProperty("rulerPrecision", value, typeof value === "number" || value === "Default" || value === "Auto");
|
|
589
643
|
}
|
|
590
644
|
get cameraMode() {
|
|
591
|
-
return this._data.cameraMode
|
|
645
|
+
return this._data.cameraMode;
|
|
592
646
|
}
|
|
593
647
|
set cameraMode(value) {
|
|
594
|
-
this.setProperty("cameraMode", value);
|
|
648
|
+
this.setProperty("cameraMode", value, value === "perspective" || value === "orthographic");
|
|
595
649
|
}
|
|
596
650
|
get snapshotMimeType() {
|
|
597
651
|
return this._data.snapshotMimeType;
|