@kimap/indoor-positioning-sdk-vue2 5.9.6 → 5.9.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kimap/indoor-positioning-sdk-vue2",
3
- "version": "5.9.6",
3
+ "version": "5.9.7",
4
4
  "description": "Vue2自包含室内定位SDK - 完全兼容Webpack3+Babel6 | Vue2 Self-Contained Indoor Positioning SDK",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -146,6 +146,41 @@ KimapSDK.prototype.handleClick = function(event) {
146
146
  KimapSDK.prototype.startRenderLoop = function() {
147
147
  var self = this;
148
148
  var lastTime = Date.now();
149
+ var _cameraMoving = false;
150
+ var _movementTimer = null;
151
+
152
+ // 检测相机停止后打印俯仰角和缩放距离
153
+ function checkCameraStopped() {
154
+ if (!self.core || !self.core.camera || !self.core.controls) return;
155
+ var cam = self.core.camera;
156
+ var ctl = self.core.controls;
157
+ // 计算球面坐标中的俯仰角(极角,从+Y方向看过去)
158
+ var dx = cam.position.x - ctl.target.x;
159
+ var dy = cam.position.y - ctl.target.y;
160
+ var dz = cam.position.z - ctl.target.z;
161
+ var dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
162
+ // polar angle: 从+Y轴向下看的角度,0=正上方,PI/2=地平线
163
+ var polarRad = Math.acos(dy / dist);
164
+ // azimuth: 从+Z方向逆时针到XZ平面的角度
165
+ var azimuthRad = Math.atan2(dx, dz);
166
+ var polarDeg = (polarRad * 180 / Math.PI).toFixed(2);
167
+ var azimuthDeg = (azimuthRad * 180 / Math.PI).toFixed(2);
168
+ var distDeg = dist.toFixed(2);
169
+ console.log('[Camera Debug] 俯仰角: ' + polarDeg + '° | 方位角: ' + azimuthDeg + '° | 距离: ' + distDeg);
170
+ }
171
+
172
+ function onControlsChange() {
173
+ _cameraMoving = true;
174
+ if (_movementTimer) clearTimeout(_movementTimer);
175
+ _movementTimer = setTimeout(function() {
176
+ _cameraMoving = false;
177
+ checkCameraStopped();
178
+ }, 300);
179
+ }
180
+
181
+ if (this.core && this.core.controls) {
182
+ this.core.controls.addEventListener('change', onControlsChange);
183
+ }
149
184
 
150
185
  function animate() {
151
186
  self.animationFrameId = requestAnimationFrame(animate);
@@ -629,9 +664,9 @@ KimapSDK.prototype.showSingleFloor = function(floorIndex) {
629
664
  this.floorGroups.forEach(function(group, idx) {
630
665
  if (idx === floorIndex) {
631
666
  if (isFromAll) {
632
- // ALL→单楼:目标层保持在 ALL 位置
667
+ // ALL→单楼:目标层回到 Y=0 贴地
633
668
  group.visible = true;
634
- group.position.y = self.core.floorOriginalY[idx] || 0;
669
+ group.position.y = 0;
635
670
  } else {
636
671
  // 单楼→单楼:目标层滑入动画
637
672
  group.visible = true;
@@ -644,13 +679,9 @@ KimapSDK.prototype.showSingleFloor = function(floorIndex) {
644
679
  });
645
680
  }
646
681
  } else {
647
- if (isFromAll) {
648
- // ALL→单楼:其他楼层保持 ALL 位置,不隐藏
649
- group.visible = true;
650
- group.position.y = self.core.floorOriginalY[idx] || 0;
651
- } else {
652
- // 单楼→单楼:离场层立即消失
653
- group.visible = false;
682
+ // 无论 ALL→单楼 还是 单楼→单楼,非目标楼层一律隐藏
683
+ group.visible = false;
684
+ if (!isFromAll) {
654
685
  var origY = self.core.floorOriginalY[idx] || 0;
655
686
  group.position.y = -origY - 1;
656
687
  }
@@ -708,13 +739,13 @@ KimapSDK.prototype._adjustCameraToFloor = function(floorIndex) {
708
739
  box.getCenter(center);
709
740
  box.getSize(size);
710
741
  var maxSize = Math.max(size.x, size.z);
711
- var dist = maxSize * 1.5;
742
+ var dist = maxSize * 1.2;
712
743
 
713
- // -60° 俯角:camera.y = center.y + dist*1.732, camera.z = center.z + dist
744
+ // -60° 俯角:camera.y = center.y + dist*0.866, camera.z = center.z + dist*0.5
714
745
  var targetPosition = new THREE.Vector3(
715
746
  center.x,
716
- center.y + dist * 1.732,
717
- center.z + dist
747
+ center.y + dist * 0.866,
748
+ center.z + dist * 0.5
718
749
  );
719
750
 
720
751
  this._animateCamera({
@@ -774,13 +805,13 @@ KimapSDK.prototype._zoomToShowAllFloors = function() {
774
805
  box.getCenter(center);
775
806
  box.getSize(size);
776
807
  var maxSize = Math.max(size.x, size.z);
777
- var dist = maxSize * 2.5;
808
+ var dist = maxSize * 1.2;
778
809
 
779
- // -15° 俯角:sin(-15°)0.259, cos(-15°)0.966(从建筑斜上方俯视)
810
+ // -60° 俯角:sin(60°)=0.866, cos(60°)=0.5(从模型斜上方俯视)
780
811
  var targetPosition = new THREE.Vector3(
781
812
  center.x,
782
- center.y + dist * 0.259,
783
- center.z + dist * 0.966
813
+ center.y + dist * 0.866,
814
+ center.z + dist * 0.5
784
815
  );
785
816
 
786
817
  this._animateCamera({
@@ -1652,15 +1683,15 @@ KimapSDK.prototype.destroy = function() {
1652
1683
  if (this.animationFrameId) {
1653
1684
  cancelAnimationFrame(this.animationFrameId);
1654
1685
  }
1655
-
1686
+
1656
1687
  if (this.resizeHandler) {
1657
1688
  window.removeEventListener('resize', this.resizeHandler);
1658
1689
  }
1659
-
1690
+
1660
1691
  if (this.clickHandler && this.core && this.core.renderer) {
1661
1692
  this.core.renderer.domElement.removeEventListener('click', this.clickHandler);
1662
1693
  }
1663
-
1694
+
1664
1695
  if (this.core) {
1665
1696
  this.core.destroy();
1666
1697
  }