Handle as error when it fails to load draco decoder.

This commit is contained in:
kovacsv 2021-07-15 23:44:59 +02:00
parent ab0d0172e7
commit 04da400129

View File

@ -264,10 +264,10 @@ OV.GltfExtensions = class
this.draco = null; this.draco = null;
} }
LoadLibraries (extensionsRequired, onReady) LoadLibraries (extensionsRequired, callbacks)
{ {
if (extensionsRequired === undefined) { if (extensionsRequired === undefined) {
onReady (); callbacks.onSuccess ();
return; return;
} }
if (this.draco === null && extensionsRequired.indexOf ('KHR_draco_mesh_compression') !== -1) { if (this.draco === null && extensionsRequired.indexOf ('KHR_draco_mesh_compression') !== -1) {
@ -275,15 +275,15 @@ OV.GltfExtensions = class
success : () => { success : () => {
DracoDecoderModule ().then ((draco) => { DracoDecoderModule ().then ((draco) => {
this.draco = draco; this.draco = draco;
onReady (); callbacks.onSuccess ();
}); });
}, },
error : () => { error : () => {
onReady (); callbacks.onError ();
} }
}); });
} else { } else {
onReady (); callbacks.onSuccess ();
} }
} }
@ -624,23 +624,30 @@ OV.ImporterGltf = class extends OV.ImporterBase
return; return;
} }
this.gltfExtensions.LoadLibraries (gltf.extensionsRequired, () => { this.gltfExtensions.LoadLibraries (gltf.extensionsRequired, {
this.ImportModelProperties (gltf); onSuccess : () => {
this.ImportModelProperties (gltf);
let materials = gltf.materials; let materials = gltf.materials;
if (materials !== undefined) { if (materials !== undefined) {
for (let i = 0; i < materials.length; i++) { for (let i = 0; i < materials.length; i++) {
this.ImportMaterial (gltf, i); this.ImportMaterial (gltf, i);
} }
} }
let nodeTree = this.CollectMeshNodesForScene (gltf, defaultScene); let nodeTree = this.CollectMeshNodesForScene (gltf, defaultScene);
for (let i = 0; i < nodeTree.nodes.length; i++) { for (let i = 0; i < nodeTree.nodes.length; i++) {
let nodeIndex = nodeTree.nodes[i]; let nodeIndex = nodeTree.nodes[i];
this.ImportMeshNode (gltf, nodeIndex, nodeTree); this.ImportMeshNode (gltf, nodeIndex, nodeTree);
} }
onFinish (); onFinish ();
},
onError : () => {
this.SetError ();
this.SetMessage ('Failed to load draco decoder.');
onFinish ();
}
}); });
} }