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