@kimap/indoor-positioning-sdk-vue2 6.0.7 → 6.0.9
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 +48 -1
- package/src/core/SceneCore.js +21 -40
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,52 @@ 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) {
|
|
928
|
+
mesh.material.transparent = true;
|
|
929
|
+
if (mesh.material.opacity !== undefined) {
|
|
930
|
+
mesh.material.opacity = 0;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
var startTime = performance.now();
|
|
936
|
+
|
|
937
|
+
function fadeAnimate() {
|
|
938
|
+
var elapsed = performance.now() - startTime;
|
|
939
|
+
var progress = Math.min(elapsed / duration, 1);
|
|
940
|
+
|
|
941
|
+
self.core._allModeBuildings.forEach(function(mesh) {
|
|
942
|
+
if (mesh.material) {
|
|
943
|
+
// 主体灰色半透明,描边和顶部标记淡蓝色
|
|
944
|
+
if (mesh.name && mesh.name.startsWith('__build__edges')) {
|
|
945
|
+
mesh.material.opacity = 0.8 * progress;
|
|
946
|
+
} else if (mesh.name && mesh.name.startsWith('__build__tip')) {
|
|
947
|
+
mesh.material.opacity = progress;
|
|
948
|
+
} else {
|
|
949
|
+
mesh.material.opacity = 0.3 * progress;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
});
|
|
953
|
+
|
|
954
|
+
if (progress < 1) {
|
|
955
|
+
requestAnimationFrame(fadeAnimate);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
fadeAnimate();
|
|
960
|
+
};
|
|
961
|
+
|
|
915
962
|
/**
|
|
916
963
|
* 多楼层:是否正在显示所有楼层
|
|
917
964
|
* @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: 0xf9f9f9,
|
|
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);
|
|
@@ -641,10 +607,12 @@ SceneCore.prototype._addAllModeBuildings = function() {
|
|
|
641
607
|
heights.forEach(function(h, i) {
|
|
642
608
|
var o = offsets[i];
|
|
643
609
|
var geo = new THREE.BoxGeometry(o.w, h, o.d);
|
|
610
|
+
|
|
611
|
+
// 灰色半透明主体
|
|
644
612
|
var mat = new THREE.MeshBasicMaterial({
|
|
645
|
-
color:
|
|
613
|
+
color: 0x888888,
|
|
646
614
|
transparent: true,
|
|
647
|
-
opacity: 0.
|
|
615
|
+
opacity: 0.3,
|
|
648
616
|
depthWrite: false
|
|
649
617
|
});
|
|
650
618
|
var mesh = new THREE.Mesh(geo, mat);
|
|
@@ -655,7 +623,20 @@ SceneCore.prototype._addAllModeBuildings = function() {
|
|
|
655
623
|
self.scene.add(mesh);
|
|
656
624
|
self._allModeBuildings.push(mesh);
|
|
657
625
|
|
|
658
|
-
//
|
|
626
|
+
// 淡蓝色描边
|
|
627
|
+
var edgesGeo = new THREE.EdgesGeometry(geo);
|
|
628
|
+
var edgesMat = new THREE.LineBasicMaterial({
|
|
629
|
+
color: 0x4fc3f7,
|
|
630
|
+
transparent: true,
|
|
631
|
+
opacity: 0.8
|
|
632
|
+
});
|
|
633
|
+
var edges = new THREE.LineSegments(edgesGeo, edgesMat);
|
|
634
|
+
edges.position.copy(mesh.position);
|
|
635
|
+
edges.name = '__build__edges' + i;
|
|
636
|
+
self.scene.add(edges);
|
|
637
|
+
self._allModeBuildings.push(edges);
|
|
638
|
+
|
|
639
|
+
// 顶部标记(淡蓝色)
|
|
659
640
|
var tipGeo = new THREE.BoxGeometry(o.w * 0.3, 0.1, o.d * 0.3);
|
|
660
641
|
var tipMat = new THREE.MeshBasicMaterial({ color: 0x4fc3f7 });
|
|
661
642
|
var tip = new THREE.Mesh(tipGeo, tipMat);
|