@kimap/indoor-positioning-sdk-vue2 5.3.4 → 5.3.6

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.4",
3
+ "version": "5.3.6",
4
4
  "description": "Vue2自包含室内定位SDK - 完全兼容Webpack3+Babel6 | Vue2 Self-Contained Indoor Positioning SDK",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -105,6 +105,11 @@ 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
+ });
108
113
  }
109
114
 
110
115
  return self;
@@ -1258,24 +1263,25 @@ KimapSDK.prototype._createTechGround = function() {
1258
1263
  this.techGroundGroup.visible = false; // 默认隐藏
1259
1264
  this.core.scene.add(this.techGroundGroup);
1260
1265
 
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
- // 创建地面平面
1266
+ // 创建半透明深色地面(ALL 模式背景,不遮挡模型)
1269
1267
  var groundGeometry = new THREE.PlaneGeometry(groundSize, groundSize);
1270
1268
  var groundMaterial = new THREE.MeshBasicMaterial({
1271
- color: 0x0a1628,
1269
+ color: 0x1a2a3a, // 深蓝灰色,比之前稍浅以免太暗
1272
1270
  transparent: true,
1273
- opacity: 0.8
1271
+ opacity: 0.4, // 降低透明度避免遮挡
1272
+ side: THREE.DoubleSide
1274
1273
  });
1275
1274
  var ground = new THREE.Mesh(groundGeometry, groundMaterial);
1276
1275
  ground.rotation.x = -Math.PI / 2;
1277
- ground.position.y = -0.2;
1276
+ ground.position.y = -0.15;
1278
1277
  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);
1279
1285
  };
1280
1286
 
1281
1287
  /**
@@ -1954,15 +1960,21 @@ KimapSDK.prototype._loadSingleFurniture = function(furniture, serverUrl) {
1954
1960
  // =====================================================
1955
1961
  furnitureGroup.renderOrder = 3000;
1956
1962
 
1957
- // 遍历模型,设置材质的depthWrite = false
1963
+ // 只对透明材质关闭 depthWrite,避免不透明家具被遮挡
1958
1964
  obj.traverse(function(child) {
1959
1965
  if (child instanceof THREE.Mesh) {
1960
1966
  if (Array.isArray(child.material)) {
1961
1967
  child.material.forEach(function(mat) {
1962
- mat.depthWrite = false;
1968
+ // 仅对透明材质关闭 depthWrite
1969
+ if (mat.transparent || mat.opacity < 1) {
1970
+ mat.depthWrite = false;
1971
+ }
1963
1972
  });
1964
1973
  } else if (child.material) {
1965
- child.material.depthWrite = false;
1974
+ // 仅对透明材质关闭 depthWrite
1975
+ if (child.material.transparent || child.material.opacity < 1) {
1976
+ child.material.depthWrite = false;
1977
+ }
1966
1978
  }
1967
1979
  }
1968
1980
  });
@@ -2009,15 +2021,21 @@ KimapSDK.prototype._loadSingleFurniture = function(furniture, serverUrl) {
2009
2021
  // 应用Y轴微小偏移
2010
2022
  obj.position.y += totalYOffset;
2011
2023
 
2012
- // 遍历模型,设置材质的depthWrite = false
2024
+ // 只对透明材质关闭 depthWrite,避免不透明家具被遮挡
2013
2025
  obj.traverse(function(child) {
2014
2026
  if (child instanceof THREE.Mesh) {
2015
2027
  if (Array.isArray(child.material)) {
2016
2028
  child.material.forEach(function(mat) {
2017
- mat.depthWrite = false;
2029
+ // 仅对透明材质关闭 depthWrite
2030
+ if (mat.transparent || mat.opacity < 1) {
2031
+ mat.depthWrite = false;
2032
+ }
2018
2033
  });
2019
2034
  } else if (child.material) {
2020
- child.material.depthWrite = false;
2035
+ // 仅对透明材质关闭 depthWrite
2036
+ if (child.material.transparent || child.material.opacity < 1) {
2037
+ child.material.depthWrite = false;
2038
+ }
2021
2039
  }
2022
2040
  }
2023
2041
  });
@@ -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.25);
183
+ var ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
184
184
  this.scene.add(ambientLight);
185
-
185
+
186
186
  // 主光源(从上方)
187
- var directionalLight1 = new THREE.DirectionalLight(0xffffff, 0.05);
187
+ var directionalLight1 = new THREE.DirectionalLight(0xffffff, 0.8);
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);
197
+ var directionalLight2 = new THREE.DirectionalLight(0xffffff, 0.3);
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.3);
202
+ var hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.4);
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._isHiddenGroundMesh(child.name)) {
701
+ // 隐藏底平面交互层(综合检查对象名、父对象名、材质名、启发式)
702
+ if (self._shouldHideGroundMesh(child)) {
703
703
  child.visible = false;
704
- console.log('✅ 隐藏交互层底平面:', child.name);
704
+ console.log('✅ 隐藏交互层底平面:', child.name || (child.parent && child.parent.name) || '(启发式)');
705
705
  return;
706
706
  }
707
707
 
@@ -789,7 +789,7 @@ SceneCore.prototype._processLoadedModelToGroup = function(object, materials, col
789
789
 
790
790
  // 处理材质
791
791
  object.traverse(function(child) {
792
- if (self._isHiddenGroundMesh(child.name)) {
792
+ if (self._shouldHideGroundMesh(child)) {
793
793
  child.visible = false;
794
794
  return;
795
795
  }
@@ -855,6 +855,7 @@ SceneCore.prototype._adjustCameraToAllFloors = function() {
855
855
 
856
856
  /**
857
857
  * 判断是否为需要隐藏的底面/交互层mesh
858
+ * 检查对象名、父对象名、材质名,以及启发式(薄黑水平面)
858
859
  * @private
859
860
  */
860
861
  SceneCore.prototype._isHiddenGroundMesh = function(name) {
@@ -876,6 +877,41 @@ SceneCore.prototype._isHiddenGroundMesh = function(name) {
876
877
  });
877
878
  };
878
879
 
880
+ /**
881
+ * 判断mesh是否应隐藏(综合检查对象名、父对象名、材质名、启发式)
882
+ * @private
883
+ */
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) {
896
+ 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
+ }
910
+ }
911
+ }
912
+ return false;
913
+ };
914
+
879
915
  /**
880
916
  * 处理材质(内部方法)
881
917
  * @private
@@ -931,10 +967,8 @@ SceneCore.prototype._processMaterial = function(child, materials, colorMap) {
931
967
  depthWrite = opacity >= 0.8;
932
968
  }
933
969
  }
934
- // 混合10%白色,让颜色更浅一点
935
- var color = new THREE.Color(mtlColor);
936
- color.lerp(new THREE.Color(0xffffff), 0.3);
937
- finalColor = color.getHex();
970
+ // 直接使用原始颜色,不做混白处理
971
+ finalColor = mtlColor;
938
972
  }
939
973
 
940
974
  child.material = new THREE.MeshStandardMaterial({