@inweb/viewer-core 27.5.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 +138 -125
- package/dist/viewer-core.js.map +1 -1
- package/dist/viewer-core.module.js +138 -125
- package/dist/viewer-core.module.js.map +1 -1
- package/lib/options/IOptions.d.ts +39 -45
- package/lib/options/Options.d.ts +17 -7
- package/package.json +3 -3
- package/src/loaders/Loader.ts +4 -5
- package/src/loaders/Loaders.ts +1 -1
- package/src/options/IOptions.ts +39 -46
- package/src/options/Options.ts +198 -157
|
@@ -158,8 +158,7 @@ class Loader {
|
|
|
158
158
|
this.abortController = new AbortController();
|
|
159
159
|
}
|
|
160
160
|
dispose() {
|
|
161
|
-
this.
|
|
162
|
-
this.abortController = undefined;
|
|
161
|
+
this.cancel();
|
|
163
162
|
}
|
|
164
163
|
isSupport(file, format) {
|
|
165
164
|
return false;
|
|
@@ -178,10 +177,10 @@ class Loader {
|
|
|
178
177
|
extractFileName(file) {
|
|
179
178
|
const regex = /[^/\\?#:]+(?=\?|#|$)/;
|
|
180
179
|
if (typeof file === "string")
|
|
181
|
-
return (file.match(regex) || [])[0];
|
|
180
|
+
return (file.match(regex) || [])[0] || "";
|
|
182
181
|
else if (file instanceof globalThis.File)
|
|
183
|
-
return (file.name.match(regex) || [])[0];
|
|
184
|
-
return
|
|
182
|
+
return (file.name.match(regex) || [])[0] || "";
|
|
183
|
+
return "";
|
|
185
184
|
}
|
|
186
185
|
}
|
|
187
186
|
|
|
@@ -266,21 +265,44 @@ function defaultOptions() {
|
|
|
266
265
|
};
|
|
267
266
|
}
|
|
268
267
|
|
|
268
|
+
function isColorRGB(value) {
|
|
269
|
+
return (typeof value === "object" &&
|
|
270
|
+
value !== null &&
|
|
271
|
+
typeof value.r === "number" &&
|
|
272
|
+
typeof value.g === "number" &&
|
|
273
|
+
typeof value.b === "number");
|
|
274
|
+
}
|
|
275
|
+
function isLegacyRGB(value) {
|
|
276
|
+
return (typeof value === "object" &&
|
|
277
|
+
value !== null &&
|
|
278
|
+
typeof value.red === "number" &&
|
|
279
|
+
typeof value.green === "number" &&
|
|
280
|
+
typeof value.blue === "number");
|
|
281
|
+
}
|
|
269
282
|
class Options {
|
|
270
283
|
constructor(emitter) {
|
|
284
|
+
this._updateCount = 0;
|
|
271
285
|
this._emitter = emitter;
|
|
272
|
-
this._data =
|
|
286
|
+
this._data = Options.defaults();
|
|
287
|
+
this._defaults = Options.defaults();
|
|
273
288
|
this.loadFromStorage();
|
|
274
289
|
}
|
|
275
290
|
static defaults() {
|
|
276
291
|
return defaultOptions();
|
|
277
292
|
}
|
|
278
293
|
change() {
|
|
279
|
-
if (this._emitter !== undefined) {
|
|
294
|
+
if (this._emitter !== undefined && this._updateCount === 0) {
|
|
280
295
|
this.saveToStorage();
|
|
281
296
|
this._emitter.emit({ type: "optionschange", data: this });
|
|
282
297
|
}
|
|
283
298
|
}
|
|
299
|
+
beginUpdate() {
|
|
300
|
+
this._updateCount++;
|
|
301
|
+
}
|
|
302
|
+
endUpdate() {
|
|
303
|
+
this._updateCount--;
|
|
304
|
+
this.change();
|
|
305
|
+
}
|
|
284
306
|
saveToStorage() {
|
|
285
307
|
if (typeof window !== "undefined")
|
|
286
308
|
try {
|
|
@@ -294,321 +316,312 @@ class Options {
|
|
|
294
316
|
if (typeof window !== "undefined")
|
|
295
317
|
try {
|
|
296
318
|
const item = localStorage.getItem("od-client-settings");
|
|
297
|
-
if (item)
|
|
298
|
-
|
|
299
|
-
this.data = { ...data };
|
|
300
|
-
}
|
|
319
|
+
if (item)
|
|
320
|
+
this.data = JSON.parse(item);
|
|
301
321
|
}
|
|
302
322
|
catch (error) {
|
|
303
323
|
console.error("Cannot load client settings.", error);
|
|
304
324
|
}
|
|
305
325
|
}
|
|
306
|
-
resetToDefaults(fields) {
|
|
307
|
-
if (fields
|
|
308
|
-
const
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
this.data =
|
|
326
|
+
resetToDefaults(fields, defaults = this._defaults) {
|
|
327
|
+
if (Array.isArray(fields)) {
|
|
328
|
+
const resetData = {};
|
|
329
|
+
for (const field of fields) {
|
|
330
|
+
if (field in defaults)
|
|
331
|
+
resetData[field] = defaults[field];
|
|
332
|
+
}
|
|
333
|
+
this.data = resetData;
|
|
314
334
|
}
|
|
315
335
|
else {
|
|
316
|
-
this.data =
|
|
336
|
+
this.data = defaults;
|
|
317
337
|
}
|
|
318
338
|
}
|
|
339
|
+
setProperty(key, value = this._defaults[key], accept = this.isValidValue(key, value)) {
|
|
340
|
+
if (!accept) {
|
|
341
|
+
console.warn(`Options.${key}: Invalid value`, value);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (this._data[key] !== value) {
|
|
345
|
+
this._data[key] = value;
|
|
346
|
+
this.change();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
isValidValue(key, value) {
|
|
350
|
+
return typeof value === typeof this._defaults[key];
|
|
351
|
+
}
|
|
319
352
|
get data() {
|
|
320
353
|
return this._data;
|
|
321
354
|
}
|
|
322
355
|
set data(value) {
|
|
323
|
-
this.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
356
|
+
this.beginUpdate();
|
|
357
|
+
try {
|
|
358
|
+
for (const key of Object.keys(value)) {
|
|
359
|
+
if (key in this._defaults)
|
|
360
|
+
this[key] = value[key];
|
|
361
|
+
else
|
|
362
|
+
this._data[key] = value[key];
|
|
363
|
+
}
|
|
364
|
+
if ("enablePartialMode" in value) {
|
|
365
|
+
this.enablePartialMode = value.enablePartialMode;
|
|
366
|
+
}
|
|
367
|
+
if ("sectionFillColor" in value) {
|
|
368
|
+
this.sectionFillColor = value.sectionFillColor;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
finally {
|
|
372
|
+
this.endUpdate();
|
|
327
373
|
}
|
|
328
|
-
if (!value.sectionFillColor && value.cuttingPlaneFillColor)
|
|
329
|
-
this._data.sectionFillColor = {
|
|
330
|
-
r: value.cuttingPlaneFillColor.red,
|
|
331
|
-
g: value.cuttingPlaneFillColor.green,
|
|
332
|
-
b: value.cuttingPlaneFillColor.blue,
|
|
333
|
-
};
|
|
334
|
-
this.change();
|
|
335
374
|
}
|
|
336
375
|
get showWCS() {
|
|
337
376
|
return this._data.showWCS;
|
|
338
377
|
}
|
|
339
378
|
set showWCS(value) {
|
|
340
|
-
this.
|
|
341
|
-
this.change();
|
|
379
|
+
this.setProperty("showWCS", value);
|
|
342
380
|
}
|
|
343
381
|
get cameraAnimation() {
|
|
344
382
|
return this._data.cameraAnimation;
|
|
345
383
|
}
|
|
346
384
|
set cameraAnimation(value) {
|
|
347
|
-
this.
|
|
348
|
-
this.change();
|
|
385
|
+
this.setProperty("cameraAnimation", value);
|
|
349
386
|
}
|
|
350
387
|
get antialiasing() {
|
|
351
388
|
return this._data.antialiasing;
|
|
352
389
|
}
|
|
353
390
|
set antialiasing(value) {
|
|
354
|
-
this.
|
|
355
|
-
this.change();
|
|
391
|
+
this.setProperty("antialiasing", value, typeof value === "boolean" || typeof value === "string");
|
|
356
392
|
}
|
|
357
393
|
get groundShadow() {
|
|
358
394
|
return this._data.groundShadow;
|
|
359
395
|
}
|
|
360
396
|
set groundShadow(value) {
|
|
361
|
-
this.
|
|
362
|
-
this.change();
|
|
397
|
+
this.setProperty("groundShadow", value);
|
|
363
398
|
}
|
|
364
399
|
get shadows() {
|
|
365
400
|
return this._data.shadows;
|
|
366
401
|
}
|
|
367
402
|
set shadows(value) {
|
|
368
|
-
this.
|
|
369
|
-
this.change();
|
|
403
|
+
this.setProperty("shadows", value);
|
|
370
404
|
}
|
|
371
405
|
get cameraAxisXSpeed() {
|
|
372
406
|
return this._data.cameraAxisXSpeed;
|
|
373
407
|
}
|
|
374
408
|
set cameraAxisXSpeed(value) {
|
|
375
|
-
this.
|
|
376
|
-
this.change();
|
|
409
|
+
this.setProperty("cameraAxisXSpeed", value);
|
|
377
410
|
}
|
|
378
411
|
get cameraAxisYSpeed() {
|
|
379
412
|
return this._data.cameraAxisYSpeed;
|
|
380
413
|
}
|
|
381
414
|
set cameraAxisYSpeed(value) {
|
|
382
|
-
this.cameraAxisYSpeed
|
|
383
|
-
this.change();
|
|
415
|
+
this.setProperty("cameraAxisYSpeed", value);
|
|
384
416
|
}
|
|
385
417
|
get ambientOcclusion() {
|
|
386
418
|
return this._data.ambientOcclusion;
|
|
387
419
|
}
|
|
388
420
|
set ambientOcclusion(value) {
|
|
389
|
-
this.
|
|
390
|
-
this.change();
|
|
421
|
+
this.setProperty("ambientOcclusion", value);
|
|
391
422
|
}
|
|
392
423
|
get enableStreamingMode() {
|
|
393
424
|
return this._data.enableStreamingMode;
|
|
394
425
|
}
|
|
395
426
|
set enableStreamingMode(value) {
|
|
396
|
-
this.
|
|
397
|
-
|
|
398
|
-
this._data.enablePartialMode = false;
|
|
399
|
-
this.change();
|
|
427
|
+
this.setProperty("enableStreamingMode", value);
|
|
428
|
+
this.setProperty("enablePartialMode", this.enablePartialMode && this.enableStreamingMode);
|
|
400
429
|
}
|
|
401
430
|
get enablePartialMode() {
|
|
402
431
|
return this._data.enablePartialMode;
|
|
403
432
|
}
|
|
404
433
|
set enablePartialMode(value) {
|
|
405
|
-
this.
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
this._data.sceneGraph = false;
|
|
409
|
-
}
|
|
410
|
-
this.change();
|
|
434
|
+
this.setProperty("enablePartialMode", value);
|
|
435
|
+
this.setProperty("enableStreamingMode", this.enableStreamingMode || this.enablePartialMode);
|
|
436
|
+
this.setProperty("sceneGraph", this.sceneGraph && !this.enablePartialMode);
|
|
411
437
|
}
|
|
412
438
|
get memoryLimit() {
|
|
413
439
|
return this._data.memoryLimit;
|
|
414
440
|
}
|
|
415
441
|
set memoryLimit(value) {
|
|
416
|
-
this.
|
|
417
|
-
this.change();
|
|
442
|
+
this.setProperty("memoryLimit", value);
|
|
418
443
|
}
|
|
419
444
|
get cuttingPlaneFillColor() {
|
|
420
|
-
|
|
421
|
-
return {
|
|
422
|
-
red: this._data.sectionFillColor.r,
|
|
423
|
-
green: this._data.sectionFillColor.g,
|
|
424
|
-
blue: this._data.sectionFillColor.b,
|
|
425
|
-
};
|
|
445
|
+
return this._data.cuttingPlaneFillColor;
|
|
426
446
|
}
|
|
427
447
|
set cuttingPlaneFillColor(value) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
448
|
+
if (this._updateCount === 0) {
|
|
449
|
+
console.warn("Options.cuttingPlaneFillColor has been deprecated since 27.5 and will be removed in a future release, use sectionFillColor instead");
|
|
450
|
+
}
|
|
451
|
+
this.setProperty("cuttingPlaneFillColor", value, isLegacyRGB(value));
|
|
452
|
+
this.setProperty("sectionFillColor", {
|
|
453
|
+
r: this._data.cuttingPlaneFillColor.red,
|
|
454
|
+
g: this._data.cuttingPlaneFillColor.green,
|
|
455
|
+
b: this._data.cuttingPlaneFillColor.blue,
|
|
456
|
+
}, true);
|
|
435
457
|
}
|
|
436
458
|
get enableSectionFill() {
|
|
437
459
|
return this._data.enableSectionFill;
|
|
438
460
|
}
|
|
439
461
|
set enableSectionFill(value) {
|
|
440
|
-
this.
|
|
441
|
-
this.change();
|
|
462
|
+
this.setProperty("enableSectionFill", value);
|
|
442
463
|
}
|
|
443
464
|
get sectionFillColor() {
|
|
444
465
|
return this._data.sectionFillColor;
|
|
445
466
|
}
|
|
446
467
|
set sectionFillColor(value) {
|
|
447
|
-
this.
|
|
448
|
-
this.
|
|
468
|
+
this.setProperty("sectionFillColor", value, isColorRGB(value));
|
|
469
|
+
this.setProperty("cuttingPlaneFillColor", {
|
|
470
|
+
red: this._data.sectionFillColor.r,
|
|
471
|
+
green: this._data.sectionFillColor.g,
|
|
472
|
+
blue: this._data.sectionFillColor.b,
|
|
473
|
+
}, true);
|
|
449
474
|
}
|
|
450
475
|
get sectionUseObjectColor() {
|
|
451
476
|
return this._data.sectionUseObjectColor;
|
|
452
477
|
}
|
|
453
478
|
set sectionUseObjectColor(value) {
|
|
454
|
-
this.
|
|
455
|
-
this.change();
|
|
479
|
+
this.setProperty("sectionUseObjectColor", value);
|
|
456
480
|
}
|
|
457
481
|
get enableSectionHatch() {
|
|
458
482
|
return this._data.enableSectionHatch;
|
|
459
483
|
}
|
|
460
484
|
set enableSectionHatch(value) {
|
|
461
|
-
this.
|
|
462
|
-
this.change();
|
|
485
|
+
this.setProperty("enableSectionHatch", value);
|
|
463
486
|
}
|
|
464
487
|
get sectionHatchColor() {
|
|
465
488
|
return this._data.sectionHatchColor;
|
|
466
489
|
}
|
|
467
490
|
set sectionHatchColor(value) {
|
|
468
|
-
this.
|
|
469
|
-
this.change();
|
|
491
|
+
this.setProperty("sectionHatchColor", value, isColorRGB(value));
|
|
470
492
|
}
|
|
471
493
|
get sectionHatchScale() {
|
|
472
494
|
return this._data.sectionHatchScale;
|
|
473
495
|
}
|
|
474
496
|
set sectionHatchScale(value) {
|
|
475
|
-
this.
|
|
476
|
-
this.change();
|
|
497
|
+
this.setProperty("sectionHatchScale", value);
|
|
477
498
|
}
|
|
478
499
|
get enableSectionOutline() {
|
|
479
500
|
return this._data.enableSectionOutline;
|
|
480
501
|
}
|
|
481
502
|
set enableSectionOutline(value) {
|
|
482
|
-
this.
|
|
483
|
-
this.change();
|
|
503
|
+
this.setProperty("enableSectionOutline", value);
|
|
484
504
|
}
|
|
485
505
|
get sectionOutlineColor() {
|
|
486
506
|
return this._data.sectionOutlineColor;
|
|
487
507
|
}
|
|
488
508
|
set sectionOutlineColor(value) {
|
|
489
|
-
this.
|
|
490
|
-
this.change();
|
|
509
|
+
this.setProperty("sectionOutlineColor", value, isColorRGB(value));
|
|
491
510
|
}
|
|
492
511
|
get sectionOutlineWidth() {
|
|
493
512
|
return this._data.sectionOutlineWidth;
|
|
494
513
|
}
|
|
495
514
|
set sectionOutlineWidth(value) {
|
|
496
|
-
this.
|
|
497
|
-
this.change();
|
|
515
|
+
this.setProperty("sectionOutlineWidth", value);
|
|
498
516
|
}
|
|
499
517
|
get edgesColor() {
|
|
500
518
|
return this._data.edgesColor;
|
|
501
519
|
}
|
|
502
520
|
set edgesColor(value) {
|
|
503
|
-
this.
|
|
504
|
-
this.change();
|
|
521
|
+
this.setProperty("edgesColor", value, isColorRGB(value));
|
|
505
522
|
}
|
|
506
523
|
get facesColor() {
|
|
507
524
|
return this._data.facesColor;
|
|
508
525
|
}
|
|
509
526
|
set facesColor(value) {
|
|
510
|
-
this.
|
|
511
|
-
this.change();
|
|
527
|
+
this.setProperty("facesColor", value, isColorRGB(value));
|
|
512
528
|
}
|
|
513
529
|
get edgesVisibility() {
|
|
514
530
|
return this._data.edgesVisibility;
|
|
515
531
|
}
|
|
516
532
|
set edgesVisibility(value) {
|
|
517
|
-
this.
|
|
518
|
-
this.change();
|
|
533
|
+
this.setProperty("edgesVisibility", value);
|
|
519
534
|
}
|
|
520
535
|
get edgesOverlap() {
|
|
521
536
|
return this._data.edgesOverlap;
|
|
522
537
|
}
|
|
523
538
|
set edgesOverlap(value) {
|
|
524
|
-
this.
|
|
525
|
-
this.change();
|
|
539
|
+
this.setProperty("edgesOverlap", value);
|
|
526
540
|
}
|
|
527
541
|
get facesOverlap() {
|
|
528
542
|
return this._data.facesOverlap;
|
|
529
543
|
}
|
|
530
544
|
set facesOverlap(value) {
|
|
531
|
-
this.
|
|
532
|
-
this.change();
|
|
545
|
+
this.setProperty("facesOverlap", value);
|
|
533
546
|
}
|
|
534
547
|
get facesTransparancy() {
|
|
535
548
|
return this._data.facesTransparancy;
|
|
536
549
|
}
|
|
537
550
|
set facesTransparancy(value) {
|
|
538
|
-
this.
|
|
539
|
-
this.change();
|
|
551
|
+
this.setProperty("facesTransparancy", value);
|
|
540
552
|
}
|
|
541
553
|
get enableCustomHighlight() {
|
|
542
554
|
return this._data.enableCustomHighlight;
|
|
543
555
|
}
|
|
544
556
|
set enableCustomHighlight(value) {
|
|
545
|
-
this.
|
|
546
|
-
this.change();
|
|
557
|
+
this.setProperty("enableCustomHighlight", value);
|
|
547
558
|
}
|
|
548
559
|
get sceneGraph() {
|
|
549
560
|
return this._data.sceneGraph;
|
|
550
561
|
}
|
|
551
562
|
set sceneGraph(value) {
|
|
552
|
-
this.
|
|
553
|
-
|
|
554
|
-
this._data.enablePartialMode = false;
|
|
555
|
-
this.change();
|
|
563
|
+
this.setProperty("sceneGraph", value);
|
|
564
|
+
this.setProperty("enablePartialMode", this.enablePartialMode && !this.sceneGraph);
|
|
556
565
|
}
|
|
557
566
|
get edgeModel() {
|
|
558
567
|
return Boolean(this._data.edgeModel);
|
|
559
568
|
}
|
|
560
569
|
set edgeModel(value) {
|
|
561
|
-
this.
|
|
562
|
-
this.change();
|
|
570
|
+
this.setProperty("edgeModel", value);
|
|
563
571
|
}
|
|
564
572
|
get reverseZoomWheel() {
|
|
565
573
|
return this._data.reverseZoomWheel;
|
|
566
574
|
}
|
|
567
575
|
set reverseZoomWheel(value) {
|
|
568
|
-
this.
|
|
569
|
-
this.change();
|
|
576
|
+
this.setProperty("reverseZoomWheel", value);
|
|
570
577
|
}
|
|
571
578
|
get enableZoomWheel() {
|
|
572
579
|
return this._data.enableZoomWheel;
|
|
573
580
|
}
|
|
574
581
|
set enableZoomWheel(value) {
|
|
575
|
-
this.
|
|
576
|
-
this.change();
|
|
582
|
+
this.setProperty("enableZoomWheel", value);
|
|
577
583
|
}
|
|
578
584
|
get enableGestures() {
|
|
579
585
|
return this._data.enableGestures;
|
|
580
586
|
}
|
|
581
587
|
set enableGestures(value) {
|
|
582
|
-
this.
|
|
583
|
-
this.change();
|
|
588
|
+
this.setProperty("enableGestures", value);
|
|
584
589
|
}
|
|
585
590
|
get geometryType() {
|
|
586
591
|
return this._data.geometryType;
|
|
587
592
|
}
|
|
588
593
|
set geometryType(value) {
|
|
589
|
-
this.
|
|
590
|
-
this.change();
|
|
594
|
+
this.setProperty("geometryType", value);
|
|
591
595
|
}
|
|
592
596
|
get rulerUnit() {
|
|
593
597
|
return this._data.rulerUnit;
|
|
594
598
|
}
|
|
595
599
|
set rulerUnit(value) {
|
|
596
|
-
this.
|
|
597
|
-
this.change();
|
|
600
|
+
this.setProperty("rulerUnit", value);
|
|
598
601
|
}
|
|
599
602
|
get rulerPrecision() {
|
|
600
603
|
return this._data.rulerPrecision;
|
|
601
604
|
}
|
|
602
605
|
set rulerPrecision(value) {
|
|
603
|
-
this.
|
|
604
|
-
this.change();
|
|
606
|
+
this.setProperty("rulerPrecision", value, typeof value === "number" || value === "Default" || value === "Auto");
|
|
605
607
|
}
|
|
606
608
|
get cameraMode() {
|
|
607
|
-
return this._data.cameraMode
|
|
609
|
+
return this._data.cameraMode;
|
|
608
610
|
}
|
|
609
611
|
set cameraMode(value) {
|
|
610
|
-
this.
|
|
611
|
-
|
|
612
|
+
this.setProperty("cameraMode", value, value === "perspective" || value === "orthographic");
|
|
613
|
+
}
|
|
614
|
+
get snapshotMimeType() {
|
|
615
|
+
return this._data.snapshotMimeType;
|
|
616
|
+
}
|
|
617
|
+
set snapshotMimeType(value) {
|
|
618
|
+
this.setProperty("snapshotMimeType", value);
|
|
619
|
+
}
|
|
620
|
+
get snapshotQuality() {
|
|
621
|
+
return this._data.snapshotQuality;
|
|
622
|
+
}
|
|
623
|
+
set snapshotQuality(value) {
|
|
624
|
+
this.setProperty("snapshotQuality", value);
|
|
612
625
|
}
|
|
613
626
|
}
|
|
614
627
|
|