diff --git a/index.html b/index.html index 9b059f59..217daa15 100644 --- a/index.html +++ b/index.html @@ -283,10 +283,8 @@

glTF Validator

Number of warnings: {{validationReport?.issues?.numWarnings ?? 0}}

Number of infos: {{validationReport?.issues?.numInfos ?? 0}}

- - + + Powered by glTF-Validator diff --git a/package.json b/package.json index 0a92c985..7ea1fc02 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "build:ui": { "patterns": [ "src", - "main.js" + "main.js", + "index.html" ], "extensions": "js,scss,html", "delay": 1000, diff --git a/src/main.js b/src/main.js index 4e13d9bb..84ec904b 100644 --- a/src/main.js +++ b/src/main.js @@ -56,8 +56,8 @@ export default async () => { const parent = model.mainFile.substring(0, model.mainFile.lastIndexOf("/") + 1); return new Promise((resolve, reject) => { fetch(parent + uri).then(response => { - response.bytes().then(buffer => { - resolve(buffer); + response.arrayBuffer().then(buffer => { + resolve(new Uint8Array(buffer)); }).catch(error => { reject(error); }); @@ -67,9 +67,11 @@ export default async () => { }); }; const response = await fetch(model.mainFile); - const buffer = await response.bytes(); - const result = await validateBytes(buffer, {externalResourceFunction: externalRefFunction, uri: model.mainFile}); - return result; + const buffer = await response.arrayBuffer(); + return await validateBytes(new Uint8Array(buffer), { + externalResourceFunction: externalRefFunction, + uri: model.mainFile + }); } else if (Array.isArray(model.mainFile)) { const externalRefFunction = (uri) => { uri = "/" + uri; @@ -83,8 +85,8 @@ export default async () => { } } if (foundFile) { - foundFile.bytes().then((buffer) => { - resolve(buffer); + foundFile.arrayBuffer().then((buffer) => { + resolve(new Uint8Array(buffer)); }).catch((error) => { reject(error); }); @@ -94,14 +96,17 @@ export default async () => { }); }; - const buffer = await model.mainFile[1].bytes(); - return await validateBytes(buffer, {externalResourceFunction: externalRefFunction, uri: model.mainFile[0]}); + const buffer = await model.mainFile[1].arrayBuffer(); + return await validateBytes(new Uint8Array(buffer), { + externalResourceFunction: externalRefFunction, + uri: model.mainFile[0] + }); } } catch (error) { console.error(error); } }; - return from(func(model)); + return from(func(model)).pipe(catchError((error) => { console.error(`Validation failed: ${error}`); return EMPTY; })); }) ); diff --git a/src/ui/ui.js b/src/ui/ui.js index 924d2447..d98839f6 100644 --- a/src/ui/ui.js +++ b/src/ui/ui.js @@ -172,6 +172,17 @@ const appCreated = createApp({ this.error("Error copying to clipboard."); } }, + downloadJSON(filename, json) { + const text = JSON.stringify(json, undefined, 4); + const dataURL = "data:application/json;charset=utf-8," + encodeURIComponent(text); + const element = document.createElement("a"); + element.setAttribute("href", dataURL); + element.setAttribute("download", filename); + element.style.display = "none"; + document.body.appendChild(element); + element.click(); + document.body.removeChild(element); + }, getValidationCounter: function(){ let number = 0; let color = "white";