@inweb/viewer-three 26.4.1 → 26.5.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.
@@ -68,25 +68,22 @@
68
68
 
69
69
  class DraggersRegistry {
70
70
  constructor() {
71
- this._draggers = new Map;
71
+ this._providers = new Map;
72
72
  }
73
73
  registerDragger(name, provider) {
74
- this._draggers.set(name, provider);
74
+ this._providers.set(name, provider);
75
75
  }
76
76
  registerDraggerAlias(name, alias) {
77
- const provider = this.getDragger(name);
77
+ const provider = this._providers.get(name);
78
78
  if (provider) this.registerDragger(alias, (viewer => provider(viewer)));
79
79
  }
80
- getDragger(name) {
81
- return this._draggers.get(name);
82
- }
83
80
  getDraggers() {
84
81
  const map = new Map;
85
- this._draggers.forEach(((value, key) => map.set(key, value)));
82
+ this._providers.forEach(((value, key) => map.set(key, value)));
86
83
  return map;
87
84
  }
88
85
  createDragger(name, viewer) {
89
- const provider = this.getDragger(name);
86
+ const provider = this._providers.get(name);
90
87
  if (!provider) return null;
91
88
  const dragger = provider(viewer);
92
89
  dragger.name = name;
@@ -114,25 +111,22 @@
114
111
 
115
112
  class Components {
116
113
  constructor() {
117
- this._components = new Map;
114
+ this._providers = new Map;
118
115
  }
119
116
  registerComponent(name, provider) {
120
- this._components.set(name, provider);
117
+ this._providers.set(name, provider);
121
118
  }
122
119
  registerComponentAlias(name, alias) {
123
- const provider = this.getComponent(name);
120
+ const provider = this._providers.get(name);
124
121
  if (provider) this.registerComponent(alias, (viewer => provider(viewer)));
125
122
  }
126
- getComponent(name) {
127
- return this._components.get(name);
128
- }
129
123
  getComponents() {
130
124
  const map = new Map;
131
- this._components.forEach(((value, key) => map.set(key, value)));
125
+ this._providers.forEach(((value, key) => map.set(key, value)));
132
126
  return map;
133
127
  }
134
128
  createComponent(name, viewer) {
135
- const provider = this.getComponent(name);
129
+ const provider = this._providers.get(name);
136
130
  if (!provider) return null;
137
131
  const component = provider(viewer);
138
132
  component.name = name;
@@ -12798,8 +12792,8 @@
12798
12792
  y: 0
12799
12793
  };
12800
12794
  if (params.position2) {
12801
- params.width = params.position.x - params.position2.x;
12802
- params.height = params.position.y - params.position2.y;
12795
+ params.width = params.position2.x - params.position.x;
12796
+ params.height = params.position2.y - params.position.y;
12803
12797
  } else {
12804
12798
  if (!params.width || !params.height) {
12805
12799
  params.position2 = {
@@ -12923,6 +12917,12 @@
12923
12917
  x: x,
12924
12918
  y: y
12925
12919
  }));
12920
+ const rightLowerPoint = {
12921
+ x: x + this._ref.width(),
12922
+ y: y + this._ref.y()
12923
+ };
12924
+ const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
12925
+ this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
12926
12926
  }
12927
12927
  ref() {
12928
12928
  return this._ref;
@@ -12980,6 +12980,10 @@
12980
12980
  }
12981
12981
  }
12982
12982
 
12983
+ function getDistanceIn2D(p1, p2) {
12984
+ return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
12985
+ }
12986
+
12983
12987
  class KonvaEllipse {
12984
12988
  constructor(params, ref = null, worldTransformer = new WorldTransform) {
12985
12989
  var _a, _b;
@@ -13014,10 +13018,15 @@
13014
13018
  x: 0,
13015
13019
  y: 0
13016
13020
  };
13017
- if (!params.radius) params.radius = {
13018
- x: 25,
13019
- y: 25
13020
- };
13021
+ if (params.position2) {
13022
+ params.radius.x = getDistanceIn2D(params.position, params.position2);
13023
+ if (params.position3) params.radius.y = getDistanceIn2D(params.position, params.position3); else params.radius.x = params.radius.y;
13024
+ } else {
13025
+ if (!params.radius) params.radius = {
13026
+ x: 25,
13027
+ y: 25
13028
+ };
13029
+ }
13021
13030
  this._ref = new Konva.Ellipse({
13022
13031
  stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
13023
13032
  strokeWidth: (_b = params.lineWidth) !== null && _b !== undefined ? _b : 4,
@@ -13410,12 +13419,23 @@
13410
13419
  this._canvasImage = ref.image();
13411
13420
  this._ratio = this._ref.height() <= this.EPSILON || this._ref.width() <= this.EPSILON ? 1 : this._ref.height() / this._ref.width();
13412
13421
  const wcsStart = this._ref.getAttr("wcsStart");
13422
+ const wcsEnd = this._ref.getAttr("wcsEnd");
13413
13423
  if (!wcsStart) {
13414
13424
  this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
13415
13425
  x: ref.x(),
13416
13426
  y: ref.y()
13417
13427
  }));
13418
13428
  }
13429
+ if (!wcsEnd) {
13430
+ const rightBottomPoint = {
13431
+ x: ref.x() + ref.width(),
13432
+ y: ref.y() + ref.height()
13433
+ };
13434
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
13435
+ x: rightBottomPoint.x,
13436
+ y: rightBottomPoint.y
13437
+ }));
13438
+ }
13419
13439
  return;
13420
13440
  }
13421
13441
  if (!params) params = {};
@@ -13424,6 +13444,10 @@
13424
13444
  y: 0
13425
13445
  };
13426
13446
  if (!params.src || !params.src.startsWith(this.BASE64_HEADER_START)) params.src = this.BASE64_NOT_FOUND;
13447
+ if (params.position2) {
13448
+ params.width = params.position2.x - params.position.x;
13449
+ params.height = params.position2.y - params.position.y;
13450
+ }
13427
13451
  this._canvasImage = new Image;
13428
13452
  this._canvasImage.onload = () => {
13429
13453
  this._ref.image(this._canvasImage);
@@ -13441,6 +13465,11 @@
13441
13465
  this._ref.width(params.maxHeight / this._ratio);
13442
13466
  this._ref.height(params.maxHeight);
13443
13467
  }
13468
+ const wcsEnd = this._worldTransformer.screenToWorld({
13469
+ x: params.position.x + this._ref.width(),
13470
+ y: params.position.y + this._ref.height()
13471
+ });
13472
+ this._ref.setAttr("wcsEnd", wcsEnd);
13444
13473
  }
13445
13474
  }
13446
13475
  };
@@ -13498,6 +13527,10 @@
13498
13527
  y: this._ref.y()
13499
13528
  });
13500
13529
  this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
13530
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
13531
+ x: position.x + this._ref.width(),
13532
+ y: position.y + this._ref.height()
13533
+ }));
13501
13534
  }));
13502
13535
  this._ref.on("dragend", (e => {
13503
13536
  const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
@@ -13506,6 +13539,10 @@
13506
13539
  y: this._ref.y()
13507
13540
  });
13508
13541
  this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
13542
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
13543
+ x: position.x + this._ref.width(),
13544
+ y: position.y + this._ref.height()
13545
+ }));
13509
13546
  }));
13510
13547
  this._ref.id(this._ref._id.toString());
13511
13548
  }
@@ -13521,6 +13558,12 @@
13521
13558
  setWidth(w) {
13522
13559
  this._ref.width(w);
13523
13560
  this._ref.height(w * this._ratio);
13561
+ const rightLowerPoint = {
13562
+ x: this._ref.x() + w,
13563
+ y: this._ref.y() + this._ref.height()
13564
+ };
13565
+ const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
13566
+ this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
13524
13567
  }
13525
13568
  getHeight() {
13526
13569
  return this._ref.height();
@@ -13528,6 +13571,12 @@
13528
13571
  setHeight(h) {
13529
13572
  this._ref.height(h);
13530
13573
  this._ref.width(h / this._ratio);
13574
+ const rightLowerPoint = {
13575
+ x: this._ref.x() + this._ref.width(),
13576
+ y: this._ref.y() + h
13577
+ };
13578
+ const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
13579
+ this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
13531
13580
  }
13532
13581
  ref() {
13533
13582
  return this._ref;
@@ -13569,16 +13618,26 @@
13569
13618
  x: x,
13570
13619
  y: y
13571
13620
  }));
13621
+ const rightLowerPoint = {
13622
+ x: x + this._ref.width(),
13623
+ y: y + this._ref.y()
13624
+ };
13625
+ const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
13626
+ this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
13572
13627
  }
13573
13628
  updateScreenCoordinates() {
13574
13629
  let screenPositionStart = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));
13630
+ let screenPositionEnd = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));
13575
13631
  let invert = this._ref.getStage().getAbsoluteTransform().copy();
13576
13632
  invert = invert.invert();
13577
13633
  const positionStart = invert.point(screenPositionStart);
13634
+ const positionEnd = invert.point(screenPositionEnd);
13578
13635
  this._ref.position({
13579
13636
  x: positionStart.x,
13580
13637
  y: positionStart.y
13581
13638
  });
13639
+ this._ref.width(Math.abs(positionEnd.x - positionStart.x));
13640
+ this._ref.height(Math.abs(positionEnd.y - positionStart.y));
13582
13641
  }
13583
13642
  }
13584
13643
 
@@ -13614,8 +13673,8 @@
13614
13673
  y: 0
13615
13674
  };
13616
13675
  if (params.position2) {
13617
- params.width = params.position.x - params.position2.x;
13618
- params.height = params.position.y - params.position2.y;
13676
+ params.width = params.position2.x - params.position.x;
13677
+ params.height = params.position2.y - params.position.y;
13619
13678
  } else {
13620
13679
  if (!params.width || !params.height) {
13621
13680
  params.position2 = {
@@ -13814,6 +13873,12 @@
13814
13873
  x: x,
13815
13874
  y: y
13816
13875
  }));
13876
+ const rightLowerPoint = {
13877
+ x: x + this._ref.width(),
13878
+ y: y + this._ref.y()
13879
+ };
13880
+ const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
13881
+ this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
13817
13882
  }
13818
13883
  getWidth() {
13819
13884
  return this._ref.width();
@@ -14072,11 +14137,14 @@
14072
14137
  }));
14073
14138
  (_d = viewpoint.rectangles) === null || _d === undefined ? undefined : _d.forEach((rect => {
14074
14139
  const screenPoint = this._worldTransformer.worldToScreen(rect.position);
14075
- this.addRectangle(screenPoint, null, rect.width, rect.height, rect.line_width, rect.color, rect.id);
14140
+ const screenPoint2 = rect.position2 ? this._worldTransformer.worldToScreen(rect.position2) : null;
14141
+ this.addRectangle(screenPoint, screenPoint2, rect.width, rect.height, rect.line_width, rect.color, rect.id);
14076
14142
  }));
14077
14143
  (_e = viewpoint.ellipses) === null || _e === undefined ? undefined : _e.forEach((ellipse => {
14078
14144
  const screenPoint = this._worldTransformer.worldToScreen(ellipse.position);
14079
- this.addEllipse(screenPoint, ellipse.radius, ellipse.line_width, ellipse.color, ellipse.id);
14145
+ const screenPoint2 = ellipse.position2 ? this._worldTransformer.worldToScreen(ellipse.position2) : null;
14146
+ const screenPoint3 = ellipse.position3 ? this._worldTransformer.worldToScreen(ellipse.position3) : null;
14147
+ this.addEllipse(screenPoint, screenPoint2, screenPoint3, ellipse.radius, ellipse.line_width, ellipse.color, ellipse.id);
14080
14148
  }));
14081
14149
  (_f = viewpoint.arrows) === null || _f === undefined ? undefined : _f.forEach((arrow => {
14082
14150
  const startPoint = this._worldTransformer.worldToScreen(arrow.start);
@@ -14085,11 +14153,13 @@
14085
14153
  }));
14086
14154
  (_g = viewpoint.clouds) === null || _g === undefined ? undefined : _g.forEach((cloud => {
14087
14155
  const screenPoint = this._worldTransformer.worldToScreen(cloud.position);
14088
- this.addCloud(screenPoint, null, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
14156
+ const screenPoint2 = cloud.position2 ? this._worldTransformer.worldToScreen(cloud.position2) : null;
14157
+ this.addCloud(screenPoint, screenPoint2, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
14089
14158
  }));
14090
14159
  (_h = viewpoint.images) === null || _h === undefined ? undefined : _h.forEach((image => {
14091
14160
  const screenPoint = this._worldTransformer.worldToScreen(image.position);
14092
- this.addImage(screenPoint, image.src, image.width, image.height, image.id);
14161
+ const screenPoint2 = image.position2 ? this._worldTransformer.worldToScreen(image.position2) : null;
14162
+ this.addImage(screenPoint, screenPoint2, image.src, image.width, image.height, image.id);
14093
14163
  }));
14094
14164
  }
14095
14165
  getViewpoint(viewpoint) {
@@ -14224,7 +14294,7 @@
14224
14294
  this.addEllipse({
14225
14295
  x: startX,
14226
14296
  y: startY
14227
- }, {
14297
+ }, null, null, {
14228
14298
  x: dX / 2,
14229
14299
  y: dY / 2
14230
14300
  });
@@ -14288,7 +14358,7 @@
14288
14358
  } else lastObj = this.addEllipse({
14289
14359
  x: startX,
14290
14360
  y: startY
14291
- }, {
14361
+ }, null, null, {
14292
14362
  x: dX,
14293
14363
  y: dY
14294
14364
  });
@@ -14315,7 +14385,7 @@
14315
14385
  if (this._imageInputRef && this._imageInputRef.value) this.addImage({
14316
14386
  x: this._imageInputPos.x,
14317
14387
  y: this._imageInputPos.y
14318
- }, this._imageInputRef.value, 0, 0, this._imageInputRef.value); else if (transformer.nodes().length === 0) {
14388
+ }, null, this._imageInputRef.value, 0, 0, this._imageInputRef.value); else if (transformer.nodes().length === 0) {
14319
14389
  const pos = this.getRelativePointerPosition(stage);
14320
14390
  this.createImageInput(pos);
14321
14391
  }
@@ -14336,7 +14406,7 @@
14336
14406
  }
14337
14407
  if (this._markupMode === "Image" || this._markupMode === "SelectMarkup") {
14338
14408
  if (e.target.className === "Image" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
14339
- if (this._imageInputRef && this._imageInputRef.value) this.addImage(this._imageInputPos, this._imageInputRef.value, 0, 0); else this.createImageInput({
14409
+ if (this._imageInputRef && this._imageInputRef.value) this.addImage(this._imageInputPos, null, this._imageInputRef.value, 0, 0); else this.createImageInput({
14340
14410
  x: e.target.attrs.x,
14341
14411
  y: e.target.attrs.y
14342
14412
  });
@@ -14438,6 +14508,7 @@
14438
14508
  const rectangle = {
14439
14509
  id: shape.id(),
14440
14510
  position: wcsStart,
14511
+ position2: wcsEnd,
14441
14512
  width: Math.abs(screenStart.x - screenEnd.x),
14442
14513
  height: Math.abs(screenStart.y - screenEnd.y),
14443
14514
  line_width: shape.getLineWidth(),
@@ -14451,12 +14522,16 @@
14451
14522
  const ellipses = [];
14452
14523
  this.konvaLayerFind("Ellipse").forEach((ref => {
14453
14524
  const wcsPosition = ref.getAttr("wcsPosition");
14525
+ const wcsPosition2 = ref.getAttr("wcsRadiusX");
14526
+ const wcsPosition3 = ref.getAttr("wcsRadiusY");
14454
14527
  const stageAbsoluteTransform = this._konvaStage.getAbsoluteTransform();
14455
14528
  const scale = stageAbsoluteTransform.getMatrix()[0];
14456
14529
  const shape = new KonvaEllipse(null, ref, this._worldTransformer);
14457
14530
  const ellipse = {
14458
14531
  id: shape.id(),
14459
14532
  position: wcsPosition,
14533
+ position2: wcsPosition2,
14534
+ position3: wcsPosition3,
14460
14535
  radius: {
14461
14536
  x: ref.getRadiusX() * scale,
14462
14537
  y: ref.getRadiusY() * scale
@@ -14488,12 +14563,14 @@
14488
14563
  const images = [];
14489
14564
  this.konvaLayerFind("Image").forEach((ref => {
14490
14565
  const wcsStart = ref.getAttr("wcsStart");
14566
+ const wcsEnd = ref.getAttr("wcsEnd");
14491
14567
  const stageAbsoluteTransform = this._konvaStage.getAbsoluteTransform();
14492
14568
  const scale = stageAbsoluteTransform.getMatrix()[0];
14493
14569
  const shape = new KonvaImage(null, ref, this._worldTransformer);
14494
14570
  const image = {
14495
14571
  id: shape.id(),
14496
14572
  position: wcsStart,
14573
+ position2: wcsEnd,
14497
14574
  src: shape.getSrc(),
14498
14575
  width: shape.getWidth() * scale,
14499
14576
  height: shape.getHeight() * scale
@@ -14513,6 +14590,7 @@
14513
14590
  const cloud = {
14514
14591
  id: shape.id(),
14515
14592
  position: wcsStart,
14593
+ position2: wcsEnd,
14516
14594
  width: Math.abs(screenStart.x - screenEnd.x),
14517
14595
  height: Math.abs(screenStart.y - screenEnd.y),
14518
14596
  line_width: shape.getLineWidth(),
@@ -14617,7 +14695,7 @@
14617
14695
  this.addImage({
14618
14696
  x: this._imageInputPos.x,
14619
14697
  y: this._imageInputPos.y
14620
- }, base64.toString(), 0, 0);
14698
+ }, null, base64.toString(), 0, 0);
14621
14699
  };
14622
14700
  this._imageInputRef.oncancel = event => {
14623
14701
  this.removeImageInput();
@@ -14676,10 +14754,12 @@
14676
14754
  this.addObject(konvaRectangle);
14677
14755
  return konvaRectangle;
14678
14756
  }
14679
- addEllipse(position, radius, lineWidth, color, id) {
14757
+ addEllipse(position, position2, position3, radius, lineWidth, color, id) {
14680
14758
  if (!position) return;
14681
14759
  const konvaEllipse = new KonvaEllipse({
14682
14760
  position: position,
14761
+ position2: position2,
14762
+ position3: position3,
14683
14763
  radius: radius,
14684
14764
  lineWidth: lineWidth,
14685
14765
  color: color || this._markupColor.asHex(),
@@ -14713,7 +14793,7 @@
14713
14793
  this.addObject(konvaCloud);
14714
14794
  return konvaCloud;
14715
14795
  }
14716
- addImage(position, src, width, height, id) {
14796
+ addImage(position, position2, src, width, height, id) {
14717
14797
  var _a;
14718
14798
  if (!position || !src) return;
14719
14799
  (_a = this.getSelectedObjects().at(0)) === null || _a === undefined ? undefined : _a.delete();
@@ -14721,6 +14801,7 @@
14721
14801
  this.removeImageInput();
14722
14802
  const konvaImage = new KonvaImage({
14723
14803
  position: position,
14804
+ position2: position2,
14724
14805
  src: src,
14725
14806
  width: width,
14726
14807
  height: height,
@@ -58048,7 +58129,7 @@ void main() {
58048
58129
  // acknowledge and accept the above terms.
58049
58130
  ///////////////////////////////////////////////////////////////////////////////
58050
58131
  /**
58051
- * A commands registry. Use this registry to register custom commands.
58132
+ * Viewer commands registry. Use this registry to register custom commands.
58052
58133
  *
58053
58134
  * To implement custom command:
58054
58135
  *
@@ -58122,6 +58203,45 @@ void main() {
58122
58203
  commands.registerCommandAlias("ne", "k3DViewNE");
58123
58204
  commands.registerCommandAlias("nw", "k3DViewNW");
58124
58205
 
58206
+ ///////////////////////////////////////////////////////////////////////////////
58207
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
58208
+ // All rights reserved.
58209
+ //
58210
+ // This software and its documentation and related materials are owned by
58211
+ // the Alliance. The software may only be incorporated into application
58212
+ // programs owned by members of the Alliance, subject to a signed
58213
+ // Membership Agreement and Supplemental Software License Agreement with the
58214
+ // Alliance. The structure and organization of this software are the valuable
58215
+ // trade secrets of the Alliance and its suppliers. The software is also
58216
+ // protected by copyright law and international treaty provisions. Application
58217
+ // programs incorporating this software must include the following statement
58218
+ // with their copyright notices:
58219
+ //
58220
+ // This application incorporates Open Design Alliance software pursuant to a
58221
+ // license agreement with Open Design Alliance.
58222
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
58223
+ // All rights reserved.
58224
+ //
58225
+ // By use of this software, its documentation or related materials, you
58226
+ // acknowledge and accept the above terms.
58227
+ ///////////////////////////////////////////////////////////////////////////////
58228
+ class BackgroundComponent {
58229
+ constructor(viewer) {
58230
+ this.syncOptions = () => {
58231
+ this.backgroundColor.setHex(0xffffff);
58232
+ };
58233
+ this.viewer = viewer;
58234
+ this.backgroundColor = new Color(0xffffff);
58235
+ this.viewer.renderer.setClearColor(this.backgroundColor);
58236
+ this.viewer.scene.background = this.backgroundColor;
58237
+ this.viewer.addEventListener("optionschange", this.syncOptions);
58238
+ }
58239
+ dispose() {
58240
+ this.viewer.removeEventListener("optionschange", this.syncOptions);
58241
+ this.viewer.scene.background = undefined;
58242
+ }
58243
+ }
58244
+
58125
58245
  /**
58126
58246
  * https://github.com/google/model-viewer/blob/master/packages/model-viewer/src/three-components/EnvironmentScene.ts
58127
58247
  */
@@ -58278,25 +58398,16 @@ void main() {
58278
58398
  // By use of this software, its documentation or related materials, you
58279
58399
  // acknowledge and accept the above terms.
58280
58400
  ///////////////////////////////////////////////////////////////////////////////
58281
- class BackgroundComponent {
58401
+ class RoomEnvironmentComponent {
58282
58402
  constructor(viewer) {
58283
- this.syncOptions = () => {
58284
- this.backgroundColor.setHex(0xffffff);
58285
- };
58286
58403
  this.viewer = viewer;
58287
- this.backgroundColor = new Color(0xffffff);
58288
58404
  const environment = new RoomEnvironment();
58289
58405
  const pmremGenerator = new PMREMGenerator(this.viewer.renderer);
58290
- this.viewer.renderer.setClearColor(this.backgroundColor);
58291
- this.viewer.scene.background = this.backgroundColor;
58292
58406
  this.viewer.scene.environment = pmremGenerator.fromScene(environment).texture;
58293
- this.viewer.addEventListener("optionschange", this.syncOptions);
58294
58407
  environment.dispose();
58295
58408
  }
58296
58409
  dispose() {
58297
- this.viewer.removeEventListener("optionschange", this.syncOptions);
58298
58410
  this.viewer.scene.environment = undefined;
58299
- this.viewer.scene.background = undefined;
58300
58411
  }
58301
58412
  }
58302
58413
 
@@ -58325,9 +58436,11 @@ void main() {
58325
58436
  class CameraComponent {
58326
58437
  constructor(viewer) {
58327
58438
  this.geometryEnd = () => {
58439
+ const extentsCenter = this.viewer.extents.getCenter(new Vector3());
58328
58440
  const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere()).radius * 2;
58329
58441
  const rendererSize = this.viewer.renderer.getSize(new Vector2());
58330
58442
  const aspect = rendererSize.x / rendererSize.y;
58443
+ // TODO: do not change the camera and target after opening the second model in "append" mode
58331
58444
  let sceneCamera;
58332
58445
  this.viewer.scene.traverse((object) => {
58333
58446
  if (object.isCamera)
@@ -58355,6 +58468,7 @@ void main() {
58355
58468
  camera.far = extentsSize * 100;
58356
58469
  camera.updateProjectionMatrix();
58357
58470
  }
58471
+ this.viewer.target.copy(extentsCenter);
58358
58472
  if (!sceneCamera) {
58359
58473
  this.viewer.executeCommand("setDefaultViewPosition");
58360
58474
  }
@@ -58395,7 +58509,6 @@ void main() {
58395
58509
  const extents = new Box3();
58396
58510
  this.viewer.scene.traverseVisible((object) => !object.children.length && extents.expandByObject(object));
58397
58511
  this.viewer.extents.copy(extents);
58398
- this.viewer.target.copy(extents.getCenter(new Vector3()));
58399
58512
  };
58400
58513
  this.viewer = viewer;
58401
58514
  this.viewer.addEventListener("databasechunk", this.syncExtents);
@@ -58700,6 +58813,7 @@ void main() {
58700
58813
  components.registerComponent("ExtentsComponent", (viewer) => new ExtentsComponent(viewer));
58701
58814
  components.registerComponent("CameraComponent", (viewer) => new CameraComponent(viewer));
58702
58815
  components.registerComponent("BackgroundComponent", (viewer) => new BackgroundComponent(viewer));
58816
+ components.registerComponent("RoomEnvironmentComponent", (viewer) => new RoomEnvironmentComponent(viewer));
58703
58817
  // components.registerComponent("LightComponent", (viewer) => new LightComponent(viewer));
58704
58818
  components.registerComponent("ResizeCanvasComponent", (viewer) => new ResizeCanvasComponent(viewer));
58705
58819
  components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));