@kimap/indoor-positioning-sdk-vue2 6.0.6 → 6.0.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 +1 -1
- package/src/core/KimapSDK.js +38 -1
- package/src/core/SceneCore.js +6 -41
package/package.json
CHANGED
package/src/core/KimapSDK.js
CHANGED
|
@@ -795,8 +795,9 @@ KimapSDK.prototype.showAllFloors = function() {
|
|
|
795
795
|
// 相机动画飞到 ALL 外景视角(参考正式版 _zoomToShowAllFloors)
|
|
796
796
|
this._zoomToShowAllFloors();
|
|
797
797
|
|
|
798
|
-
// 渲染 ALL
|
|
798
|
+
// 渲染 ALL 模式周边建筑物(带淡入效果)
|
|
799
799
|
this.core._addAllModeBuildings();
|
|
800
|
+
this._fadeInAllModeBuildings(600);
|
|
800
801
|
|
|
801
802
|
this._currentShowingFloorIndex = -1; // ALL 状态
|
|
802
803
|
this._currentMode = 'all';
|
|
@@ -912,6 +913,42 @@ KimapSDK.prototype._animateCamera = function(target, duration, onComplete) {
|
|
|
912
913
|
animate();
|
|
913
914
|
};
|
|
914
915
|
|
|
916
|
+
/**
|
|
917
|
+
* 淡入 ALL 模式建筑物(带透明度动画)
|
|
918
|
+
* @param {number} duration - 动画时长 ms
|
|
919
|
+
* @private
|
|
920
|
+
*/
|
|
921
|
+
KimapSDK.prototype._fadeInAllModeBuildings = function(duration) {
|
|
922
|
+
var self = this;
|
|
923
|
+
if (!this.core._allModeBuildings || this.core._allModeBuildings.length === 0) return;
|
|
924
|
+
|
|
925
|
+
// 初始透明度设为0
|
|
926
|
+
this.core._allModeBuildings.forEach(function(mesh) {
|
|
927
|
+
if (mesh.material && mesh.material.opacity !== undefined) {
|
|
928
|
+
mesh.material.opacity = 0;
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
|
|
932
|
+
var startTime = performance.now();
|
|
933
|
+
|
|
934
|
+
function fadeAnimate() {
|
|
935
|
+
var elapsed = performance.now() - startTime;
|
|
936
|
+
var progress = Math.min(elapsed / duration, 1);
|
|
937
|
+
|
|
938
|
+
self.core._allModeBuildings.forEach(function(mesh) {
|
|
939
|
+
if (mesh.material && mesh.material.opacity !== undefined) {
|
|
940
|
+
mesh.material.opacity = 0.5 * progress; // 目标透明度0.5
|
|
941
|
+
}
|
|
942
|
+
});
|
|
943
|
+
|
|
944
|
+
if (progress < 1) {
|
|
945
|
+
requestAnimationFrame(fadeAnimate);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
fadeAnimate();
|
|
950
|
+
};
|
|
951
|
+
|
|
915
952
|
/**
|
|
916
953
|
* 多楼层:是否正在显示所有楼层
|
|
917
954
|
* @public
|
package/src/core/SceneCore.js
CHANGED
|
@@ -233,55 +233,21 @@ SceneCore.prototype.setupLights = function() {
|
|
|
233
233
|
};
|
|
234
234
|
|
|
235
235
|
/**
|
|
236
|
-
*
|
|
236
|
+
* 设置地面(不使用) - 地面已移除
|
|
237
237
|
*/
|
|
238
238
|
SceneCore.prototype.setupGround = function() {
|
|
239
|
-
|
|
240
|
-
var maxX = this.coordinateSystem.maxX;
|
|
241
|
-
var maxZ = this.coordinateSystem.maxY;
|
|
242
|
-
|
|
243
|
-
// 地面尺寸稍大于地图,留出边距
|
|
244
|
-
var groundSize = Math.max(maxX, maxZ) * 1.6;
|
|
245
|
-
|
|
246
|
-
// 地面纯色平面(不接收阴影、不投射阴影)
|
|
247
|
-
var groundGeo = new THREE.PlaneGeometry(groundSize, groundSize);
|
|
248
|
-
var groundMat = new THREE.MeshLambertMaterial({
|
|
249
|
-
color: 0xfdfdfd,
|
|
250
|
-
side: THREE.DoubleSide
|
|
251
|
-
});
|
|
252
|
-
var ground = new THREE.Mesh(groundGeo, groundMat);
|
|
253
|
-
ground.rotation.x = -Math.PI / 2;
|
|
254
|
-
ground.position.set(origin.x + maxX / 2, -0.001, origin.z);
|
|
255
|
-
ground.receiveShadow = false;
|
|
256
|
-
this.scene.add(ground);
|
|
257
|
-
|
|
258
|
-
// 网格线(与地面颜色协调,线色 #d0d0d0,格间距 maxX/10)
|
|
259
|
-
var gridSize = Math.max(maxX, maxZ) * 1.5;
|
|
260
|
-
var gridDivisions = Math.max(10, Math.round(gridSize / (maxX / 10)));
|
|
261
|
-
var grid = new THREE.GridHelper(gridSize, gridDivisions, 0xbdbdbd, 0xd0d0d0);
|
|
262
|
-
grid.position.set(origin.x + maxX / 2, 0, origin.z);
|
|
263
|
-
grid.material.opacity = 0.5;
|
|
264
|
-
grid.material.transparent = true;
|
|
265
|
-
this.scene.add(grid);
|
|
239
|
+
// 地面和网格已移除
|
|
266
240
|
};
|
|
267
241
|
|
|
268
242
|
/**
|
|
269
|
-
*
|
|
243
|
+
* 添加坐标辅助器(仅坐标轴,无网格)
|
|
270
244
|
*/
|
|
271
245
|
SceneCore.prototype.addCoordinateHelper = function() {
|
|
272
246
|
var origin = this.coordinateSystem.origin;
|
|
273
247
|
var maxX = this.coordinateSystem.maxX;
|
|
274
248
|
var maxY = this.coordinateSystem.maxY;
|
|
275
|
-
var showGrid = this.config.showGrid === true;
|
|
276
249
|
var showAxes = this.config.showAxes === true;
|
|
277
250
|
|
|
278
|
-
if (showGrid) {
|
|
279
|
-
var gridSize = Math.max(maxX, maxY) * 1.5;
|
|
280
|
-
var gridHelper = new THREE.GridHelper(gridSize, 50, 0x888888, 0xcccccc);
|
|
281
|
-
gridHelper.position.set(origin.x + maxX / 2, origin.y, origin.z);
|
|
282
|
-
this.scene.add(gridHelper);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
251
|
if (showAxes) {
|
|
286
252
|
var axesSize = Math.min(maxX, maxY) * 0.5;
|
|
287
253
|
var axesHelper = new THREE.AxesHelper(axesSize);
|
|
@@ -608,10 +574,9 @@ SceneCore.prototype._addAllModeBuildings = function() {
|
|
|
608
574
|
|
|
609
575
|
var box = new THREE.Box3();
|
|
610
576
|
allMeshes.forEach(function(mesh) { box.expandByObject(mesh); });
|
|
611
|
-
|
|
612
|
-
var
|
|
613
|
-
box.
|
|
614
|
-
box.getMax(boxMax);
|
|
577
|
+
// 用 .min / .max 属性而非 .getMin() / .getMax()(兼容旧版 THREE.js)
|
|
578
|
+
var boxMin = box.min;
|
|
579
|
+
var boxMax = box.max;
|
|
615
580
|
var centerX = (boxMin.x + boxMax.x) / 2;
|
|
616
581
|
var centerZ = (boxMin.z + boxMax.z) / 2;
|
|
617
582
|
var modelW = boxMax.x - boxMin.x;
|