@kimap/indoor-positioning-sdk-vue2 5.8.6 → 5.8.8

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.8.6",
3
+ "version": "5.8.8",
4
4
  "description": "Vue2自包含室内定位SDK - 完全兼容Webpack3+Babel6 | Vue2 Self-Contained Indoor Positioning SDK",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -84,9 +84,10 @@ KimapSDK.prototype.init = function() {
84
84
  self.startRenderLoop();
85
85
  self._extractWallsFromModel();
86
86
 
87
- // 多楼层默认显示第一个楼层
87
+ // 多楼层默认显示第一个楼层,并设 -60° 俯角相机
88
88
  if (self.isMultiFloor && self.floorGroups && self.floorGroups.length > 0) {
89
89
  self.showSingleFloor(0);
90
+ self.core.adjustCameraToSingleFloorView(0);
90
91
  }
91
92
 
92
93
  // 渲染内置楼层选择器 UI
@@ -667,6 +668,7 @@ KimapSDK.prototype.showSingleFloor = function(floorIndex) {
667
668
  };
668
669
 
669
670
  this._currentShowingFloorIndex = floorIndex;
671
+ self.core._lastSingleFloorIndex = floorIndex;
670
672
  // 退出 ALL 时:相机动画恢复到单楼层视角(保持当前位置,不重置)
671
673
  if (self.core.cameraPitchState === 1) {
672
674
  self.core.animateCameraToFloorView(600);
@@ -532,16 +532,16 @@ SceneCore.prototype.adjustCameraToFloor = function(floorIndex) {
532
532
  box.getCenter(center);
533
533
  box.getSize(size);
534
534
  var maxSize = Math.max(size.x, size.z);
535
- var distance = maxSize * 2;
535
+ var distance = maxSize * 1.5;
536
536
 
537
- this.camera.position.set(center.x, center.y + distance * 1.5, center.z + distance);
537
+ // -60° 俯角(与 ALL -45° 区分,单楼层更俯视)
538
+ this.camera.position.set(center.x, center.y - distance * 1.732, center.z + distance);
538
539
  var lookAtTgt = new THREE.Vector3(center.x, center.y, center.z);
539
540
  this.camera.lookAt(lookAtTgt);
540
541
  if (this.controls) {
541
542
  this.controls.target.copy(lookAtTgt);
542
543
  this.controls.update();
543
544
  }
544
- // 记录当前 lookAt 目标(ALL 退场恢复用)
545
545
  this.camera.lookAtTarget = lookAtTgt;
546
546
  this.coordinateSystem.maxX = size.x;
547
547
  this.coordinateSystem.maxY = size.z;
@@ -550,6 +550,14 @@ SceneCore.prototype.adjustCameraToFloor = function(floorIndex) {
550
550
  }
551
551
  };
552
552
 
553
+ /**
554
+ * 首次加载 / ALL 退出时:单楼层 -60° 俯角相机定位(独立方法,不改变现有 adjustCameraToFloor)
555
+ * @param {number} floorIndex
556
+ */
557
+ SceneCore.prototype.adjustCameraToSingleFloorView = function(floorIndex) {
558
+ this.adjustCameraToFloor(floorIndex);
559
+ };
560
+
553
561
  /**
554
562
  * 加载 Kimap 加密文件(内部方法)
555
563
  * @private
@@ -1385,22 +1393,49 @@ SceneCore.prototype.animateCameraToFloorView = function(duration) {
1385
1393
  this.cameraPitchAnim = null;
1386
1394
  }
1387
1395
 
1388
- // 退场恢复点
1389
- var toPos = this.cameraPrePitchPos || this.camera.position.clone();
1390
- var toTarget = this.cameraPrePitchTarget || this.camera.position.clone();
1396
+ // 计算当前单楼层中心(-60° 单楼层俯角,不压低)
1397
+ var floorIdx = this._lastSingleFloorIndex !== undefined ? this._lastSingleFloorIndex : 0;
1398
+ var floorGroup = this.floorGroups[floorIdx];
1399
+ var toTarget, toPos, dist, maxSize;
1400
+
1401
+ if (floorGroup) {
1402
+ var meshes = [];
1403
+ floorGroup.traverse(function(child) { if (child.isMesh) meshes.push(child); });
1404
+ if (meshes.length > 0) {
1405
+ var box = new THREE.Box3();
1406
+ meshes.forEach(function(mesh) { box.expandByObject(mesh); });
1407
+ toTarget = new THREE.Vector3();
1408
+ var size = new THREE.Vector3();
1409
+ box.getCenter(toTarget);
1410
+ box.getSize(size);
1411
+ maxSize = Math.max(size.x, size.z);
1412
+ dist = maxSize * 1.5;
1413
+ // -60° 俯角,与 ALL -45° 区分
1414
+ toPos = new THREE.Vector3(toTarget.x, toTarget.y - dist * 1.732, toTarget.z + dist);
1415
+ }
1416
+ }
1417
+
1418
+ if (!toPos) {
1419
+ toTarget = this.camera.lookAtTarget || this.camera.position.clone();
1420
+ toPos = this.camera.position.clone();
1421
+ }
1422
+
1423
+ var fromPos = this.camera.position.clone();
1424
+ var fromTarget = this.camera.lookAtTarget ? this.camera.lookAtTarget.clone() : toTarget.clone();
1391
1425
 
1392
1426
  this.cameraPitchAnim = {
1393
1427
  running: true,
1394
1428
  startTime: Date.now(),
1395
1429
  duration: duration,
1396
- fromPos: this.camera.position.clone(),
1430
+ fromPos: fromPos,
1397
1431
  toPos: toPos,
1398
- fromTarget: this.camera.lookAtTarget ? this.camera.lookAtTarget.clone() : toTarget.clone(),
1432
+ fromTarget: fromTarget,
1399
1433
  toTarget: toTarget
1400
1434
  };
1401
1435
  this.cameraPitchState = 0;
1402
1436
  this.cameraPrePitchPos = null;
1403
1437
  this.cameraPrePitchTarget = null;
1438
+ this.camera.lookAtTarget = toTarget.clone();
1404
1439
  };
1405
1440
 
1406
1441
  module.exports = SceneCore;