@inweb/viewer-three 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-three.js +113 -59
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +4 -4
- package/package.json +5 -5
package/dist/viewer-three.js
CHANGED
|
@@ -263,21 +263,44 @@
|
|
|
263
263
|
snapshotQuality: 0.25,
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
|
+
function isColorRGB(value) {
|
|
267
|
+
return (typeof value === "object" &&
|
|
268
|
+
value !== null &&
|
|
269
|
+
typeof value.r === "number" &&
|
|
270
|
+
typeof value.g === "number" &&
|
|
271
|
+
typeof value.b === "number");
|
|
272
|
+
}
|
|
273
|
+
function isLegacyRGB(value) {
|
|
274
|
+
return (typeof value === "object" &&
|
|
275
|
+
value !== null &&
|
|
276
|
+
typeof value.red === "number" &&
|
|
277
|
+
typeof value.green === "number" &&
|
|
278
|
+
typeof value.blue === "number");
|
|
279
|
+
}
|
|
266
280
|
class Options {
|
|
267
281
|
constructor(emitter) {
|
|
282
|
+
this._updateCount = 0;
|
|
268
283
|
this._emitter = emitter;
|
|
269
|
-
this._data =
|
|
284
|
+
this._data = Options.defaults();
|
|
285
|
+
this._defaults = Options.defaults();
|
|
270
286
|
this.loadFromStorage();
|
|
271
287
|
}
|
|
272
288
|
static defaults() {
|
|
273
289
|
return defaultOptions();
|
|
274
290
|
}
|
|
275
291
|
change() {
|
|
276
|
-
if (this._emitter !== undefined) {
|
|
292
|
+
if (this._emitter !== undefined && this._updateCount === 0) {
|
|
277
293
|
this.saveToStorage();
|
|
278
294
|
this._emitter.emit({ type: "optionschange", data: this });
|
|
279
295
|
}
|
|
280
296
|
}
|
|
297
|
+
beginUpdate() {
|
|
298
|
+
this._updateCount++;
|
|
299
|
+
}
|
|
300
|
+
endUpdate() {
|
|
301
|
+
this._updateCount--;
|
|
302
|
+
this.change();
|
|
303
|
+
}
|
|
281
304
|
saveToStorage() {
|
|
282
305
|
if (typeof window !== "undefined")
|
|
283
306
|
try {
|
|
@@ -291,18 +314,15 @@
|
|
|
291
314
|
if (typeof window !== "undefined")
|
|
292
315
|
try {
|
|
293
316
|
const item = localStorage.getItem("od-client-settings");
|
|
294
|
-
if (item)
|
|
295
|
-
|
|
296
|
-
this.data = { ...data };
|
|
297
|
-
}
|
|
317
|
+
if (item)
|
|
318
|
+
this.data = JSON.parse(item);
|
|
298
319
|
}
|
|
299
320
|
catch (error) {
|
|
300
321
|
console.error("Cannot load client settings.", error);
|
|
301
322
|
}
|
|
302
323
|
}
|
|
303
|
-
resetToDefaults(fields) {
|
|
304
|
-
|
|
305
|
-
if (fields !== undefined) {
|
|
324
|
+
resetToDefaults(fields, defaults = this._defaults) {
|
|
325
|
+
if (Array.isArray(fields)) {
|
|
306
326
|
const resetData = {};
|
|
307
327
|
for (const field of fields) {
|
|
308
328
|
if (field in defaults)
|
|
@@ -314,34 +334,41 @@
|
|
|
314
334
|
this.data = defaults;
|
|
315
335
|
}
|
|
316
336
|
}
|
|
317
|
-
setProperty(key, value =
|
|
337
|
+
setProperty(key, value = this._defaults[key], accept = this.isValidValue(key, value)) {
|
|
338
|
+
if (!accept) {
|
|
339
|
+
console.warn(`Options.${key}: Invalid value`, value);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
318
342
|
if (this._data[key] !== value) {
|
|
319
343
|
this._data[key] = value;
|
|
320
344
|
this.change();
|
|
321
345
|
}
|
|
322
346
|
}
|
|
347
|
+
isValidValue(key, value) {
|
|
348
|
+
return typeof value === typeof this._defaults[key];
|
|
349
|
+
}
|
|
323
350
|
get data() {
|
|
324
351
|
return this._data;
|
|
325
352
|
}
|
|
326
353
|
set data(value) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
354
|
+
this.beginUpdate();
|
|
355
|
+
try {
|
|
356
|
+
for (const key of Object.keys(value)) {
|
|
357
|
+
if (key in this._defaults)
|
|
358
|
+
this[key] = value[key];
|
|
359
|
+
else
|
|
360
|
+
this._data[key] = value[key];
|
|
361
|
+
}
|
|
362
|
+
if ("enablePartialMode" in value) {
|
|
363
|
+
this.enablePartialMode = value.enablePartialMode;
|
|
364
|
+
}
|
|
365
|
+
if ("sectionFillColor" in value) {
|
|
366
|
+
this.sectionFillColor = value.sectionFillColor;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
finally {
|
|
370
|
+
this.endUpdate();
|
|
371
|
+
}
|
|
345
372
|
}
|
|
346
373
|
get showWCS() {
|
|
347
374
|
return this._data.showWCS;
|
|
@@ -359,7 +386,7 @@
|
|
|
359
386
|
return this._data.antialiasing;
|
|
360
387
|
}
|
|
361
388
|
set antialiasing(value) {
|
|
362
|
-
this.setProperty("antialiasing", value);
|
|
389
|
+
this.setProperty("antialiasing", value, typeof value === "boolean" || typeof value === "string");
|
|
363
390
|
}
|
|
364
391
|
get groundShadow() {
|
|
365
392
|
return this._data.groundShadow;
|
|
@@ -395,19 +422,27 @@
|
|
|
395
422
|
return this._data.enableStreamingMode;
|
|
396
423
|
}
|
|
397
424
|
set enableStreamingMode(value) {
|
|
398
|
-
this.
|
|
399
|
-
|
|
400
|
-
this.setProperty("
|
|
425
|
+
this.beginUpdate();
|
|
426
|
+
try {
|
|
427
|
+
this.setProperty("enableStreamingMode", value);
|
|
428
|
+
this.setProperty("enablePartialMode", this.enablePartialMode && this.enableStreamingMode);
|
|
429
|
+
}
|
|
430
|
+
finally {
|
|
431
|
+
this.endUpdate();
|
|
401
432
|
}
|
|
402
433
|
}
|
|
403
434
|
get enablePartialMode() {
|
|
404
435
|
return this._data.enablePartialMode;
|
|
405
436
|
}
|
|
406
437
|
set enablePartialMode(value) {
|
|
407
|
-
this.
|
|
408
|
-
|
|
409
|
-
this.setProperty("
|
|
410
|
-
this.setProperty("
|
|
438
|
+
this.beginUpdate();
|
|
439
|
+
try {
|
|
440
|
+
this.setProperty("enablePartialMode", value);
|
|
441
|
+
this.setProperty("enableStreamingMode", this.enableStreamingMode || this.enablePartialMode);
|
|
442
|
+
this.setProperty("sceneGraph", this.sceneGraph && !this.enablePartialMode);
|
|
443
|
+
}
|
|
444
|
+
finally {
|
|
445
|
+
this.endUpdate();
|
|
411
446
|
}
|
|
412
447
|
}
|
|
413
448
|
get memoryLimit() {
|
|
@@ -417,20 +452,24 @@
|
|
|
417
452
|
this.setProperty("memoryLimit", value);
|
|
418
453
|
}
|
|
419
454
|
get cuttingPlaneFillColor() {
|
|
420
|
-
|
|
421
|
-
return {
|
|
422
|
-
red: this._data.sectionFillColor.r,
|
|
423
|
-
green: this._data.sectionFillColor.g,
|
|
424
|
-
blue: this._data.sectionFillColor.b,
|
|
425
|
-
};
|
|
455
|
+
return this._data.cuttingPlaneFillColor;
|
|
426
456
|
}
|
|
427
457
|
set cuttingPlaneFillColor(value) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
458
|
+
if (this._updateCount === 0) {
|
|
459
|
+
console.warn("Options.cuttingPlaneFillColor has been deprecated since 27.5 and will be removed in a future release, use sectionFillColor instead");
|
|
460
|
+
}
|
|
461
|
+
this.beginUpdate();
|
|
462
|
+
try {
|
|
463
|
+
this.setProperty("cuttingPlaneFillColor", value, isLegacyRGB(value));
|
|
464
|
+
this.setProperty("sectionFillColor", {
|
|
465
|
+
r: this._data.cuttingPlaneFillColor.red,
|
|
466
|
+
g: this._data.cuttingPlaneFillColor.green,
|
|
467
|
+
b: this._data.cuttingPlaneFillColor.blue,
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
finally {
|
|
471
|
+
this.endUpdate();
|
|
472
|
+
}
|
|
434
473
|
}
|
|
435
474
|
get enableSectionFill() {
|
|
436
475
|
return this._data.enableSectionFill;
|
|
@@ -442,7 +481,18 @@
|
|
|
442
481
|
return this._data.sectionFillColor;
|
|
443
482
|
}
|
|
444
483
|
set sectionFillColor(value) {
|
|
445
|
-
this.
|
|
484
|
+
this.beginUpdate();
|
|
485
|
+
try {
|
|
486
|
+
this.setProperty("sectionFillColor", value, isColorRGB(value));
|
|
487
|
+
this.setProperty("cuttingPlaneFillColor", {
|
|
488
|
+
red: this._data.sectionFillColor.r,
|
|
489
|
+
green: this._data.sectionFillColor.g,
|
|
490
|
+
blue: this._data.sectionFillColor.b,
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
finally {
|
|
494
|
+
this.endUpdate();
|
|
495
|
+
}
|
|
446
496
|
}
|
|
447
497
|
get sectionUseObjectColor() {
|
|
448
498
|
return this._data.sectionUseObjectColor;
|
|
@@ -460,7 +510,7 @@
|
|
|
460
510
|
return this._data.sectionHatchColor;
|
|
461
511
|
}
|
|
462
512
|
set sectionHatchColor(value) {
|
|
463
|
-
this.setProperty("sectionHatchColor", value);
|
|
513
|
+
this.setProperty("sectionHatchColor", value, isColorRGB(value));
|
|
464
514
|
}
|
|
465
515
|
get sectionHatchScale() {
|
|
466
516
|
return this._data.sectionHatchScale;
|
|
@@ -478,7 +528,7 @@
|
|
|
478
528
|
return this._data.sectionOutlineColor;
|
|
479
529
|
}
|
|
480
530
|
set sectionOutlineColor(value) {
|
|
481
|
-
this.setProperty("sectionOutlineColor", value);
|
|
531
|
+
this.setProperty("sectionOutlineColor", value, isColorRGB(value));
|
|
482
532
|
}
|
|
483
533
|
get sectionOutlineWidth() {
|
|
484
534
|
return this._data.sectionOutlineWidth;
|
|
@@ -490,13 +540,13 @@
|
|
|
490
540
|
return this._data.edgesColor;
|
|
491
541
|
}
|
|
492
542
|
set edgesColor(value) {
|
|
493
|
-
this.setProperty("edgesColor", value);
|
|
543
|
+
this.setProperty("edgesColor", value, isColorRGB(value));
|
|
494
544
|
}
|
|
495
545
|
get facesColor() {
|
|
496
546
|
return this._data.facesColor;
|
|
497
547
|
}
|
|
498
548
|
set facesColor(value) {
|
|
499
|
-
this.setProperty("facesColor", value);
|
|
549
|
+
this.setProperty("facesColor", value, isColorRGB(value));
|
|
500
550
|
}
|
|
501
551
|
get edgesVisibility() {
|
|
502
552
|
return this._data.edgesVisibility;
|
|
@@ -532,9 +582,13 @@
|
|
|
532
582
|
return this._data.sceneGraph;
|
|
533
583
|
}
|
|
534
584
|
set sceneGraph(value) {
|
|
535
|
-
this.
|
|
536
|
-
|
|
537
|
-
this.setProperty("
|
|
585
|
+
this.beginUpdate();
|
|
586
|
+
try {
|
|
587
|
+
this.setProperty("sceneGraph", value);
|
|
588
|
+
this.setProperty("enablePartialMode", this.enablePartialMode && !this.sceneGraph);
|
|
589
|
+
}
|
|
590
|
+
finally {
|
|
591
|
+
this.endUpdate();
|
|
538
592
|
}
|
|
539
593
|
}
|
|
540
594
|
get edgeModel() {
|
|
@@ -577,13 +631,13 @@
|
|
|
577
631
|
return this._data.rulerPrecision;
|
|
578
632
|
}
|
|
579
633
|
set rulerPrecision(value) {
|
|
580
|
-
this.setProperty("rulerPrecision", value);
|
|
634
|
+
this.setProperty("rulerPrecision", value, typeof value === "number" || value === "Default" || value === "Auto");
|
|
581
635
|
}
|
|
582
636
|
get cameraMode() {
|
|
583
|
-
return this._data.cameraMode
|
|
637
|
+
return this._data.cameraMode;
|
|
584
638
|
}
|
|
585
639
|
set cameraMode(value) {
|
|
586
|
-
this.setProperty("cameraMode", value);
|
|
640
|
+
this.setProperty("cameraMode", value, value === "perspective" || value === "orthographic");
|
|
587
641
|
}
|
|
588
642
|
get snapshotMimeType() {
|
|
589
643
|
return this._data.snapshotMimeType;
|