@inweb/viewer-core 27.4.7 → 27.6.0

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.
@@ -164,8 +164,7 @@
164
164
  this.abortController = new AbortController();
165
165
  }
166
166
  dispose() {
167
- this.abortController.abort();
168
- this.abortController = undefined;
167
+ this.cancel();
169
168
  }
170
169
  isSupport(file, format) {
171
170
  return false;
@@ -184,10 +183,10 @@
184
183
  extractFileName(file) {
185
184
  const regex = /[^/\\?#:]+(?=\?|#|$)/;
186
185
  if (typeof file === "string")
187
- return (file.match(regex) || [])[0];
186
+ return (file.match(regex) || [])[0] || "";
188
187
  else if (file instanceof globalThis.File)
189
- return (file.name.match(regex) || [])[0];
190
- return undefined;
188
+ return (file.name.match(regex) || [])[0] || "";
189
+ return "";
191
190
  }
192
191
  }
193
192
 
@@ -242,6 +241,15 @@
242
241
  enablePartialMode: false,
243
242
  memoryLimit: 3294967296,
244
243
  cuttingPlaneFillColor: { red: 0xff, green: 0x98, blue: 0x00 },
244
+ enableSectionFill: true,
245
+ sectionFillColor: { r: 0xff, g: 0x98, b: 0x00 },
246
+ sectionUseObjectColor: false,
247
+ enableSectionHatch: true,
248
+ sectionHatchColor: { r: 0, g: 0, b: 0 },
249
+ sectionHatchScale: 8,
250
+ enableSectionOutline: true,
251
+ sectionOutlineColor: { r: 0, g: 0, b: 0 },
252
+ sectionOutlineWidth: 2,
245
253
  edgesColor: { r: 0xff, g: 0x98, b: 0x00 },
246
254
  facesColor: { r: 0xff, g: 0x98, b: 0x00 },
247
255
  edgesVisibility: true,
@@ -301,230 +309,301 @@
301
309
  }
302
310
  }
303
311
  resetToDefaults(fields) {
312
+ const defaults = Options.defaults();
304
313
  if (fields !== undefined) {
305
- const defaults = Options.defaults();
306
- const resetData = fields.reduce((acc, field) => {
307
- acc[field] = defaults[field];
308
- return acc;
309
- }, {});
310
- this.data = { ...this.data, ...resetData };
314
+ const resetData = {};
315
+ for (const field of fields) {
316
+ if (field in defaults)
317
+ resetData[field] = defaults[field];
318
+ }
319
+ this.data = resetData;
311
320
  }
312
321
  else {
313
- this.data = { ...this.data, ...Options.defaults() };
322
+ this.data = defaults;
323
+ }
324
+ }
325
+ setProperty(key, value = Options.defaults()[key]) {
326
+ if (this._data[key] !== value) {
327
+ this._data[key] = value;
328
+ this.change();
314
329
  }
315
330
  }
316
331
  get data() {
317
332
  return this._data;
318
333
  }
319
334
  set data(value) {
320
- const enablePartialMode = value.enableStreamingMode ? value.enablePartialMode : false;
321
- const sceneGraph = enablePartialMode ? false : value.sceneGraph;
322
- this._data = { ...Options.defaults(), ...this._data, ...value, enablePartialMode, sceneGraph };
335
+ const defaults = Options.defaults();
336
+ const merged = { ...defaults, ...this._data, ...value };
337
+ for (const key of Object.keys(defaults)) {
338
+ if (merged[key] === undefined)
339
+ merged[key] = defaults[key];
340
+ }
341
+ this._data = merged;
342
+ if (this._data.enablePartialMode) {
343
+ this._data.enableStreamingMode = true;
344
+ this._data.sceneGraph = false;
345
+ }
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
+ };
323
352
  this.change();
324
353
  }
325
354
  get showWCS() {
326
355
  return this._data.showWCS;
327
356
  }
328
357
  set showWCS(value) {
329
- this._data.showWCS = value;
330
- this.change();
358
+ this.setProperty("showWCS", value);
331
359
  }
332
360
  get cameraAnimation() {
333
361
  return this._data.cameraAnimation;
334
362
  }
335
363
  set cameraAnimation(value) {
336
- this._data.cameraAnimation = value;
337
- this.change();
364
+ this.setProperty("cameraAnimation", value);
338
365
  }
339
366
  get antialiasing() {
340
367
  return this._data.antialiasing;
341
368
  }
342
369
  set antialiasing(value) {
343
- this._data.antialiasing = value;
344
- this.change();
370
+ this.setProperty("antialiasing", value);
345
371
  }
346
372
  get groundShadow() {
347
373
  return this._data.groundShadow;
348
374
  }
349
375
  set groundShadow(value) {
350
- this._data.groundShadow = value;
351
- this.change();
376
+ this.setProperty("groundShadow", value);
352
377
  }
353
378
  get shadows() {
354
379
  return this._data.shadows;
355
380
  }
356
381
  set shadows(value) {
357
- this._data.shadows = value;
358
- this.change();
382
+ this.setProperty("shadows", value);
359
383
  }
360
384
  get cameraAxisXSpeed() {
361
385
  return this._data.cameraAxisXSpeed;
362
386
  }
363
387
  set cameraAxisXSpeed(value) {
364
- this._data.cameraAxisXSpeed = value;
365
- this.change();
388
+ this.setProperty("cameraAxisXSpeed", value);
366
389
  }
367
390
  get cameraAxisYSpeed() {
368
391
  return this._data.cameraAxisYSpeed;
369
392
  }
370
393
  set cameraAxisYSpeed(value) {
371
- this.cameraAxisYSpeed = value;
372
- this.change();
394
+ this.setProperty("cameraAxisYSpeed", value);
373
395
  }
374
396
  get ambientOcclusion() {
375
397
  return this._data.ambientOcclusion;
376
398
  }
377
399
  set ambientOcclusion(value) {
378
- this._data.ambientOcclusion = value;
379
- this.change();
400
+ this.setProperty("ambientOcclusion", value);
380
401
  }
381
402
  get enableStreamingMode() {
382
403
  return this._data.enableStreamingMode;
383
404
  }
384
405
  set enableStreamingMode(value) {
385
- this._data.enableStreamingMode = value;
386
- if (!value)
387
- this._data.enablePartialMode = false;
388
- this.change();
406
+ this.setProperty("enableStreamingMode", value);
407
+ if (!value) {
408
+ this.setProperty("enablePartialMode", false);
409
+ }
389
410
  }
390
411
  get enablePartialMode() {
391
412
  return this._data.enablePartialMode;
392
413
  }
393
414
  set enablePartialMode(value) {
394
- this._data.enablePartialMode = value;
415
+ this.setProperty("enablePartialMode", value);
395
416
  if (value) {
396
- this._data.enableStreamingMode = true;
397
- this._data.sceneGraph = false;
417
+ this.setProperty("enableStreamingMode", true);
418
+ this.setProperty("sceneGraph", false);
398
419
  }
399
- this.change();
400
420
  }
401
421
  get memoryLimit() {
402
422
  return this._data.memoryLimit;
403
423
  }
404
424
  set memoryLimit(value) {
405
- this._data.memoryLimit = value;
406
- this.change();
425
+ this.setProperty("memoryLimit", value);
407
426
  }
408
427
  get cuttingPlaneFillColor() {
409
- return this._data.cuttingPlaneFillColor;
428
+ console.warn("Options.cuttingPlaneFillColor has been deprecated since 27.5 and will be removed in a future release, use sectionFillColor instead");
429
+ return {
430
+ red: this._data.sectionFillColor.r,
431
+ green: this._data.sectionFillColor.g,
432
+ blue: this._data.sectionFillColor.b,
433
+ };
410
434
  }
411
435
  set cuttingPlaneFillColor(value) {
412
- this._data.cuttingPlaneFillColor = value;
413
- this.change();
436
+ console.warn("Options.cuttingPlaneFillColor has been deprecated since 27.5 and will be removed in a future release, use sectionFillColor instead");
437
+ this.setProperty("sectionFillColor", {
438
+ r: value.red,
439
+ g: value.green,
440
+ b: value.blue,
441
+ });
442
+ }
443
+ get enableSectionFill() {
444
+ return this._data.enableSectionFill;
445
+ }
446
+ set enableSectionFill(value) {
447
+ this.setProperty("enableSectionFill", value);
448
+ }
449
+ get sectionFillColor() {
450
+ return this._data.sectionFillColor;
451
+ }
452
+ set sectionFillColor(value) {
453
+ this.setProperty("sectionFillColor", value);
454
+ }
455
+ get sectionUseObjectColor() {
456
+ return this._data.sectionUseObjectColor;
457
+ }
458
+ set sectionUseObjectColor(value) {
459
+ this.setProperty("sectionUseObjectColor", value);
460
+ }
461
+ get enableSectionHatch() {
462
+ return this._data.enableSectionHatch;
463
+ }
464
+ set enableSectionHatch(value) {
465
+ this.setProperty("enableSectionHatch", value);
466
+ }
467
+ get sectionHatchColor() {
468
+ return this._data.sectionHatchColor;
469
+ }
470
+ set sectionHatchColor(value) {
471
+ this.setProperty("sectionHatchColor", value);
472
+ }
473
+ get sectionHatchScale() {
474
+ return this._data.sectionHatchScale;
475
+ }
476
+ set sectionHatchScale(value) {
477
+ this.setProperty("sectionHatchScale", value);
478
+ }
479
+ get enableSectionOutline() {
480
+ return this._data.enableSectionOutline;
481
+ }
482
+ set enableSectionOutline(value) {
483
+ this.setProperty("enableSectionOutline", value);
484
+ }
485
+ get sectionOutlineColor() {
486
+ return this._data.sectionOutlineColor;
487
+ }
488
+ set sectionOutlineColor(value) {
489
+ this.setProperty("sectionOutlineColor", value);
490
+ }
491
+ get sectionOutlineWidth() {
492
+ return this._data.sectionOutlineWidth;
493
+ }
494
+ set sectionOutlineWidth(value) {
495
+ this.setProperty("sectionOutlineWidth", value);
414
496
  }
415
497
  get edgesColor() {
416
498
  return this._data.edgesColor;
417
499
  }
418
500
  set edgesColor(value) {
419
- this._data.edgesColor = value;
420
- this.change();
501
+ this.setProperty("edgesColor", value);
421
502
  }
422
503
  get facesColor() {
423
504
  return this._data.facesColor;
424
505
  }
425
506
  set facesColor(value) {
426
- this._data.facesColor = value;
427
- this.change();
507
+ this.setProperty("facesColor", value);
428
508
  }
429
509
  get edgesVisibility() {
430
510
  return this._data.edgesVisibility;
431
511
  }
432
512
  set edgesVisibility(value) {
433
- this._data.edgesVisibility = value;
434
- this.change();
513
+ this.setProperty("edgesVisibility", value);
435
514
  }
436
515
  get edgesOverlap() {
437
516
  return this._data.edgesOverlap;
438
517
  }
439
518
  set edgesOverlap(value) {
440
- this._data.edgesOverlap = value;
441
- this.change();
519
+ this.setProperty("edgesOverlap", value);
442
520
  }
443
521
  get facesOverlap() {
444
522
  return this._data.facesOverlap;
445
523
  }
446
524
  set facesOverlap(value) {
447
- this._data.facesOverlap = value;
448
- this.change();
525
+ this.setProperty("facesOverlap", value);
449
526
  }
450
527
  get facesTransparancy() {
451
528
  return this._data.facesTransparancy;
452
529
  }
453
530
  set facesTransparancy(value) {
454
- this._data.facesTransparancy = value;
455
- this.change();
531
+ this.setProperty("facesTransparancy", value);
456
532
  }
457
533
  get enableCustomHighlight() {
458
534
  return this._data.enableCustomHighlight;
459
535
  }
460
536
  set enableCustomHighlight(value) {
461
- this._data.enableCustomHighlight = value;
462
- this.change();
537
+ this.setProperty("enableCustomHighlight", value);
463
538
  }
464
539
  get sceneGraph() {
465
540
  return this._data.sceneGraph;
466
541
  }
467
542
  set sceneGraph(value) {
468
- this._data.sceneGraph = value;
469
- if (value)
470
- this._data.enablePartialMode = false;
471
- this.change();
543
+ this.setProperty("sceneGraph", value);
544
+ if (value) {
545
+ this.setProperty("enablePartialMode", false);
546
+ }
472
547
  }
473
548
  get edgeModel() {
474
549
  return Boolean(this._data.edgeModel);
475
550
  }
476
551
  set edgeModel(value) {
477
- this._data.edgeModel = Boolean(value);
478
- this.change();
552
+ this.setProperty("edgeModel", value);
479
553
  }
480
554
  get reverseZoomWheel() {
481
555
  return this._data.reverseZoomWheel;
482
556
  }
483
557
  set reverseZoomWheel(value) {
484
- this._data.reverseZoomWheel = !!value;
485
- this.change();
558
+ this.setProperty("reverseZoomWheel", value);
486
559
  }
487
560
  get enableZoomWheel() {
488
561
  return this._data.enableZoomWheel;
489
562
  }
490
563
  set enableZoomWheel(value) {
491
- this._data.enableZoomWheel = !!value;
492
- this.change();
564
+ this.setProperty("enableZoomWheel", value);
493
565
  }
494
566
  get enableGestures() {
495
567
  return this._data.enableGestures;
496
568
  }
497
569
  set enableGestures(value) {
498
- this._data.enableGestures = !!value;
499
- this.change();
570
+ this.setProperty("enableGestures", value);
500
571
  }
501
572
  get geometryType() {
502
573
  return this._data.geometryType;
503
574
  }
504
575
  set geometryType(value) {
505
- this._data.geometryType = value;
506
- this.change();
576
+ this.setProperty("geometryType", value);
507
577
  }
508
578
  get rulerUnit() {
509
579
  return this._data.rulerUnit;
510
580
  }
511
581
  set rulerUnit(value) {
512
- this._data.rulerUnit = value;
513
- this.change();
582
+ this.setProperty("rulerUnit", value);
514
583
  }
515
584
  get rulerPrecision() {
516
585
  return this._data.rulerPrecision;
517
586
  }
518
587
  set rulerPrecision(value) {
519
- this._data.rulerPrecision = value;
520
- this.change();
588
+ this.setProperty("rulerPrecision", value);
521
589
  }
522
590
  get cameraMode() {
523
591
  return this._data.cameraMode || "perspective";
524
592
  }
525
593
  set cameraMode(value) {
526
- this._data.cameraMode = value;
527
- this.change();
594
+ this.setProperty("cameraMode", value);
595
+ }
596
+ get snapshotMimeType() {
597
+ return this._data.snapshotMimeType;
598
+ }
599
+ set snapshotMimeType(value) {
600
+ this.setProperty("snapshotMimeType", value);
601
+ }
602
+ get snapshotQuality() {
603
+ return this._data.snapshotQuality;
604
+ }
605
+ set snapshotQuality(value) {
606
+ this.setProperty("snapshotQuality", value);
528
607
  }
529
608
  }
530
609