@xtctwins/tctwins-core 1.0.26 → 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
  */
@@ -12772,7 +12772,7 @@ class AngleMeasurementsPlugin extends Plugin {
12772
12772
 
12773
12773
  this._measurements = {};
12774
12774
 
12775
- this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
12775
+ this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#0065fc";
12776
12776
  this.defaultLabelsVisible = cfg.defaultLabelsVisible !== false;
12777
12777
  this.zIndex = cfg.zIndex || 10000;
12778
12778
 
@@ -32045,13 +32045,13 @@ class Scene extends Component {
32045
32045
  */
32046
32046
  destroy(callback) {
32047
32047
  super.destroy();
32048
-
32049
32048
  for (const id in this.components) {
32050
32049
  if (this.components.hasOwnProperty(id)) {
32051
32050
  this.components[id].destroy();
32052
32051
  }
32053
32052
  }
32054
- this.canvas.destroy();
32053
+ // this.canvas.destroy(); // canvas是scene的其中一个component,所有以不必再destroy
32054
+
32055
32055
  // Memory leak prevention
32056
32056
  this.components = null;
32057
32057
  this.models = null;
@@ -32073,13 +32073,14 @@ class Scene extends Component {
32073
32073
  this._selectedObjectIds = null;
32074
32074
  this._colorizedObjectIds = null;
32075
32075
  this.types = null;
32076
- this.components = null;
32077
- this.canvas = null;
32078
32076
  this._renderer = null;
32079
32077
  this.input = null;
32080
32078
  this._viewport = null;
32081
32079
  this._camera = null;
32082
- if (callback) callback();
32080
+ this.canvas = null;
32081
+ if (typeof callback === "function") {
32082
+ callback();
32083
+ }
32083
32084
  }
32084
32085
  }
32085
32086
 
@@ -87717,7 +87718,7 @@ class DistanceMeasurementsPlugin extends Plugin {
87717
87718
  * @param {boolean} [cfg.defaultXAxisVisible=true] The default value of the DistanceMeasurements `xAxisVisible` property.
87718
87719
  * @param {boolean} [cfg.defaultYAxisVisible=true] The default value of the DistanceMeasurements `yAxisVisible` property.
87719
87720
  * @param {boolean} [cfg.defaultZAxisVisible=true] The default value of the DistanceMeasurements `zAxisVisible` property.
87720
- * @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.
87721
87722
  * @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
87722
87723
  * @param {boolean} [cfg.defaultLabelsOnWires=true] The default value of the DistanceMeasurements `labelsOnWires` property.
87723
87724
  * @param {PointerCircle} [cfg.pointerLens] A PointerLens to help the user position the pointer. This can be shared with other plugins.
@@ -87744,7 +87745,7 @@ class DistanceMeasurementsPlugin extends Plugin {
87744
87745
  this.defaultXAxisVisible = cfg.defaultXAxisVisible !== false;
87745
87746
  this.defaultYAxisVisible = cfg.defaultYAxisVisible !== false;
87746
87747
  this.defaultZAxisVisible = cfg.defaultZAxisVisible !== false;
87747
- this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
87748
+ this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#0065fc";
87748
87749
  this.zIndex = cfg.zIndex || 10000;
87749
87750
  this.defaultLabelsOnWires = cfg.defaultLabelsOnWires !== false;
87750
87751
 
@@ -95195,7 +95196,7 @@ class MousePanRotateDollyHandler {
95195
95196
 
95196
95197
  let mouseMovedOnCanvasSinceLastWheel = true;
95197
95198
 
95198
- const canvas = this._scene.canvas.canvas;
95199
+ this.canvas = this._scene.canvas.canvas;
95199
95200
 
95200
95201
  const keyDown = [];
95201
95202
 
@@ -95221,13 +95222,13 @@ class MousePanRotateDollyHandler {
95221
95222
  })
95222
95223
  );
95223
95224
 
95224
- function setMousedownState(pick = true) {
95225
- canvas.style.cursor = "move";
95225
+ const setMousedownState = (pick = true) => {
95226
+ this.canvas.style.cursor = "move";
95226
95227
  setMousedownPositions();
95227
95228
  if (pick) {
95228
95229
  setMousedownPick();
95229
95230
  }
95230
- }
95231
+ };
95231
95232
 
95232
95233
  function setMousedownPositions() {
95233
95234
 
@@ -95255,7 +95256,7 @@ class MousePanRotateDollyHandler {
95255
95256
  }
95256
95257
  }
95257
95258
 
95258
- canvas.addEventListener(
95259
+ this.canvas.addEventListener(
95259
95260
  "mousedown",
95260
95261
  (this._mouseDownHandler = (e) => {
95261
95262
  if (!(configs.active && configs.pointerEnabled)) {
@@ -95362,7 +95363,7 @@ class MousePanRotateDollyHandler {
95362
95363
  })
95363
95364
  );
95364
95365
 
95365
- canvas.addEventListener(
95366
+ this.canvas.addEventListener(
95366
95367
  "mousemove",
95367
95368
  (this._canvasMouseMoveHandler = (e) => {
95368
95369
  if (!(configs.active && configs.pointerEnabled)) {
@@ -95403,7 +95404,7 @@ class MousePanRotateDollyHandler {
95403
95404
  })
95404
95405
  );
95405
95406
 
95406
- canvas.addEventListener(
95407
+ this.canvas.addEventListener(
95407
95408
  "mouseup",
95408
95409
  (this._mouseUpHandler = (e) => {
95409
95410
  if (!(configs.active && configs.pointerEnabled)) {
@@ -95428,11 +95429,11 @@ class MousePanRotateDollyHandler {
95428
95429
  }
95429
95430
  break;
95430
95431
  }
95431
- canvas.style.removeProperty("cursor");
95432
+ this.canvas.style.removeProperty("cursor");
95432
95433
  })
95433
95434
  );
95434
95435
 
95435
- canvas.addEventListener(
95436
+ this.canvas.addEventListener(
95436
95437
  "mouseenter",
95437
95438
  (this._mouseEnterHandler = () => {
95438
95439
  if (!(configs.active && configs.pointerEnabled)) {
@@ -95446,7 +95447,7 @@ class MousePanRotateDollyHandler {
95446
95447
 
95447
95448
  let secsNowLast = null;
95448
95449
 
95449
- canvas.addEventListener(
95450
+ this.canvas.addEventListener(
95450
95451
  "wheel",
95451
95452
  (this._mouseWheelHandler = (e) => {
95452
95453
  e.preventDefault();
@@ -95480,18 +95481,17 @@ class MousePanRotateDollyHandler {
95480
95481
  reset() {}
95481
95482
 
95482
95483
  destroy() {
95483
- const canvas = this._scene.canvas.canvas;
95484
- if (canvas) {
95485
- document.removeEventListener("keydown", this._documentKeyDownHandler);
95486
- document.removeEventListener("keyup", this._documentKeyUpHandler);
95487
- canvas.removeEventListener("mousedown", this._mouseDownHandler);
95488
- document.removeEventListener("mousemove", this._documentMouseMoveHandler);
95489
- canvas.removeEventListener("mousemove", this._canvasMouseMoveHandler);
95490
- document.removeEventListener("mouseup", this._documentMouseUpHandler);
95491
- canvas.removeEventListener("mouseup", this._mouseUpHandler);
95492
- canvas.removeEventListener("mouseenter", this._mouseEnterHandler);
95493
- canvas.removeEventListener("wheel", this._mouseWheelHandler);
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);
95494
95490
  }
95491
+ document.removeEventListener("keydown", this._documentKeyDownHandler);
95492
+ document.removeEventListener("keyup", this._documentKeyUpHandler);
95493
+ document.removeEventListener("mousemove", this._documentMouseMoveHandler);
95494
+ document.removeEventListener("mouseup", this._documentMouseUpHandler);
95495
95495
  }
95496
95496
  }
95497
95497
 
@@ -95502,116 +95502,113 @@ const tempVec3c$1 = math.vec3();
95502
95502
  const tempVec3d = math.vec3();
95503
95503
 
95504
95504
  const tempCameraTarget = {
95505
- eye: math.vec3(),
95506
- look: math.vec3(),
95507
- up: math.vec3()
95505
+ eye: math.vec3(),
95506
+ look: math.vec3(),
95507
+ up: math.vec3()
95508
95508
  };
95509
95509
 
95510
95510
  /**
95511
95511
  * @private
95512
95512
  */
95513
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;
95514
95519
 
95515
- constructor(scene, controllers, configs, states) {
95516
-
95517
- this._scene = scene;
95518
- const cameraControl = controllers.cameraControl;
95519
- const camera = scene.camera;
95520
-
95521
- this._onSceneKeyDown = scene.input.on("keydown", () => {
95522
-
95523
- if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
95524
- return;
95525
- }
95526
-
95527
- if (!states.mouseover) {
95528
- return;
95529
- }
95530
-
95531
- const axisViewRight = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_RIGHT);
95532
- const axisViewBack = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BACK);
95533
- const axisViewLeft = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_LEFT);
95534
- const axisViewFront = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_FRONT);
95535
- const axisViewTop = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_TOP);
95536
- const axisViewBottom = cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BOTTOM);
95537
-
95538
- if ((!axisViewRight) && (!axisViewBack) && (!axisViewLeft) && (!axisViewFront) && (!axisViewTop) && (!axisViewBottom)) {
95539
- return;
95540
- }
95541
-
95542
- const aabb = scene.aabb;
95543
- const diag = math.getAABB3Diag(aabb);
95544
-
95545
- math.getAABB3Center(aabb, center);
95546
-
95547
- const perspectiveDist = Math.abs(diag / Math.tan(controllers.cameraFlight.fitFOV * math.DEGTORAD));
95548
- const orthoScale = diag * 1.1;
95549
-
95550
- tempCameraTarget.orthoScale = orthoScale;
95551
-
95552
- if (axisViewRight) {
95553
-
95554
- tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldRight, perspectiveDist, tempVec3a$5), tempVec3d));
95555
- tempCameraTarget.look.set(center);
95556
- tempCameraTarget.up.set(camera.worldUp);
95557
-
95558
- } else if (axisViewBack) {
95559
-
95560
- tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldForward, perspectiveDist, tempVec3a$5), tempVec3d));
95561
- tempCameraTarget.look.set(center);
95562
- tempCameraTarget.up.set(camera.worldUp);
95563
-
95564
- } else if (axisViewLeft) {
95520
+ this._onSceneKeyDown = scene.input.on("keydown", () => {
95521
+ if (!(configs.active && configs.pointerEnabled) || !scene.input.keyboardEnabled) {
95522
+ return;
95523
+ }
95565
95524
 
95566
- tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldRight, -perspectiveDist, tempVec3a$5), tempVec3d));
95567
- tempCameraTarget.look.set(center);
95568
- tempCameraTarget.up.set(camera.worldUp);
95525
+ if (!states.mouseover) {
95526
+ return;
95527
+ }
95569
95528
 
95570
- } 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);
95571
95535
 
95572
- tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldForward, -perspectiveDist, tempVec3a$5), tempVec3d));
95573
- tempCameraTarget.look.set(center);
95574
- tempCameraTarget.up.set(camera.worldUp);
95536
+ if (!axisViewRight && !axisViewBack && !axisViewLeft && !axisViewFront && !axisViewTop && !axisViewBottom) {
95537
+ return;
95538
+ }
95575
95539
 
95576
- } else if (axisViewTop) {
95540
+ const aabb = scene.aabb;
95541
+ const diag = math.getAABB3Diag(aabb);
95577
95542
 
95578
- tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldUp, perspectiveDist, tempVec3a$5), tempVec3d));
95579
- tempCameraTarget.look.set(center);
95580
- tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward, 1, tempVec3b$2), tempVec3c$1));
95543
+ math.getAABB3Center(aabb, center);
95581
95544
 
95582
- } else if (axisViewBottom) {
95545
+ const perspectiveDist = Math.abs(diag / Math.tan(controllers.cameraFlight.fitFOV * math.DEGTORAD));
95546
+ const orthoScale = diag * 1.1;
95583
95547
 
95584
- tempCameraTarget.eye.set(math.addVec3(center, math.mulVec3Scalar(camera.worldUp, -perspectiveDist, tempVec3a$5), tempVec3d));
95585
- tempCameraTarget.look.set(center);
95586
- tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward, -1, tempVec3b$2)));
95587
- }
95548
+ tempCameraTarget.orthoScale = orthoScale;
95588
95549
 
95589
- if ((!configs.firstPerson) && configs.followPointer) {
95590
- controllers.pivotController.setPivotPos(center);
95591
- }
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
+ }
95592
95587
 
95593
- if (controllers.cameraFlight.duration > 0) {
95594
- controllers.cameraFlight.flyTo(tempCameraTarget, () => {
95595
- if (controllers.pivotController.getPivoting() && configs.followPointer) {
95596
- controllers.pivotController.showPivot();
95597
- }
95598
- });
95588
+ if (!configs.firstPerson && configs.followPointer) {
95589
+ controllers.pivotController.setPivotPos(center);
95590
+ }
95599
95591
 
95600
- } else {
95601
- controllers.cameraFlight.jumpTo(tempCameraTarget);
95602
- if (controllers.pivotController.getPivoting() && configs.followPointer) {
95603
- controllers.pivotController.showPivot();
95604
- }
95605
- }
95606
- });
95607
- }
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
+ }
95608
95606
 
95609
- reset() {
95610
- }
95607
+ reset() {}
95611
95608
 
95612
- destroy() {
95613
- this._scene.input.off(this._onSceneKeyDown);
95614
- }
95609
+ destroy() {
95610
+ this.input.off(this._onSceneKeyDown);
95611
+ }
95615
95612
  }
95616
95613
 
95617
95614
  /**
@@ -95632,7 +95629,7 @@ class MousePickHandler {
95632
95629
  let leftDown = false;
95633
95630
  let rightDown = false;
95634
95631
 
95635
- const canvas = this._scene.canvas.canvas;
95632
+ this.canvas = this._scene.canvas.canvas;
95636
95633
 
95637
95634
  const tickifiedMouseMoveFn = scene.tickify(
95638
95635
  (this._canvasMouseMoveHandler = (e) => {
@@ -95714,8 +95711,8 @@ class MousePickHandler {
95714
95711
  })
95715
95712
  );
95716
95713
 
95717
- canvas.addEventListener("mousemove", tickifiedMouseMoveFn);
95718
- canvas.addEventListener(
95714
+ this.canvas.addEventListener("mousemove", tickifiedMouseMoveFn);
95715
+ this.canvas.addEventListener(
95719
95716
  "dblclick",
95720
95717
  (this._canvasDblClickHandler = (e) => {
95721
95718
  states.mouseDownClientX = e.clientX;
@@ -95746,7 +95743,7 @@ class MousePickHandler {
95746
95743
  })
95747
95744
  );
95748
95745
 
95749
- canvas.addEventListener(
95746
+ this.canvas.addEventListener(
95750
95747
  "mousedown",
95751
95748
  (this._canvasMouseDownHandler = (e) => {
95752
95749
  if (e.which === 1) {
@@ -95818,7 +95815,7 @@ class MousePickHandler {
95818
95815
  })
95819
95816
  );
95820
95817
 
95821
- canvas.addEventListener(
95818
+ this.canvas.addEventListener(
95822
95819
  "mouseup",
95823
95820
  (this._canvasMouseUpHandler = (e) => {
95824
95821
  if (!(configs.active && configs.pointerEnabled)) {
@@ -95992,12 +95989,13 @@ class MousePickHandler {
95992
95989
  }
95993
95990
 
95994
95991
  destroy() {
95995
- const canvas = this._scene.canvas.canvas;
95996
- canvas.removeEventListener("mousemove", this._canvasMouseMoveHandler);
95997
- canvas.removeEventListener("mousedown", this._canvasMouseDownHandler);
95998
- 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
+ }
95999
95998
  document.removeEventListener("mouseup", this._documentMouseUpHandler);
96000
- canvas.removeEventListener("mouseup", this._canvasMouseUpHandler);
96001
95999
  if (this._timeout) {
96002
96000
  window.clearTimeout(this._timeout);
96003
96001
  this._timeout = null;
@@ -96013,7 +96011,7 @@ class KeyboardPanRotateDollyHandler {
96013
96011
  this._scene = scene;
96014
96012
  this._updates = updates;
96015
96013
  const input = scene.input;
96016
-
96014
+ this.input = input;
96017
96015
  const keyDownMap = [];
96018
96016
 
96019
96017
  const canvas = scene.canvas.canvas;
@@ -96167,9 +96165,9 @@ class KeyboardPanRotateDollyHandler {
96167
96165
  destroy() {
96168
96166
  this._scene.off(this._onTick);
96169
96167
 
96170
- this._scene.input.off(this._onSceneMouseMove);
96171
- this._scene.input.off(this._onSceneKeyDown);
96172
- this._scene.input.off(this._onSceneKeyUp);
96168
+ this.input.off(this._onSceneMouseMove);
96169
+ this.input.off(this._onSceneKeyDown);
96170
+ this.input.off(this._onSceneKeyUp);
96173
96171
  }
96174
96172
  }
96175
96173
 
@@ -96489,42 +96487,42 @@ class MouseMiscHandler {
96489
96487
  constructor(scene, controllers, configs, states, updates) {
96490
96488
  this._scene = scene;
96491
96489
 
96492
- const canvas = this._scene.canvas.canvas;
96490
+ this.canvas = this._scene.canvas.canvas;
96493
96491
 
96494
- canvas.addEventListener(
96492
+ this.canvas.addEventListener(
96495
96493
  "mouseenter",
96496
96494
  (this._mouseEnterHandler = () => {
96497
96495
  states.mouseover = true;
96498
96496
  })
96499
96497
  );
96500
96498
 
96501
- canvas.addEventListener(
96499
+ this.canvas.addEventListener(
96502
96500
  "mouseleave",
96503
96501
  (this._mouseLeaveHandler = () => {
96504
96502
  states.mouseover = false;
96505
- canvas.style.cursor = null;
96503
+ this.canvas.style.cursor = null;
96506
96504
  })
96507
96505
  );
96508
96506
 
96509
96507
  document.addEventListener(
96510
96508
  "mousemove",
96511
96509
  (this._mouseMoveHandler = (e) => {
96512
- getCanvasPosFromEvent$2(e, canvas, states.pointerCanvasPos);
96510
+ getCanvasPosFromEvent$2(e, this.canvas, states.pointerCanvasPos);
96513
96511
  })
96514
96512
  );
96515
96513
 
96516
- canvas.addEventListener(
96514
+ this.canvas.addEventListener(
96517
96515
  "mousedown",
96518
96516
  (this._mouseDownHandler = (e) => {
96519
96517
  if (!(configs.active && configs.pointerEnabled)) {
96520
96518
  return;
96521
96519
  }
96522
- getCanvasPosFromEvent$2(e, canvas, states.pointerCanvasPos);
96520
+ getCanvasPosFromEvent$2(e, this.canvas, states.pointerCanvasPos);
96523
96521
  states.mouseover = true;
96524
96522
  })
96525
96523
  );
96526
96524
 
96527
- canvas.addEventListener(
96525
+ this.canvas.addEventListener(
96528
96526
  "mouseup",
96529
96527
  (this._mouseUpHandler = (e) => {
96530
96528
  if (!(configs.active && configs.pointerEnabled)) {
@@ -96537,16 +96535,15 @@ class MouseMiscHandler {
96537
96535
  reset() {}
96538
96536
 
96539
96537
  destroy() {
96540
- const canvas = this._scene.canvas.canvas;
96541
96538
  //网络问题导致的模型加载失败等情况时,如果切换模型,会找不到canvas
96542
96539
  //因此暂时在此加判断
96543
- if (canvas) {
96544
- document.removeEventListener("mousemove", this._mouseMoveHandler);
96545
- canvas.removeEventListener("mouseenter", this._mouseEnterHandler);
96546
- canvas.removeEventListener("mouseleave", this._mouseLeaveHandler);
96547
- canvas.removeEventListener("mousedown", this._mouseDownHandler);
96548
- 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);
96549
96545
  }
96546
+ document.removeEventListener("mousemove", this._mouseMoveHandler);
96550
96547
  }
96551
96548
  }
96552
96549
 
@@ -96599,7 +96596,7 @@ class TouchPanRotateAndDollyHandler {
96599
96596
  const touch0Vec = math.vec2();
96600
96597
 
96601
96598
  const lastCanvasTouchPosList = [];
96602
- const canvas = this._scene.canvas.canvas;
96599
+ this.canvas = this._scene.canvas.canvas;
96603
96600
 
96604
96601
  let numTouches = 0;
96605
96602
  let waitForTick = false;
@@ -96608,7 +96605,7 @@ class TouchPanRotateAndDollyHandler {
96608
96605
  waitForTick = false;
96609
96606
  });
96610
96607
 
96611
- canvas.addEventListener(
96608
+ this.canvas.addEventListener(
96612
96609
  "touchstart",
96613
96610
  (this._canvasTouchStartHandler = (event) => {
96614
96611
  if (!(configs.active && configs.pointerEnabled)) {
@@ -96674,7 +96671,7 @@ class TouchPanRotateAndDollyHandler {
96674
96671
  })
96675
96672
  );
96676
96673
 
96677
- canvas.addEventListener(
96674
+ this.canvas.addEventListener(
96678
96675
  "touchend",
96679
96676
  (this._canvasTouchEndHandler = () => {
96680
96677
  if (pivotController.getPivoting()) {
@@ -96683,9 +96680,9 @@ class TouchPanRotateAndDollyHandler {
96683
96680
  }
96684
96681
  })
96685
96682
  );
96686
- canvas.addEventListener("touchcancel", this._canvasTouchEndHandler);
96683
+ this.canvas.addEventListener("touchcancel", this._canvasTouchEndHandler);
96687
96684
 
96688
- canvas.addEventListener(
96685
+ this.canvas.addEventListener(
96689
96686
  "touchmove",
96690
96687
  (this._canvasTouchMoveHandler = (event) => {
96691
96688
  if (!(configs.active && configs.pointerEnabled)) {
@@ -96831,11 +96828,12 @@ class TouchPanRotateAndDollyHandler {
96831
96828
  reset() {}
96832
96829
 
96833
96830
  destroy() {
96834
- const canvas = this._scene.canvas.canvas;
96835
- canvas.removeEventListener("touchstart", this._canvasTouchStartHandler);
96836
- canvas.removeEventListener("touchend", this._canvasTouchEndHandler);
96837
- canvas.removeEventListener("touchcancel", this._canvasTouchEndHandler);
96838
- 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
+ }
96839
96837
  this._scene.off(this._onTick);
96840
96838
  }
96841
96839
  }
@@ -96880,7 +96878,7 @@ class TouchPickHandler {
96880
96878
  let tapStartTime = -1;
96881
96879
  let lastTapTime = -1;
96882
96880
 
96883
- const canvas = this._scene.canvas.canvas;
96881
+ this.canvas = this._scene.canvas.canvas;
96884
96882
 
96885
96883
  const flyCameraTo = (pickResult) => {
96886
96884
  let pos;
@@ -96904,7 +96902,7 @@ class TouchPickHandler {
96904
96902
  }
96905
96903
  };
96906
96904
 
96907
- canvas.addEventListener(
96905
+ this.canvas.addEventListener(
96908
96906
  "touchstart",
96909
96907
  (this._canvasTouchStartHandler = (e) => {
96910
96908
  if (!(configs.active && configs.pointerEnabled)) {
@@ -96982,7 +96980,7 @@ class TouchPickHandler {
96982
96980
  { passive: true }
96983
96981
  );
96984
96982
 
96985
- canvas.addEventListener(
96983
+ this.canvas.addEventListener(
96986
96984
  "touchend",
96987
96985
  (this._canvasTouchEndHandler = (e) => {
96988
96986
  if (!(configs.active && configs.pointerEnabled)) {
@@ -97079,7 +97077,7 @@ class TouchPickHandler {
97079
97077
  { passive: true }
97080
97078
  );
97081
97079
 
97082
- canvas.addEventListener("touchcancel", this._canvasTouchEndHandler);
97080
+ this.canvas.addEventListener("touchcancel", this._canvasTouchEndHandler);
97083
97081
  }
97084
97082
 
97085
97083
  reset() {
@@ -97089,10 +97087,11 @@ class TouchPickHandler {
97089
97087
  }
97090
97088
 
97091
97089
  destroy() {
97092
- const canvas = this._scene.canvas.canvas;
97093
- canvas.removeEventListener("touchstart", this._canvasTouchStartHandler);
97094
- canvas.removeEventListener("touchend", this._canvasTouchEndHandler);
97095
- canvas.removeEventListener("touchcancel", 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
+ }
97096
97095
  }
97097
97096
  }
97098
97097
 
@@ -108381,13 +108380,16 @@ class Viewer {
108381
108380
  this._snapshotBegun = false;
108382
108381
  }
108383
108382
 
108384
- /** Destroys this Viewer.
108383
+ /**
108384
+ * Destroys this Viewer.
108385
108385
  */
108386
108386
  destroy(callback) {
108387
108387
  const plugins = this._plugins.slice(); // Array will modify as we delete plugins
108388
- for (let i = 0, len = plugins.length; i < len; i++) {
108389
- const plugin = plugins[i];
108390
- 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
+ }
108391
108393
  }
108392
108394
  this.cameraControl.destroy();
108393
108395
  this.scene.destroy(callback);
@@ -121157,235 +121159,241 @@ class Plane$1 {
121157
121159
  * @private
121158
121160
  */
121159
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
+ }
121160
121169
 
121161
- /**
121162
- * @private
121163
- */
121164
- constructor(plugin, cfg) {
121165
-
121166
- if (!cfg.onHoverEnterPlane || !cfg.onHoverLeavePlane || !cfg.onClickedNothing || !cfg.onClickedPlane) {
121167
- throw "Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";
121168
- }
121169
-
121170
- /**
121171
- * The {@link SectionPlanesPlugin} that owns this SectionPlanesOverview.
121172
- *
121173
- * @type {SectionPlanesPlugin}
121174
- */
121175
- this.plugin = plugin;
121170
+ /**
121171
+ * The {@link SectionPlanesPlugin} that owns this SectionPlanesOverview.
121172
+ *
121173
+ * @type {SectionPlanesPlugin}
121174
+ */
121175
+ this.plugin = plugin;
121176
121176
 
121177
- this._viewer = plugin.viewer;
121177
+ this._viewer = plugin.viewer;
121178
121178
 
121179
- this._onHoverEnterPlane = cfg.onHoverEnterPlane;
121180
- this._onHoverLeavePlane = cfg.onHoverLeavePlane;
121181
- this._onClickedNothing = cfg.onClickedNothing;
121182
- this._onClickedPlane = cfg.onClickedPlane;
121183
- 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;
121184
121184
 
121185
- this._planes = {};
121185
+ this._planes = {};
121186
121186
 
121187
- //--------------------------------------------------------------------------------------------------------------
121188
- // Init canvas
121189
- //--------------------------------------------------------------------------------------------------------------
121187
+ //--------------------------------------------------------------------------------------------------------------
121188
+ // Init canvas
121189
+ //--------------------------------------------------------------------------------------------------------------
121190
121190
 
121191
- this._canvas = cfg.overviewCanvas;
121191
+ this._canvas = cfg.overviewCanvas;
121192
121192
 
121193
- //--------------------------------------------------------------------------------------------------------------
121194
- // Init scene
121195
- //--------------------------------------------------------------------------------------------------------------
121193
+ //--------------------------------------------------------------------------------------------------------------
121194
+ // Init scene
121195
+ //--------------------------------------------------------------------------------------------------------------
121196
121196
 
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
- });
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
+ });
121220
121220
 
121221
- this._scene.camera;
121222
- this._scene.camera.perspective.fov = 70;
121221
+ this._scene.camera;
121222
+ this._scene.camera.perspective.fov = 70;
121223
121223
 
121224
- this._zUp = false;
121224
+ this._zUp = false;
121225
121225
 
121226
- //--------------------------------------------------------------------------------------------------------------
121227
- // Synchronize overview scene camera with viewer camera
121228
- //--------------------------------------------------------------------------------------------------------------
121226
+ //--------------------------------------------------------------------------------------------------------------
121227
+ // Synchronize overview scene camera with viewer camera
121228
+ //--------------------------------------------------------------------------------------------------------------
121229
121229
 
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) { // +Z up
121243
- math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
121244
- math.transformVec3(matrix, up, upOverview);
121245
- camera.look = [0, 0, 0];
121246
- camera.eye = math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
121247
- camera.up = math.transformPoint3(matrix, up, upOverview);
121248
- } else { // +Y up
121249
- camera.look = [0, 0, 0];
121250
- camera.eye = eyeLookVec;
121251
- camera.up = up;
121252
- }
121253
- };
121254
- }
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
+ }
121255
121257
 
121256
- this._onViewerCameraMatrix = this._viewer.camera.on("matrix", this._synchCamera);
121258
+ this._onViewerCameraMatrix = this._viewer.camera.on("matrix", this._synchCamera);
121257
121259
 
121258
- this._onViewerCameraWorldAxis = this._viewer.camera.on("worldAxis", this._synchCamera);
121260
+ this._onViewerCameraWorldAxis = this._viewer.camera.on("worldAxis", this._synchCamera);
121259
121261
 
121260
- this._onViewerCameraFOV = this._viewer.camera.perspective.on("fov", (fov) => {
121261
- this._scene.camera.perspective.fov = fov;
121262
- });
121262
+ this._onViewerCameraFOV = this._viewer.camera.perspective.on("fov", (fov) => {
121263
+ this._scene.camera.perspective.fov = fov;
121264
+ });
121263
121265
 
121264
- //--------------------------------------------------------------------------------------------------------------
121265
- // Bind overview canvas events
121266
- //--------------------------------------------------------------------------------------------------------------
121266
+ //--------------------------------------------------------------------------------------------------------------
121267
+ // Bind overview canvas events
121268
+ //--------------------------------------------------------------------------------------------------------------
121267
121269
 
121268
- {
121269
- var hoveredEntity = null;
121270
+ {
121271
+ var hoveredEntity = null;
121270
121272
 
121271
- this._onInputMouseMove = this._scene.input.on("mousemove", (coords) => {
121272
- const hit = this._scene.pick({
121273
- canvasPos: coords
121274
- });
121275
- if (hit) {
121276
- if (!hoveredEntity || hit.entity.id !== hoveredEntity.id) {
121277
- if (hoveredEntity) {
121278
- const plane = this._planes[hoveredEntity.id];
121279
- if (plane) {
121280
- this._onHoverLeavePlane(hoveredEntity.id);
121281
- }
121282
- }
121283
- hoveredEntity = hit.entity;
121284
- const plane = this._planes[hoveredEntity.id];
121285
- if (plane) {
121286
- this._onHoverEnterPlane(hoveredEntity.id);
121287
- }
121288
- }
121289
- } else {
121290
- if (hoveredEntity) {
121291
- this._onHoverLeavePlane(hoveredEntity.id);
121292
- hoveredEntity = null;
121293
- }
121294
- }
121295
- });
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
+ });
121296
121298
 
121297
- this._scene.canvas.canvas.addEventListener("mouseup", this._onCanvasMouseUp = () => {
121298
- if (hoveredEntity) {
121299
- const plane = this._planes[hoveredEntity.id];
121300
- if (plane) {
121301
- this._onClickedPlane(hoveredEntity.id);
121302
- }
121303
- } else {
121304
- this._onClickedNothing();
121305
- }
121306
- });
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
+ );
121307
121312
 
121308
- this._scene.canvas.canvas.addEventListener("mouseout", this._onCanvasMouseOut = () => {
121309
- if (hoveredEntity) {
121310
- this._onHoverLeavePlane(hoveredEntity.id);
121311
- hoveredEntity = null;
121312
- }
121313
- });
121314
- }
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
+ }
121315
121323
 
121316
- //--------------------------------------------------------------------------------------------------------------
121317
- // Configure overview
121318
- //--------------------------------------------------------------------------------------------------------------
121324
+ //--------------------------------------------------------------------------------------------------------------
121325
+ // Configure overview
121326
+ //--------------------------------------------------------------------------------------------------------------
121319
121327
 
121320
- this.setVisible(cfg.overviewVisible);
121321
- }
121328
+ this.setVisible(cfg.overviewVisible);
121329
+ }
121322
121330
 
121323
- /** Called by SectionPlanesPlugin#createSectionPlane()
121324
- * @private
121325
- */
121326
- addSectionPlane(sectionPlane) {
121327
- this._planes[sectionPlane.id] = new Plane$1(this, this._scene, sectionPlane);
121328
- }
121331
+ /** Called by SectionPlanesPlugin#createSectionPlane()
121332
+ * @private
121333
+ */
121334
+ addSectionPlane(sectionPlane) {
121335
+ this._planes[sectionPlane.id] = new Plane$1(this, this._scene, sectionPlane);
121336
+ }
121329
121337
 
121330
- /** @private
121331
- */
121332
- setPlaneHighlighted(id, highlighted) {
121333
- const plane = this._planes[id];
121334
- if (plane) {
121335
- plane.setHighlighted(highlighted);
121336
- }
121337
- }
121338
+ /** @private
121339
+ */
121340
+ setPlaneHighlighted(id, highlighted) {
121341
+ const plane = this._planes[id];
121342
+ if (plane) {
121343
+ plane.setHighlighted(highlighted);
121344
+ }
121345
+ }
121338
121346
 
121339
- /** @private
121340
- */
121341
- setPlaneSelected(id, selected) {
121342
- const plane = this._planes[id];
121343
- if (plane) {
121344
- plane.setSelected(selected);
121345
- }
121346
- }
121347
+ /** @private
121348
+ */
121349
+ setPlaneSelected(id, selected) {
121350
+ const plane = this._planes[id];
121351
+ if (plane) {
121352
+ plane.setSelected(selected);
121353
+ }
121354
+ }
121347
121355
 
121348
- /** @private
121349
- */
121350
- removeSectionPlane(sectionPlane) {
121351
- const plane = this._planes[sectionPlane.id];
121352
- if (plane) {
121353
- plane.destroy();
121354
- delete this._planes[sectionPlane.id];
121355
- }
121356
- }
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
+ }
121357
121365
 
121358
- /**
121359
- * Sets if this SectionPlanesOverview is visible.
121360
- *
121361
- * @param {Boolean} visible Whether or not this SectionPlanesOverview is visible.
121362
- */
121363
- setVisible(visible = true) {
121364
- this._visible = visible;
121365
- this._canvas.style.visibility = visible ? "visible" : "hidden";
121366
- }
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
+ }
121367
121375
 
121368
- /**
121369
- * Gets if this SectionPlanesOverview is visible.
121370
- *
121371
- * @return {Boolean} True when this SectionPlanesOverview is visible.
121372
- */
121373
- getVisible() {
121374
- return this._visible;
121375
- }
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
+ }
121376
121384
 
121377
- /** @private
121378
- */
121379
- destroy() {
121380
- this._viewer.camera.off(this._onViewerCameraMatrix);
121381
- this._viewer.camera.off(this._onViewerCameraWorldAxis);
121382
- 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);
121383
121391
 
121384
- this._scene.input.off(this._onInputMouseMove);
121385
- this._scene.canvas.canvas.removeEventListener("mouseup", this._onCanvasMouseUp);
121386
- this._scene.canvas.canvas.removeEventListener("mouseout", this._onCanvasMouseOut);
121387
- this._scene.destroy();
121388
- }
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
+ }
121389
121397
  }
121390
121398
 
121391
121399
  const tempAABB$1 = math.AABB3();
@@ -123538,235 +123546,241 @@ class Plane {
123538
123546
  * @private
123539
123547
  */
123540
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
+ }
123541
123556
 
123542
- /**
123543
- * @private
123544
- */
123545
- constructor(plugin, cfg) {
123546
-
123547
- if (!cfg.onHoverEnterPlane || !cfg.onHoverLeavePlane || !cfg.onClickedNothing || !cfg.onClickedPlane) {
123548
- throw "Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";
123549
- }
123550
-
123551
- /**
123552
- * The {@link FaceAlignedSectionPlanesPlugin} that owns this SectionPlanesOverview.
123553
- *
123554
- * @type {FaceAlignedSectionPlanesPlugin}
123555
- */
123556
- this.plugin = plugin;
123557
+ /**
123558
+ * The {@link FaceAlignedSectionPlanesPlugin} that owns this SectionPlanesOverview.
123559
+ *
123560
+ * @type {FaceAlignedSectionPlanesPlugin}
123561
+ */
123562
+ this.plugin = plugin;
123557
123563
 
123558
- this._viewer = plugin.viewer;
123564
+ this._viewer = plugin.viewer;
123559
123565
 
123560
- this._onHoverEnterPlane = cfg.onHoverEnterPlane;
123561
- this._onHoverLeavePlane = cfg.onHoverLeavePlane;
123562
- this._onClickedNothing = cfg.onClickedNothing;
123563
- this._onClickedPlane = cfg.onClickedPlane;
123564
- 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;
123565
123571
 
123566
- this._planes = {};
123572
+ this._planes = {};
123567
123573
 
123568
- //--------------------------------------------------------------------------------------------------------------
123569
- // Init canvas
123570
- //--------------------------------------------------------------------------------------------------------------
123574
+ //--------------------------------------------------------------------------------------------------------------
123575
+ // Init canvas
123576
+ //--------------------------------------------------------------------------------------------------------------
123571
123577
 
123572
- this._canvas = cfg.overviewCanvas;
123578
+ this._canvas = cfg.overviewCanvas;
123573
123579
 
123574
- //--------------------------------------------------------------------------------------------------------------
123575
- // Init scene
123576
- //--------------------------------------------------------------------------------------------------------------
123580
+ //--------------------------------------------------------------------------------------------------------------
123581
+ // Init scene
123582
+ //--------------------------------------------------------------------------------------------------------------
123577
123583
 
123578
- this._scene = new Scene(this._viewer, {
123579
- canvasId: this._canvas.id,
123580
- transparent: true
123581
- });
123582
- this._scene.clearLights();
123583
- new DirLight(this._scene, {
123584
- dir: [0.4, -0.4, 0.8],
123585
- color: [0.8, 1.0, 1.0],
123586
- intensity: 1.0,
123587
- space: "view"
123588
- });
123589
- new DirLight(this._scene, {
123590
- dir: [-0.8, -0.3, -0.4],
123591
- color: [0.8, 0.8, 0.8],
123592
- intensity: 1.0,
123593
- space: "view"
123594
- });
123595
- new DirLight(this._scene, {
123596
- dir: [0.8, -0.6, -0.8],
123597
- color: [1.0, 1.0, 1.0],
123598
- intensity: 1.0,
123599
- space: "view"
123600
- });
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
+ });
123601
123607
 
123602
- this._scene.camera;
123603
- this._scene.camera.perspective.fov = 70;
123608
+ this._scene.camera;
123609
+ this._scene.camera.perspective.fov = 70;
123604
123610
 
123605
- this._zUp = false;
123611
+ this._zUp = false;
123606
123612
 
123607
- //--------------------------------------------------------------------------------------------------------------
123608
- // Synchronize overview scene camera with viewer camera
123609
- //--------------------------------------------------------------------------------------------------------------
123613
+ //--------------------------------------------------------------------------------------------------------------
123614
+ // Synchronize overview scene camera with viewer camera
123615
+ //--------------------------------------------------------------------------------------------------------------
123610
123616
 
123611
- {
123612
- const camera = this._scene.camera;
123613
- const matrix = math.rotationMat4c(-90 * math.DEGTORAD, 1, 0, 0);
123614
- const eyeLookVec = math.vec3();
123615
- const eyeLookVecOverview = math.vec3();
123616
- const upOverview = math.vec3();
123617
-
123618
- this._synchCamera = () => {
123619
- const eye = this._viewer.camera.eye;
123620
- const look = this._viewer.camera.look;
123621
- const up = this._viewer.camera.up;
123622
- math.mulVec3Scalar(math.normalizeVec3(math.subVec3(eye, look, eyeLookVec)), 7);
123623
- if (this._zUp) { // +Z up
123624
- math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
123625
- math.transformVec3(matrix, up, upOverview);
123626
- camera.look = [0, 0, 0];
123627
- camera.eye = math.transformVec3(matrix, eyeLookVec, eyeLookVecOverview);
123628
- camera.up = math.transformPoint3(matrix, up, upOverview);
123629
- } else { // +Y up
123630
- camera.look = [0, 0, 0];
123631
- camera.eye = eyeLookVec;
123632
- camera.up = up;
123633
- }
123634
- };
123635
- }
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
+ }
123636
123644
 
123637
- this._onViewerCameraMatrix = this._viewer.camera.on("matrix", this._synchCamera);
123645
+ this._onViewerCameraMatrix = this._viewer.camera.on("matrix", this._synchCamera);
123638
123646
 
123639
- this._onViewerCameraWorldAxis = this._viewer.camera.on("worldAxis", this._synchCamera);
123647
+ this._onViewerCameraWorldAxis = this._viewer.camera.on("worldAxis", this._synchCamera);
123640
123648
 
123641
- this._onViewerCameraFOV = this._viewer.camera.perspective.on("fov", (fov) => {
123642
- this._scene.camera.perspective.fov = fov;
123643
- });
123649
+ this._onViewerCameraFOV = this._viewer.camera.perspective.on("fov", (fov) => {
123650
+ this._scene.camera.perspective.fov = fov;
123651
+ });
123644
123652
 
123645
- //--------------------------------------------------------------------------------------------------------------
123646
- // Bind overview canvas events
123647
- //--------------------------------------------------------------------------------------------------------------
123653
+ //--------------------------------------------------------------------------------------------------------------
123654
+ // Bind overview canvas events
123655
+ //--------------------------------------------------------------------------------------------------------------
123648
123656
 
123649
- {
123650
- var hoveredEntity = null;
123657
+ {
123658
+ var hoveredEntity = null;
123651
123659
 
123652
- this._onInputMouseMove = this._scene.input.on("mousemove", (coords) => {
123653
- const hit = this._scene.pick({
123654
- canvasPos: coords
123655
- });
123656
- if (hit) {
123657
- if (!hoveredEntity || hit.entity.id !== hoveredEntity.id) {
123658
- if (hoveredEntity) {
123659
- const plane = this._planes[hoveredEntity.id];
123660
- if (plane) {
123661
- this._onHoverLeavePlane(hoveredEntity.id);
123662
- }
123663
- }
123664
- hoveredEntity = hit.entity;
123665
- const plane = this._planes[hoveredEntity.id];
123666
- if (plane) {
123667
- this._onHoverEnterPlane(hoveredEntity.id);
123668
- }
123669
- }
123670
- } else {
123671
- if (hoveredEntity) {
123672
- this._onHoverLeavePlane(hoveredEntity.id);
123673
- hoveredEntity = null;
123674
- }
123675
- }
123676
- });
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
+ });
123677
123685
 
123678
- this._scene.canvas.canvas.addEventListener("mouseup", this._onCanvasMouseUp = () => {
123679
- if (hoveredEntity) {
123680
- const plane = this._planes[hoveredEntity.id];
123681
- if (plane) {
123682
- this._onClickedPlane(hoveredEntity.id);
123683
- }
123684
- } else {
123685
- this._onClickedNothing();
123686
- }
123687
- });
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
+ );
123688
123699
 
123689
- this._scene.canvas.canvas.addEventListener("mouseout", this._onCanvasMouseOut = () => {
123690
- if (hoveredEntity) {
123691
- this._onHoverLeavePlane(hoveredEntity.id);
123692
- hoveredEntity = null;
123693
- }
123694
- });
123695
- }
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
+ }
123696
123710
 
123697
- //--------------------------------------------------------------------------------------------------------------
123698
- // Configure overview
123699
- //--------------------------------------------------------------------------------------------------------------
123711
+ //--------------------------------------------------------------------------------------------------------------
123712
+ // Configure overview
123713
+ //--------------------------------------------------------------------------------------------------------------
123700
123714
 
123701
- this.setVisible(cfg.overviewVisible);
123702
- }
123715
+ this.setVisible(cfg.overviewVisible);
123716
+ }
123703
123717
 
123704
- /** Called by SectionPlanesPlugin#createSectionPlane()
123705
- * @private
123706
- */
123707
- addSectionPlane(sectionPlane) {
123708
- this._planes[sectionPlane.id] = new Plane(this, this._scene, sectionPlane);
123709
- }
123718
+ /** Called by SectionPlanesPlugin#createSectionPlane()
123719
+ * @private
123720
+ */
123721
+ addSectionPlane(sectionPlane) {
123722
+ this._planes[sectionPlane.id] = new Plane(this, this._scene, sectionPlane);
123723
+ }
123710
123724
 
123711
- /** @private
123712
- */
123713
- setPlaneHighlighted(id, highlighted) {
123714
- const plane = this._planes[id];
123715
- if (plane) {
123716
- plane.setHighlighted(highlighted);
123717
- }
123718
- }
123725
+ /** @private
123726
+ */
123727
+ setPlaneHighlighted(id, highlighted) {
123728
+ const plane = this._planes[id];
123729
+ if (plane) {
123730
+ plane.setHighlighted(highlighted);
123731
+ }
123732
+ }
123719
123733
 
123720
- /** @private
123721
- */
123722
- setPlaneSelected(id, selected) {
123723
- const plane = this._planes[id];
123724
- if (plane) {
123725
- plane.setSelected(selected);
123726
- }
123727
- }
123734
+ /** @private
123735
+ */
123736
+ setPlaneSelected(id, selected) {
123737
+ const plane = this._planes[id];
123738
+ if (plane) {
123739
+ plane.setSelected(selected);
123740
+ }
123741
+ }
123728
123742
 
123729
- /** @private
123730
- */
123731
- removeSectionPlane(sectionPlane) {
123732
- const plane = this._planes[sectionPlane.id];
123733
- if (plane) {
123734
- plane.destroy();
123735
- delete this._planes[sectionPlane.id];
123736
- }
123737
- }
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
+ }
123738
123752
 
123739
- /**
123740
- * Sets if this SectionPlanesOverview is visible.
123741
- *
123742
- * @param {Boolean} visible Whether or not this SectionPlanesOverview is visible.
123743
- */
123744
- setVisible(visible = true) {
123745
- this._visible = visible;
123746
- this._canvas.style.visibility = visible ? "visible" : "hidden";
123747
- }
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
+ }
123748
123762
 
123749
- /**
123750
- * Gets if this SectionPlanesOverview is visible.
123751
- *
123752
- * @return {Boolean} True when this SectionPlanesOverview is visible.
123753
- */
123754
- getVisible() {
123755
- return this._visible;
123756
- }
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
+ }
123757
123771
 
123758
- /** @private
123759
- */
123760
- destroy() {
123761
- this._viewer.camera.off(this._onViewerCameraMatrix);
123762
- this._viewer.camera.off(this._onViewerCameraWorldAxis);
123763
- 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);
123764
123778
 
123765
- this._scene.input.off(this._onInputMouseMove);
123766
- this._scene.canvas.canvas.removeEventListener("mouseup", this._onCanvasMouseUp);
123767
- this._scene.canvas.canvas.removeEventListener("mouseout", this._onCanvasMouseOut);
123768
- this._scene.destroy();
123769
- }
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
+ }
123770
123784
  }
123771
123785
 
123772
123786
  const tempAABB = math.AABB3();