@kimap/indoor-positioning-sdk-vue2 4.2.2 → 4.2.3
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/SceneCore.js +38 -18
package/package.json
CHANGED
package/src/core/SceneCore.js
CHANGED
|
@@ -405,27 +405,47 @@ SceneCore.prototype._loadKimapFile = function(kimapUrl, themeUrl, objLoader, mtl
|
|
|
405
405
|
SceneCore.prototype._loadOBJFile = function(url, objLoader, resolve, reject) {
|
|
406
406
|
var self = this;
|
|
407
407
|
|
|
408
|
-
console.log('加载OBJ文件...');
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
function(
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
if (
|
|
419
|
-
|
|
420
|
-
console.log('OBJ加载进度:', percent + '%');
|
|
408
|
+
console.log('加载OBJ文件...', url);
|
|
409
|
+
|
|
410
|
+
// 先验证URL是否返回正确的内容
|
|
411
|
+
fetch(url, { method: 'HEAD' })
|
|
412
|
+
.then(function(response) {
|
|
413
|
+
if (!response.ok) {
|
|
414
|
+
throw new Error('文件不存在或无法访问 (HTTP ' + response.status + ')');
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
var contentType = response.headers.get('content-type');
|
|
418
|
+
if (contentType && contentType.includes('text/html')) {
|
|
419
|
+
throw new Error('URL返回的是HTML页面而不是OBJ文件,请检查URL是否正确');
|
|
421
420
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
421
|
+
|
|
422
|
+
// URL验证通过,开始加载
|
|
423
|
+
objLoader.load(
|
|
424
|
+
url,
|
|
425
|
+
function(object) {
|
|
426
|
+
console.log('OBJ文件下载完成,开始处理...');
|
|
427
|
+
self._processLoadedModel(object, null, {});
|
|
428
|
+
resolve();
|
|
429
|
+
},
|
|
430
|
+
function(progress) {
|
|
431
|
+
if (progress.lengthComputable) {
|
|
432
|
+
var percent = (progress.loaded / progress.total * 100).toFixed(2);
|
|
433
|
+
console.log('OBJ加载进度:', percent + '%');
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
function(error) {
|
|
437
|
+
console.error('❌ OBJ文件加载失败:', error);
|
|
438
|
+
console.error('URL:', url);
|
|
439
|
+
reject(error);
|
|
440
|
+
}
|
|
441
|
+
);
|
|
442
|
+
})
|
|
443
|
+
.catch(function(error) {
|
|
444
|
+
console.error('❌ OBJ文件URL验证失败:', error.message);
|
|
425
445
|
console.error('URL:', url);
|
|
446
|
+
console.error('提示: 请确保URL指向有效的.obj文件');
|
|
426
447
|
reject(error);
|
|
427
|
-
}
|
|
428
|
-
);
|
|
448
|
+
});
|
|
429
449
|
};
|
|
430
450
|
|
|
431
451
|
/**
|