@kimap/indoor-positioning-sdk-vue2 4.2.3 → 4.2.4
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 +39 -19
package/package.json
CHANGED
package/src/core/KimapSDK.js
CHANGED
|
@@ -852,11 +852,25 @@ KimapSDK.prototype._loadSingleFurniture = function(furniture, serverUrl) {
|
|
|
852
852
|
|
|
853
853
|
// 等待loader加载完成后再加载模型
|
|
854
854
|
loaderPromise.then(function(loader) {
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
function(
|
|
858
|
-
|
|
859
|
-
|
|
855
|
+
// 先验证URL是否有效
|
|
856
|
+
return fetch(modelUrl, { method: 'HEAD' })
|
|
857
|
+
.then(function(response) {
|
|
858
|
+
if (!response.ok) {
|
|
859
|
+
throw new Error('家具模型文件不存在 (HTTP ' + response.status + '): ' + modelUrl);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
var contentType = response.headers.get('content-type');
|
|
863
|
+
if (contentType && contentType.includes('text/html')) {
|
|
864
|
+
throw new Error('URL返回HTML而不是3D模型文件: ' + modelUrl);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// URL验证通过,开始加载模型
|
|
868
|
+
return new Promise(function(resolveLoad, rejectLoad) {
|
|
869
|
+
loader.load(
|
|
870
|
+
modelUrl,
|
|
871
|
+
function(result) {
|
|
872
|
+
// GLTF/GLB格式返回的是gltf对象,需要提取scene
|
|
873
|
+
var obj = (ext === '.glb' || ext === '.gltf') ? result.scene : result;
|
|
860
874
|
// 应用旋转
|
|
861
875
|
obj.rotation.set(
|
|
862
876
|
furniture.rotation.x,
|
|
@@ -916,22 +930,28 @@ KimapSDK.prototype._loadSingleFurniture = function(furniture, serverUrl) {
|
|
|
916
930
|
furniture.position.z
|
|
917
931
|
);
|
|
918
932
|
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
933
|
+
obj.userData = {
|
|
934
|
+
type: 'furniture',
|
|
935
|
+
furnitureId: furniture.id,
|
|
936
|
+
furnitureType: furniture.type
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
resolveLoad(obj);
|
|
940
|
+
},
|
|
941
|
+
undefined,
|
|
942
|
+
function(error) {
|
|
943
|
+
console.error('❌ 家具模型加载失败:', furniture.type, error);
|
|
944
|
+
rejectLoad(error);
|
|
945
|
+
}
|
|
946
|
+
);
|
|
947
|
+
});
|
|
948
|
+
})
|
|
949
|
+
.then(function(obj) {
|
|
925
950
|
resolve(obj);
|
|
926
|
-
}
|
|
927
|
-
undefined,
|
|
928
|
-
function(error) {
|
|
929
|
-
console.error('❌ 家具模型加载失败:', furniture.type, error);
|
|
930
|
-
reject(error);
|
|
931
|
-
}
|
|
932
|
-
);
|
|
951
|
+
});
|
|
933
952
|
}).catch(function(error) {
|
|
934
|
-
console.error('❌
|
|
953
|
+
console.error('❌ 家具模型URL验证或加载失败:', furniture.type, error.message);
|
|
954
|
+
console.error('URL:', modelUrl);
|
|
935
955
|
reject(error);
|
|
936
956
|
});
|
|
937
957
|
});
|