Comments (9)
The second message is "expected" although an unfortunate side-effect of an early design decision. Early on I wanted this project to handle both glTF 1.0 and 2.0 schemas, but, VSCode's JSON validation has but a single contribution point, and there's no way for a VSCode extension at runtime to control which of two different schemas gets applied.
Thus, "the Chooser" was born. Behold and weep:
{
"$schema" : "http://json-schema.org/draft-04/schema",
"title" : "glTF",
"type" : "object",
"description" : "The root object for a glTF asset.",
"oneOf" : [
{
"$ref" : "gltf-2.0/glTF.schema.json"
},
{
"$ref" : "gltf-1.0/glTF.schema.json"
}
]
}
With this construct in play, a glTF file in VSCode must match enough of one of the glTF schemas that VSCode's built-in JSON validation can figure out which of the two schemas is being used. For "real-world" files, this isn't a problem, because almost every child of root is an object in 1.0 and an array in 2.0. So the moment any real content is added to the file, the choice of schema becomes clear.
Although we've added the official validator, I still need to keep the "dumb" JSON schema validation around for now, because it supplies hover-descriptions, enum auto-completion, etc., and it's the only way to validate glTF 1.0.
Sometimes, if you commit a simple JSON schema violation in VSCode, you'll see duplicate error messages, one marked source: 'glTF Validator'
and another marked source: ''
from the JSON validator. This is basically unavoidable, and the correct action is to fix the broken glTF.
As for the first message, that one comes directly from server.ts on this line. The "glTF Language Server" built-in to this extension is attempting to parse the JSON document, which it needs to do to gather a map of JSON pointers to document locations. It won't even call the glTF Validator if this parsing fails, and instead just reports its own error, since it knows it wouldn't be able to make heads or tails of anything reported by the validator. This one does get marked source: 'glTF Validator'
even though it came from the preparations just prior to launching the validator.
If needed, we could change the source
on this to JSON.parse
or similar, to keep the validator free of blame for these errors. Is that desirable?
from gltf-vscode.
Could 1.0
schemas include a simple regex (or even a const value) for asset.version
?
So the moment any real content is added to the file, the choice of schema becomes clear.
extensions
is an object in both versions, so there could be a real-world example looking like this:
{
"asset": {
"version": "2.0"
},
"extensionsUsed": [
"EXT_demo"
],
"extensions": {
"EXT_demo": {}
}
}
If needed, we could change the
source
on this toJSON.parse
or similar, to keep the validator free of blame for these errors. Is that desirable?
No strong opinion here. Users don't have to precisely understand internal layers of validation routines.
However I see some value in glTF Validator
-attributed output being the same across different runtime environments.
from gltf-vscode.
Could 1.0 schemas include a simple regex (or even a const value) for asset.version?
The 1.0 schema didn't require asset
or version
to be present at all, unfortunately.
from gltf-vscode.
asset
is optional, but asset.version
is required:
https://github.com/KhronosGroup/glTF/blob/master/specification/1.0/schema/asset.schema.json#L34
from gltf-vscode.
I tried hand-editing my copy of the glTF 1.0 schema to have a pattern
added to version
, like so:
"version" : {
"type" : "string",
"pattern": "^1",
"description" : "The API version.",
"default" : "1.0.3"
}
Unfortunately this doesn't seem to work. Your EXT_demo
example above still claims to match both 1.0 and 2.0 schemas, even after this edit.
from gltf-vscode.
That's because our 2.0
regex doesn't care about actual version number. Tweaking both schemas helps:
v1
"version" : {
"type" : "string",
"description" : "The glTF version.",
"pattern" : "^1"
}
v2
"version" : {
"type" : "string",
"description" : "The glTF version that this asset targets.",
"pattern" : "^2\\.[0-9]+$"
},
Your snippet above seems to be from asset.profile
.
from gltf-vscode.
Your snippet above seems to be from asset.profile.
Doh. That's the problem.
from gltf-vscode.
Fixing this upstream in KhronosGroup/glTF#1168.
from gltf-vscode.
Published as 2.1.2
from gltf-vscode.
Related Issues (20)
- Context menu tree does not show all options in v2.3.13 Mac HOT 1
- Autocompletion for extensionsUsed? HOT 2
- rotate skybox in three.js, front view is dark
- You may want to upload this extension to the Open VSX registry.
- Add new keys to end of JSON blocks
- Preserve image mimeType when converting from GLB to GLTF HOT 5
- TypeError when converting .gltf to .glb HOT 3
- Tabs interfere with validation report columns
- [cesium] gltf preview: Uncaught RuntimeError HOT 2
- Dependency update strategy HOT 2
- Validation error for missing bufferView in sparse accessors HOT 2
- Update rendering engines? HOT 2
- Please add support for KHR_materials_anisotropy HOT 2
- Feature request: add a glTF pathtracer
- Update extension schema mappings
- Can't inspect data inside draco compressed attributes
- Possible crash in language server HOT 1
- In official gltf sample BOX.gltf, why am i unable to display inspect-data window when using inspect-data tools?
- Unable to enable plug-ins
- glTF Tools breaks other extensions in a weird way
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gltf-vscode.