@xtctwins/tctwins-core 1.0.22 → 1.0.23

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.
@@ -95820,182 +95820,168 @@ class MousePickHandler {
95820
95820
  * @private
95821
95821
  */
95822
95822
  class KeyboardPanRotateDollyHandler {
95823
+ constructor(scene, controllers, configs, states, updates) {
95824
+ this._scene = scene;
95825
+ this._updates = updates;
95826
+ const input = scene.input;
95823
95827
 
95824
- constructor(scene, controllers, configs, states, updates) {
95825
-
95826
- this._scene = scene;
95827
- const input = scene.input;
95828
-
95829
- const keyDownMap = [];
95830
-
95831
- const canvas = scene.canvas.canvas;
95832
-
95833
- let mouseMovedSinceLastKeyboardDolly = true;
95834
-
95835
- this._onSceneMouseMove = input.on("mousemove", () => {
95836
- mouseMovedSinceLastKeyboardDolly = true;
95837
- });
95838
-
95839
- this._onSceneKeyDown = input.on("keydown", (keyCode) => {
95840
- if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
95841
- return;
95842
- }
95843
- if (!states.mouseover) {
95844
- return;
95845
- }
95846
- keyDownMap[keyCode] = true;
95847
-
95848
- if (keyCode === input.KEY_SHIFT) {
95849
- canvas.style.cursor = "move";
95850
- }
95851
- });
95852
-
95853
- this._onSceneKeyUp = input.on("keyup", (keyCode) => {
95854
- if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
95855
- return;
95856
- }
95857
- keyDownMap[keyCode] = false;
95858
-
95859
- if (keyCode === input.KEY_SHIFT) {
95860
- canvas.style.cursor = null;
95861
- }
95862
-
95863
- if (controllers.pivotController.getPivoting()) {
95864
- controllers.pivotController.endPivot();
95865
- }
95866
- });
95867
-
95868
- this._onTick = scene.on("tick", (e) => {
95869
-
95870
- if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
95871
- return;
95872
- }
95873
-
95874
- if (!states.mouseover) {
95875
- return;
95876
- }
95877
-
95878
- const cameraControl = controllers.cameraControl;
95879
- const elapsedSecs = (e.deltaTime / 1000.0);
95828
+ const keyDownMap = [];
95880
95829
 
95881
- //-------------------------------------------------------------------------------------------------
95882
- // Keyboard rotation
95883
- //-------------------------------------------------------------------------------------------------
95830
+ const canvas = scene.canvas.canvas;
95884
95831
 
95885
- if (!configs.planView) {
95832
+ let mouseMovedSinceLastKeyboardDolly = true;
95886
95833
 
95887
- const rotateYPos = cameraControl._isKeyDownForAction(cameraControl.ROTATE_Y_POS, keyDownMap);
95888
- const rotateYNeg = cameraControl._isKeyDownForAction(cameraControl.ROTATE_Y_NEG, keyDownMap);
95889
- const rotateXPos = cameraControl._isKeyDownForAction(cameraControl.ROTATE_X_POS, keyDownMap);
95890
- const rotateXNeg = cameraControl._isKeyDownForAction(cameraControl.ROTATE_X_NEG, keyDownMap);
95834
+ this._onSceneMouseMove = input.on("mousemove", () => {
95835
+ mouseMovedSinceLastKeyboardDolly = true;
95836
+ });
95891
95837
 
95892
- const orbitDelta = elapsedSecs * configs.keyboardRotationRate;
95838
+ this._onSceneKeyDown = input.on("keydown", (keyCode) => {
95839
+ if (!(configs.active && configs.pointerEnabled) || !scene.input.keyboardEnabled) {
95840
+ return;
95841
+ }
95842
+ if (!states.mouseover) {
95843
+ return;
95844
+ }
95845
+ keyDownMap[keyCode] = true;
95893
95846
 
95894
- if (rotateYPos || rotateYNeg || rotateXPos || rotateXNeg) {
95847
+ if (keyCode === input.KEY_SHIFT) {
95848
+ canvas.style.cursor = "move";
95849
+ }
95850
+ });
95895
95851
 
95896
- if ((!configs.firstPerson) && configs.followPointer) {
95897
- controllers.pivotController.startPivot();
95898
- }
95852
+ this._onSceneKeyUp = input.on("keyup", (keyCode) => {
95853
+ if (!(configs.active && configs.pointerEnabled) || !scene.input.keyboardEnabled) {
95854
+ return;
95855
+ }
95856
+ keyDownMap[keyCode] = false;
95899
95857
 
95900
- if (rotateYPos) {
95901
- updates.rotateDeltaY += orbitDelta;
95858
+ if (keyCode === input.KEY_SHIFT) {
95859
+ canvas.style.cursor = null;
95860
+ }
95902
95861
 
95903
- } else if (rotateYNeg) {
95904
- updates.rotateDeltaY -= orbitDelta;
95905
- }
95862
+ if (controllers.pivotController.getPivoting()) {
95863
+ controllers.pivotController.endPivot();
95864
+ }
95865
+ });
95906
95866
 
95907
- if (rotateXPos) {
95908
- updates.rotateDeltaX += orbitDelta;
95867
+ this._onTick = scene.on("tick", (e) => {
95868
+ if (!(configs.active && configs.pointerEnabled) || !scene.input.keyboardEnabled) {
95869
+ return;
95870
+ }
95909
95871
 
95910
- } else if (rotateXNeg) {
95911
- updates.rotateDeltaX -= orbitDelta;
95912
- }
95872
+ if (!states.mouseover) {
95873
+ return;
95874
+ }
95913
95875
 
95914
- if ((!configs.firstPerson) && configs.followPointer) {
95915
- controllers.pivotController.startPivot();
95916
- }
95917
- }
95918
- }
95876
+ const cameraControl = controllers.cameraControl;
95877
+ const elapsedSecs = e.deltaTime / 1000.0;
95919
95878
 
95920
- //-------------------------------------------------------------------------------------------------
95921
- // Keyboard panning
95922
- //-------------------------------------------------------------------------------------------------
95879
+ //-------------------------------------------------------------------------------------------------
95880
+ // Keyboard rotation
95881
+ //-------------------------------------------------------------------------------------------------
95923
95882
 
95924
- if (!keyDownMap[input.KEY_CTRL] && !keyDownMap[input.KEY_ALT]) {
95883
+ if (!configs.planView) {
95884
+ const rotateYPos = cameraControl._isKeyDownForAction(cameraControl.ROTATE_Y_POS, keyDownMap);
95885
+ const rotateYNeg = cameraControl._isKeyDownForAction(cameraControl.ROTATE_Y_NEG, keyDownMap);
95886
+ const rotateXPos = cameraControl._isKeyDownForAction(cameraControl.ROTATE_X_POS, keyDownMap);
95887
+ const rotateXNeg = cameraControl._isKeyDownForAction(cameraControl.ROTATE_X_NEG, keyDownMap);
95925
95888
 
95926
- const dollyBackwards = cameraControl._isKeyDownForAction(cameraControl.DOLLY_BACKWARDS, keyDownMap);
95927
- const dollyForwards = cameraControl._isKeyDownForAction(cameraControl.DOLLY_FORWARDS, keyDownMap);
95889
+ const orbitDelta = elapsedSecs * configs.keyboardRotationRate;
95928
95890
 
95929
- if (dollyBackwards || dollyForwards) {
95891
+ if (rotateYPos || rotateYNeg || rotateXPos || rotateXNeg) {
95892
+ if (!configs.firstPerson && configs.followPointer) {
95893
+ controllers.pivotController.startPivot();
95894
+ }
95930
95895
 
95931
- const dollyDelta = elapsedSecs * configs.keyboardDollyRate;
95896
+ if (rotateYPos) {
95897
+ updates.rotateDeltaY += orbitDelta;
95898
+ } else if (rotateYNeg) {
95899
+ updates.rotateDeltaY -= orbitDelta;
95900
+ }
95932
95901
 
95933
- if ((!configs.firstPerson) && configs.followPointer) {
95934
- controllers.pivotController.startPivot();
95935
- }
95936
- if (dollyForwards) {
95937
- updates.dollyDelta -= dollyDelta;
95938
- } else if (dollyBackwards) {
95939
- updates.dollyDelta += dollyDelta;
95940
- }
95902
+ if (rotateXPos) {
95903
+ updates.rotateDeltaX += orbitDelta;
95904
+ } else if (rotateXNeg) {
95905
+ updates.rotateDeltaX -= orbitDelta;
95906
+ }
95941
95907
 
95942
- if (mouseMovedSinceLastKeyboardDolly) {
95943
- states.followPointerDirty = true;
95944
- mouseMovedSinceLastKeyboardDolly = false;
95945
- }
95946
- }
95947
- }
95908
+ if (!configs.firstPerson && configs.followPointer) {
95909
+ controllers.pivotController.startPivot();
95910
+ }
95911
+ }
95912
+ }
95948
95913
 
95949
- const panForwards = cameraControl._isKeyDownForAction(cameraControl.PAN_FORWARDS, keyDownMap);
95950
- const panBackwards = cameraControl._isKeyDownForAction(cameraControl.PAN_BACKWARDS, keyDownMap);
95951
- const panLeft = cameraControl._isKeyDownForAction(cameraControl.PAN_LEFT, keyDownMap);
95952
- const panRight = cameraControl._isKeyDownForAction(cameraControl.PAN_RIGHT, keyDownMap);
95953
- const panUp = cameraControl._isKeyDownForAction(cameraControl.PAN_UP, keyDownMap);
95954
- const panDown = cameraControl._isKeyDownForAction(cameraControl.PAN_DOWN, keyDownMap);
95914
+ //-------------------------------------------------------------------------------------------------
95915
+ // Keyboard panning
95916
+ //-------------------------------------------------------------------------------------------------
95955
95917
 
95956
- const panDelta = (keyDownMap[input.KEY_ALT] ? 0.3 : 1.0) * elapsedSecs * configs.keyboardPanRate; // ALT for slower pan rate
95918
+ if (!keyDownMap[input.KEY_CTRL] && !keyDownMap[input.KEY_ALT]) {
95919
+ const dollyBackwards = cameraControl._isKeyDownForAction(cameraControl.DOLLY_BACKWARDS, keyDownMap);
95920
+ const dollyForwards = cameraControl._isKeyDownForAction(cameraControl.DOLLY_FORWARDS, keyDownMap);
95957
95921
 
95958
- if (panForwards || panBackwards || panLeft || panRight || panUp || panDown) {
95922
+ if (dollyBackwards || dollyForwards) {
95923
+ const dollyDelta = elapsedSecs * configs.keyboardDollyRate;
95959
95924
 
95960
- if ((!configs.firstPerson) && configs.followPointer) {
95961
- controllers.pivotController.startPivot();
95962
- }
95925
+ if (!configs.firstPerson && configs.followPointer) {
95926
+ controllers.pivotController.startPivot();
95927
+ }
95928
+ if (dollyForwards) {
95929
+ updates.dollyDelta -= dollyDelta;
95930
+ } else if (dollyBackwards) {
95931
+ updates.dollyDelta += dollyDelta;
95932
+ }
95963
95933
 
95964
- if (panDown) {
95965
- updates.panDeltaY += panDelta;
95934
+ if (mouseMovedSinceLastKeyboardDolly) {
95935
+ states.followPointerDirty = true;
95936
+ mouseMovedSinceLastKeyboardDolly = false;
95937
+ }
95938
+ }
95939
+ }
95966
95940
 
95967
- } else if (panUp) {
95968
- updates.panDeltaY += -panDelta;
95969
- }
95941
+ const panForwards = cameraControl._isKeyDownForAction(cameraControl.PAN_FORWARDS, keyDownMap);
95942
+ const panBackwards = cameraControl._isKeyDownForAction(cameraControl.PAN_BACKWARDS, keyDownMap);
95943
+ const panLeft = cameraControl._isKeyDownForAction(cameraControl.PAN_LEFT, keyDownMap);
95944
+ const panRight = cameraControl._isKeyDownForAction(cameraControl.PAN_RIGHT, keyDownMap);
95945
+ const panUp = cameraControl._isKeyDownForAction(cameraControl.PAN_UP, keyDownMap);
95946
+ const panDown = cameraControl._isKeyDownForAction(cameraControl.PAN_DOWN, keyDownMap);
95970
95947
 
95971
- if (panRight) {
95972
- updates.panDeltaX += -panDelta;
95948
+ const panDelta = (keyDownMap[input.KEY_ALT] ? 0.3 : 1.0) * elapsedSecs * configs.keyboardPanRate; // ALT for slower pan rate
95973
95949
 
95974
- } else if (panLeft) {
95975
- updates.panDeltaX += panDelta;
95976
- }
95950
+ if (panForwards || panBackwards || panLeft || panRight || panUp || panDown) {
95951
+ if (!configs.firstPerson && configs.followPointer) {
95952
+ controllers.pivotController.startPivot();
95953
+ }
95977
95954
 
95978
- if (panBackwards) {
95979
- updates.panDeltaZ += panDelta;
95955
+ if (panDown) {
95956
+ updates.panDeltaY += panDelta;
95957
+ } else if (panUp) {
95958
+ updates.panDeltaY += -panDelta;
95959
+ }
95980
95960
 
95981
- } else if (panForwards) {
95982
- updates.panDeltaZ += -panDelta;
95983
- }
95984
- }
95985
- });
95986
- }
95961
+ if (panRight) {
95962
+ updates.panDeltaX += -panDelta;
95963
+ } else if (panLeft) {
95964
+ updates.panDeltaX += panDelta;
95965
+ }
95987
95966
 
95988
- reset() {
95989
- }
95967
+ if (panBackwards) {
95968
+ updates.panDeltaZ += panDelta;
95969
+ } else if (panForwards) {
95970
+ updates.panDeltaZ += -panDelta;
95971
+ }
95972
+ }
95973
+ });
95974
+ }
95990
95975
 
95991
- destroy() {
95976
+ reset() {}
95992
95977
 
95993
- this._scene.off(this._onTick);
95978
+ destroy() {
95979
+ this._scene.off(this._onTick);
95994
95980
 
95995
- this._scene.input.off(this._onSceneMouseMove);
95996
- this._scene.input.off(this._onSceneKeyDown);
95997
- this._scene.input.off(this._onSceneKeyUp);
95998
- }
95981
+ this._scene.input.off(this._onSceneMouseMove);
95982
+ this._scene.input.off(this._onSceneKeyDown);
95983
+ this._scene.input.off(this._onSceneKeyUp);
95984
+ }
95999
95985
  }
96000
95986
 
96001
95987
  const SCALE_DOLLY_EACH_FRAME = 1; // Recalculate dolly speed for eye->target distance on each Nth frame
@@ -97639,6 +97625,95 @@ class CameraControl extends Component {
97639
97625
  this.pointerEnabled = true;
97640
97626
  this.keyboardDollyRate = cfg.keyboardDollyRate;
97641
97627
  this.mouseWheelDollyRate = cfg.mouseWheelDollyRate;
97628
+ this._moveRate = 1;
97629
+ this.scene.on("tick", () => {
97630
+ // if (!(this._configs.active && this._configs.pointerEnabled)) return;
97631
+ // if (!this._states.mouseover) return;
97632
+ if (!(this._goLeft || this._goRight || this._goUp || this._goDown || this._goForward || this._goBackward)) {
97633
+ // this._inputDirectionCommand = false;
97634
+ return;
97635
+ }
97636
+ if (this._goRight) {
97637
+ this._updates.panDeltaX += -0.1 * this._moveRate;
97638
+ } else if (this._goLeft) {
97639
+ this._updates.panDeltaX += 0.1 * this._moveRate;
97640
+ }
97641
+
97642
+ if (this._goUp) {
97643
+ this._updates.panDeltaY += 0.1 * this._moveRate;
97644
+ } else if (this._goDown) {
97645
+ this._updates.panDeltaY += -0.1 * this._moveRate;
97646
+ }
97647
+
97648
+ if (this._goForward) {
97649
+ this._updates.panDeltaZ += -0.1 * this._moveRate;
97650
+ } else if (this._goBackward) {
97651
+ this._updates.panDeltaZ += +0.1 * this._moveRate;
97652
+ }
97653
+ this._inputDirectionCommand = true;
97654
+ });
97655
+ }
97656
+ /**
97657
+ * 停止漫游
97658
+ */
97659
+ setdirectionChangeCancel() {
97660
+ this._goLeft = false;
97661
+ this._goRight = false;
97662
+ this._goUp = false;
97663
+ this._goDown = false;
97664
+ this._goForward = false;
97665
+ this._goBackward = false;
97666
+ }
97667
+
97668
+ /**
97669
+ * 设置漫游移动速率
97670
+ * @param {number} rate
97671
+ */
97672
+ set moveRate(rate) {
97673
+ this._moveRate = rate;
97674
+ }
97675
+
97676
+ /**
97677
+ * 漫游向右
97678
+ * @param {boolean} go
97679
+ */
97680
+ set goRight(go) {
97681
+ this._goRight = go;
97682
+ }
97683
+ /**
97684
+ * 漫游向左
97685
+ * @param {boolean} go
97686
+ */
97687
+ set goLeft(go) {
97688
+ this._goLeft = go;
97689
+ }
97690
+ /**
97691
+ * 漫游向上
97692
+ * @param {boolean} go
97693
+ */
97694
+ set goUp(go) {
97695
+ this._goUp = go;
97696
+ }
97697
+ /**
97698
+ * 漫游向下
97699
+ * @param {boolean} go
97700
+ */
97701
+ set goDown(go) {
97702
+ this._goDown = go;
97703
+ }
97704
+ /**
97705
+ * 漫游向前
97706
+ * @param {boolean} go
97707
+ */
97708
+ set goForward(go) {
97709
+ this._goForward = go;
97710
+ }
97711
+ /**
97712
+ * 漫游向后
97713
+ * @param {boolean} go
97714
+ */
97715
+ set goBackward(go) {
97716
+ this._goBackward = go;
97642
97717
  }
97643
97718
 
97644
97719
  updatePivotElement() {
@@ -117492,14 +117567,14 @@ class NavCubePlugin extends Plugin {
117492
117567
  this.setIsProjectNorth(cfg.isProjectNorth);
117493
117568
  this.setProjectNorthOffsetAngle(cfg.projectNorthOffsetAngle);
117494
117569
 
117495
- const rotateTrueNorth = (function () {
117570
+ const rotateTrueNorth = (this.rotateTrueNorth = (function () {
117496
117571
  const trueNorthMatrix = math.mat4();
117497
117572
  return function (dir, vec, dest) {
117498
117573
  math.identityMat4(trueNorthMatrix);
117499
117574
  math.rotationMat4v(dir * self._projectNorthOffsetAngle * math.DEGTORAD, [0, 1, 0], trueNorthMatrix);
117500
117575
  return math.transformVec3(trueNorthMatrix, vec, dest);
117501
117576
  };
117502
- })();
117577
+ })());
117503
117578
 
117504
117579
  this._synchCamera = (function () {
117505
117580
  var matrix = math.rotationMat4c(-90 * math.DEGTORAD, 1, 0, 0);
@@ -117727,6 +117802,7 @@ class NavCubePlugin extends Plugin {
117727
117802
  if (hit) {
117728
117803
  if (hit.uv) {
117729
117804
  var areaId = self._cubeTextureCanvas.getArea(hit.uv);
117805
+ console.log(areaId);
117730
117806
  if (areaId >= 0) {
117731
117807
  document.body.style.cursor = "pointer";
117732
117808
  if (lastAreaId >= 0) {
@@ -117748,6 +117824,8 @@ class NavCubePlugin extends Plugin {
117748
117824
  dir = rotateTrueNorth(+1, dir, tempVec3a$4);
117749
117825
  up = rotateTrueNorth(+1, up, tempVec3b$1);
117750
117826
  }
117827
+ console.log(dir);
117828
+ console.log(up);
117751
117829
  flyTo(dir, up, function () {
117752
117830
  if (lastAreaId >= 0) {
117753
117831
  self._cubeTextureCanvas.setAreaHighlighted(lastAreaId, false);
@@ -117827,7 +117905,7 @@ class NavCubePlugin extends Plugin {
117827
117905
  })
117828
117906
  );
117829
117907
 
117830
- var flyTo = (function () {
117908
+ var flyTo = (this.flyTo = (function () {
117831
117909
  var center = math.vec3();
117832
117910
  return function (dir, up, ok) {
117833
117911
  var aabb = self._fitVisible ? viewer.scene.getAABB(viewer.scene.visibleObjectIds) : viewer.scene.aabb;
@@ -117860,7 +117938,7 @@ class NavCubePlugin extends Plugin {
117860
117938
  );
117861
117939
  }
117862
117940
  };
117863
- })();
117941
+ })());
117864
117942
  }
117865
117943
 
117866
117944
  this._onUpdated = viewer.localeService.on("updated", () => {
@@ -117876,6 +117954,28 @@ class NavCubePlugin extends Plugin {
117876
117954
  this.setSynchProjection(cfg.synchProjection);
117877
117955
  }
117878
117956
 
117957
+ flyByClick(areaId) {
117958
+ if (areaId >= 0) {
117959
+ this._cubeTextureCanvas.setAreaHighlighted(areaId, true);
117960
+ this._repaint();
117961
+ var dir = this._cubeTextureCanvas.getAreaDir(areaId);
117962
+ if (dir) {
117963
+ var up = this._cubeTextureCanvas.getAreaUp(areaId);
117964
+ if (this._isProjectNorth && this._projectNorthOffsetAngle) {
117965
+ dir = this.rotateTrueNorth(+1, dir, tempVec3a$4);
117966
+ up = this.rotateTrueNorth(+1, up, tempVec3b$1);
117967
+ }
117968
+ this.flyTo(dir, up, function () {
117969
+ document.body.style.cursor = "pointer";
117970
+ });
117971
+ }
117972
+ }
117973
+ }
117974
+
117975
+ get navCubeScene() {
117976
+ return this._navCubeScene;
117977
+ }
117978
+
117879
117979
  send(name, value) {
117880
117980
  switch (name) {
117881
117981
  case "language":