{"action":"created","issue":{"url":"https://api.github.com/repos/KhronosGroup/glTF/issues/646","repository_url":"https://api.github.com/repos/KhronosGroup/glTF","labels_url":"https://api.github.com/repos/KhronosGroup/glTF/issues/646/labels{/name}","comments_url":"https://api.github.com/repos/KhronosGroup/glTF/issues/646/comments","events_url":"https://api.github.com/repos/KhronosGroup/glTF/issues/646/events","html_url":"https://github.com/KhronosGroup/glTF/issues/646","id":164635897,"number":646,"title":"Usage of null in glTF","user":{"login":"lexaknyazev","id":3479527,"avatar_url":"https://avatars.githubusercontent.com/u/3479527?v=3","gravatar_id":"","url":"https://api.github.com/users/lexaknyazev","html_url":"https://github.com/lexaknyazev","followers_url":"https://api.github.com/users/lexaknyazev/followers","following_url":"https://api.github.com/users/lexaknyazev/following{/other_user}","gists_url":"https://api.github.com/users/lexaknyazev/gists{/gist_id}","starred_url":"https://api.github.com/users/lexaknyazev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lexaknyazev/subscriptions","organizations_url":"https://api.github.com/users/lexaknyazev/orgs","repos_url":"https://api.github.com/users/lexaknyazev/repos","events_url":"https://api.github.com/users/lexaknyazev/events{/privacy}","received_events_url":"https://api.github.com/users/lexaknyazev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-08T23:38:34Z","updated_at":"2016-07-09T12:32:23Z","closed_at":null,"body":"`null` is one of four JSON primitive types. At the current state of spec, no field can have `null` as a value.\r\nYet, there could be reasonable use cases for it:\r\n\r\n- Stub for required `uri` fields instead of an empty data URI (because such URI means actually \"empty plain text string\" and requires syntax check in general case):\r\n\r\n ```js\r\n  \"buffers\": {\r\n    \"binary_glTF\": {\r\n      \"byteLength\": 12345,\r\n      \"uri\": null // instead of \"data:,\"\r\n    }\r\n  }\r\n```\r\n\r\n- A way to mark a mesh as non-renderable by setting `[mesh.primitive.]material : null`.\r\n\r\nAllowing field to be \"nullable\" will require a small change in JSON schema, e.g.:\r\n```js\r\n{\r\n    \"$schema\" : \"http://json-schema.org/draft-03/schema\",\r\n    \"title\" : \"buffer\",\r\n    \"type\" : \"object\",\r\n    \"description\" : \"A buffer points to binary geometry, animation, or skins.\",\r\n    \"extends\" : { \"$ref\" : \"glTFChildOfRootProperty.schema.json\" },\r\n    \"properties\" : {\r\n        \"uri\" : {\r\n            \"type\" : [\"string\", \"null\"] // <------\r\n            \"description\" : \"The uri of the buffer.\",\r\n            \"format\" : \"uri\",\r\n            \"required\" : true,\r\n            \"gltf_detailedDescription\" : \"The uri of the buffer.  Relative paths are relative to the .gltf file.  Instead of referencing an external file, the uri can also be a data-uri.\",\r\n            \"gltf_uriType\" : \"application\"\r\n        },\r\n```"},"comment":{"url":"https://api.github.com/repos/KhronosGroup/glTF/issues/comments/231532251","html_url":"https://github.com/KhronosGroup/glTF/issues/646#issuecomment-231532251","issue_url":"https://api.github.com/repos/KhronosGroup/glTF/issues/646","id":231532251,"user":{"login":"javagl","id":5597569,"avatar_url":"https://avatars.githubusercontent.com/u/5597569?v=3","gravatar_id":"","url":"https://api.github.com/users/javagl","html_url":"https://github.com/javagl","followers_url":"https://api.github.com/users/javagl/followers","following_url":"https://api.github.com/users/javagl/following{/other_user}","gists_url":"https://api.github.com/users/javagl/gists{/gist_id}","starred_url":"https://api.github.com/users/javagl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javagl/subscriptions","organizations_url":"https://api.github.com/users/javagl/orgs","repos_url":"https://api.github.com/users/javagl/repos","events_url":"https://api.github.com/users/javagl/events{/privacy}","received_events_url":"https://api.github.com/users/javagl/received_events","type":"User","site_admin":false},"created_at":"2016-07-09T12:32:23Z","updated_at":"2016-07-09T12:32:23Z","body":"One should be careful here. The treatment of `null` may be a bit subtle. Assigning a \"special\" meaning to a \"special\" value may always be a source of confusion (and some purists demonize the use of `null` in general). \r\n\r\nFor example, in the non-JavaScript world, it may be hard to distinguish between a property that has the value `null`, and a property that simply was missing (because it was optional). I think JavaScript has another level of nothingness, namely `undefined`, so it may not be an issue there, but may be worth pointing out nevertheless. \r\n\r\nWould the use of `null` be limited to properties that are marked as `required`? One could argue that this boils down to making a `required` field `optional` through the back door (but I'm not sure whether this is true on a strict, technical level). \r\n\r\nThe case of the `uri` for `buffer`, `image` and `shader` is particularly fuzzy. The binary glTF spec says\r\n> a runtime can ignore the `uri` property \r\nwhich is a remedy to the `uri` being marked as *required* in the main spec - but I can imagine that some parsers would bail out if it was not a valid URI at all.\r\n\r\nFor the poroposed case of \"switching off\" a mesh primitive by setting its material to `null`, one could consider whether it wouldn't make more sense to simply *remove* the respective mesh primitive from its owning mesh. Alternatively, one could say that something like this could or should be modeled more explicitly and cleanly by introducing some `boolean` `isRendered` property....\r\n\r\n ---\r\n\r\n(Note that these are not strict arguments *against* this proposal. There are just some caveats to consider)\r\n"}}
{"actor":{"display_login":"javagl"}}