@xtctwins/tctwins-core 1.0.25 → 1.0.27

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.
@@ -11669,7 +11669,7 @@ class AngleMeasurement extends Component {
11669
11669
  /**
11670
11670
  * Gets the color of the angle measurement.
11671
11671
  *
11672
- * The color is an HTML string representation, eg. "#00BBFF" and "blue".
11672
+ * The color is an HTML string representation, eg. "#0065fc" and "blue".
11673
11673
  *
11674
11674
  * @type {String}
11675
11675
  */
@@ -12460,9 +12460,6 @@ s * @param {function} [cfg.canvasToPagePos] Optional function to map canvas-spa
12460
12460
  if (this.pointerLens) {
12461
12461
  this.pointerLens.visible = false;
12462
12462
  }
12463
- if (this.markerDiv) {
12464
- this._destroyMarkerDiv();
12465
- }
12466
12463
  this.reset();
12467
12464
  const canvas = this.scene.canvas.canvas;
12468
12465
  canvas.removeEventListener("mousedown", this._onMouseDown);
@@ -12505,7 +12502,6 @@ s * @param {function} [cfg.canvasToPagePos] Optional function to map canvas-spa
12505
12502
  destroy() {
12506
12503
  this.deactivate();
12507
12504
  this._destroyMarkerDiv();
12508
-
12509
12505
  if (this.pointerLens) {
12510
12506
  this.pointerLens.destroy();
12511
12507
  }
@@ -12776,7 +12772,7 @@ class AngleMeasurementsPlugin extends Plugin {
12776
12772
 
12777
12773
  this._measurements = {};
12778
12774
 
12779
- this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
12775
+ this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#0065fc";
12780
12776
  this.defaultLabelsVisible = cfg.defaultLabelsVisible !== false;
12781
12777
  this.zIndex = cfg.zIndex || 10000;
12782
12778
 
@@ -13321,6 +13317,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13321
13317
  canvas.addEventListener(
13322
13318
  "touchstart",
13323
13319
  (this._onCanvasTouchStart = (event) => {
13320
+ if (!event.isTrusted) return;
13324
13321
  const currentNumTouches = event.touches.length;
13325
13322
 
13326
13323
  //多指触碰
@@ -13847,6 +13844,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13847
13844
  touchEndCanvasPos.set([touchX, touchY]);
13848
13845
 
13849
13846
  switch (this._touchState) {
13847
+ //起点短按
13850
13848
  case WAITING_FOR_ORIGIN_QUICK_TOUCH_END$1:
13851
13849
  {
13852
13850
  if (
@@ -13876,7 +13874,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13876
13874
  worldPos: pickResult.worldPos
13877
13875
  }
13878
13876
  });
13879
- this._currentAngleMeasurement.clickable = false;
13877
+ // this._currentAngleMeasurement.clickable = false;
13880
13878
  this._currentAngleMeasurement.originVisible = true;
13881
13879
  this._currentAngleMeasurement.originWireVisible = false;
13882
13880
  this._currentAngleMeasurement.cornerVisible = false;
@@ -13898,6 +13896,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13898
13896
  enableCameraNavigation();
13899
13897
  break;
13900
13898
 
13899
+ //起点长按
13901
13900
  case WAITING_FOR_ORIGIN_LONG_TOUCH_END$1:
13902
13901
  if (this.pointerLens) {
13903
13902
  this.pointerLens.visible = false;
@@ -13916,6 +13915,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13916
13915
  enableCameraNavigation();
13917
13916
  break;
13918
13917
 
13918
+ //拐角短按
13919
13919
  case WAITING_FOR_CORNER_QUICK_TOUCH_END:
13920
13920
  {
13921
13921
  if (
@@ -13955,6 +13955,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13955
13955
  enableCameraNavigation();
13956
13956
  break;
13957
13957
 
13958
+ //拐角长按
13958
13959
  case WAITING_FOR_CORNER_LONG_TOUCH_END:
13959
13960
  if (this.pointerLens) {
13960
13961
  this.pointerLens.visible = false;
@@ -13964,6 +13965,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13964
13965
  enableCameraNavigation();
13965
13966
  break;
13966
13967
 
13968
+ //终点短按
13967
13969
  case WAITING_FOR_TARGET_QUICK_TOUCH_END$1:
13968
13970
  {
13969
13971
  if (
@@ -14004,6 +14006,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14004
14006
  enableCameraNavigation();
14005
14007
  break;
14006
14008
 
14009
+ //终点长按
14007
14010
  case WAITING_FOR_TARGET_LONG_TOUCH_END$1:
14008
14011
  if (this.pointerLens) {
14009
14012
  this.pointerLens.visible = false;
@@ -14029,6 +14032,8 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14029
14032
  { passive: true }
14030
14033
  );
14031
14034
 
14035
+ canvas.addEventListener("touchcancel", this._onCanvasTouchEnd);
14036
+
14032
14037
  this._active = true;
14033
14038
  }
14034
14039
 
@@ -14048,6 +14053,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14048
14053
  const canvas = this.plugin.viewer.scene.canvas.canvas;
14049
14054
  canvas.removeEventListener("touchstart", this._onCanvasTouchStart);
14050
14055
  canvas.removeEventListener("touchend", this._onCanvasTouchEnd);
14056
+ canvas.removeEventListener("touchcancel", this._onCanvasTouchEnd);
14051
14057
  if (this._currentAngleMeasurement) {
14052
14058
  this.angleMeasurementsPlugin.fire("measurementCancel", this._currentAngleMeasurement);
14053
14059
  this._currentAngleMeasurement.destroy();
@@ -21697,6 +21703,7 @@ class Input extends Component {
21697
21703
  if (!this.enabled) {
21698
21704
  return;
21699
21705
  }
21706
+ if (!e.isTrusted) return;
21700
21707
  if (e.touches.length == 1) {
21701
21708
  this.touchDown = true;
21702
21709
  }
@@ -21720,6 +21727,8 @@ class Input extends Component {
21720
21727
  }),
21721
21728
  true
21722
21729
  );
21730
+ //touchcancel
21731
+ this.element.addEventListener("touchcancel", this._touchUpListener, true);
21723
21732
  //touchmove
21724
21733
  this.element.addEventListener(
21725
21734
  "touchmove",
@@ -21789,6 +21798,7 @@ class Input extends Component {
21789
21798
 
21790
21799
  this.element.removeEventListener("touchstart", this._touchDownListener);
21791
21800
  document.removeEventListener("touchend", this._touchUpListener);
21801
+ document.removeEventListener("touchcancel", this._touchUpListener);
21792
21802
  this.element.removeEventListener("touchmove", this._touchMoveListener);
21793
21803
 
21794
21804
  if (window.OrientationChangeEvent) {
@@ -32035,13 +32045,13 @@ class Scene extends Component {
32035
32045
  */
32036
32046
  destroy(callback) {
32037
32047
  super.destroy();
32038
-
32039
32048
  for (const id in this.components) {
32040
32049
  if (this.components.hasOwnProperty(id)) {
32041
32050
  this.components[id].destroy();
32042
32051
  }
32043
32052
  }
32044
- this.canvas.destroy();
32053
+ // this.canvas.destroy(); // canvas是scene的其中一个component,所有以不必再destroy
32054
+
32045
32055
  // Memory leak prevention
32046
32056
  this.components = null;
32047
32057
  this.models = null;
@@ -32063,13 +32073,14 @@ class Scene extends Component {
32063
32073
  this._selectedObjectIds = null;
32064
32074
  this._colorizedObjectIds = null;
32065
32075
  this.types = null;
32066
- this.components = null;
32067
- this.canvas = null;
32068
32076
  this._renderer = null;
32069
32077
  this.input = null;
32070
32078
  this._viewport = null;
32071
32079
  this._camera = null;
32072
- if (callback) callback();
32080
+ this.canvas = null;
32081
+ if (typeof callback === "function") {
32082
+ callback();
32083
+ }
32073
32084
  }
32074
32085
  }
32075
32086
 
@@ -87380,13 +87391,10 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
87380
87391
  if (this.pointerLens) {
87381
87392
  this.pointerLens.visible = false;
87382
87393
  }
87383
- if (this._markerDiv) {
87384
- this._destroyMarkerDiv();
87385
- }
87386
87394
  this.reset();
87387
87395
  const canvas = this.scene.canvas.canvas;
87388
- canvas.removeEventListener("mousedown" , this._onMouseDown);
87389
- canvas.removeEventListener("mouseup" , this._onMouseUp);
87396
+ canvas.removeEventListener("mousedown", this._onMouseDown);
87397
+ canvas.removeEventListener("mouseup", this._onMouseUp);
87390
87398
  const cameraControl = this.distanceMeasurementsPlugin.viewer.cameraControl;
87391
87399
  cameraControl.off(this._onCameraControlHoverSnapOrSurface);
87392
87400
  cameraControl.off(this._onCameraControlHoverSnapOrSurfaceOff);
@@ -87710,7 +87718,7 @@ class DistanceMeasurementsPlugin extends Plugin {
87710
87718
  * @param {boolean} [cfg.defaultXAxisVisible=true] The default value of the DistanceMeasurements `xAxisVisible` property.
87711
87719
  * @param {boolean} [cfg.defaultYAxisVisible=true] The default value of the DistanceMeasurements `yAxisVisible` property.
87712
87720
  * @param {boolean} [cfg.defaultZAxisVisible=true] The default value of the DistanceMeasurements `zAxisVisible` property.
87713
- * @param {string} [cfg.defaultColor=#00BBFF] The default color of the length dots, wire and label.
87721
+ * @param {string} [cfg.defaultColor=#0065fc] The default color of the length dots, wire and label.
87714
87722
  * @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
87715
87723
  * @param {boolean} [cfg.defaultLabelsOnWires=true] The default value of the DistanceMeasurements `labelsOnWires` property.
87716
87724
  * @param {PointerCircle} [cfg.pointerLens] A PointerLens to help the user position the pointer. This can be shared with other plugins.
@@ -87737,7 +87745,7 @@ class DistanceMeasurementsPlugin extends Plugin {
87737
87745
  this.defaultXAxisVisible = cfg.defaultXAxisVisible !== false;
87738
87746
  this.defaultYAxisVisible = cfg.defaultYAxisVisible !== false;
87739
87747
  this.defaultZAxisVisible = cfg.defaultZAxisVisible !== false;
87740
- this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
87748
+ this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#0065fc";
87741
87749
  this.zIndex = cfg.zIndex || 10000;
87742
87750
  this.defaultLabelsOnWires = cfg.defaultLabelsOnWires !== false;
87743
87751
 
@@ -88217,6 +88225,7 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
88217
88225
  canvas.addEventListener(
88218
88226
  "touchstart",
88219
88227
  (this._onCanvasTouchStart = (event) => {
88228
+ if (!event.isTrusted) return;
88220
88229
  const currentNumTouches = event.touches.length;
88221
88230
 
88222
88231
  if (currentNumTouches !== 1) {
@@ -88626,6 +88635,7 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
88626
88635
  touchEndCanvasPos.set([touchX, touchY]);
88627
88636
 
88628
88637
  switch (this._touchState) {
88638
+ //等待起点短按
88629
88639
  case WAITING_FOR_ORIGIN_QUICK_TOUCH_END:
88630
88640
  {
88631
88641
  if (
@@ -88661,7 +88671,7 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
88661
88671
  this._currentDistanceMeasurement.wireVisible = false;
88662
88672
  this._currentDistanceMeasurement.originVisible = true;
88663
88673
  this._currentDistanceMeasurement.targetVisible = false;
88664
- this._currentDistanceMeasurement.clickable = false;
88674
+ // this._currentDistanceMeasurement.clickable = false;
88665
88675
  this._touchState = WAITING_FOR_TARGET_TOUCH_START;
88666
88676
  this.distanceMeasurementsPlugin.fire("measurementStart", this._currentDistanceMeasurement);
88667
88677
  // console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
@@ -88759,6 +88769,8 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
88759
88769
  { passive: true }
88760
88770
  );
88761
88771
 
88772
+ canvas.addEventListener("touchcancel", this._onCanvasTouchEnd);
88773
+
88762
88774
  this._active = true;
88763
88775
  }
88764
88776
 
@@ -88778,6 +88790,7 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
88778
88790
  const canvas = this.plugin.viewer.scene.canvas.canvas;
88779
88791
  canvas.removeEventListener("touchstart", this._onCanvasTouchStart);
88780
88792
  canvas.removeEventListener("touchend", this._onCanvasTouchEnd);
88793
+ canvas.removeEventListener("touchcancel", this._onCanvasTouchEnd);
88781
88794
  if (this._currentDistanceMeasurement) {
88782
88795
  this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
88783
88796
  this._currentDistanceMeasurement.destroy();
@@ -95183,7 +95196,7 @@ class MousePanRotateDollyHandler {
95183
95196
 
95184
95197
  let mouseMovedOnCanvasSinceLastWheel = true;
95185
95198
 
95186
- const canvas = this._scene.canvas.canvas;
95199
+ this.canvas = this._scene.canvas.canvas;
95187
95200
 
95188
95201
  const keyDown = [];
95189
95202
 
@@ -95209,13 +95222,13 @@ class MousePanRotateDollyHandler {
95209
95222
  })
95210
95223
  );
95211
95224
 
95212
- function setMousedownState(pick = true) {
95213
- canvas.style.cursor = "move";
95225
+ const setMousedownState = (pick = true) => {
95226
+ this.canvas.style.cursor = "move";
95214
95227
  setMousedownPositions();
95215
95228
  if (pick) {
95216
95229
  setMousedownPick();
95217
95230
  }
95218
- }
95231
+ };
95219
95232
 
95220
95233
  function setMousedownPositions() {
95221
95234
 
@@ -95243,7 +95256,7 @@ class MousePanRotateDollyHandler {
95243
95256
  }
95244
95257
  }
95245
95258
 
95246
- canvas.addEventListener(
95259
+ this.canvas.addEventListener(
95247
95260
  "mousedown",
95248
95261
  (this._mouseDownHandler = (e) => {
95249
95262
  if (!(configs.active && configs.pointerEnabled)) {
@@ -95350,7 +95363,7 @@ class MousePanRotateDollyHandler {
95350
95363
  })
95351
95364
  );
95352
95365
 
95353
- canvas.addEventListener(
95366
+ this.canvas.addEventListener(
95354
95367
  "mousemove",
95355
95368
  (this._canvasMouseMoveHandler = (e) => {
95356
95369
  if (!(configs.active && configs.pointerEnabled)) {
@@ -95391,7 +95404,7 @@ class MousePanRotateDollyHandler {
95391
95404
  })
95392
95405
  );
95393
95406
 
95394
- canvas.addEventListener(
95407
+ this.canvas.addEventListener(
95395
95408
  "mouseup",
95396
95409
  (this._mouseUpHandler = (e) => {
95397
95410
  if (!(configs.active && configs.pointerEnabled)) {
@@ -95416,11 +95429,11 @@ class MousePanRotateDollyHandler {
95416
95429
  }
95417
95430
  break;
95418
95431
  }
95419
- canvas.style.removeProperty("cursor");
95432
+ this.canvas.style.removeProperty("cursor");
95420
95433
  })
95421
95434
  );
95422
95435
 
95423
- canvas.addEventListener(
95436
+ this.canvas.addEventListener(
95424
95437
  "mouseenter",
95425
95438
  (this._mouseEnterHandler = () => {
95426
95439
  if (!(configs.active && configs.pointerEnabled)) {
@@ -95434,7 +95447,7 @@ class MousePanRotateDollyHandler {
95434
95447
 
95435
95448
  let secsNowLast = null;
95436
95449
 
95437
- canvas.addEventListener(
95450
+ this.canvas.addEventListener(
95438
95451
  "wheel",
95439
95452
  (this._mouseWheelHandler = (e) => {
95440
95453
  e.preventDefault();
@@ -95468,17 +95481,17 @@ class MousePanRotateDollyHandler {
95468
95481
  reset() {}
95469
95482
 
95470
95483
  destroy() {
95471
- const canvas = this._scene.canvas.canvas;
95472
-
95484
+ if (this.canvas != null) {
95485
+ this.canvas.removeEventListener("mousedown", this._mouseDownHandler);
95486
+ this.canvas.removeEventListener("mousemove", this._canvasMouseMoveHandler);
95487
+ this.canvas.removeEventListener("mouseup", this._mouseUpHandler);
95488
+ this.canvas.removeEventListener("mouseenter", this._mouseEnterHandler);
95489
+ this.canvas.removeEventListener("wheel", this._mouseWheelHandler);
95490
+ }
95473
95491
  document.removeEventListener("keydown", this._documentKeyDownHandler);
95474
95492
  document.removeEventListener("keyup", this._documentKeyUpHandler);
95475
- canvas.removeEventListener("mousedown", this._mouseDownHandler);
95476
95493
  document.removeEventListener("mousemove", this._documentMouseMoveHandler);
95477
- canvas.removeEventListener("mousemove", this._canvasMouseMoveHandler);
95478
95494
  document.removeEventListener("mouseup", this._documentMouseUpHandler);
95479
- canvas.removeEventListener("mouseup", this._mouseUpHandler);
95480
- canvas.removeEventListener("mouseenter", this._mouseEnterHandler);
95481
- canvas.removeEventListener("wheel", this._mouseWheelHandler);
95482
95495
  }
95483
95496
  }
95484
95497
 
@@ -95489,116 +95502,113 @@ const tempVec3c$1 = math.vec3();
95489
95502
  const tempVec3d = math.vec3();
95490
95503
 
95491
95504
  const tempCameraTarget = {
95492
- eye: math.vec3(),
95493
- look: math.vec3(),
95494
- up: math.vec3()
95505
+ eye: math.vec3(),
95506
+ look: math.vec3(),
95507
+ up: math.vec3()
95495
95508
  };
95496
95509
 
95497
95510
  /**
95498
95511
  * @private
95499
95512
  */
95500
95513
  class KeyboardAxisViewHandler {
95514
+ constructor(scene, controllers, configs, states) {
95515
+ this._scene = scene;
95516
+ this.input = scene.input;
95517
+ const cameraControl = controllers.cameraControl;
95518
+ const camera = scene.camera;
95501
95519
 
95502
- constructor(scene, controllers, configs, states) {
95503
-
95504
- this._scene = scene;
95505
- const cameraControl = controllers.cameraControl;
95506
- const camera = scene.camera;
95507
-
95508
- this._onSceneKeyDown = scene.input.on("keydown", () => {
95509
-
95510
- if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
95511
- return;
95512
- }
95513
-
95514
- if (!states.mouseover) {
95515
- return;
95516
- }
95517
-
95518
- const axisViewRight = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_RIGHT);
95519
- const axisViewBack = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BACK);
95520
- const axisViewLeft = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_LEFT);
95521
- const axisViewFront = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_FRONT);
95522
- const axisViewTop = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_TOP);
95523
- const axisViewBottom = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BOTTOM);
95524
-
95525
- if ((!axisViewRight) && (!axisViewBack) && (!axisViewLeft) && (!axisViewFront) && (!axisViewTop) && (!axisViewBottom)) {
95526
- return;
95527
- }
95528
-
95529
- const aabb = scene.aabb;
95530
- const diag = math.getAABB3Diag(aabb);
95531
-
95532
- math.getAABB3Center(aabb, center);
95533
-
95534
- const perspectiveDist = Math.abs(diag / Math.tan(controllers.cameraFlight.fitFOV * math.DEGTORAD));
95535
- const orthoScale = diag * 1.1;
95536
-
95537
- tempCameraTarget.orthoScale = orthoScale;
95538
-
95539
- if (axisViewRight) {
95540
-
95541
- tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldRight, perspectiveDist, tempVec3a$5), tempVec3d));
95542
- tempCameraTarget.look.set(center);
95543
- tempCameraTarget.up.set(camera.worldUp);
95544
-
95545
- } else if (axisViewBack) {
95546
-
95547
- tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldForward, perspectiveDist, tempVec3a$5), tempVec3d));
95548
- tempCameraTarget.look.set(center);
95549
- tempCameraTarget.up.set(camera.worldUp);
95550
-
95551
- } else if (axisViewLeft) {
95520
+ this._onSceneKeyDown = scene.input.on("keydown", () => {
95521
+ if (!(configs.active && configs.pointerEnabled) || !scene.input.keyboardEnabled) {
95522
+ return;
95523
+ }
95552
95524
 
95553
- tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldRight, -perspectiveDist, tempVec3a$5), tempVec3d));
95554
- tempCameraTarget.look.set(center);
95555
- tempCameraTarget.up.set(camera.worldUp);
95525
+ if (!states.mouseover) {
95526
+ return;
95527
+ }
95556
95528
 
95557
- } else if (axisViewFront) {
95529
+ const axisViewRight = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_RIGHT);
95530
+ const axisViewBack = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BACK);
95531
+ const axisViewLeft = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_LEFT);
95532
+ const axisViewFront = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_FRONT);
95533
+ const axisViewTop = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_TOP);
95534
+ const axisViewBottom = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BOTTOM);
95558
95535
 
95559
- tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldForward, -perspectiveDist, tempVec3a$5), tempVec3d));
95560
- tempCameraTarget.look.set(center);
95561
- tempCameraTarget.up.set(camera.worldUp);
95536
+ if (!axisViewRight && !axisViewBack && !axisViewLeft && !axisViewFront && !axisViewTop && !axisViewBottom) {
95537
+ return;
95538
+ }
95562
95539
 
95563
- } else if (axisViewTop) {
95540
+ const aabb = scene.aabb;
95541
+ const diag = math.getAABB3Diag(aabb);
95564
95542
 
95565
- tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldUp, perspectiveDist, tempVec3a$5), tempVec3d));
95566
- tempCameraTarget.look.set(center);
95567
- tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward, 1, tempVec3b$2), tempVec3c$1));
95543
+ math.getAABB3Center(aabb, center);
95568
95544
 
95569
- } else if (axisViewBottom) {
95545
+ const perspectiveDist = Math.abs(diag / Math.tan(controllers.cameraFlight.fitFOV * math.DEGTORAD));
95546
+ const orthoScale = diag * 1.1;
95570
95547
 
95571
- tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldUp, -perspectiveDist, tempVec3a$5), tempVec3d));
95572
- tempCameraTarget.look.set(center);
95573
- tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward, -1, tempVec3b$2)));
95574
- }
95548
+ tempCameraTarget.orthoScale = orthoScale;
95575
95549
 
95576
- if ((!configs.firstPerson) && configs.followPointer) {
95577
- controllers.pivotController.setPivotPos(center);
95578
- }
95550
+ if (axisViewRight) {
95551
+ tempCameraTarget.eye.set(
95552
+ math.addVec3(center, math.mulVec3Scalar(camera.worldRight, perspectiveDist, tempVec3a$5), tempVec3d)
95553
+ );
95554
+ tempCameraTarget.look.set(center);
95555
+ tempCameraTarget.up.set(camera.worldUp);
95556
+ } else if (axisViewBack) {
95557
+ tempCameraTarget.eye.set(
95558
+ math.addVec3(center, math.mulVec3Scalar(camera.worldForward, perspectiveDist, tempVec3a$5), tempVec3d)
95559
+ );
95560
+ tempCameraTarget.look.set(center);
95561
+ tempCameraTarget.up.set(camera.worldUp);
95562
+ } else if (axisViewLeft) {
95563
+ tempCameraTarget.eye.set(
95564
+ math.addVec3(center, math.mulVec3Scalar(camera.worldRight, -perspectiveDist, tempVec3a$5), tempVec3d)
95565
+ );
95566
+ tempCameraTarget.look.set(center);
95567
+ tempCameraTarget.up.set(camera.worldUp);
95568
+ } else if (axisViewFront) {
95569
+ tempCameraTarget.eye.set(
95570
+ math.addVec3(center, math.mulVec3Scalar(camera.worldForward, -perspectiveDist, tempVec3a$5), tempVec3d)
95571
+ );
95572
+ tempCameraTarget.look.set(center);
95573
+ tempCameraTarget.up.set(camera.worldUp);
95574
+ } else if (axisViewTop) {
95575
+ tempCameraTarget.eye.set(
95576
+ math.addVec3(center, math.mulVec3Scalar(camera.worldUp, perspectiveDist, tempVec3a$5), tempVec3d)
95577
+ );
95578
+ tempCameraTarget.look.set(center);
95579
+ tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward, 1, tempVec3b$2), tempVec3c$1));
95580
+ } else if (axisViewBottom) {
95581
+ tempCameraTarget.eye.set(
95582
+ math.addVec3(center, math.mulVec3Scalar(camera.worldUp, -perspectiveDist, tempVec3a$5), tempVec3d)
95583
+ );
95584
+ tempCameraTarget.look.set(center);
95585
+ tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward, -1, tempVec3b$2)));
95586
+ }
95579
95587
 
95580
- if (controllers.cameraFlight.duration > 0) {
95581
- controllers.cameraFlight.flyTo(tempCameraTarget, () => {
95582
- if (controllers.pivotController.getPivoting() && configs.followPointer) {
95583
- controllers.pivotController.showPivot();
95584
- }
95585
- });
95588
+ if (!configs.firstPerson && configs.followPointer) {
95589
+ controllers.pivotController.setPivotPos(center);
95590
+ }
95586
95591
 
95587
- } else {
95588
- controllers.cameraFlight.jumpTo(tempCameraTarget);
95589
- if (controllers.pivotController.getPivoting() && configs.followPointer) {
95590
- controllers.pivotController.showPivot();
95591
- }
95592
- }
95593
- });
95594
- }
95592
+ if (controllers.cameraFlight.duration > 0) {
95593
+ controllers.cameraFlight.flyTo(tempCameraTarget, () => {
95594
+ if (controllers.pivotController.getPivoting() && configs.followPointer) {
95595
+ controllers.pivotController.showPivot();
95596
+ }
95597
+ });
95598
+ } else {
95599
+ controllers.cameraFlight.jumpTo(tempCameraTarget);
95600
+ if (controllers.pivotController.getPivoting() && configs.followPointer) {
95601
+ controllers.pivotController.showPivot();
95602
+ }
95603
+ }
95604
+ });
95605
+ }
95595
95606
 
95596
- reset() {
95597
- }
95607
+ reset() {}
95598
95608
 
95599
- destroy() {
95600
- this._scene.input.off(this._onSceneKeyDown);
95601
- }
95609
+ destroy() {
95610
+ this.input.off(this._onSceneKeyDown);
95611
+ }
95602
95612
  }
95603
95613
 
95604
95614
  /**
@@ -95619,7 +95629,7 @@ class MousePickHandler {
95619
95629
  let leftDown = false;
95620
95630
  let rightDown = false;
95621
95631
 
95622
- const canvas = this._scene.canvas.canvas;
95632
+ this.canvas = this._scene.canvas.canvas;
95623
95633
 
95624
95634
  const tickifiedMouseMoveFn = scene.tickify(
95625
95635
  (this._canvasMouseMoveHandler = (e) => {
@@ -95701,8 +95711,8 @@ class MousePickHandler {
95701
95711
  })
95702
95712
  );
95703
95713
 
95704
- canvas.addEventListener("mousemove", tickifiedMouseMoveFn);
95705
- canvas.addEventListener(
95714
+ this.canvas.addEventListener("mousemove", tickifiedMouseMoveFn);
95715
+ this.canvas.addEventListener(
95706
95716
  "dblclick",
95707
95717
  (this._canvasDblClickHandler = (e) => {
95708
95718
  states.mouseDownClientX = e.clientX;
@@ -95733,7 +95743,7 @@ class MousePickHandler {
95733
95743
  })
95734
95744
  );
95735
95745
 
95736
- canvas.addEventListener(
95746
+ this.canvas.addEventListener(
95737
95747
  "mousedown",
95738
95748
  (this._canvasMouseDownHandler = (e) => {
95739
95749
  if (e.which === 1) {
@@ -95772,6 +95782,7 @@ class MousePickHandler {
95772
95782
  const pickResult = pickController.pickResult;
95773
95783
 
95774
95784
  if (pickResult && pickResult.worldPos) {
95785
+ pivotController.setCanvasPivotPos(states.pointerCanvasPos);
95775
95786
  cameraControl.fire("mouseDownEntity", pickController.pickResult, true);
95776
95787
  } else {
95777
95788
  if (configs.smartPivot) {
@@ -95804,7 +95815,7 @@ class MousePickHandler {
95804
95815
  })
95805
95816
  );
95806
95817
 
95807
- canvas.addEventListener(
95818
+ this.canvas.addEventListener(
95808
95819
  "mouseup",
95809
95820
  (this._canvasMouseUpHandler = (e) => {
95810
95821
  if (!(configs.active && configs.pointerEnabled)) {
@@ -95978,12 +95989,13 @@ class MousePickHandler {
95978
95989
  }
95979
95990
 
95980
95991
  destroy() {
95981
- const canvas = this._scene.canvas.canvas;
95982
- canvas.removeEventListener("mousemove", this._canvasMouseMoveHandler);
95983
- canvas.removeEventListener("mousedown", this._canvasMouseDownHandler);
95984
- canvas.removeEventListener("dblclick", this._canvasDblClickHandler);
95992
+ if (this.canvas != null) {
95993
+ this.canvas.removeEventListener("mousemove", this._canvasMouseMoveHandler);
95994
+ this.canvas.removeEventListener("mousedown", this._canvasMouseDownHandler);
95995
+ this.canvas.removeEventListener("dblclick", this._canvasDblClickHandler);
95996
+ this.canvas.removeEventListener("mouseup", this._canvasMouseUpHandler);
95997
+ }
95985
95998
  document.removeEventListener("mouseup", this._documentMouseUpHandler);
95986
- canvas.removeEventListener("mouseup", this._canvasMouseUpHandler);
95987
95999
  if (this._timeout) {
95988
96000
  window.clearTimeout(this._timeout);
95989
96001
  this._timeout = null;
@@ -95999,7 +96011,7 @@ class KeyboardPanRotateDollyHandler {
95999
96011
  this._scene = scene;
96000
96012
  this._updates = updates;
96001
96013
  const input = scene.input;
96002
-
96014
+ this.input = input;
96003
96015
  const keyDownMap = [];
96004
96016
 
96005
96017
  const canvas = scene.canvas.canvas;
@@ -96153,9 +96165,9 @@ class KeyboardPanRotateDollyHandler {
96153
96165
  destroy() {
96154
96166
  this._scene.off(this._onTick);
96155
96167
 
96156
- this._scene.input.off(this._onSceneMouseMove);
96157
- this._scene.input.off(this._onSceneKeyDown);
96158
- this._scene.input.off(this._onSceneKeyUp);
96168
+ this.input.off(this._onSceneMouseMove);
96169
+ this.input.off(this._onSceneKeyDown);
96170
+ this.input.off(this._onSceneKeyUp);
96159
96171
  }
96160
96172
  }
96161
96173
 
@@ -96274,7 +96286,7 @@ class CameraUpdater {
96274
96286
 
96275
96287
  if ((!configs.firstPerson) && configs.followPointer && pivotController.getPivoting()) {
96276
96288
  pivotController.continuePivot(updates.rotateDeltaY, updates.rotateDeltaX);
96277
- pivotController.showPivot();
96289
+ // pivotController.showPivot();
96278
96290
 
96279
96291
  } else {
96280
96292
 
@@ -96475,42 +96487,42 @@ class MouseMiscHandler {
96475
96487
  constructor(scene, controllers, configs, states, updates) {
96476
96488
  this._scene = scene;
96477
96489
 
96478
- const canvas = this._scene.canvas.canvas;
96490
+ this.canvas = this._scene.canvas.canvas;
96479
96491
 
96480
- canvas.addEventListener(
96492
+ this.canvas.addEventListener(
96481
96493
  "mouseenter",
96482
96494
  (this._mouseEnterHandler = () => {
96483
96495
  states.mouseover = true;
96484
96496
  })
96485
96497
  );
96486
96498
 
96487
- canvas.addEventListener(
96499
+ this.canvas.addEventListener(
96488
96500
  "mouseleave",
96489
96501
  (this._mouseLeaveHandler = () => {
96490
96502
  states.mouseover = false;
96491
- canvas.style.cursor = null;
96503
+ this.canvas.style.cursor = null;
96492
96504
  })
96493
96505
  );
96494
96506
 
96495
96507
  document.addEventListener(
96496
96508
  "mousemove",
96497
96509
  (this._mouseMoveHandler = (e) => {
96498
- getCanvasPosFromEvent$2(e, canvas, states.pointerCanvasPos);
96510
+ getCanvasPosFromEvent$2(e, this.canvas, states.pointerCanvasPos);
96499
96511
  })
96500
96512
  );
96501
96513
 
96502
- canvas.addEventListener(
96514
+ this.canvas.addEventListener(
96503
96515
  "mousedown",
96504
96516
  (this._mouseDownHandler = (e) => {
96505
96517
  if (!(configs.active && configs.pointerEnabled)) {
96506
96518
  return;
96507
96519
  }
96508
- getCanvasPosFromEvent$2(e, canvas, states.pointerCanvasPos);
96520
+ getCanvasPosFromEvent$2(e, this.canvas, states.pointerCanvasPos);
96509
96521
  states.mouseover = true;
96510
96522
  })
96511
96523
  );
96512
96524
 
96513
- canvas.addEventListener(
96525
+ this.canvas.addEventListener(
96514
96526
  "mouseup",
96515
96527
  (this._mouseUpHandler = (e) => {
96516
96528
  if (!(configs.active && configs.pointerEnabled)) {
@@ -96523,16 +96535,15 @@ class MouseMiscHandler {
96523
96535
  reset() {}
96524
96536
 
96525
96537
  destroy() {
96526
- const canvas = this._scene.canvas.canvas;
96527
96538
  //网络问题导致的模型加载失败等情况时,如果切换模型,会找不到canvas
96528
96539
  //因此暂时在此加判断
96529
- if (canvas) {
96530
- document.removeEventListener("mousemove", this._mouseMoveHandler);
96531
- canvas.removeEventListener("mouseenter", this._mouseEnterHandler);
96532
- canvas.removeEventListener("mouseleave", this._mouseLeaveHandler);
96533
- canvas.removeEventListener("mousedown", this._mouseDownHandler);
96534
- canvas.removeEventListener("mouseup", this._mouseUpHandler);
96540
+ if (this.canvas != null) {
96541
+ this.canvas.removeEventListener("mouseenter", this._mouseEnterHandler);
96542
+ this.canvas.removeEventListener("mouseleave", this._mouseLeaveHandler);
96543
+ this.canvas.removeEventListener("mousedown", this._mouseDownHandler);
96544
+ this.canvas.removeEventListener("mouseup", this._mouseUpHandler);
96535
96545
  }
96546
+ document.removeEventListener("mousemove", this._mouseMoveHandler);
96536
96547
  }
96537
96548
  }
96538
96549
 
@@ -96585,7 +96596,7 @@ class TouchPanRotateAndDollyHandler {
96585
96596
  const touch0Vec = math.vec2();
96586
96597
 
96587
96598
  const lastCanvasTouchPosList = [];
96588
- const canvas = this._scene.canvas.canvas;
96599
+ this.canvas = this._scene.canvas.canvas;
96589
96600
 
96590
96601
  let numTouches = 0;
96591
96602
  let waitForTick = false;
@@ -96594,12 +96605,13 @@ class TouchPanRotateAndDollyHandler {
96594
96605
  waitForTick = false;
96595
96606
  });
96596
96607
 
96597
- canvas.addEventListener(
96608
+ this.canvas.addEventListener(
96598
96609
  "touchstart",
96599
96610
  (this._canvasTouchStartHandler = (event) => {
96600
96611
  if (!(configs.active && configs.pointerEnabled)) {
96601
96612
  return;
96602
96613
  }
96614
+ if (!event.isTrusted) return;
96603
96615
 
96604
96616
  event.preventDefault();
96605
96617
 
@@ -96617,31 +96629,33 @@ class TouchPanRotateAndDollyHandler {
96617
96629
  pickController.pickCursorPos = tapStartCanvasPos;
96618
96630
  pickController.schedulePickSurface = true;
96619
96631
  pickController.update();
96620
-
96621
- if (!configs.planView) {
96622
- if (
96623
- pickController.picked &&
96624
- pickController.pickedSurface &&
96625
- pickController.pickResult &&
96626
- pickController.pickResult.worldPos
96627
- ) {
96628
- pivotController.setPivotPos(pickController.pickResult.worldPos);
96629
-
96630
- if (!configs.firstPerson && pivotController.startPivot()) {
96631
- pivotController.showPivot();
96632
- }
96633
- } else {
96634
- if (configs.smartPivot) {
96635
- pivotController.setCanvasPivotPos(states.pointerCanvasPos);
96636
- } else {
96637
- pivotController.setPivotPos(scene.camera.look);
96638
- }
96639
-
96640
- if (!configs.firstPerson && pivotController.startPivot()) {
96641
- pivotController.showPivot();
96642
- }
96643
- }
96644
- }
96632
+ pivotController.setPivotPos(scene.camera.look);
96633
+
96634
+ // if (!configs.planView) {
96635
+ // if (
96636
+ // pickController.picked &&
96637
+ // pickController.pickedSurface &&
96638
+ // pickController.pickResult &&
96639
+ // pickController.pickResult.worldPos
96640
+ // ) {
96641
+ // // pivotController.setPivotPos(pickController.pickResult.worldPos);
96642
+ // pivotController.setPivotPos(scene.camera.look);
96643
+ // if (!configs.firstPerson && pivotController.startPivot()) {
96644
+ // // pivotController.showPivot();
96645
+ // }
96646
+ // } else {
96647
+ // if (configs.smartPivot) {
96648
+ // pivotController.setPivotPos(scene.camera.look);
96649
+ // // pivotController.setCanvasPivotPos(states.pointerCanvasPos);
96650
+ // } else {
96651
+ // pivotController.setPivotPos(scene.camera.look);
96652
+ // }
96653
+
96654
+ // if (!configs.firstPerson && pivotController.startPivot()) {
96655
+ // // pivotController.showPivot();
96656
+ // }
96657
+ // }
96658
+ // }
96645
96659
  }
96646
96660
  }
96647
96661
 
@@ -96657,7 +96671,7 @@ class TouchPanRotateAndDollyHandler {
96657
96671
  })
96658
96672
  );
96659
96673
 
96660
- canvas.addEventListener(
96674
+ this.canvas.addEventListener(
96661
96675
  "touchend",
96662
96676
  (this._canvasTouchEndHandler = () => {
96663
96677
  if (pivotController.getPivoting()) {
@@ -96666,8 +96680,9 @@ class TouchPanRotateAndDollyHandler {
96666
96680
  }
96667
96681
  })
96668
96682
  );
96683
+ this.canvas.addEventListener("touchcancel", this._canvasTouchEndHandler);
96669
96684
 
96670
- canvas.addEventListener(
96685
+ this.canvas.addEventListener(
96671
96686
  "touchmove",
96672
96687
  (this._canvasTouchMoveHandler = (event) => {
96673
96688
  if (!(configs.active && configs.pointerEnabled)) {
@@ -96813,10 +96828,12 @@ class TouchPanRotateAndDollyHandler {
96813
96828
  reset() {}
96814
96829
 
96815
96830
  destroy() {
96816
- const canvas = this._scene.canvas.canvas;
96817
- canvas.removeEventListener("touchstart", this._canvasTouchStartHandler);
96818
- canvas.removeEventListener("touchend", this._canvasTouchEndHandler);
96819
- canvas.removeEventListener("touchmove", this._canvasTouchMoveHandler);
96831
+ if (this.canvas != null) {
96832
+ this.canvas.removeEventListener("touchstart", this._canvasTouchStartHandler);
96833
+ this.canvas.removeEventListener("touchend", this._canvasTouchEndHandler);
96834
+ this.canvas.removeEventListener("touchcancel", this._canvasTouchEndHandler);
96835
+ this.canvas.removeEventListener("touchmove", this._canvasTouchMoveHandler);
96836
+ }
96820
96837
  this._scene.off(this._onTick);
96821
96838
  }
96822
96839
  }
@@ -96861,7 +96878,7 @@ class TouchPickHandler {
96861
96878
  let tapStartTime = -1;
96862
96879
  let lastTapTime = -1;
96863
96880
 
96864
- const canvas = this._scene.canvas.canvas;
96881
+ this.canvas = this._scene.canvas.canvas;
96865
96882
 
96866
96883
  const flyCameraTo = (pickResult) => {
96867
96884
  let pos;
@@ -96885,12 +96902,13 @@ class TouchPickHandler {
96885
96902
  }
96886
96903
  };
96887
96904
 
96888
- canvas.addEventListener(
96905
+ this.canvas.addEventListener(
96889
96906
  "touchstart",
96890
96907
  (this._canvasTouchStartHandler = (e) => {
96891
96908
  if (!(configs.active && configs.pointerEnabled)) {
96892
96909
  return;
96893
96910
  }
96911
+ if (!e.isTrusted) return;
96894
96912
 
96895
96913
  if (states.longTouchTimeout !== null) {
96896
96914
  clearTimeout(states.longTouchTimeout);
@@ -96962,7 +96980,7 @@ class TouchPickHandler {
96962
96980
  { passive: true }
96963
96981
  );
96964
96982
 
96965
- canvas.addEventListener(
96983
+ this.canvas.addEventListener(
96966
96984
  "touchend",
96967
96985
  (this._canvasTouchEndHandler = (e) => {
96968
96986
  if (!(configs.active && configs.pointerEnabled)) {
@@ -97058,6 +97076,8 @@ class TouchPickHandler {
97058
97076
  }),
97059
97077
  { passive: true }
97060
97078
  );
97079
+
97080
+ this.canvas.addEventListener("touchcancel", this._canvasTouchEndHandler);
97061
97081
  }
97062
97082
 
97063
97083
  reset() {
@@ -97067,9 +97087,11 @@ class TouchPickHandler {
97067
97087
  }
97068
97088
 
97069
97089
  destroy() {
97070
- const canvas = this._scene.canvas.canvas;
97071
- canvas.removeEventListener("touchstart", this._canvasTouchStartHandler);
97072
- canvas.removeEventListener("touchend", this._canvasTouchEndHandler);
97090
+ if (this.canvas != null) {
97091
+ this.canvas.removeEventListener("touchstart", this._canvasTouchStartHandler);
97092
+ this.canvas.removeEventListener("touchend", this._canvasTouchEndHandler);
97093
+ this.canvas.removeEventListener("touchcancel", this._canvasTouchEndHandler);
97094
+ }
97073
97095
  }
97074
97096
  }
97075
97097
 
@@ -108358,13 +108380,16 @@ class Viewer {
108358
108380
  this._snapshotBegun = false;
108359
108381
  }
108360
108382
 
108361
- /** Destroys this Viewer.
108383
+ /**
108384
+ * Destroys this Viewer.
108362
108385
  */
108363
108386
  destroy(callback) {
108364
108387
  const plugins = this._plugins.slice(); // Array will modify as we delete plugins
108365
- for (let i = 0, len = plugins.length; i < len; i++) {
108366
- const plugin = plugins[i];
108367
- plugin.destroy();
108388
+ if (plugins.length > 0) {
108389
+ for (let i = 0, len = plugins.length; i < len; i++) {
108390
+ const plugin = plugins[i];
108391
+ plugin.destroy();
108392
+ }
108368
108393
  }
108369
108394
  this.cameraControl.destroy();
108370
108395
  this.scene.destroy(callback);
@@ -120912,7 +120937,7 @@ class Control {
120912
120937
  //touchend
120913
120938
  canvas.addEventListener(
120914
120939
  "touchend",
120915
- (this._canvasMouseUpListener = (e) => {
120940
+ (this._canvasTouchEndListener = (e) => {
120916
120941
  // if (!this._visible) return;
120917
120942
  this._viewer.cameraControl.pointerEnabled = true;
120918
120943
  if (lastAffordanceMesh) {
@@ -120924,6 +120949,7 @@ class Control {
120924
120949
  grabbed = false;
120925
120950
  })
120926
120951
  );
120952
+ canvas.addEventListener("touchcancel", this._canvasTouchEndListener);
120927
120953
  }
120928
120954
  }
120929
120955
 
@@ -120945,6 +120971,8 @@ class Control {
120945
120971
  canvas.removeEventListener("mousemove", this._canvasMouseMoveListener);
120946
120972
  canvas.removeEventListener("mouseup", this._canvasMouseUpListener);
120947
120973
  canvas.removeEventListener("wheel", this._canvasWheelListener);
120974
+ canvas.removeEventListener("touchend", this._canvasTouchEndListener);
120975
+ canvas.removeEventListener("touchcancel", this._canvasTouchEndListener);
120948
120976
 
120949
120977
  camera.off(this._onCameraViewMatrix);
120950
120978
  camera.off(this._onCameraProjMatrix);
@@ -121131,235 +121159,241 @@ class Plane$1 {
121131
121159
  * @private
121132
121160
  */
121133
121161
  class Overview$1 {
121162
+ /**
121163
+ * @private
121164
+ */
121165
+ constructor(plugin, cfg) {
121166
+ if (!cfg.onHoverEnterPlane || !cfg.onHoverLeavePlane || !cfg.onClickedNothing || !cfg.onClickedPlane) {
121167
+ throw "Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";
121168
+ }
121134
121169
 
121135
- /**
121136
- * @private
121137
- */
121138
- constructor(plugin, cfg) {
121139
-
121140
- if (!cfg.onHoverEnterPlane || !cfg.onHoverLeavePlane || !cfg.onClickedNothing || !cfg.onClickedPlane) {
121141
- throw "Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";
121142
- }
121143
-
121144
- /**
121145
- * The {@link SectionPlanesPlugin} that owns this SectionPlanesOverview.
121146
- *
121147
- * @type {SectionPlanesPlugin}
121148
- */
121149
- this.plugin = plugin;
121170
+ /**
121171
+ * The {@link SectionPlanesPlugin} that owns this SectionPlanesOverview.
121172
+ *
121173
+ * @type {SectionPlanesPlugin}
121174
+ */
121175
+ this.plugin = plugin;
121150
121176
 
121151
- this._viewer = plugin.viewer;
121177
+ this._viewer = plugin.viewer;
121152
121178
 
121153
- this._onHoverEnterPlane = cfg.onHoverEnterPlane;
121154
- this._onHoverLeavePlane = cfg.onHoverLeavePlane;
121155
- this._onClickedNothing = cfg.onClickedNothing;
121156
- this._onClickedPlane = cfg.onClickedPlane;
121157
- this._visible = true;
121179
+ this._onHoverEnterPlane = cfg.onHoverEnterPlane;
121180
+ this._onHoverLeavePlane = cfg.onHoverLeavePlane;
121181
+ this._onClickedNothing = cfg.onClickedNothing;
121182
+ this._onClickedPlane = cfg.onClickedPlane;
121183
+ this._visible = true;
121158
121184
 
121159
- this._planes = {};
121185
+ this._planes = {};
121160
121186
 
121161
- //--------------------------------------------------------------------------------------------------------------
121162
- // Init canvas
121163
- //--------------------------------------------------------------------------------------------------------------
121187
+ //--------------------------------------------------------------------------------------------------------------
121188
+ // Init canvas
121189
+ //--------------------------------------------------------------------------------------------------------------
121164
121190
 
121165
- this._canvas = cfg.overviewCanvas;
121191
+ this._canvas = cfg.overviewCanvas;
121166
121192
 
121167
- //--------------------------------------------------------------------------------------------------------------
121168
- // Init scene
121169
- //--------------------------------------------------------------------------------------------------------------
121193
+ //--------------------------------------------------------------------------------------------------------------
121194
+ // Init scene
121195
+ //--------------------------------------------------------------------------------------------------------------
121170
121196
 
121171
- this._scene = new Scene(this._viewer, {
121172
- canvasId: this._canvas.id,
121173
- transparent: true
121174
- });
121175
- this._scene.clearLights();
121176
- new DirLight(this._scene, {
121177
- dir: [0.4, -0.4, 0.8],
121178
- color: [0.8, 1.0, 1.0],
121179
- intensity: 1.0,
121180
- space: "view"
121181
- });
121182
- new DirLight(this._scene, {
121183
- dir: [-0.8, -0.3, -0.4],
121184
- color: [0.8, 0.8, 0.8],
121185
- intensity: 1.0,
121186
- space: "view"
121187
- });
121188
- new DirLight(this._scene, {
121189
- dir: [0.8, -0.6, -0.8],
121190
- color: [1.0, 1.0, 1.0],
121191
- intensity: 1.0,
121192
- space: "view"
121193
- });
121197
+ this._scene = new Scene(this._viewer, {
121198
+ canvasId: this._canvas.id,
121199
+ transparent: true
121200
+ });
121201
+ this._scene.clearLights();
121202
+ new DirLight(this._scene, {
121203
+ dir: [0.4, -0.4, 0.8],
121204
+ color: [0.8, 1.0, 1.0],
121205
+ intensity: 1.0,
121206
+ space: "view"
121207
+ });
121208
+ new DirLight(this._scene, {
121209
+ dir: [-0.8, -0.3, -0.4],
121210
+ color: [0.8, 0.8, 0.8],
121211
+ intensity: 1.0,
121212
+ space: "view"
121213
+ });
121214
+ new DirLight(this._scene, {
121215
+ dir: [0.8, -0.6, -0.8],
121216
+ color: [1.0, 1.0, 1.0],
121217
+ intensity: 1.0,
121218
+ space: "view"
121219
+ });
121194
121220
 
121195
- this._scene.camera;
121196
- this._scene.camera.perspective.fov = 70;
121221
+ this._scene.camera;
121222
+ this._scene.camera.perspective.fov = 70;
121197
121223
 
121198
- this._zUp = false;
121224
+ this._zUp = false;
121199
121225
 
121200
- //--------------------------------------------------------------------------------------------------------------
121201
- // Synchronize overview scene camera with viewer camera
121202
- //--------------------------------------------------------------------------------------------------------------
121226
+ //--------------------------------------------------------------------------------------------------------------
121227
+ // Synchronize overview scene camera with viewer camera
121228
+ //--------------------------------------------------------------------------------------------------------------
121203
121229
 
121204
- {
121205
- const camera = this._scene.camera;
121206
- const matrix = math.rotationMat4c(-90 * math.DEGTORAD, 1, 0, 0);
121207
- const eyeLookVec = math.vec3();
121208
- const eyeLookVecOverview = math.vec3();
121209
- const upOverview = math.vec3();
121210
-
121211
- this._synchCamera = () => {
121212
- const eye = this._viewer.camera.eye;
121213
- const look = this._viewer.camera.look;
121214
- const up = this._viewer.camera.up;
121215
- math.mulVec3Scalar(math.normalizeVec3(math.subVec3(eye, look, eyeLookVec)), 7);
121216
- if (this._zUp) { // +Z up
121217
- math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
121218
- math.transformVec3(matrix, up, upOverview);
121219
- camera.look = [0, 0, 0];
121220
- camera.eye = math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
121221
- camera.up = math.transformPoint3(matrix, up, upOverview);
121222
- } else { // +Y up
121223
- camera.look = [0, 0, 0];
121224
- camera.eye = eyeLookVec;
121225
- camera.up = up;
121226
- }
121227
- };
121228
- }
121230
+ {
121231
+ const camera = this._scene.camera;
121232
+ const matrix = math.rotationMat4c(-90 * math.DEGTORAD, 1, 0, 0);
121233
+ const eyeLookVec = math.vec3();
121234
+ const eyeLookVecOverview = math.vec3();
121235
+ const upOverview = math.vec3();
121236
+
121237
+ this._synchCamera = () => {
121238
+ const eye = this._viewer.camera.eye;
121239
+ const look = this._viewer.camera.look;
121240
+ const up = this._viewer.camera.up;
121241
+ math.mulVec3Scalar(math.normalizeVec3(math.subVec3(eye, look, eyeLookVec)), 7);
121242
+ if (this._zUp) {
121243
+ // +Z up
121244
+ math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
121245
+ math.transformVec3(matrix, up, upOverview);
121246
+ camera.look = [0, 0, 0];
121247
+ camera.eye = math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
121248
+ camera.up = math.transformPoint3(matrix, up, upOverview);
121249
+ } else {
121250
+ // +Y up
121251
+ camera.look = [0, 0, 0];
121252
+ camera.eye = eyeLookVec;
121253
+ camera.up = up;
121254
+ }
121255
+ };
121256
+ }
121229
121257
 
121230
- this._onViewerCameraMatrix = this._viewer.camera.on("matrix", this._synchCamera);
121258
+ this._onViewerCameraMatrix = this._viewer.camera.on("matrix", this._synchCamera);
121231
121259
 
121232
- this._onViewerCameraWorldAxis = this._viewer.camera.on("worldAxis", this._synchCamera);
121260
+ this._onViewerCameraWorldAxis = this._viewer.camera.on("worldAxis", this._synchCamera);
121233
121261
 
121234
- this._onViewerCameraFOV = this._viewer.camera.perspective.on("fov", (fov) => {
121235
- this._scene.camera.perspective.fov = fov;
121236
- });
121262
+ this._onViewerCameraFOV = this._viewer.camera.perspective.on("fov", (fov) => {
121263
+ this._scene.camera.perspective.fov = fov;
121264
+ });
121237
121265
 
121238
- //--------------------------------------------------------------------------------------------------------------
121239
- // Bind overview canvas events
121240
- //--------------------------------------------------------------------------------------------------------------
121266
+ //--------------------------------------------------------------------------------------------------------------
121267
+ // Bind overview canvas events
121268
+ //--------------------------------------------------------------------------------------------------------------
121241
121269
 
121242
- {
121243
- var hoveredEntity = null;
121270
+ {
121271
+ var hoveredEntity = null;
121244
121272
 
121245
- this._onInputMouseMove = this._scene.input.on("mousemove", (coords) => {
121246
- const hit = this._scene.pick({
121247
- canvasPos: coords
121248
- });
121249
- if (hit) {
121250
- if (!hoveredEntity || hit.entity.id !== hoveredEntity.id) {
121251
- if (hoveredEntity) {
121252
- const plane = this._planes[hoveredEntity.id];
121253
- if (plane) {
121254
- this._onHoverLeavePlane(hoveredEntity.id);
121255
- }
121256
- }
121257
- hoveredEntity = hit.entity;
121258
- const plane = this._planes[hoveredEntity.id];
121259
- if (plane) {
121260
- this._onHoverEnterPlane(hoveredEntity.id);
121261
- }
121262
- }
121263
- } else {
121264
- if (hoveredEntity) {
121265
- this._onHoverLeavePlane(hoveredEntity.id);
121266
- hoveredEntity = null;
121267
- }
121268
- }
121269
- });
121273
+ this._onInputMouseMove = this._scene.input.on("mousemove", (coords) => {
121274
+ const hit = this._scene.pick({
121275
+ canvasPos: coords
121276
+ });
121277
+ if (hit) {
121278
+ if (!hoveredEntity || hit.entity.id !== hoveredEntity.id) {
121279
+ if (hoveredEntity) {
121280
+ const plane = this._planes[hoveredEntity.id];
121281
+ if (plane) {
121282
+ this._onHoverLeavePlane(hoveredEntity.id);
121283
+ }
121284
+ }
121285
+ hoveredEntity = hit.entity;
121286
+ const plane = this._planes[hoveredEntity.id];
121287
+ if (plane) {
121288
+ this._onHoverEnterPlane(hoveredEntity.id);
121289
+ }
121290
+ }
121291
+ } else {
121292
+ if (hoveredEntity) {
121293
+ this._onHoverLeavePlane(hoveredEntity.id);
121294
+ hoveredEntity = null;
121295
+ }
121296
+ }
121297
+ });
121270
121298
 
121271
- this._scene.canvas.canvas.addEventListener("mouseup", this._onCanvasMouseUp = () => {
121272
- if (hoveredEntity) {
121273
- const plane = this._planes[hoveredEntity.id];
121274
- if (plane) {
121275
- this._onClickedPlane(hoveredEntity.id);
121276
- }
121277
- } else {
121278
- this._onClickedNothing();
121279
- }
121280
- });
121299
+ this._scene.canvas.canvas.addEventListener(
121300
+ "mouseup",
121301
+ (this._onCanvasMouseUp = () => {
121302
+ if (hoveredEntity) {
121303
+ const plane = this._planes[hoveredEntity.id];
121304
+ if (plane) {
121305
+ this._onClickedPlane(hoveredEntity.id);
121306
+ }
121307
+ } else {
121308
+ this._onClickedNothing();
121309
+ }
121310
+ })
121311
+ );
121281
121312
 
121282
- this._scene.canvas.canvas.addEventListener("mouseout", this._onCanvasMouseOut = () => {
121283
- if (hoveredEntity) {
121284
- this._onHoverLeavePlane(hoveredEntity.id);
121285
- hoveredEntity = null;
121286
- }
121287
- });
121288
- }
121313
+ this._scene.canvas.canvas.addEventListener(
121314
+ "mouseout",
121315
+ (this._onCanvasMouseOut = () => {
121316
+ if (hoveredEntity) {
121317
+ this._onHoverLeavePlane(hoveredEntity.id);
121318
+ hoveredEntity = null;
121319
+ }
121320
+ })
121321
+ );
121322
+ }
121289
121323
 
121290
- //--------------------------------------------------------------------------------------------------------------
121291
- // Configure overview
121292
- //--------------------------------------------------------------------------------------------------------------
121324
+ //--------------------------------------------------------------------------------------------------------------
121325
+ // Configure overview
121326
+ //--------------------------------------------------------------------------------------------------------------
121293
121327
 
121294
- this.setVisible(cfg.overviewVisible);
121295
- }
121328
+ this.setVisible(cfg.overviewVisible);
121329
+ }
121296
121330
 
121297
- /** Called by SectionPlanesPlugin#createSectionPlane()
121298
- * @private
121299
- */
121300
- addSectionPlane(sectionPlane) {
121301
- this._planes[sectionPlane.id] = new Plane$1(this, this._scene, sectionPlane);
121302
- }
121331
+ /** Called by SectionPlanesPlugin#createSectionPlane()
121332
+ * @private
121333
+ */
121334
+ addSectionPlane(sectionPlane) {
121335
+ this._planes[sectionPlane.id] = new Plane$1(this, this._scene, sectionPlane);
121336
+ }
121303
121337
 
121304
- /** @private
121305
- */
121306
- setPlaneHighlighted(id, highlighted) {
121307
- const plane = this._planes[id];
121308
- if (plane) {
121309
- plane.setHighlighted(highlighted);
121310
- }
121311
- }
121338
+ /** @private
121339
+ */
121340
+ setPlaneHighlighted(id, highlighted) {
121341
+ const plane = this._planes[id];
121342
+ if (plane) {
121343
+ plane.setHighlighted(highlighted);
121344
+ }
121345
+ }
121312
121346
 
121313
- /** @private
121314
- */
121315
- setPlaneSelected(id, selected) {
121316
- const plane = this._planes[id];
121317
- if (plane) {
121318
- plane.setSelected(selected);
121319
- }
121320
- }
121347
+ /** @private
121348
+ */
121349
+ setPlaneSelected(id, selected) {
121350
+ const plane = this._planes[id];
121351
+ if (plane) {
121352
+ plane.setSelected(selected);
121353
+ }
121354
+ }
121321
121355
 
121322
- /** @private
121323
- */
121324
- removeSectionPlane(sectionPlane) {
121325
- const plane = this._planes[sectionPlane.id];
121326
- if (plane) {
121327
- plane.destroy();
121328
- delete this._planes[sectionPlane.id];
121329
- }
121330
- }
121356
+ /** @private
121357
+ */
121358
+ removeSectionPlane(sectionPlane) {
121359
+ const plane = this._planes[sectionPlane.id];
121360
+ if (plane) {
121361
+ plane.destroy();
121362
+ delete this._planes[sectionPlane.id];
121363
+ }
121364
+ }
121331
121365
 
121332
- /**
121333
- * Sets if this SectionPlanesOverview is visible.
121334
- *
121335
- * @param {Boolean} visible Whether or not this SectionPlanesOverview is visible.
121336
- */
121337
- setVisible(visible = true) {
121338
- this._visible = visible;
121339
- this._canvas.style.visibility = visible ? "visible" : "hidden";
121340
- }
121366
+ /**
121367
+ * Sets if this SectionPlanesOverview is visible.
121368
+ *
121369
+ * @param {Boolean} visible Whether or not this SectionPlanesOverview is visible.
121370
+ */
121371
+ setVisible(visible = true) {
121372
+ this._visible = visible;
121373
+ this._canvas.style.visibility = visible ? "visible" : "hidden";
121374
+ }
121341
121375
 
121342
- /**
121343
- * Gets if this SectionPlanesOverview is visible.
121344
- *
121345
- * @return {Boolean} True when this SectionPlanesOverview is visible.
121346
- */
121347
- getVisible() {
121348
- return this._visible;
121349
- }
121376
+ /**
121377
+ * Gets if this SectionPlanesOverview is visible.
121378
+ *
121379
+ * @return {Boolean} True when this SectionPlanesOverview is visible.
121380
+ */
121381
+ getVisible() {
121382
+ return this._visible;
121383
+ }
121350
121384
 
121351
- /** @private
121352
- */
121353
- destroy() {
121354
- this._viewer.camera.off(this._onViewerCameraMatrix);
121355
- this._viewer.camera.off(this._onViewerCameraWorldAxis);
121356
- this._viewer.camera.perspective.off(this._onViewerCameraFOV);
121385
+ /** @private
121386
+ */
121387
+ destroy() {
121388
+ this._viewer.camera.off(this._onViewerCameraMatrix);
121389
+ this._viewer.camera.off(this._onViewerCameraWorldAxis);
121390
+ this._viewer.camera.perspective.off(this._onViewerCameraFOV);
121357
121391
 
121358
- this._scene.input.off(this._onInputMouseMove);
121359
- this._scene.canvas.canvas.removeEventListener("mouseup", this._onCanvasMouseUp);
121360
- this._scene.canvas.canvas.removeEventListener("mouseout", this._onCanvasMouseOut);
121361
- this._scene.destroy();
121362
- }
121392
+ this._scene.input.off(this._onInputMouseMove);
121393
+ this._scene.canvas.canvas.removeEventListener("mouseup", this._onCanvasMouseUp);
121394
+ this._scene.canvas.canvas.removeEventListener("mouseout", this._onCanvasMouseOut);
121395
+ this._scene.destroy();
121396
+ }
121363
121397
  }
121364
121398
 
121365
121399
  const tempAABB$1 = math.AABB3();
@@ -122669,597 +122703,677 @@ const quat = new Float64Array(4);
122669
122703
  * Controls a {@link SectionPlane} with mouse and touch input.
122670
122704
  */
122671
122705
  class FaceAlignedSectionPlanesControl {
122706
+ /** @private */
122707
+ constructor(plugin) {
122708
+ /**
122709
+ * ID of this FaceAlignedSectionPlanesControl.
122710
+ *
122711
+ * FaceAlignedSectionPlanesControl are mapped by this ID in {@link FaceAlignedSectionPlanesPlugin#controls}.
122712
+ *
122713
+ * @property id
122714
+ * @type {String|Number}
122715
+ */
122716
+ this.id = null;
122672
122717
 
122673
- /** @private */
122674
- constructor(plugin) {
122675
-
122676
- /**
122677
- * ID of this FaceAlignedSectionPlanesControl.
122678
- *
122679
- * FaceAlignedSectionPlanesControl are mapped by this ID in {@link FaceAlignedSectionPlanesPlugin#controls}.
122680
- *
122681
- * @property id
122682
- * @type {String|Number}
122683
- */
122684
- this.id = null;
122685
-
122686
- this._viewer = plugin.viewer;
122687
- this._plugin = plugin;
122688
- this._visible = false;
122689
- this._pos = math.vec3(); // Full-precision position of the center of the FaceAlignedSectionPlanesControl
122690
- this._origin = math.vec3();
122691
- this._rtcPos = math.vec3();
122692
-
122693
- this._baseDir = math.vec3(); // Saves direction of clip plane when we start dragging an arrow or ring.
122694
- this._rootNode = null; // Root of Node graph that represents this control in the 3D scene
122695
- this._displayMeshes = null; // Meshes that are always visible
122696
- this._affordanceMeshes = null; // Meshes displayed momentarily for affordance
122718
+ this._viewer = plugin.viewer;
122719
+ this._plugin = plugin;
122720
+ this._visible = false;
122721
+ this._pos = math.vec3(); // Full-precision position of the center of the FaceAlignedSectionPlanesControl
122722
+ this._origin = math.vec3();
122723
+ this._rtcPos = math.vec3();
122697
122724
 
122698
- this._ignoreNextSectionPlaneDirUpdate = false;
122725
+ this._baseDir = math.vec3(); // Saves direction of clip plane when we start dragging an arrow or ring.
122726
+ this._rootNode = null; // Root of Node graph that represents this control in the 3D scene
122727
+ this._displayMeshes = null; // Meshes that are always visible
122728
+ this._affordanceMeshes = null; // Meshes displayed momentarily for affordance
122699
122729
 
122700
- this._createNodes();
122701
- this._bindEvents();
122702
- }
122730
+ this._ignoreNextSectionPlaneDirUpdate = false;
122703
122731
 
122704
- /**
122705
- * Called by FaceAlignedSectionPlanesPlugin to assign this FaceAlignedSectionPlanesControl to a SectionPlane.
122706
- * FaceAlignedSectionPlanesPlugin keeps FaceAlignedSectionPlanesControls in a reuse pool.
122707
- * Call with a null or undefined value to disconnect the FaceAlignedSectionPlanesControl ffrom whatever SectionPlane it was assigned to.
122708
- * @private
122709
- */
122710
- _setSectionPlane(sectionPlane) {
122711
- if (this._sectionPlane) {
122712
- this._sectionPlane.off(this._onSectionPlanePos);
122713
- this._sectionPlane.off(this._onSectionPlaneDir);
122714
- this._onSectionPlanePos = null;
122715
- this._onSectionPlaneDir = null;
122716
- this._sectionPlane = null;
122717
- }
122718
- if (sectionPlane) {
122719
- this.id = sectionPlane.id;
122720
- this._setPos(sectionPlane.pos);
122721
- this._setDir(sectionPlane.dir);
122722
- this._sectionPlane = sectionPlane;
122723
- this._onSectionPlanePos = sectionPlane.on("pos", () => {
122724
- this._setPos(this._sectionPlane.pos);
122725
- });
122726
- this._onSectionPlaneDir = sectionPlane.on("dir", () => {
122727
- if (!this._ignoreNextSectionPlaneDirUpdate) {
122728
- this._setDir(this._sectionPlane.dir);
122729
- } else {
122730
- this._ignoreNextSectionPlaneDirUpdate = false;
122731
- }
122732
- });
122733
- }
122734
- }
122732
+ this._createNodes();
122733
+ this._bindEvents();
122734
+ }
122735
122735
 
122736
- /**
122737
- * Gets the {@link SectionPlane} controlled by this FaceAlignedSectionPlanesControl.
122738
- * @returns {SectionPlane} The SectionPlane.
122739
- */
122740
- get sectionPlane() {
122741
- return this._sectionPlane;
122742
- }
122736
+ /**
122737
+ * Called by FaceAlignedSectionPlanesPlugin to assign this FaceAlignedSectionPlanesControl to a SectionPlane.
122738
+ * FaceAlignedSectionPlanesPlugin keeps FaceAlignedSectionPlanesControls in a reuse pool.
122739
+ * Call with a null or undefined value to disconnect the FaceAlignedSectionPlanesControl ffrom whatever SectionPlane it was assigned to.
122740
+ * @private
122741
+ */
122742
+ _setSectionPlane(sectionPlane) {
122743
+ if (this._sectionPlane) {
122744
+ this._sectionPlane.off(this._onSectionPlanePos);
122745
+ this._sectionPlane.off(this._onSectionPlaneDir);
122746
+ this._onSectionPlanePos = null;
122747
+ this._onSectionPlaneDir = null;
122748
+ this._sectionPlane = null;
122749
+ }
122750
+ if (sectionPlane) {
122751
+ this.id = sectionPlane.id;
122752
+ this._setPos(sectionPlane.pos);
122753
+ this._setDir(sectionPlane.dir);
122754
+ this._sectionPlane = sectionPlane;
122755
+ this._onSectionPlanePos = sectionPlane.on("pos", () => {
122756
+ this._setPos(this._sectionPlane.pos);
122757
+ });
122758
+ this._onSectionPlaneDir = sectionPlane.on("dir", () => {
122759
+ if (!this._ignoreNextSectionPlaneDirUpdate) {
122760
+ this._setDir(this._sectionPlane.dir);
122761
+ } else {
122762
+ this._ignoreNextSectionPlaneDirUpdate = false;
122763
+ }
122764
+ });
122765
+ }
122766
+ }
122743
122767
 
122744
- /** @private */
122745
- _setPos(xyz) {
122768
+ /**
122769
+ * Gets the {@link SectionPlane} controlled by this FaceAlignedSectionPlanesControl.
122770
+ * @returns {SectionPlane} The SectionPlane.
122771
+ */
122772
+ get sectionPlane() {
122773
+ return this._sectionPlane;
122774
+ }
122746
122775
 
122747
- this._pos.set(xyz);
122776
+ /** @private */
122777
+ _setPos(xyz) {
122778
+ this._pos.set(xyz);
122748
122779
 
122749
- worldToRTCPos(this._pos, this._origin, this._rtcPos);
122780
+ worldToRTCPos(this._pos, this._origin, this._rtcPos);
122750
122781
 
122751
- this._rootNode.origin = this._origin;
122752
- this._rootNode.position = this._rtcPos;
122753
- }
122782
+ this._rootNode.origin = this._origin;
122783
+ this._rootNode.position = this._rtcPos;
122784
+ }
122754
122785
 
122755
- /** @private */
122756
- _setDir(xyz) {
122757
- this._baseDir.set(xyz);
122758
- this._rootNode.quaternion = math.vec3PairToQuaternion(zeroVec, xyz, quat);
122759
- }
122786
+ /** @private */
122787
+ _setDir(xyz) {
122788
+ this._baseDir.set(xyz);
122789
+ this._rootNode.quaternion = math.vec3PairToQuaternion(zeroVec, xyz, quat);
122790
+ }
122760
122791
 
122761
- _setSectionPlaneDir(dir) {
122762
- if (this._sectionPlane) {
122763
- this._ignoreNextSectionPlaneDirUpdate = true;
122764
- this._sectionPlane.dir = dir;
122765
- }
122766
- }
122792
+ _setSectionPlaneDir(dir) {
122793
+ if (this._sectionPlane) {
122794
+ this._ignoreNextSectionPlaneDirUpdate = true;
122795
+ this._sectionPlane.dir = dir;
122796
+ }
122797
+ }
122767
122798
 
122768
- /**
122769
- * Sets if this FaceAlignedSectionPlanesControl is visible.
122770
- *
122771
- * @type {Boolean}
122772
- */
122773
- setVisible(visible = true) {
122774
- if (this._visible === visible) {
122775
- return;
122776
- }
122777
- this._visible = visible;
122778
- var id;
122779
- for (id in this._displayMeshes) {
122780
- if (this._displayMeshes.hasOwnProperty(id)) {
122781
- this._displayMeshes[id].visible = visible;
122782
- }
122783
- }
122784
- if (!visible) {
122785
- for (id in this._affordanceMeshes) {
122786
- if (this._affordanceMeshes.hasOwnProperty(id)) {
122787
- this._affordanceMeshes[id].visible = visible;
122788
- }
122789
- }
122790
- }
122791
- }
122799
+ /**
122800
+ * Sets if this FaceAlignedSectionPlanesControl is visible.
122801
+ *
122802
+ * @type {Boolean}
122803
+ */
122804
+ setVisible(visible = true) {
122805
+ if (this._visible === visible) {
122806
+ return;
122807
+ }
122808
+ this._visible = visible;
122809
+ var id;
122810
+ for (id in this._displayMeshes) {
122811
+ if (this._displayMeshes.hasOwnProperty(id)) {
122812
+ this._displayMeshes[id].visible = visible;
122813
+ }
122814
+ }
122815
+ if (!visible) {
122816
+ for (id in this._affordanceMeshes) {
122817
+ if (this._affordanceMeshes.hasOwnProperty(id)) {
122818
+ this._affordanceMeshes[id].visible = visible;
122819
+ }
122820
+ }
122821
+ }
122822
+ }
122792
122823
 
122793
- /**
122794
- * Gets if this FaceAlignedSectionPlanesControl is visible.
122795
- *
122796
- * @type {Boolean}
122797
- */
122798
- getVisible() {
122799
- return this._visible;
122800
- }
122824
+ /**
122825
+ * Gets if this FaceAlignedSectionPlanesControl is visible.
122826
+ *
122827
+ * @type {Boolean}
122828
+ */
122829
+ getVisible() {
122830
+ return this._visible;
122831
+ }
122801
122832
 
122802
- /**
122803
- * Sets if this FaceAlignedSectionPlanesControl is culled. This is called by FaceAlignedSectionPlanesPlugin to
122804
- * temporarily hide the FaceAlignedSectionPlanesControl while a snapshot is being taken by Viewer#getSnapshot().
122805
- * @param culled
122806
- */
122807
- setCulled(culled) {
122808
- var id;
122809
- for (id in this._displayMeshes) {
122810
- if (this._displayMeshes.hasOwnProperty(id)) {
122811
- this._displayMeshes[id].culled = culled;
122812
- }
122813
- }
122814
- if (!culled) {
122815
- for (id in this._affordanceMeshes) {
122816
- if (this._affordanceMeshes.hasOwnProperty(id)) {
122817
- this._affordanceMeshes[id].culled = culled;
122818
- }
122819
- }
122820
- }
122821
- }
122833
+ /**
122834
+ * Sets if this FaceAlignedSectionPlanesControl is culled. This is called by FaceAlignedSectionPlanesPlugin to
122835
+ * temporarily hide the FaceAlignedSectionPlanesControl while a snapshot is being taken by Viewer#getSnapshot().
122836
+ * @param culled
122837
+ */
122838
+ setCulled(culled) {
122839
+ var id;
122840
+ for (id in this._displayMeshes) {
122841
+ if (this._displayMeshes.hasOwnProperty(id)) {
122842
+ this._displayMeshes[id].culled = culled;
122843
+ }
122844
+ }
122845
+ if (!culled) {
122846
+ for (id in this._affordanceMeshes) {
122847
+ if (this._affordanceMeshes.hasOwnProperty(id)) {
122848
+ this._affordanceMeshes[id].culled = culled;
122849
+ }
122850
+ }
122851
+ }
122852
+ }
122822
122853
 
122823
- /**
122824
- * Builds the Entities that represent this FaceAlignedSectionPlanesControl.
122825
- * @private
122826
- */
122827
- _createNodes() {
122854
+ /**
122855
+ * Builds the Entities that represent this FaceAlignedSectionPlanesControl.
122856
+ * @private
122857
+ */
122858
+ _createNodes() {
122859
+ const NO_STATE_INHERIT = false;
122860
+ const scene = this._viewer.scene;
122861
+ const radius = 1.0;
122862
+ const tubeRadius = 0.01;
122863
+ const arrowRadius = 0.07;
122828
122864
 
122829
- const NO_STATE_INHERIT = false;
122830
- const scene = this._viewer.scene;
122831
- const radius = 1.0;
122832
- const tubeRadius = 0.01;
122833
- const arrowRadius = 0.07;
122865
+ this._rootNode = new Node$2(scene, {
122866
+ position: [0, 0, 0],
122867
+ scale: [5, 5, 5]
122868
+ });
122834
122869
 
122835
- this._rootNode = new Node$2(scene, {
122836
- position: [0, 0, 0],
122837
- scale: [5, 5, 5]
122838
- });
122870
+ const rootNode = this._rootNode;
122839
122871
 
122840
- const rootNode = this._rootNode;
122872
+ const shapes = {
122873
+ // Reusable geometries
122841
122874
 
122842
- const shapes = {// Reusable geometries
122875
+ arrowHead: new ReadableGeometry(
122876
+ rootNode,
122877
+ buildCylinderGeometry({
122878
+ radiusTop: 0.001,
122879
+ radiusBottom: arrowRadius,
122880
+ radialSegments: 32,
122881
+ heightSegments: 1,
122882
+ height: 0.2,
122883
+ openEnded: false
122884
+ })
122885
+ ),
122843
122886
 
122844
- arrowHead: new ReadableGeometry(rootNode, buildCylinderGeometry({
122845
- radiusTop: 0.001,
122846
- radiusBottom: arrowRadius,
122847
- radialSegments: 32,
122848
- heightSegments: 1,
122849
- height: 0.2,
122850
- openEnded: false
122851
- })),
122887
+ arrowHeadBig: new ReadableGeometry(
122888
+ rootNode,
122889
+ buildCylinderGeometry({
122890
+ radiusTop: 0.001,
122891
+ radiusBottom: 0.09,
122892
+ radialSegments: 32,
122893
+ heightSegments: 1,
122894
+ height: 0.25,
122895
+ openEnded: false
122896
+ })
122897
+ ),
122852
122898
 
122853
- arrowHeadBig: new ReadableGeometry(rootNode, buildCylinderGeometry({
122854
- radiusTop: 0.001,
122855
- radiusBottom: 0.09,
122856
- radialSegments: 32,
122857
- heightSegments: 1,
122858
- height: 0.25,
122859
- openEnded: false
122860
- })),
122899
+ axis: new ReadableGeometry(
122900
+ rootNode,
122901
+ buildCylinderGeometry({
122902
+ radiusTop: tubeRadius,
122903
+ radiusBottom: tubeRadius,
122904
+ radialSegments: 20,
122905
+ heightSegments: 1,
122906
+ height: radius,
122907
+ openEnded: false
122908
+ })
122909
+ )
122910
+ };
122861
122911
 
122862
- axis: new ReadableGeometry(rootNode, buildCylinderGeometry({
122863
- radiusTop: tubeRadius,
122864
- radiusBottom: tubeRadius,
122865
- radialSegments: 20,
122866
- heightSegments: 1,
122867
- height: radius,
122868
- openEnded: false
122869
- }))
122870
- };
122912
+ const materials = {
122913
+ // Reusable materials
122871
122914
 
122872
- const materials = { // Reusable materials
122915
+ red: new PhongMaterial(rootNode, {
122916
+ diffuse: [1, 0.0, 0.0],
122917
+ emissive: [1, 0.0, 0.0],
122918
+ ambient: [0.0, 0.0, 0.0],
122919
+ specular: [0.6, 0.6, 0.3],
122920
+ shininess: 80,
122921
+ lineWidth: 2
122922
+ }),
122873
122923
 
122874
- red: new PhongMaterial(rootNode, {
122875
- diffuse: [1, 0.0, 0.0],
122876
- emissive: [1, 0.0, 0.0],
122877
- ambient: [0.0, 0.0, 0.0],
122878
- specular: [.6, .6, .3],
122879
- shininess: 80,
122880
- lineWidth: 2
122881
- }),
122924
+ green: new PhongMaterial(rootNode, {
122925
+ diffuse: [0, 1.0, 0.0],
122926
+ emissive: [1, 0.0, 0.0],
122927
+ ambient: [0.0, 0.0, 0.0],
122928
+ specular: [0.6, 0.6, 0.3],
122929
+ shininess: 80,
122930
+ lineWidth: 2
122931
+ }),
122882
122932
 
122883
- green: new PhongMaterial(rootNode, {
122884
- diffuse: [0, 1.0, 0.0],
122885
- emissive: [1, 0.0, 0.0],
122886
- ambient: [0.0, 0.0, 0.0],
122887
- specular: [.6, .6, .3],
122888
- shininess: 80,
122889
- lineWidth: 2
122890
- }),
122933
+ blue: new PhongMaterial(rootNode, {
122934
+ diffuse: [0, 0.0, 1.0],
122935
+ emissive: [1, 0.0, 0.0],
122936
+ ambient: [0.0, 0.0, 0.0],
122937
+ specular: [0.6, 0.6, 0.3],
122938
+ shininess: 80,
122939
+ lineWidth: 2
122940
+ }),
122891
122941
 
122892
- blue: new PhongMaterial(rootNode, {
122893
- diffuse: [0, 0.0, 1.0],
122894
- emissive: [1, 0.0, 0.0],
122895
- ambient: [0.0, 0.0, 0.0],
122896
- specular: [.6, .6, .3],
122897
- shininess: 80,
122898
- lineWidth: 2
122899
- }),
122942
+ highlightRed: new EmphasisMaterial(rootNode, {
122943
+ // Emphasis for red rotation affordance hoop
122944
+ edges: false,
122945
+ fill: true,
122946
+ fillColor: [1, 0, 0],
122947
+ fillAlpha: 0.6
122948
+ })
122949
+ };
122900
122950
 
122901
- highlightRed: new EmphasisMaterial(rootNode, { // Emphasis for red rotation affordance hoop
122902
- edges: false,
122903
- fill: true,
122904
- fillColor: [1, 0, 0],
122905
- fillAlpha: 0.6
122906
- })
122907
- };
122951
+ this._displayMeshes = {
122952
+ plane: rootNode.addChild(
122953
+ new Mesh(rootNode, {
122954
+ geometry: new ReadableGeometry(rootNode, {
122955
+ primitive: "triangles",
122956
+ positions: [
122957
+ 0.5,
122958
+ 0.5,
122959
+ 0.0,
122960
+ 0.5,
122961
+ -0.5,
122962
+ 0.0, // 0
122963
+ -0.5,
122964
+ -0.5,
122965
+ 0.0,
122966
+ -0.5,
122967
+ 0.5,
122968
+ 0.0, // 1
122969
+ 0.5,
122970
+ 0.5,
122971
+ -0.0,
122972
+ 0.5,
122973
+ -0.5,
122974
+ -0.0, // 2
122975
+ -0.5,
122976
+ -0.5,
122977
+ -0.0,
122978
+ -0.5,
122979
+ 0.5,
122980
+ -0.0 // 3
122981
+ ],
122982
+ indices: [0, 1, 2, 2, 3, 0]
122983
+ }),
122984
+ material: new PhongMaterial(rootNode, {
122985
+ emissive: [0, 0.0, 0],
122986
+ diffuse: [0, 0, 0],
122987
+ backfaces: true
122988
+ }),
122989
+ opacity: 0.6,
122990
+ ghosted: true,
122991
+ pickable: false,
122992
+ collidable: true,
122993
+ clippable: false,
122994
+ visible: false,
122995
+ scale: [2.4, 2.4, 1]
122996
+ }),
122997
+ NO_STATE_INHERIT
122998
+ ),
122908
122999
 
122909
- this._displayMeshes = {
123000
+ planeFrame: rootNode.addChild(
123001
+ new Mesh(rootNode, {
123002
+ // Visible frame
123003
+ geometry: new ReadableGeometry(
123004
+ rootNode,
123005
+ buildTorusGeometry({
123006
+ center: [0, 0, 0],
123007
+ radius: 1.7,
123008
+ tube: tubeRadius * 2,
123009
+ radialSegments: 4,
123010
+ tubeSegments: 4,
123011
+ arc: Math.PI * 2.0
123012
+ })
123013
+ ),
123014
+ material: new PhongMaterial(rootNode, {
123015
+ emissive: [0, 0, 0],
123016
+ diffuse: [0, 0, 0],
123017
+ specular: [0, 0, 0],
123018
+ shininess: 0
123019
+ }),
123020
+ pickable: false,
123021
+ collidable: false,
123022
+ clippable: false,
123023
+ visible: false,
123024
+ scale: [1, 1, 0.1],
123025
+ rotation: [0, 0, 45]
123026
+ }),
123027
+ NO_STATE_INHERIT
123028
+ ),
122910
123029
 
122911
- plane: rootNode.addChild(new Mesh(rootNode, {
122912
- geometry: new ReadableGeometry(rootNode, {
122913
- primitive: "triangles",
122914
- positions: [
122915
- 0.5, 0.5, 0.0, 0.5, -0.5, 0.0, // 0
122916
- -0.5, -0.5, 0.0, -0.5, 0.5, 0.0, // 1
122917
- 0.5, 0.5, -0.0, 0.5, -0.5, -0.0, // 2
122918
- -0.5, -0.5, -0.0, -0.5, 0.5, -0.0 // 3
122919
- ],
122920
- indices: [0, 1, 2, 2, 3, 0]
122921
- }),
122922
- material: new PhongMaterial(rootNode, {
122923
- emissive: [0, 0.0, 0],
122924
- diffuse: [0, 0, 0],
122925
- backfaces: true
122926
- }),
122927
- opacity: 0.6,
122928
- ghosted: true,
122929
- pickable: false,
122930
- collidable: true,
122931
- clippable: false,
122932
- visible: false,
122933
- scale: [2.4, 2.4, 1]
122934
- }), NO_STATE_INHERIT),
122935
-
122936
- planeFrame: rootNode.addChild(new Mesh(rootNode, { // Visible frame
122937
- geometry: new ReadableGeometry(rootNode, buildTorusGeometry({
122938
- center: [0, 0, 0],
122939
- radius: 1.7,
122940
- tube: tubeRadius * 2,
122941
- radialSegments: 4,
122942
- tubeSegments: 4,
122943
- arc: Math.PI * 2.0
122944
- })),
122945
- material: new PhongMaterial(rootNode, {
122946
- emissive: [0, 0, 0],
122947
- diffuse: [0, 0, 0],
122948
- specular: [0, 0, 0],
122949
- shininess: 0
122950
- }),
122951
- pickable: false,
122952
- collidable: false,
122953
- clippable: false,
122954
- visible: false,
122955
- scale: [1, 1, .1],
122956
- rotation: [0, 0, 45]
122957
- }), NO_STATE_INHERIT),
122958
-
122959
- center: rootNode.addChild(new Mesh(rootNode, {
122960
- geometry: new ReadableGeometry(rootNode, buildSphereGeometry({
122961
- radius: 0.05
122962
- })),
122963
- material: materials.center,
122964
- pickable: false,
122965
- collidable: true,
122966
- clippable: false,
122967
- visible: false
122968
- }), NO_STATE_INHERIT),
122969
-
122970
- zAxisArrow: rootNode.addChild(new Mesh(rootNode, {
122971
- geometry: shapes.arrowHead,
122972
- material: materials.blue,
122973
- matrix: (function () {
122974
- const translate = math.translateMat4c(0, radius + .1, 0, math.identityMat4());
122975
- const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [0.8, 0, 0], math.identityMat4());
122976
- return math.mulMat4(rotate, translate, math.identityMat4());
122977
- })(),
122978
- pickable: false,
122979
- collidable: true,
122980
- clippable: false,
122981
- visible: false
122982
- }), NO_STATE_INHERIT),
122983
-
122984
- zShaft: rootNode.addChild(new Mesh(rootNode, {
122985
- geometry: shapes.axis,
122986
- material: materials.blue,
122987
- matrix: (function () {
122988
- const translate = math.translateMat4c(0, radius / 2, 0, math.identityMat4());
122989
- const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
122990
- return math.mulMat4(rotate, translate, math.identityMat4());
122991
- })(),
122992
- clippable: false,
122993
- pickable: false,
122994
- collidable: true,
122995
- visible: false
122996
- }), NO_STATE_INHERIT)
122997
- };
123030
+ center: rootNode.addChild(
123031
+ new Mesh(rootNode, {
123032
+ geometry: new ReadableGeometry(
123033
+ rootNode,
123034
+ buildSphereGeometry({
123035
+ radius: 0.05
123036
+ })
123037
+ ),
123038
+ material: materials.center,
123039
+ pickable: false,
123040
+ collidable: true,
123041
+ clippable: false,
123042
+ visible: false
123043
+ }),
123044
+ NO_STATE_INHERIT
123045
+ ),
122998
123046
 
122999
- this._affordanceMeshes = {
123047
+ zAxisArrow: rootNode.addChild(
123048
+ new Mesh(rootNode, {
123049
+ geometry: shapes.arrowHead,
123050
+ material: materials.blue,
123051
+ matrix: (function () {
123052
+ const translate = math.translateMat4c(0, radius + 0.1, 0, math.identityMat4());
123053
+ const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [0.8, 0, 0], math.identityMat4());
123054
+ return math.mulMat4(rotate, translate, math.identityMat4());
123055
+ })(),
123056
+ pickable: false,
123057
+ collidable: true,
123058
+ clippable: false,
123059
+ visible: false
123060
+ }),
123061
+ NO_STATE_INHERIT
123062
+ ),
123000
123063
 
123001
- planeFrame: rootNode.addChild(new Mesh(rootNode, {
123002
- geometry: new ReadableGeometry(rootNode, buildTorusGeometry({
123003
- center: [0, 0, 0],
123004
- radius: 2,
123005
- tube: tubeRadius,
123006
- radialSegments: 4,
123007
- tubeSegments: 4,
123008
- arc: Math.PI * 2.0
123009
- })),
123010
- material: new PhongMaterial(rootNode, {
123011
- ambient: [1, 1, 1],
123012
- diffuse: [0, 0, 0],
123013
- emissive: [1, 1, 0]
123014
- }),
123015
- highlighted: true,
123016
- highlightMaterial: new EmphasisMaterial(rootNode, {
123017
- edges: false,
123018
- filled: true,
123019
- fillColor: [1, 1, 0],
123020
- fillAlpha: 1.0
123021
- }),
123022
- pickable: false,
123023
- collidable: false,
123024
- clippable: false,
123025
- visible: false,
123026
- scale: [1, 1, 1],
123027
- rotation: [0, 0, 45]
123028
- }), NO_STATE_INHERIT),
123029
-
123030
- zAxisArrow: rootNode.addChild(new Mesh(rootNode, {
123031
- geometry: shapes.arrowHeadBig,
123032
- material: materials.blue,
123033
- matrix: (function () {
123034
- const translate = math.translateMat4c(0, radius + .1, 0, math.identityMat4());
123035
- const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [0.8, 0, 0], math.identityMat4());
123036
- return math.mulMat4(rotate, translate, math.identityMat4());
123037
- })(),
123038
- pickable: false,
123039
- collidable: true,
123040
- clippable: false,
123041
- visible: false
123042
- }), NO_STATE_INHERIT)
123043
- };
123044
- }
123064
+ zShaft: rootNode.addChild(
123065
+ new Mesh(rootNode, {
123066
+ geometry: shapes.axis,
123067
+ material: materials.blue,
123068
+ matrix: (function () {
123069
+ const translate = math.translateMat4c(0, radius / 2, 0, math.identityMat4());
123070
+ const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
123071
+ return math.mulMat4(rotate, translate, math.identityMat4());
123072
+ })(),
123073
+ clippable: false,
123074
+ pickable: false,
123075
+ collidable: true,
123076
+ visible: false
123077
+ }),
123078
+ NO_STATE_INHERIT
123079
+ )
123080
+ };
123045
123081
 
123046
- _bindEvents() {
123082
+ this._affordanceMeshes = {
123083
+ planeFrame: rootNode.addChild(
123084
+ new Mesh(rootNode, {
123085
+ geometry: new ReadableGeometry(
123086
+ rootNode,
123087
+ buildTorusGeometry({
123088
+ center: [0, 0, 0],
123089
+ radius: 2,
123090
+ tube: tubeRadius,
123091
+ radialSegments: 4,
123092
+ tubeSegments: 4,
123093
+ arc: Math.PI * 2.0
123094
+ })
123095
+ ),
123096
+ material: new PhongMaterial(rootNode, {
123097
+ ambient: [1, 1, 1],
123098
+ diffuse: [0, 0, 0],
123099
+ emissive: [1, 1, 0]
123100
+ }),
123101
+ highlighted: true,
123102
+ highlightMaterial: new EmphasisMaterial(rootNode, {
123103
+ edges: false,
123104
+ filled: true,
123105
+ fillColor: [1, 1, 0],
123106
+ fillAlpha: 1.0
123107
+ }),
123108
+ pickable: false,
123109
+ collidable: false,
123110
+ clippable: false,
123111
+ visible: false,
123112
+ scale: [1, 1, 1],
123113
+ rotation: [0, 0, 45]
123114
+ }),
123115
+ NO_STATE_INHERIT
123116
+ ),
123047
123117
 
123048
- const rootNode = this._rootNode;
123049
- const lastCanvasPos = math.vec2();
123050
- const camera = this._viewer.camera;
123051
- const scene = this._viewer.scene;
123118
+ zAxisArrow: rootNode.addChild(
123119
+ new Mesh(rootNode, {
123120
+ geometry: shapes.arrowHeadBig,
123121
+ material: materials.blue,
123122
+ matrix: (function () {
123123
+ const translate = math.translateMat4c(0, radius + 0.1, 0, math.identityMat4());
123124
+ const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [0.8, 0, 0], math.identityMat4());
123125
+ return math.mulMat4(rotate, translate, math.identityMat4());
123126
+ })(),
123127
+ pickable: false,
123128
+ collidable: true,
123129
+ clippable: false,
123130
+ visible: false
123131
+ }),
123132
+ NO_STATE_INHERIT
123133
+ )
123134
+ };
123135
+ }
123052
123136
 
123053
- let deltaUpdate = 0;
123054
- let waitForTick = false;
123137
+ _bindEvents() {
123138
+ const rootNode = this._rootNode;
123139
+ const lastCanvasPos = math.vec2();
123140
+ const camera = this._viewer.camera;
123141
+ const scene = this._viewer.scene;
123055
123142
 
123056
- { // Keep gizmo screen size constant
123143
+ let deltaUpdate = 0;
123144
+ let waitForTick = false;
123057
123145
 
123058
- const tempVec3a = math.vec3([0, 0, 0]);
123059
- let lastDist = -1;
123146
+ {
123147
+ // Keep gizmo screen size constant
123060
123148
 
123061
- this._onCameraViewMatrix = scene.camera.on("viewMatrix", () => {
123062
- });
123149
+ const tempVec3a = math.vec3([0, 0, 0]);
123150
+ let lastDist = -1;
123063
123151
 
123064
- this._onCameraProjMatrix = scene.camera.on("projMatrix", () => {
123065
- });
123152
+ this._onCameraViewMatrix = scene.camera.on("viewMatrix", () => {
123153
+ });
123066
123154
 
123067
- this._onSceneTick = scene.on("tick", () => {
123155
+ this._onCameraProjMatrix = scene.camera.on("projMatrix", () => {
123156
+ });
123068
123157
 
123069
- waitForTick = false;
123070
- const dist = Math.abs(math.lenVec3(math.subVec3(scene.camera.eye, this._pos, tempVec3a)));
123158
+ this._onSceneTick = scene.on("tick", () => {
123159
+ waitForTick = false;
123160
+ const dist = Math.abs(math.lenVec3(math.subVec3(scene.camera.eye, this._pos, tempVec3a)));
123071
123161
 
123072
- if (dist !== lastDist) {
123073
- if (camera.projection === "perspective") {
123074
- const worldSize = (Math.tan(camera.perspective.fov * math.DEGTORAD)) * dist;
123075
- const size = 0.07 * worldSize;
123076
- rootNode.scale = [size, size, size];
123077
- lastDist = dist;
123078
- }
123079
- }
123162
+ if (dist !== lastDist) {
123163
+ if (camera.projection === "perspective") {
123164
+ const worldSize = Math.tan(camera.perspective.fov * math.DEGTORAD) * dist;
123165
+ const size = 0.07 * worldSize;
123166
+ rootNode.scale = [size, size, size];
123167
+ lastDist = dist;
123168
+ }
123169
+ }
123080
123170
 
123081
- if (camera.projection === "ortho") {
123082
- const worldSize = camera.ortho.scale / 10;
123083
- const size = worldSize;
123084
- rootNode.scale = [size, size, size];
123085
- lastDist = dist;
123086
- }
123171
+ if (camera.projection === "ortho") {
123172
+ const worldSize = camera.ortho.scale / 10;
123173
+ const size = worldSize;
123174
+ rootNode.scale = [size, size, size];
123175
+ lastDist = dist;
123176
+ }
123087
123177
 
123088
- if (deltaUpdate !== 0) {
123089
- moveSectionPlane(deltaUpdate);
123090
- deltaUpdate = 0;
123091
- }
123092
- });
123093
- }
123178
+ if (deltaUpdate !== 0) {
123179
+ moveSectionPlane(deltaUpdate);
123180
+ deltaUpdate = 0;
123181
+ }
123182
+ });
123183
+ }
123094
123184
 
123095
- const getClickCoordsWithinElement = (function () {
123096
- const canvasPos = new Float64Array(2);
123097
- return function (event) {
123098
- if (!event) {
123099
- event = window.event;
123100
- canvasPos[0] = event.x;
123101
- canvasPos[1] = event.y;
123102
- } else {
123103
- var element = event.target;
123104
- var totalOffsetLeft = 0;
123105
- var totalOffsetTop = 0;
123106
-
123107
- while (element.offsetParent) {
123108
- totalOffsetLeft += element.offsetLeft;
123109
- totalOffsetTop += element.offsetTop;
123110
- element = element.offsetParent;
123111
- }
123112
- canvasPos[0] = event.pageX - totalOffsetLeft;
123113
- canvasPos[1] = event.pageY - totalOffsetTop;
123114
- }
123115
- return canvasPos;
123116
- };
123117
- })();
123185
+ const getClickCoordsWithinElement = (function () {
123186
+ const canvasPos = new Float64Array(2);
123187
+ return function (event) {
123188
+ if (!event) {
123189
+ event = window.event;
123190
+ canvasPos[0] = event.x;
123191
+ canvasPos[1] = event.y;
123192
+ } else {
123193
+ var element = event.target;
123194
+ var totalOffsetLeft = 0;
123195
+ var totalOffsetTop = 0;
123118
123196
 
123119
- const moveSectionPlane = (delta) => {
123120
- const pos = this._sectionPlane.pos;
123121
- const dir = this._sectionPlane.dir;
123122
- math.addVec3(pos, math.mulVec3Scalar(dir, 0.1 * delta * this._plugin.getDragSensitivity(), math.vec3()));
123123
- this._sectionPlane.pos = pos;
123124
- };
123197
+ while (element.offsetParent) {
123198
+ totalOffsetLeft += element.offsetLeft;
123199
+ totalOffsetTop += element.offsetTop;
123200
+ element = element.offsetParent;
123201
+ }
123202
+ canvasPos[0] = event.pageX - totalOffsetLeft;
123203
+ canvasPos[1] = event.pageY - totalOffsetTop;
123204
+ }
123205
+ return canvasPos;
123206
+ };
123207
+ })();
123125
123208
 
123126
- {
123127
- let down = false;
123209
+ const moveSectionPlane = (delta) => {
123210
+ const pos = this._sectionPlane.pos;
123211
+ const dir = this._sectionPlane.dir;
123212
+ math.addVec3(pos, math.mulVec3Scalar(dir, 0.1 * delta * this._plugin.getDragSensitivity(), math.vec3()));
123213
+ this._sectionPlane.pos = pos;
123214
+ };
123128
123215
 
123129
- this._plugin._controlElement.addEventListener("mousedown", this._canvasMouseDownListener = (e) => {
123130
- e.preventDefault();
123131
- if (!this._visible) {
123132
- return;
123133
- }
123134
- this._viewer.cameraControl.pointerEnabled = false;
123135
- switch (e.which) {
123136
- case 1: // Left button
123137
- down = true;
123138
- var canvasPos = getClickCoordsWithinElement(e);
123139
- lastCanvasPos[0] = canvasPos[0];
123140
- lastCanvasPos[1] = canvasPos[1];
123141
- break;
123142
- }
123143
- });
123216
+ {
123217
+ let down = false;
123144
123218
 
123145
- this._plugin._controlElement.addEventListener("mousemove", this._canvasMouseMoveListener = (e) => {
123146
- if (!this._visible) {
123147
- return;
123148
- }
123149
- if (!down) {
123150
- return;
123151
- }
123152
- if (waitForTick) { // Limit changes detection to one per frame
123153
- return;
123154
- }
123155
- var canvasPos = getClickCoordsWithinElement(e);
123156
- const x = canvasPos[0];
123157
- const y = canvasPos[1];
123158
- moveSectionPlane(y - lastCanvasPos[1]);
123159
- lastCanvasPos[0] = x;
123160
- lastCanvasPos[1] = y;
123161
- });
123219
+ this._plugin._controlElement.addEventListener(
123220
+ "mousedown",
123221
+ (this._canvasMouseDownListener = (e) => {
123222
+ e.preventDefault();
123223
+ if (!this._visible) {
123224
+ return;
123225
+ }
123226
+ this._viewer.cameraControl.pointerEnabled = false;
123227
+ switch (e.which) {
123228
+ case 1: // Left button
123229
+ down = true;
123230
+ var canvasPos = getClickCoordsWithinElement(e);
123231
+ lastCanvasPos[0] = canvasPos[0];
123232
+ lastCanvasPos[1] = canvasPos[1];
123233
+ break;
123234
+ }
123235
+ })
123236
+ );
123162
123237
 
123163
- this._plugin._controlElement.addEventListener("mouseup", this._canvasMouseUpListener = (e) => {
123164
- if (!this._visible) {
123165
- return;
123166
- }
123167
- this._viewer.cameraControl.pointerEnabled = true;
123168
- if (!down) {
123169
- return;
123170
- }
123171
- switch (e.which) {
123172
- }
123173
- down = false;
123174
- });
123238
+ this._plugin._controlElement.addEventListener(
123239
+ "mousemove",
123240
+ (this._canvasMouseMoveListener = (e) => {
123241
+ if (!this._visible) {
123242
+ return;
123243
+ }
123244
+ if (!down) {
123245
+ return;
123246
+ }
123247
+ if (waitForTick) {
123248
+ // Limit changes detection to one per frame
123249
+ return;
123250
+ }
123251
+ var canvasPos = getClickCoordsWithinElement(e);
123252
+ const x = canvasPos[0];
123253
+ const y = canvasPos[1];
123254
+ moveSectionPlane(y - lastCanvasPos[1]);
123255
+ lastCanvasPos[0] = x;
123256
+ lastCanvasPos[1] = y;
123257
+ })
123258
+ );
123175
123259
 
123176
- this._plugin._controlElement.addEventListener("wheel", this._canvasWheelListener = (e) => {
123177
- if (!this._visible) {
123178
- return;
123179
- }
123180
- deltaUpdate += Math.max(-1, Math.min(1, -e.deltaY * 40));
123181
- });
123182
- }
123260
+ this._plugin._controlElement.addEventListener(
123261
+ "mouseup",
123262
+ (this._canvasMouseUpListener = (e) => {
123263
+ if (!this._visible) {
123264
+ return;
123265
+ }
123266
+ this._viewer.cameraControl.pointerEnabled = true;
123267
+ if (!down) {
123268
+ return;
123269
+ }
123270
+ switch (e.which) {
123271
+ }
123272
+ down = false;
123273
+ })
123274
+ );
123183
123275
 
123184
- {
123185
- let touchStartY, touchEndY;
123186
- let lastTouchY = null;
123276
+ this._plugin._controlElement.addEventListener(
123277
+ "wheel",
123278
+ (this._canvasWheelListener = (e) => {
123279
+ if (!this._visible) {
123280
+ return;
123281
+ }
123282
+ deltaUpdate += Math.max(-1, Math.min(1, -e.deltaY * 40));
123283
+ })
123284
+ );
123285
+ }
123187
123286
 
123188
- this._plugin._controlElement.addEventListener("touchstart", this._handleTouchStart = (e) => {
123189
- e.stopPropagation();
123190
- e.preventDefault();
123191
- if (!this._visible) {
123192
- return;
123193
- }
123194
- touchStartY = e.touches[0].clientY;
123195
- lastTouchY = touchStartY;
123196
- deltaUpdate = 0;
123197
- });
123287
+ {
123288
+ let touchStartY, touchEndY;
123289
+ let lastTouchY = null;
123198
123290
 
123199
- this._plugin._controlElement.addEventListener("touchmove", this._handleTouchMove = (e) => {
123200
- e.stopPropagation();
123201
- e.preventDefault();
123202
- if (!this._visible) {
123203
- return;
123204
- }
123205
- if (waitForTick) { // Limit changes detection to one per frame
123206
- return;
123207
- }
123208
- waitForTick = true;
123209
- touchEndY = e.touches[0].clientY;
123210
- if (lastTouchY !== null) {
123211
- deltaUpdate += touchEndY - lastTouchY;
123212
- }
123213
- lastTouchY = touchEndY;
123214
- });
123291
+ this._plugin._controlElement.addEventListener(
123292
+ "touchstart",
123293
+ (this._handleTouchStart = (e) => {
123294
+ e.stopPropagation();
123295
+ e.preventDefault();
123296
+ if (!this._visible) {
123297
+ return;
123298
+ }
123299
+ touchStartY = e.touches[0].clientY;
123300
+ lastTouchY = touchStartY;
123301
+ deltaUpdate = 0;
123302
+ })
123303
+ );
123215
123304
 
123216
- this._plugin._controlElement.addEventListener("touchend", this._handleTouchEnd = (e) => {
123217
- e.stopPropagation();
123218
- e.preventDefault();
123219
- if (!this._visible) {
123220
- return;
123221
- }
123222
- touchStartY = null;
123223
- touchEndY = null;
123224
- deltaUpdate = 0;
123225
- });
123226
- }
123227
- }
123305
+ this._plugin._controlElement.addEventListener(
123306
+ "touchmove",
123307
+ (this._handleTouchMove = (e) => {
123308
+ e.stopPropagation();
123309
+ e.preventDefault();
123310
+ if (!this._visible) {
123311
+ return;
123312
+ }
123313
+ if (waitForTick) {
123314
+ // Limit changes detection to one per frame
123315
+ return;
123316
+ }
123317
+ waitForTick = true;
123318
+ touchEndY = e.touches[0].clientY;
123319
+ if (lastTouchY !== null) {
123320
+ deltaUpdate += touchEndY - lastTouchY;
123321
+ }
123322
+ lastTouchY = touchEndY;
123323
+ })
123324
+ );
123228
123325
 
123229
- _destroy() {
123230
- this._unbindEvents();
123231
- this._destroyNodes();
123232
- }
123326
+ this._plugin._controlElement.addEventListener(
123327
+ "touchend",
123328
+ (this._handleTouchEnd = (e) => {
123329
+ e.stopPropagation();
123330
+ e.preventDefault();
123331
+ if (!this._visible) {
123332
+ return;
123333
+ }
123334
+ touchStartY = null;
123335
+ touchEndY = null;
123336
+ deltaUpdate = 0;
123337
+ })
123338
+ );
123339
+ this._plugin._controlElement.addEventListener("touchcancel", this._handleTouchEnd);
123340
+ }
123341
+ }
123233
123342
 
123234
- _unbindEvents() {
123343
+ _destroy() {
123344
+ this._unbindEvents();
123345
+ this._destroyNodes();
123346
+ }
123235
123347
 
123236
- const viewer = this._viewer;
123237
- const scene = viewer.scene;
123238
- const canvas = scene.canvas.canvas;
123239
- const camera = viewer.camera;
123240
- const controlElement = this._plugin._controlElement;
123348
+ _unbindEvents() {
123349
+ const viewer = this._viewer;
123350
+ const scene = viewer.scene;
123351
+ const canvas = scene.canvas.canvas;
123352
+ const camera = viewer.camera;
123353
+ const controlElement = this._plugin._controlElement;
123241
123354
 
123242
- scene.off(this._onSceneTick);
123355
+ scene.off(this._onSceneTick);
123243
123356
 
123244
- canvas.removeEventListener("mousedown", this._canvasMouseDownListener);
123245
- canvas.removeEventListener("mousemove", this._canvasMouseMoveListener);
123246
- canvas.removeEventListener("mouseup", this._canvasMouseUpListener);
123247
- canvas.removeEventListener("wheel", this._canvasWheelListener);
123357
+ canvas.removeEventListener("mousedown", this._canvasMouseDownListener);
123358
+ canvas.removeEventListener("mousemove", this._canvasMouseMoveListener);
123359
+ canvas.removeEventListener("mouseup", this._canvasMouseUpListener);
123360
+ canvas.removeEventListener("wheel", this._canvasWheelListener);
123248
123361
 
123249
- controlElement.removeEventListener("touchstart", this._handleTouchStart);
123250
- controlElement.removeEventListener("touchmove", this._handleTouchMove);
123251
- controlElement.removeEventListener("touchend", this._handleTouchEnd);
123362
+ controlElement.removeEventListener("touchstart", this._handleTouchStart);
123363
+ controlElement.removeEventListener("touchmove", this._handleTouchMove);
123364
+ controlElement.removeEventListener("touchend", this._handleTouchEnd);
123365
+ controlElement.removeEventListener("touchcancel", this._handleTouchEnd);
123252
123366
 
123253
- camera.off(this._onCameraViewMatrix);
123254
- camera.off(this._onCameraProjMatrix);
123255
- }
123367
+ camera.off(this._onCameraViewMatrix);
123368
+ camera.off(this._onCameraProjMatrix);
123369
+ }
123256
123370
 
123257
- _destroyNodes() {
123258
- this._setSectionPlane(null);
123259
- this._rootNode.destroy();
123260
- this._displayMeshes = {};
123261
- this._affordanceMeshes = {};
123262
- }
123371
+ _destroyNodes() {
123372
+ this._setSectionPlane(null);
123373
+ this._rootNode.destroy();
123374
+ this._displayMeshes = {};
123375
+ this._affordanceMeshes = {};
123376
+ }
123263
123377
  }
123264
123378
 
123265
123379
  /**
@@ -123432,235 +123546,241 @@ class Plane {
123432
123546
  * @private
123433
123547
  */
123434
123548
  class Overview {
123549
+ /**
123550
+ * @private
123551
+ */
123552
+ constructor(plugin, cfg) {
123553
+ if (!cfg.onHoverEnterPlane || !cfg.onHoverLeavePlane || !cfg.onClickedNothing || !cfg.onClickedPlane) {
123554
+ throw "Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";
123555
+ }
123435
123556
 
123436
- /**
123437
- * @private
123438
- */
123439
- constructor(plugin, cfg) {
123440
-
123441
- if (!cfg.onHoverEnterPlane || !cfg.onHoverLeavePlane || !cfg.onClickedNothing || !cfg.onClickedPlane) {
123442
- throw "Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";
123443
- }
123444
-
123445
- /**
123446
- * The {@link FaceAlignedSectionPlanesPlugin} that owns this SectionPlanesOverview.
123447
- *
123448
- * @type {FaceAlignedSectionPlanesPlugin}
123449
- */
123450
- this.plugin = plugin;
123557
+ /**
123558
+ * The {@link FaceAlignedSectionPlanesPlugin} that owns this SectionPlanesOverview.
123559
+ *
123560
+ * @type {FaceAlignedSectionPlanesPlugin}
123561
+ */
123562
+ this.plugin = plugin;
123451
123563
 
123452
- this._viewer = plugin.viewer;
123564
+ this._viewer = plugin.viewer;
123453
123565
 
123454
- this._onHoverEnterPlane = cfg.onHoverEnterPlane;
123455
- this._onHoverLeavePlane = cfg.onHoverLeavePlane;
123456
- this._onClickedNothing = cfg.onClickedNothing;
123457
- this._onClickedPlane = cfg.onClickedPlane;
123458
- this._visible = true;
123566
+ this._onHoverEnterPlane = cfg.onHoverEnterPlane;
123567
+ this._onHoverLeavePlane = cfg.onHoverLeavePlane;
123568
+ this._onClickedNothing = cfg.onClickedNothing;
123569
+ this._onClickedPlane = cfg.onClickedPlane;
123570
+ this._visible = true;
123459
123571
 
123460
- this._planes = {};
123572
+ this._planes = {};
123461
123573
 
123462
- //--------------------------------------------------------------------------------------------------------------
123463
- // Init canvas
123464
- //--------------------------------------------------------------------------------------------------------------
123574
+ //--------------------------------------------------------------------------------------------------------------
123575
+ // Init canvas
123576
+ //--------------------------------------------------------------------------------------------------------------
123465
123577
 
123466
- this._canvas = cfg.overviewCanvas;
123578
+ this._canvas = cfg.overviewCanvas;
123467
123579
 
123468
- //--------------------------------------------------------------------------------------------------------------
123469
- // Init scene
123470
- //--------------------------------------------------------------------------------------------------------------
123580
+ //--------------------------------------------------------------------------------------------------------------
123581
+ // Init scene
123582
+ //--------------------------------------------------------------------------------------------------------------
123471
123583
 
123472
- this._scene = new Scene(this._viewer, {
123473
- canvasId: this._canvas.id,
123474
- transparent: true
123475
- });
123476
- this._scene.clearLights();
123477
- new DirLight(this._scene, {
123478
- dir: [0.4, -0.4, 0.8],
123479
- color: [0.8, 1.0, 1.0],
123480
- intensity: 1.0,
123481
- space: "view"
123482
- });
123483
- new DirLight(this._scene, {
123484
- dir: [-0.8, -0.3, -0.4],
123485
- color: [0.8, 0.8, 0.8],
123486
- intensity: 1.0,
123487
- space: "view"
123488
- });
123489
- new DirLight(this._scene, {
123490
- dir: [0.8, -0.6, -0.8],
123491
- color: [1.0, 1.0, 1.0],
123492
- intensity: 1.0,
123493
- space: "view"
123494
- });
123584
+ this._scene = new Scene(this._viewer, {
123585
+ canvasId: this._canvas.id,
123586
+ transparent: true
123587
+ });
123588
+ this._scene.clearLights();
123589
+ new DirLight(this._scene, {
123590
+ dir: [0.4, -0.4, 0.8],
123591
+ color: [0.8, 1.0, 1.0],
123592
+ intensity: 1.0,
123593
+ space: "view"
123594
+ });
123595
+ new DirLight(this._scene, {
123596
+ dir: [-0.8, -0.3, -0.4],
123597
+ color: [0.8, 0.8, 0.8],
123598
+ intensity: 1.0,
123599
+ space: "view"
123600
+ });
123601
+ new DirLight(this._scene, {
123602
+ dir: [0.8, -0.6, -0.8],
123603
+ color: [1.0, 1.0, 1.0],
123604
+ intensity: 1.0,
123605
+ space: "view"
123606
+ });
123495
123607
 
123496
- this._scene.camera;
123497
- this._scene.camera.perspective.fov = 70;
123608
+ this._scene.camera;
123609
+ this._scene.camera.perspective.fov = 70;
123498
123610
 
123499
- this._zUp = false;
123611
+ this._zUp = false;
123500
123612
 
123501
- //--------------------------------------------------------------------------------------------------------------
123502
- // Synchronize overview scene camera with viewer camera
123503
- //--------------------------------------------------------------------------------------------------------------
123613
+ //--------------------------------------------------------------------------------------------------------------
123614
+ // Synchronize overview scene camera with viewer camera
123615
+ //--------------------------------------------------------------------------------------------------------------
123504
123616
 
123505
- {
123506
- const camera = this._scene.camera;
123507
- const matrix = math.rotationMat4c(-90 * math.DEGTORAD, 1, 0, 0);
123508
- const eyeLookVec = math.vec3();
123509
- const eyeLookVecOverview = math.vec3();
123510
- const upOverview = math.vec3();
123511
-
123512
- this._synchCamera = () => {
123513
- const eye = this._viewer.camera.eye;
123514
- const look = this._viewer.camera.look;
123515
- const up = this._viewer.camera.up;
123516
- math.mulVec3Scalar(math.normalizeVec3(math.subVec3(eye, look, eyeLookVec)), 7);
123517
- if (this._zUp) { // +Z up
123518
- math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
123519
- math.transformVec3(matrix, up, upOverview);
123520
- camera.look = [0, 0, 0];
123521
- camera.eye = math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
123522
- camera.up = math.transformPoint3(matrix, up, upOverview);
123523
- } else { // +Y up
123524
- camera.look = [0, 0, 0];
123525
- camera.eye = eyeLookVec;
123526
- camera.up = up;
123527
- }
123528
- };
123529
- }
123617
+ {
123618
+ const camera = this._scene.camera;
123619
+ const matrix = math.rotationMat4c(-90 * math.DEGTORAD, 1, 0, 0);
123620
+ const eyeLookVec = math.vec3();
123621
+ const eyeLookVecOverview = math.vec3();
123622
+ const upOverview = math.vec3();
123623
+
123624
+ this._synchCamera = () => {
123625
+ const eye = this._viewer.camera.eye;
123626
+ const look = this._viewer.camera.look;
123627
+ const up = this._viewer.camera.up;
123628
+ math.mulVec3Scalar(math.normalizeVec3(math.subVec3(eye, look, eyeLookVec)), 7);
123629
+ if (this._zUp) {
123630
+ // +Z up
123631
+ math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
123632
+ math.transformVec3(matrix, up, upOverview);
123633
+ camera.look = [0, 0, 0];
123634
+ camera.eye = math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
123635
+ camera.up = math.transformPoint3(matrix, up, upOverview);
123636
+ } else {
123637
+ // +Y up
123638
+ camera.look = [0, 0, 0];
123639
+ camera.eye = eyeLookVec;
123640
+ camera.up = up;
123641
+ }
123642
+ };
123643
+ }
123530
123644
 
123531
- this._onViewerCameraMatrix = this._viewer.camera.on("matrix", this._synchCamera);
123645
+ this._onViewerCameraMatrix = this._viewer.camera.on("matrix", this._synchCamera);
123532
123646
 
123533
- this._onViewerCameraWorldAxis = this._viewer.camera.on("worldAxis", this._synchCamera);
123647
+ this._onViewerCameraWorldAxis = this._viewer.camera.on("worldAxis", this._synchCamera);
123534
123648
 
123535
- this._onViewerCameraFOV = this._viewer.camera.perspective.on("fov", (fov) => {
123536
- this._scene.camera.perspective.fov = fov;
123537
- });
123649
+ this._onViewerCameraFOV = this._viewer.camera.perspective.on("fov", (fov) => {
123650
+ this._scene.camera.perspective.fov = fov;
123651
+ });
123538
123652
 
123539
- //--------------------------------------------------------------------------------------------------------------
123540
- // Bind overview canvas events
123541
- //--------------------------------------------------------------------------------------------------------------
123653
+ //--------------------------------------------------------------------------------------------------------------
123654
+ // Bind overview canvas events
123655
+ //--------------------------------------------------------------------------------------------------------------
123542
123656
 
123543
- {
123544
- var hoveredEntity = null;
123657
+ {
123658
+ var hoveredEntity = null;
123545
123659
 
123546
- this._onInputMouseMove = this._scene.input.on("mousemove", (coords) => {
123547
- const hit = this._scene.pick({
123548
- canvasPos: coords
123549
- });
123550
- if (hit) {
123551
- if (!hoveredEntity || hit.entity.id !== hoveredEntity.id) {
123552
- if (hoveredEntity) {
123553
- const plane = this._planes[hoveredEntity.id];
123554
- if (plane) {
123555
- this._onHoverLeavePlane(hoveredEntity.id);
123556
- }
123557
- }
123558
- hoveredEntity = hit.entity;
123559
- const plane = this._planes[hoveredEntity.id];
123560
- if (plane) {
123561
- this._onHoverEnterPlane(hoveredEntity.id);
123562
- }
123563
- }
123564
- } else {
123565
- if (hoveredEntity) {
123566
- this._onHoverLeavePlane(hoveredEntity.id);
123567
- hoveredEntity = null;
123568
- }
123569
- }
123570
- });
123660
+ this._onInputMouseMove = this._scene.input.on("mousemove", (coords) => {
123661
+ const hit = this._scene.pick({
123662
+ canvasPos: coords
123663
+ });
123664
+ if (hit) {
123665
+ if (!hoveredEntity || hit.entity.id !== hoveredEntity.id) {
123666
+ if (hoveredEntity) {
123667
+ const plane = this._planes[hoveredEntity.id];
123668
+ if (plane) {
123669
+ this._onHoverLeavePlane(hoveredEntity.id);
123670
+ }
123671
+ }
123672
+ hoveredEntity = hit.entity;
123673
+ const plane = this._planes[hoveredEntity.id];
123674
+ if (plane) {
123675
+ this._onHoverEnterPlane(hoveredEntity.id);
123676
+ }
123677
+ }
123678
+ } else {
123679
+ if (hoveredEntity) {
123680
+ this._onHoverLeavePlane(hoveredEntity.id);
123681
+ hoveredEntity = null;
123682
+ }
123683
+ }
123684
+ });
123571
123685
 
123572
- this._scene.canvas.canvas.addEventListener("mouseup", this._onCanvasMouseUp = () => {
123573
- if (hoveredEntity) {
123574
- const plane = this._planes[hoveredEntity.id];
123575
- if (plane) {
123576
- this._onClickedPlane(hoveredEntity.id);
123577
- }
123578
- } else {
123579
- this._onClickedNothing();
123580
- }
123581
- });
123686
+ this._scene.canvas.canvas.addEventListener(
123687
+ "mouseup",
123688
+ (this._onCanvasMouseUp = () => {
123689
+ if (hoveredEntity) {
123690
+ const plane = this._planes[hoveredEntity.id];
123691
+ if (plane) {
123692
+ this._onClickedPlane(hoveredEntity.id);
123693
+ }
123694
+ } else {
123695
+ this._onClickedNothing();
123696
+ }
123697
+ })
123698
+ );
123582
123699
 
123583
- this._scene.canvas.canvas.addEventListener("mouseout", this._onCanvasMouseOut = () => {
123584
- if (hoveredEntity) {
123585
- this._onHoverLeavePlane(hoveredEntity.id);
123586
- hoveredEntity = null;
123587
- }
123588
- });
123589
- }
123700
+ this._scene.canvas.canvas.addEventListener(
123701
+ "mouseout",
123702
+ (this._onCanvasMouseOut = () => {
123703
+ if (hoveredEntity) {
123704
+ this._onHoverLeavePlane(hoveredEntity.id);
123705
+ hoveredEntity = null;
123706
+ }
123707
+ })
123708
+ );
123709
+ }
123590
123710
 
123591
- //--------------------------------------------------------------------------------------------------------------
123592
- // Configure overview
123593
- //--------------------------------------------------------------------------------------------------------------
123711
+ //--------------------------------------------------------------------------------------------------------------
123712
+ // Configure overview
123713
+ //--------------------------------------------------------------------------------------------------------------
123594
123714
 
123595
- this.setVisible(cfg.overviewVisible);
123596
- }
123715
+ this.setVisible(cfg.overviewVisible);
123716
+ }
123597
123717
 
123598
- /** Called by SectionPlanesPlugin#createSectionPlane()
123599
- * @private
123600
- */
123601
- addSectionPlane(sectionPlane) {
123602
- this._planes[sectionPlane.id] = new Plane(this, this._scene, sectionPlane);
123603
- }
123718
+ /** Called by SectionPlanesPlugin#createSectionPlane()
123719
+ * @private
123720
+ */
123721
+ addSectionPlane(sectionPlane) {
123722
+ this._planes[sectionPlane.id] = new Plane(this, this._scene, sectionPlane);
123723
+ }
123604
123724
 
123605
- /** @private
123606
- */
123607
- setPlaneHighlighted(id, highlighted) {
123608
- const plane = this._planes[id];
123609
- if (plane) {
123610
- plane.setHighlighted(highlighted);
123611
- }
123612
- }
123725
+ /** @private
123726
+ */
123727
+ setPlaneHighlighted(id, highlighted) {
123728
+ const plane = this._planes[id];
123729
+ if (plane) {
123730
+ plane.setHighlighted(highlighted);
123731
+ }
123732
+ }
123613
123733
 
123614
- /** @private
123615
- */
123616
- setPlaneSelected(id, selected) {
123617
- const plane = this._planes[id];
123618
- if (plane) {
123619
- plane.setSelected(selected);
123620
- }
123621
- }
123734
+ /** @private
123735
+ */
123736
+ setPlaneSelected(id, selected) {
123737
+ const plane = this._planes[id];
123738
+ if (plane) {
123739
+ plane.setSelected(selected);
123740
+ }
123741
+ }
123622
123742
 
123623
- /** @private
123624
- */
123625
- removeSectionPlane(sectionPlane) {
123626
- const plane = this._planes[sectionPlane.id];
123627
- if (plane) {
123628
- plane.destroy();
123629
- delete this._planes[sectionPlane.id];
123630
- }
123631
- }
123743
+ /** @private
123744
+ */
123745
+ removeSectionPlane(sectionPlane) {
123746
+ const plane = this._planes[sectionPlane.id];
123747
+ if (plane) {
123748
+ plane.destroy();
123749
+ delete this._planes[sectionPlane.id];
123750
+ }
123751
+ }
123632
123752
 
123633
- /**
123634
- * Sets if this SectionPlanesOverview is visible.
123635
- *
123636
- * @param {Boolean} visible Whether or not this SectionPlanesOverview is visible.
123637
- */
123638
- setVisible(visible = true) {
123639
- this._visible = visible;
123640
- this._canvas.style.visibility = visible ? "visible" : "hidden";
123641
- }
123753
+ /**
123754
+ * Sets if this SectionPlanesOverview is visible.
123755
+ *
123756
+ * @param {Boolean} visible Whether or not this SectionPlanesOverview is visible.
123757
+ */
123758
+ setVisible(visible = true) {
123759
+ this._visible = visible;
123760
+ this._canvas.style.visibility = visible ? "visible" : "hidden";
123761
+ }
123642
123762
 
123643
- /**
123644
- * Gets if this SectionPlanesOverview is visible.
123645
- *
123646
- * @return {Boolean} True when this SectionPlanesOverview is visible.
123647
- */
123648
- getVisible() {
123649
- return this._visible;
123650
- }
123763
+ /**
123764
+ * Gets if this SectionPlanesOverview is visible.
123765
+ *
123766
+ * @return {Boolean} True when this SectionPlanesOverview is visible.
123767
+ */
123768
+ getVisible() {
123769
+ return this._visible;
123770
+ }
123651
123771
 
123652
- /** @private
123653
- */
123654
- destroy() {
123655
- this._viewer.camera.off(this._onViewerCameraMatrix);
123656
- this._viewer.camera.off(this._onViewerCameraWorldAxis);
123657
- this._viewer.camera.perspective.off(this._onViewerCameraFOV);
123772
+ /** @private
123773
+ */
123774
+ destroy() {
123775
+ this._viewer.camera.off(this._onViewerCameraMatrix);
123776
+ this._viewer.camera.off(this._onViewerCameraWorldAxis);
123777
+ this._viewer.camera.perspective.off(this._onViewerCameraFOV);
123658
123778
 
123659
- this._scene.input.off(this._onInputMouseMove);
123660
- this._scene.canvas.canvas.removeEventListener("mouseup", this._onCanvasMouseUp);
123661
- this._scene.canvas.canvas.removeEventListener("mouseout", this._onCanvasMouseOut);
123662
- this._scene.destroy();
123663
- }
123779
+ this._scene.input.off(this._onInputMouseMove);
123780
+ this._scene.canvas.canvas.removeEventListener("mouseup", this._onCanvasMouseUp);
123781
+ this._scene.canvas.canvas.removeEventListener("mouseout", this._onCanvasMouseOut);
123782
+ this._scene.destroy();
123783
+ }
123664
123784
  }
123665
123785
 
123666
123786
  const tempAABB = math.AABB3();