@inweb/viewer-three 26.12.2 → 26.12.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/dist/viewer-three.js +123 -70
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +2 -2
- package/dist/viewer-three.module.js +16 -16
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/loaders/GLTFFileDynamicLoader.d.ts +1 -1
- package/package.json +5 -5
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +1 -1
- package/src/Viewer/loaders/DynamicGltfLoader/GltfStructure.js +2 -9
- package/src/Viewer/loaders/GLTFCloudDynamicLoader.ts +6 -2
- package/src/Viewer/loaders/GLTFFileDynamicLoader.ts +10 -5
|
@@ -3672,7 +3672,6 @@ class GltfStructure {
|
|
|
3672
3672
|
constructor(id, loadController) {
|
|
3673
3673
|
this.id = `${id}`;
|
|
3674
3674
|
this.json = null;
|
|
3675
|
-
this.baseUrl = "";
|
|
3676
3675
|
this.loadController = loadController;
|
|
3677
3676
|
this.loader = null;
|
|
3678
3677
|
this.batchDelay = 10;
|
|
@@ -3691,13 +3690,11 @@ class GltfStructure {
|
|
|
3691
3690
|
}
|
|
3692
3691
|
async initialize(loader) {
|
|
3693
3692
|
this.json = await this.loadController.loadJson();
|
|
3694
|
-
this.baseUrl = await this.loadController.baseUrl();
|
|
3695
3693
|
this.loader = loader;
|
|
3696
3694
|
this.uri = this.json.buffers[0].uri || "";
|
|
3697
3695
|
}
|
|
3698
3696
|
clear() {
|
|
3699
3697
|
this.json = null;
|
|
3700
|
-
this.baseUrl = "";
|
|
3701
3698
|
this.loadController = null;
|
|
3702
3699
|
this.pendingRequests = [];
|
|
3703
3700
|
if (this.batchTimeout) {
|
|
@@ -3978,12 +3975,8 @@ class GltfStructure {
|
|
|
3978
3975
|
const loadTexture = async (imageIndex) => {
|
|
3979
3976
|
const image = this.json.images[imageIndex];
|
|
3980
3977
|
if (image.uri) {
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
} else {
|
|
3984
|
-
const fullUrl = this.baseUrl + image.uri;
|
|
3985
|
-
return await this.textureLoader.loadAsync(fullUrl);
|
|
3986
|
-
}
|
|
3978
|
+
const fullUrl = await this.loadController.resolveURL(image.uri);
|
|
3979
|
+
return this.textureLoader.loadAsync(fullUrl);
|
|
3987
3980
|
} else if (image.bufferView !== undefined) {
|
|
3988
3981
|
const bufferView = this.json.bufferViews[image.bufferView];
|
|
3989
3982
|
const array = await this.getBufferView(bufferView.byteOffset || 0, bufferView.byteLength, 5121);
|
|
@@ -4376,7 +4369,6 @@ class DynamicGltfLoader {
|
|
|
4376
4369
|
const uniqueTextureIds = new Set();
|
|
4377
4370
|
if (Array.isArray(this.structures)) {
|
|
4378
4371
|
for (const structure of this.structures) {
|
|
4379
|
-
console.log(structure.materialCache.values());
|
|
4380
4372
|
try {
|
|
4381
4373
|
for (const entry of structure.materialCache.values()) {
|
|
4382
4374
|
if (entry?.mesh?.uuid) uniqueMaterialIds.add(entry.mesh.uuid);
|
|
@@ -6154,7 +6146,10 @@ class GLTFFileDynamicLoader extends Loader {
|
|
|
6154
6146
|
const data = await loader.loadAsync(this.manager.fileURL, progress);
|
|
6155
6147
|
const extension = new GLTFBinaryExtension(data);
|
|
6156
6148
|
this.gltf = JSON.parse(extension.content);
|
|
6157
|
-
this.
|
|
6149
|
+
this.glb = extension.body;
|
|
6150
|
+
if (/\.glb$/i.test(this.manager.fileURL) && !this.glb) {
|
|
6151
|
+
throw new Error("GLTFFileDynamicLoader: Binary buffer chunk not found or type not supported.");
|
|
6152
|
+
}
|
|
6158
6153
|
return this.gltf;
|
|
6159
6154
|
},
|
|
6160
6155
|
loadBinaryData: (ranges, uri = "") => {
|
|
@@ -6162,15 +6157,16 @@ class GLTFFileDynamicLoader extends Loader {
|
|
|
6162
6157
|
loader.setRequestHeader(params.requestHeader || {});
|
|
6163
6158
|
loader.setWithCredentials(params.withCredentials || false);
|
|
6164
6159
|
loader.setAbortSignal(this.gltfLoader.abortController.signal);
|
|
6165
|
-
if (this.
|
|
6166
|
-
return loader.extractRanges(this.
|
|
6160
|
+
if (this.glb)
|
|
6161
|
+
return loader.extractRanges(this.glb, ranges);
|
|
6167
6162
|
const path = this.manager.path || this.manager.resourcePath;
|
|
6168
6163
|
const url = LoaderUtils.resolveURL(uri, path);
|
|
6169
6164
|
return loader.load(this.manager.resolveURL(url), ranges);
|
|
6170
6165
|
},
|
|
6171
|
-
|
|
6166
|
+
resolveURL: (uri) => {
|
|
6172
6167
|
const path = this.manager.path || this.manager.resourcePath;
|
|
6173
|
-
|
|
6168
|
+
const url = LoaderUtils.resolveURL(uri, path);
|
|
6169
|
+
return Promise.resolve(this.manager.resolveURL(url));
|
|
6174
6170
|
},
|
|
6175
6171
|
};
|
|
6176
6172
|
const structure = new GltfStructure(modelImpl.id, loadController);
|
|
@@ -6241,7 +6237,11 @@ class GLTFCloudDynamicLoader extends Loader {
|
|
|
6241
6237
|
}));
|
|
6242
6238
|
return model.downloadResourceRange(model.geometry[0], undefined, ranges, undefined, this.gltfLoader.getAbortController().signal);
|
|
6243
6239
|
},
|
|
6244
|
-
|
|
6240
|
+
resolveURL: (uri) => {
|
|
6241
|
+
const path = `${model.httpClient.serverUrl}${model.path}/`;
|
|
6242
|
+
const url = LoaderUtils.resolveURL(uri, path);
|
|
6243
|
+
return Promise.resolve(url);
|
|
6244
|
+
},
|
|
6245
6245
|
};
|
|
6246
6246
|
const structure = new GltfStructure(modelImpl.id, loadController);
|
|
6247
6247
|
await this.gltfLoader.loadStructure(structure);
|