From 844c05656cbea5d0bcbb4cebd9b8f5ebc4552a13 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 30 Nov 2017 15:25:57 -0500 Subject: [PATCH 1/5] Distinguish between glTF Validator and Language Server errors. --- server/src/server.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/server/src/server.ts b/server/src/server.ts index cae67ea..7e5f737 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -192,7 +192,10 @@ function parseTextDocument(parseResult: ParseResult, textDocument: TextDocument) parseResult.jsonMap = tryGetJsonMap(textDocument); if (!parseResult.jsonMap) { parseResult.parseable = false; - let diagnostics: Diagnostic[] = [getDiagnostic({ message: 'Error parsing JSON document.' }, {data: null, pointers: null})]; + let diagnostics: Diagnostic[] = [getDiagnostic({ + message: 'Error parsing JSON document.', + isFromLanguageServer: true + }, {data: null, pointers: null})]; connection.sendDiagnostics({ uri: textDocument.uri, diagnostics }); return; } @@ -202,6 +205,7 @@ function parseTextDocument(parseResult: ParseResult, textDocument: TextDocument) if ((!parseResult.jsonMap.data.asset) || (!parseResult.jsonMap.data.asset.version) || (parseResult.jsonMap.data.asset.version[0] === '1')) { let diagnostics: Diagnostic[] = [getDiagnostic({ message: 'Validation not available for glTF 1.0 files.', + isFromLanguageServer: true, severity: 2 }, jsonMap)]; connection.sendDiagnostics({ uri: textDocument.uri, diagnostics }); @@ -243,7 +247,8 @@ function parseTextDocument(parseResult: ParseResult, textDocument: TextDocument) if (result.issues.truncated) { diagnostics.push(getDiagnostic({ - message: 'VALIDATION ABORTED: Too many messages produced.' + message: 'VALIDATION ABORTED: Too many messages produced.', + isFromLanguageServer: true }, parseResult.jsonMap)); } } @@ -258,7 +263,10 @@ function parseTextDocument(parseResult: ParseResult, textDocument: TextDocument) // Validator's error console.warn('glTF Validator failed on: ' + fileName); console.warn(result); - let diagnostics: Diagnostic[] = [getDiagnostic({ message: 'glTF Validator error: ' + result }, {data: null, pointers: null})]; + let diagnostics: Diagnostic[] = [getDiagnostic({ + message: 'glTF Validator error: ' + result, + isFromLanguageServer: true + }, {data: null, pointers: null})]; connection.sendDiagnostics({ uri: textDocument.uri, diagnostics }); }); } @@ -310,7 +318,7 @@ function getDiagnostic(info: any, map: JsonMap): Diagnostic { severity: severity, range, message: info.message, - source: 'glTF Validator' + source: (info.isFromLanguageServer ? 'glTF Language Server' : 'glTF Validator') }; } From 056ea8ce48eba27342126405bb22653545ba2f7d Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 30 Nov 2017 17:06:10 -0500 Subject: [PATCH 2/5] Remove upgradeUriRefs, the change was committed upstream. --- util/importSchema.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/util/importSchema.js b/util/importSchema.js index 6d10236..e888aad 100644 --- a/util/importSchema.js +++ b/util/importSchema.js @@ -130,29 +130,11 @@ function upgradeDescriptions(data) { } } -function upgradeUriRefs(data) { - for (var key in data) { - if (data.hasOwnProperty(key)) { - var val = data[key]; - if (typeof(val) === 'object') { - upgradeUriRefs(val); - } - } - } - - // See: https://github.com/KhronosGroup/glTF/issues/1149 - if (data && data.format && data.format === 'uri') { - console.log('NOTE: uri upgraded to uriref.'); - data.format = 'uriref'; - } -} - function transformFile(inputFile, outputFile) { var schema = JSON.parse(fs.readFileSync(inputFile)); transformEnums(schema); upgradeDescriptions(schema); - upgradeUriRefs(schema); fs.writeFileSync(outputFile, JSON.stringify(schema, null, ' ').replace(/\"\:/g, '" :') + '\n'); } From f63fa816608742fe4affc8122b67b785fd1f6495 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 30 Nov 2017 17:08:55 -0500 Subject: [PATCH 3/5] Re-import glTF schemas. --- schemas/gltf-1.0/asset.schema.json | 1 + schemas/gltf-2.0/animation.channel.target.schema.json | 2 +- schemas/gltf-2.0/node.schema.json | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/schemas/gltf-1.0/asset.schema.json b/schemas/gltf-1.0/asset.schema.json index 6331673..8ad54ee 100644 --- a/schemas/gltf-1.0/asset.schema.json +++ b/schemas/gltf-1.0/asset.schema.json @@ -35,6 +35,7 @@ }, "version" : { "type" : "string", + "pattern" : "^1\\.", "description" : "The glTF version." } }, diff --git a/schemas/gltf-2.0/animation.channel.target.schema.json b/schemas/gltf-2.0/animation.channel.target.schema.json index 2fe8b56..3fe3a43 100644 --- a/schemas/gltf-2.0/animation.channel.target.schema.json +++ b/schemas/gltf-2.0/animation.channel.target.schema.json @@ -18,7 +18,7 @@ "description" : "The index of the node to target." }, "path" : { - "description" : "The name of the node's TRS property to modify, or the \"weights\" of the Morph Targets it instantiates.", + "description" : "The name of the node's TRS property to modify, or the \"weights\" of the Morph Targets it instantiates. For the \"translation\" property, the values that are provided by the sampler are the translation along the x, y, and z axes. For the \"rotation\" property, the values are a quaternion in the order (x, y, z, w), where w is the scalar. For the \"scale\" property, the values are the scaling factors along the x, y, and z axes.", "anyOf" : [ { "enum" : [ diff --git a/schemas/gltf-2.0/node.schema.json b/schemas/gltf-2.0/node.schema.json index 5040b00..b4b0b02 100644 --- a/schemas/gltf-2.0/node.schema.json +++ b/schemas/gltf-2.0/node.schema.json @@ -90,7 +90,7 @@ }, "scale" : { "type" : "array", - "description" : "The node's non-uniform scale.", + "description" : "The node's non-uniform scale, given as the scaling factors along the x, y, and z axes.", "items" : { "type" : "number" }, @@ -104,7 +104,7 @@ }, "translation" : { "type" : "array", - "description" : "The node's translation.", + "description" : "The node's translation along the x, y, and z axes.", "items" : { "type" : "number" }, From f3196ee5160d3c5491332b1eae2bf47b10955f15 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 30 Nov 2017 17:15:21 -0500 Subject: [PATCH 4/5] Update to latest validator. --- package.json | 2 +- server/package.json | 2 +- server/src/server.ts | 2 +- src/validationProvider.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 2e06c0a..5f6e934 100644 --- a/package.json +++ b/package.json @@ -273,7 +273,7 @@ "dependencies": { "babylonjs": "^3.1.0-beta6", "gltf-import-export": "^1.0.6", - "gltf-validator": "2.0.0-dev.1.3", + "gltf-validator": "2.0.0-dev.1.6", "json-source-map": "^0.4.0", "sprintf-js": "^1.1.1", "vscode": "^1.1.8", diff --git a/server/package.json b/server/package.json index 917974c..2cdc4d8 100644 --- a/server/package.json +++ b/server/package.json @@ -12,7 +12,7 @@ "url": "https://github.com/AnalyticalGraphicsInc/gltf-vscode" }, "dependencies": { - "gltf-validator": "2.0.0-dev.1.3", + "gltf-validator": "2.0.0-dev.1.6", "json-source-map": "^0.4.0", "vscode-languageserver": "3.5.0", "vscode-uri": "^1.0.1" diff --git a/server/src/server.ts b/server/src/server.ts index 7e5f737..95fef76 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -220,7 +220,7 @@ function parseTextDocument(parseResult: ParseResult, textDocument: TextDocument) severityOverrides: currentSettings.Validation.severityOverrides, externalResourceFunction: (uri) => new Promise((resolve, reject) => { - uri = path.resolve(folderName, uri); + uri = path.resolve(folderName, decodeURIComponent(uri)); fs.readFile(uri, (err, data) => { console.log("Loading external file: " + uri); if (err) { diff --git a/src/validationProvider.ts b/src/validationProvider.ts index 1ead678..3e53e96 100644 --- a/src/validationProvider.ts +++ b/src/validationProvider.ts @@ -38,7 +38,7 @@ export async function validate(sourceFilename: string) { severityOverrides: currentSettings.severityOverrides, externalResourceFunction: (uri) => new Promise((resolve, reject) => { - uri = path.resolve(folderName, uri); + uri = path.resolve(folderName, decodeURIComponent(uri)); fs.readFile(uri, (err, data) => { if (err) { reject(err.toString()); From 9028a2acba1fec164531aeb83bd6dda0964beabd Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 30 Nov 2017 17:40:44 -0500 Subject: [PATCH 5/5] CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a51de0..dee7ce9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ * Definition provider allows navigation on any index reference * View buffer data provided by Accessor (Go to Definition (F12)) * Changed viewing texture data to match VSCode inline viewer. +* Updated to latest glTF Validator and glTF schemas. +* Clarified error sources, from glTF Validator vs glTF Language Server. ### 2.1.1 - 2017-11-15