@kimap/indoor-positioning-sdk-vue2 5.3.6 → 5.3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kimap/indoor-positioning-sdk-vue2",
3
- "version": "5.3.6",
3
+ "version": "5.3.9",
4
4
  "description": "Vue2自包含室内定位SDK - 完全兼容Webpack3+Babel6 | Vue2 Self-Contained Indoor Positioning SDK",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -105,11 +105,6 @@ KimapSDK.prototype.init = function() {
105
105
  // 默认显示第一个楼层(而不是ALL模式)
106
106
  if (self.isMultiFloor && self.floorGroups && self.floorGroups.length > 0) {
107
107
  self._showSingleFloor(0);
108
- } else if (self.dataUrl && self.config.objUrl) {
109
- // 单楼层/单模型模式:自动加载家具
110
- self.loadKMData().then(function(result) {
111
- console.log('家具自动加载完成:', result);
112
- });
113
108
  }
114
109
 
115
110
  return self;
@@ -1263,25 +1258,24 @@ KimapSDK.prototype._createTechGround = function() {
1263
1258
  this.techGroundGroup.visible = false; // 默认隐藏
1264
1259
  this.core.scene.add(this.techGroundGroup);
1265
1260
 
1266
- // 创建半透明深色地面(ALL 模式背景,不遮挡模型)
1261
+ // 创建网格地面
1262
+ var gridHelper = new THREE.GridHelper(groundSize, 50, 0x0066aa, 0x003355);
1263
+ gridHelper.position.y = -0.1;
1264
+ gridHelper.material.opacity = 0.3;
1265
+ gridHelper.material.transparent = true;
1266
+ this.techGroundGroup.add(gridHelper);
1267
+
1268
+ // 创建地面平面
1267
1269
  var groundGeometry = new THREE.PlaneGeometry(groundSize, groundSize);
1268
1270
  var groundMaterial = new THREE.MeshBasicMaterial({
1269
- color: 0x1a2a3a, // 深蓝灰色,比之前稍浅以免太暗
1271
+ color: 0x0a1628,
1270
1272
  transparent: true,
1271
- opacity: 0.4, // 降低透明度避免遮挡
1272
- side: THREE.DoubleSide
1273
+ opacity: 0.8
1273
1274
  });
1274
1275
  var ground = new THREE.Mesh(groundGeometry, groundMaterial);
1275
1276
  ground.rotation.x = -Math.PI / 2;
1276
- ground.position.y = -0.15;
1277
+ ground.position.y = -0.2;
1277
1278
  this.techGroundGroup.add(ground);
1278
-
1279
- // 创建网格地面
1280
- var gridHelper = new THREE.GridHelper(groundSize, 50, 0x0066aa, 0x003355);
1281
- gridHelper.position.y = -0.1;
1282
- gridHelper.material.opacity = 0.3;
1283
- gridHelper.material.transparent = true;
1284
- this.techGroundGroup.add(gridHelper);
1285
1279
  };
1286
1280
 
1287
1281
  /**
@@ -1960,21 +1954,19 @@ KimapSDK.prototype._loadSingleFurniture = function(furniture, serverUrl) {
1960
1954
  // =====================================================
1961
1955
  furnitureGroup.renderOrder = 3000;
1962
1956
 
1963
- // 只对透明材质关闭 depthWrite,避免不透明家具被遮挡
1957
+ // 遍历模型,设置材质的深度测试和写入
1964
1958
  obj.traverse(function(child) {
1965
1959
  if (child instanceof THREE.Mesh) {
1966
1960
  if (Array.isArray(child.material)) {
1967
1961
  child.material.forEach(function(mat) {
1968
- // 仅对透明材质关闭 depthWrite
1969
- if (mat.transparent || mat.opacity < 1) {
1970
- mat.depthWrite = false;
1971
- }
1962
+ mat.depthWrite = false;
1963
+ mat.depthTest = true;
1964
+ mat.transparent = true;
1972
1965
  });
1973
1966
  } else if (child.material) {
1974
- // 仅对透明材质关闭 depthWrite
1975
- if (child.material.transparent || child.material.opacity < 1) {
1976
- child.material.depthWrite = false;
1977
- }
1967
+ child.material.depthWrite = false;
1968
+ child.material.depthTest = true;
1969
+ child.material.transparent = true;
1978
1970
  }
1979
1971
  }
1980
1972
  });
@@ -2021,21 +2013,19 @@ KimapSDK.prototype._loadSingleFurniture = function(furniture, serverUrl) {
2021
2013
  // 应用Y轴微小偏移
2022
2014
  obj.position.y += totalYOffset;
2023
2015
 
2024
- // 只对透明材质关闭 depthWrite,避免不透明家具被遮挡
2016
+ // 遍历模型,设置材质的深度测试和写入
2025
2017
  obj.traverse(function(child) {
2026
2018
  if (child instanceof THREE.Mesh) {
2027
2019
  if (Array.isArray(child.material)) {
2028
2020
  child.material.forEach(function(mat) {
2029
- // 仅对透明材质关闭 depthWrite
2030
- if (mat.transparent || mat.opacity < 1) {
2031
- mat.depthWrite = false;
2032
- }
2021
+ mat.depthWrite = false;
2022
+ mat.depthTest = true;
2023
+ mat.transparent = true;
2033
2024
  });
2034
2025
  } else if (child.material) {
2035
- // 仅对透明材质关闭 depthWrite
2036
- if (child.material.transparent || child.material.opacity < 1) {
2037
- child.material.depthWrite = false;
2038
- }
2026
+ child.material.depthWrite = false;
2027
+ child.material.depthTest = true;
2028
+ child.material.transparent = true;
2039
2029
  }
2040
2030
  }
2041
2031
  });
@@ -180,11 +180,11 @@ SceneCore.prototype.initControls = function(OrbitControls) {
180
180
  */
181
181
  SceneCore.prototype.setupLights = function() {
182
182
  // 环境光
183
- var ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
183
+ var ambientLight = new THREE.AmbientLight(0xffffff, 0.25);
184
184
  this.scene.add(ambientLight);
185
-
185
+
186
186
  // 主光源(从上方)
187
- var directionalLight1 = new THREE.DirectionalLight(0xffffff, 0.8);
187
+ var directionalLight1 = new THREE.DirectionalLight(0xffffff, 0.05);
188
188
  directionalLight1.position.set(10, 20, 10);
189
189
  directionalLight1.castShadow = true;
190
190
  directionalLight1.shadow.camera.left = -50;
@@ -192,14 +192,14 @@ SceneCore.prototype.setupLights = function() {
192
192
  directionalLight1.shadow.camera.top = 50;
193
193
  directionalLight1.shadow.camera.bottom = -50;
194
194
  this.scene.add(directionalLight1);
195
-
195
+
196
196
  // 辅助光源
197
- var directionalLight2 = new THREE.DirectionalLight(0xffffff, 0.3);
197
+ var directionalLight2 = new THREE.DirectionalLight(0xffffff, 0);
198
198
  directionalLight2.position.set(-10, 15, -10);
199
199
  this.scene.add(directionalLight2);
200
-
200
+
201
201
  // 半球光
202
- var hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.4);
202
+ var hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.3);
203
203
  this.scene.add(hemisphereLight);
204
204
  };
205
205
 
@@ -698,10 +698,10 @@ SceneCore.prototype._processLoadedModel = function(object, materials, colorMap)
698
698
  var areaLevel = 1; // 区域层级从1开始
699
699
 
700
700
  self.mapModel.traverse(function(child) {
701
- // 隐藏底平面交互层(综合检查对象名、父对象名、材质名、启发式)
702
- if (self._shouldHideGroundMesh(child)) {
701
+ // 隐藏底平面交互层(扩展匹配规则)
702
+ if (self._isHiddenGroundMesh(child.name)) {
703
703
  child.visible = false;
704
- console.log('✅ 隐藏交互层底平面:', child.name || (child.parent && child.parent.name) || '(启发式)');
704
+ console.log('✅ 隐藏交互层底平面:', child.name);
705
705
  return;
706
706
  }
707
707
 
@@ -757,7 +757,10 @@ SceneCore.prototype._processLoadedModel = function(object, materials, colorMap)
757
757
 
758
758
  areaLevel++;
759
759
  });
760
-
760
+
761
+ // 检测并隐藏大面积黑色底面mesh
762
+ self._hideLargeBlackGroundMesh(self.mapModel);
763
+
761
764
  // 自动调整相机位置
762
765
  self._adjustCameraToModel();
763
766
  };
@@ -789,7 +792,7 @@ SceneCore.prototype._processLoadedModelToGroup = function(object, materials, col
789
792
 
790
793
  // 处理材质
791
794
  object.traverse(function(child) {
792
- if (self._shouldHideGroundMesh(child)) {
795
+ if (self._isHiddenGroundMesh(child.name)) {
793
796
  child.visible = false;
794
797
  return;
795
798
  }
@@ -798,6 +801,9 @@ SceneCore.prototype._processLoadedModelToGroup = function(object, materials, col
798
801
  self._processMaterial(child, materials, colorMap);
799
802
  }
800
803
  });
804
+
805
+ // 检测并隐藏大面积黑色底面mesh
806
+ self._hideLargeBlackGroundMesh(object);
801
807
  };
802
808
 
803
809
  /**
@@ -855,13 +861,13 @@ SceneCore.prototype._adjustCameraToAllFloors = function() {
855
861
 
856
862
  /**
857
863
  * 判断是否为需要隐藏的底面/交互层mesh
858
- * 检查对象名、父对象名、材质名,以及启发式(薄黑水平面)
859
864
  * @private
860
865
  */
861
866
  SceneCore.prototype._isHiddenGroundMesh = function(name) {
862
867
  if (!name) return false;
863
868
  var lowerName = name.toLowerCase();
864
- // 扩展匹配规则:包含以下关键字的mesh将被隐藏
869
+ // 仅匹配明确标识为底板/交互层的名称关键字
870
+ // 避免泛词如 'ground'/'plane'/'base' 单独出现时误伤墙体/装饰件
865
871
  var hiddenPatterns = [
866
872
  'hiddengroundplane',
867
873
  'interactionlayer',
@@ -870,7 +876,9 @@ SceneCore.prototype._isHiddenGroundMesh = function(name) {
870
876
  'groundlayer',
871
877
  'floor_ground',
872
878
  'bottom',
873
- 'ground_base'
879
+ 'ground_base',
880
+ 'floorbase',
881
+ 'mapbase'
874
882
  ];
875
883
  return hiddenPatterns.some(function(pattern) {
876
884
  return lowerName.includes(pattern);
@@ -878,38 +886,64 @@ SceneCore.prototype._isHiddenGroundMesh = function(name) {
878
886
  };
879
887
 
880
888
  /**
881
- * 判断mesh是否应隐藏(综合检查对象名、父对象名、材质名、启发式)
889
+ * 检测并隐藏模型自带的大面积底垫mesh
890
+ * 基于世界空间包围盒的启发式判断(薄片+贴底+相对面积)
882
891
  * @private
883
892
  */
884
- SceneCore.prototype._shouldHideGroundMesh = function(child) {
885
- // 1. 检查自身名称
886
- if (child.name && this._isHiddenGroundMesh(child.name)) return true;
887
- // 2. 检查父对象名称(OBJ loader 可能将名称放在父级)
888
- if (child.parent && child.parent.name && this._isHiddenGroundMesh(child.parent.name)) return true;
889
- // 3. 检查材质名(绘制平台导出的 HiddenGroundPlane_Material)
890
- if (child.material && child.material.name) {
891
- var mtlName = child.material.name.toLowerCase();
892
- if (mtlName.includes('hiddengroundplane') || mtlName.includes('interactionlayer')) return true;
893
- }
894
- // 4. 启发式:近似水平、很薄、近黑色的大面积mesh(模型下的黑底)
895
- if (child.isMesh && child.geometry) {
893
+ SceneCore.prototype._hideLargeBlackGroundMesh = function(object) {
894
+ var self = this;
895
+
896
+ // 1. 计算模型整体世界空间包围盒
897
+ var modelBox = new THREE.Box3().setFromObject(object);
898
+ var modelMinY = modelBox.min.y;
899
+ var modelSize = new THREE.Vector3();
900
+ modelBox.getSize(modelSize);
901
+ var maxDim = Math.max(modelSize.x, modelSize.z);
902
+
903
+ // 2. 动态阈值(相对于模型尺度)
904
+ var slabMaxThickness = Math.max(0.05, 0.01 * maxDim); // 厚度上限
905
+ var minFootprint = Math.max(1, 0.05 * modelSize.x * modelSize.z); // 最小占地面积(比固定 1000 更灵活)
906
+ var epsilon = Math.max(0.01, 0.002 * modelSize.y); // 贴底判定容差
907
+
908
+ var debugMode = this.config && this.config.debugBottomMeshes === true;
909
+
910
+ object.traverse(function(child) {
911
+ if (!(child instanceof THREE.Mesh)) return;
912
+ if (child.visible === false) return;
913
+
914
+ // 名称已明确匹配的,保持隐藏(不在此重复打印)
915
+ if (self._isHiddenGroundMesh(child.name)) return;
916
+
917
+ if (!child.geometry || !child.geometry.attributes.position) return;
918
+
919
+ // 2. 计算世界空间包围盒(考虑旋转/缩放)
896
920
  child.geometry.computeBoundingBox();
897
- var box = child.geometry.boundingBox;
898
- var size = new THREE.Vector3();
899
- box.getSize(size);
900
- var height = size.y;
901
- var area = size.x * size.z;
902
- var isThinHorizontal = height < 0.05 && area > 1;
903
- if (isThinHorizontal && child.material) {
904
- var col = child.material.color;
905
- if (col) {
906
- var r = col.r, g = col.g, b = col.b;
907
- var isNearBlack = (r + g + b) < 0.15;
908
- if (isNearBlack) return true;
909
- }
921
+ var worldBox = new THREE.Box3().setFromObject(child);
922
+ var sizeWorld = new THREE.Vector3();
923
+ worldBox.getSize(sizeWorld);
924
+ var worldMinY = worldBox.min.y;
925
+
926
+ // 3. 底垫判定:必须同时满足「贴底」+「薄片」+「够大」
927
+ var isBottomSlab = (
928
+ worldMinY <= modelMinY + epsilon && // 贴底
929
+ sizeWorld.y < slabMaxThickness && // 薄片
930
+ sizeWorld.x * sizeWorld.z > minFootprint // 够大
931
+ );
932
+
933
+ if (debugMode) {
934
+ console.log('[debugBottomMeshes]', child.name || 'unnamed',
935
+ 'worldMinY:', worldMinY.toFixed(3),
936
+ 'size:', sizeWorld.x.toFixed(1), 'x', sizeWorld.z.toFixed(1), 'x', sizeWorld.y.toFixed(3),
937
+ 'isBottomSlab:', isBottomSlab
938
+ );
910
939
  }
911
- }
912
- return false;
940
+
941
+ if (isBottomSlab) {
942
+ child.visible = false;
943
+ console.log('[KimapSDK] Hidden bottom slab mesh:', child.name || 'unnamed',
944
+ 'size:', sizeWorld.x.toFixed(1), 'x', sizeWorld.z.toFixed(1), 'x', sizeWorld.y.toFixed(3));
945
+ }
946
+ });
913
947
  };
914
948
 
915
949
  /**
@@ -967,8 +1001,10 @@ SceneCore.prototype._processMaterial = function(child, materials, colorMap) {
967
1001
  depthWrite = opacity >= 0.8;
968
1002
  }
969
1003
  }
970
- // 直接使用原始颜色,不做混白处理
971
- finalColor = mtlColor;
1004
+ // 混合10%白色,让颜色更浅一点
1005
+ var color = new THREE.Color(mtlColor);
1006
+ color.lerp(new THREE.Color(0xffffff), 0.3);
1007
+ finalColor = color.getHex();
972
1008
  }
973
1009
 
974
1010
  child.material = new THREE.MeshStandardMaterial({