@inweb/viewer-core 27.6.0 → 27.6.1
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 +80 -56
- package/dist/viewer-core.js.map +1 -1
- package/dist/viewer-core.module.js +80 -56
- 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 +108 -64
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;
|
|
@@ -404,19 +431,15 @@
|
|
|
404
431
|
}
|
|
405
432
|
set enableStreamingMode(value) {
|
|
406
433
|
this.setProperty("enableStreamingMode", value);
|
|
407
|
-
|
|
408
|
-
this.setProperty("enablePartialMode", false);
|
|
409
|
-
}
|
|
434
|
+
this.setProperty("enablePartialMode", this.enablePartialMode && this.enableStreamingMode);
|
|
410
435
|
}
|
|
411
436
|
get enablePartialMode() {
|
|
412
437
|
return this._data.enablePartialMode;
|
|
413
438
|
}
|
|
414
439
|
set enablePartialMode(value) {
|
|
415
440
|
this.setProperty("enablePartialMode", value);
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
this.setProperty("sceneGraph", false);
|
|
419
|
-
}
|
|
441
|
+
this.setProperty("enableStreamingMode", this.enableStreamingMode || this.enablePartialMode);
|
|
442
|
+
this.setProperty("sceneGraph", this.sceneGraph && !this.enablePartialMode);
|
|
420
443
|
}
|
|
421
444
|
get memoryLimit() {
|
|
422
445
|
return this._data.memoryLimit;
|
|
@@ -425,20 +448,18 @@
|
|
|
425
448
|
this.setProperty("memoryLimit", value);
|
|
426
449
|
}
|
|
427
450
|
get cuttingPlaneFillColor() {
|
|
428
|
-
|
|
429
|
-
return {
|
|
430
|
-
red: this._data.sectionFillColor.r,
|
|
431
|
-
green: this._data.sectionFillColor.g,
|
|
432
|
-
blue: this._data.sectionFillColor.b,
|
|
433
|
-
};
|
|
451
|
+
return this._data.cuttingPlaneFillColor;
|
|
434
452
|
}
|
|
435
453
|
set cuttingPlaneFillColor(value) {
|
|
436
|
-
|
|
454
|
+
if (this._updateCount === 0) {
|
|
455
|
+
console.warn("Options.cuttingPlaneFillColor has been deprecated since 27.5 and will be removed in a future release, use sectionFillColor instead");
|
|
456
|
+
}
|
|
457
|
+
this.setProperty("cuttingPlaneFillColor", value, isLegacyRGB(value));
|
|
437
458
|
this.setProperty("sectionFillColor", {
|
|
438
|
-
r:
|
|
439
|
-
g:
|
|
440
|
-
b:
|
|
441
|
-
});
|
|
459
|
+
r: this._data.cuttingPlaneFillColor.red,
|
|
460
|
+
g: this._data.cuttingPlaneFillColor.green,
|
|
461
|
+
b: this._data.cuttingPlaneFillColor.blue,
|
|
462
|
+
}, true);
|
|
442
463
|
}
|
|
443
464
|
get enableSectionFill() {
|
|
444
465
|
return this._data.enableSectionFill;
|
|
@@ -450,7 +471,12 @@
|
|
|
450
471
|
return this._data.sectionFillColor;
|
|
451
472
|
}
|
|
452
473
|
set sectionFillColor(value) {
|
|
453
|
-
this.setProperty("sectionFillColor", value);
|
|
474
|
+
this.setProperty("sectionFillColor", value, isColorRGB(value));
|
|
475
|
+
this.setProperty("cuttingPlaneFillColor", {
|
|
476
|
+
red: this._data.sectionFillColor.r,
|
|
477
|
+
green: this._data.sectionFillColor.g,
|
|
478
|
+
blue: this._data.sectionFillColor.b,
|
|
479
|
+
}, true);
|
|
454
480
|
}
|
|
455
481
|
get sectionUseObjectColor() {
|
|
456
482
|
return this._data.sectionUseObjectColor;
|
|
@@ -468,7 +494,7 @@
|
|
|
468
494
|
return this._data.sectionHatchColor;
|
|
469
495
|
}
|
|
470
496
|
set sectionHatchColor(value) {
|
|
471
|
-
this.setProperty("sectionHatchColor", value);
|
|
497
|
+
this.setProperty("sectionHatchColor", value, isColorRGB(value));
|
|
472
498
|
}
|
|
473
499
|
get sectionHatchScale() {
|
|
474
500
|
return this._data.sectionHatchScale;
|
|
@@ -486,7 +512,7 @@
|
|
|
486
512
|
return this._data.sectionOutlineColor;
|
|
487
513
|
}
|
|
488
514
|
set sectionOutlineColor(value) {
|
|
489
|
-
this.setProperty("sectionOutlineColor", value);
|
|
515
|
+
this.setProperty("sectionOutlineColor", value, isColorRGB(value));
|
|
490
516
|
}
|
|
491
517
|
get sectionOutlineWidth() {
|
|
492
518
|
return this._data.sectionOutlineWidth;
|
|
@@ -498,13 +524,13 @@
|
|
|
498
524
|
return this._data.edgesColor;
|
|
499
525
|
}
|
|
500
526
|
set edgesColor(value) {
|
|
501
|
-
this.setProperty("edgesColor", value);
|
|
527
|
+
this.setProperty("edgesColor", value, isColorRGB(value));
|
|
502
528
|
}
|
|
503
529
|
get facesColor() {
|
|
504
530
|
return this._data.facesColor;
|
|
505
531
|
}
|
|
506
532
|
set facesColor(value) {
|
|
507
|
-
this.setProperty("facesColor", value);
|
|
533
|
+
this.setProperty("facesColor", value, isColorRGB(value));
|
|
508
534
|
}
|
|
509
535
|
get edgesVisibility() {
|
|
510
536
|
return this._data.edgesVisibility;
|
|
@@ -541,9 +567,7 @@
|
|
|
541
567
|
}
|
|
542
568
|
set sceneGraph(value) {
|
|
543
569
|
this.setProperty("sceneGraph", value);
|
|
544
|
-
|
|
545
|
-
this.setProperty("enablePartialMode", false);
|
|
546
|
-
}
|
|
570
|
+
this.setProperty("enablePartialMode", this.enablePartialMode && !this.sceneGraph);
|
|
547
571
|
}
|
|
548
572
|
get edgeModel() {
|
|
549
573
|
return Boolean(this._data.edgeModel);
|
|
@@ -585,13 +609,13 @@
|
|
|
585
609
|
return this._data.rulerPrecision;
|
|
586
610
|
}
|
|
587
611
|
set rulerPrecision(value) {
|
|
588
|
-
this.setProperty("rulerPrecision", value);
|
|
612
|
+
this.setProperty("rulerPrecision", value, typeof value === "number" || value === "Default" || value === "Auto");
|
|
589
613
|
}
|
|
590
614
|
get cameraMode() {
|
|
591
|
-
return this._data.cameraMode
|
|
615
|
+
return this._data.cameraMode;
|
|
592
616
|
}
|
|
593
617
|
set cameraMode(value) {
|
|
594
|
-
this.setProperty("cameraMode", value);
|
|
618
|
+
this.setProperty("cameraMode", value, value === "perspective" || value === "orthographic");
|
|
595
619
|
}
|
|
596
620
|
get snapshotMimeType() {
|
|
597
621
|
return this._data.snapshotMimeType;
|