@kimap/indoor-positioning-sdk-vue2 4.2.3 → 4.2.5

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": "4.2.3",
3
+ "version": "4.2.5",
4
4
  "description": "Vue2自包含室内定位SDK - 完全兼容Webpack3+Babel6 | Vue2 Self-Contained Indoor Positioning SDK",
5
5
  "main": "index.js",
6
6
  "files": [
package/src/KMUtil.js CHANGED
@@ -560,6 +560,7 @@
560
560
  * options: { inflationCells } 障碍膨胀(格数),默认 1
561
561
  */
562
562
  function aStarPathfinding(start, end, obstacles, gridSize) {
563
+ console.log('开始规划路径', obstacles)
563
564
  gridSize = gridSize || 0.5;
564
565
 
565
566
  var openList = [];
@@ -852,11 +852,23 @@ KimapSDK.prototype._loadSingleFurniture = function(furniture, serverUrl) {
852
852
 
853
853
  // 等待loader加载完成后再加载模型
854
854
  loaderPromise.then(function(loader) {
855
- loader.load(
856
- modelUrl,
857
- function(result) {
858
- // GLTF/GLB格式返回的是gltf对象,需要提取scene
859
- var obj = (ext === '.glb' || ext === '.gltf') ? result.scene : result;
855
+ // 先验证URL是否返回HTML(只拦截HTML,允许404等错误通过)
856
+ return fetch(modelUrl, { method: 'HEAD' })
857
+ .then(function(response) {
858
+ // 只检查Content-Type,不检查HTTP状态码
859
+ // 404等错误让OBJLoader自己处理
860
+ var contentType = response.headers.get('content-type');
861
+ if (response.ok && contentType && contentType.includes('text/html')) {
862
+ throw new Error('URL返回HTML而不是3D模型文件: ' + modelUrl);
863
+ }
864
+
865
+ // 验证通过或404等错误,继续加载(让loader处理)
866
+ return new Promise(function(resolveLoad, rejectLoad) {
867
+ loader.load(
868
+ modelUrl,
869
+ function(result) {
870
+ // GLTF/GLB格式返回的是gltf对象,需要提取scene
871
+ var obj = (ext === '.glb' || ext === '.gltf') ? result.scene : result;
860
872
  // 应用旋转
861
873
  obj.rotation.set(
862
874
  furniture.rotation.x,
@@ -916,22 +928,28 @@ KimapSDK.prototype._loadSingleFurniture = function(furniture, serverUrl) {
916
928
  furniture.position.z
917
929
  );
918
930
 
919
- obj.userData = {
920
- type: 'furniture',
921
- furnitureId: furniture.id,
922
- furnitureType: furniture.type
923
- };
924
-
931
+ obj.userData = {
932
+ type: 'furniture',
933
+ furnitureId: furniture.id,
934
+ furnitureType: furniture.type
935
+ };
936
+
937
+ resolveLoad(obj);
938
+ },
939
+ undefined,
940
+ function(error) {
941
+ console.error('❌ 家具模型加载失败:', furniture.type, error);
942
+ rejectLoad(error);
943
+ }
944
+ );
945
+ });
946
+ })
947
+ .then(function(obj) {
925
948
  resolve(obj);
926
- },
927
- undefined,
928
- function(error) {
929
- console.error('❌ 家具模型加载失败:', furniture.type, error);
930
- reject(error);
931
- }
932
- );
949
+ });
933
950
  }).catch(function(error) {
934
- console.error('❌ 加载家具模型loader失败:', furniture.type, error);
951
+ console.error('❌ 家具模型URL验证或加载失败:', furniture.type, error.message);
952
+ console.error('URL:', modelUrl);
935
953
  reject(error);
936
954
  });
937
955
  });
@@ -407,19 +407,17 @@ SceneCore.prototype._loadOBJFile = function(url, objLoader, resolve, reject) {
407
407
 
408
408
  console.log('加载OBJ文件...', url);
409
409
 
410
- // 先验证URL是否返回正确的内容
410
+ // 先验证URL是否返回HTML(只拦截HTML,允许404等错误通过)
411
411
  fetch(url, { method: 'HEAD' })
412
412
  .then(function(response) {
413
- if (!response.ok) {
414
- throw new Error('文件不存在或无法访问 (HTTP ' + response.status + ')');
415
- }
416
-
413
+ // 只检查Content-Type,不检查HTTP状态码
414
+ // 404等错误让OBJLoader自己处理
417
415
  var contentType = response.headers.get('content-type');
418
- if (contentType && contentType.includes('text/html')) {
416
+ if (response.ok && contentType && contentType.includes('text/html')) {
419
417
  throw new Error('URL返回的是HTML页面而不是OBJ文件,请检查URL是否正确');
420
418
  }
421
419
 
422
- // URL验证通过,开始加载
420
+ // 验证通过或404等错误,继续加载(让loader处理)
423
421
  objLoader.load(
424
422
  url,
425
423
  function(object) {