-
Notifications
You must be signed in to change notification settings - Fork 73
Add KHR_node_visibility validation #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lexaknyazev
merged 1 commit into
KhronosGroup:main
from
aaronfranke:khr_node_visibility
Dec 30, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| library gltf.extensions.khr_node_visibility; | ||
|
|
||
| import 'package:gltf/src/base/gltf_property.dart'; | ||
| import 'package:gltf/src/ext/extensions.dart'; | ||
|
|
||
| const String KHR_NODE_VISIBILITY = 'KHR_node_visibility'; | ||
| const String VISIBLE = 'visible'; | ||
|
|
||
| const List<String> KHR_NODE_VISIBILITY_MEMBERS = <String>[ | ||
| VISIBLE, | ||
| ]; | ||
|
|
||
| class KhrNodeVisibility extends GltfProperty { | ||
| final bool visible; | ||
|
|
||
| KhrNodeVisibility._( | ||
| this.visible, Map<String, Object> extensions, Object extras) | ||
| : super(extensions, extras); | ||
|
|
||
| static KhrNodeVisibility fromMap(Map<String, Object> map, Context context) { | ||
| if (context.validate) { | ||
| checkMembers(map, KHR_NODE_VISIBILITY_MEMBERS, context); | ||
| } | ||
| return KhrNodeVisibility._( | ||
| getBool(map, VISIBLE, context, def: true), | ||
| getExtensions(map, KhrNodeVisibility, context), | ||
| getExtras(map, context)); | ||
| } | ||
| } | ||
|
|
||
| const Extension khrNodeVisibilityExtension = | ||
| Extension(KHR_NODE_VISIBILITY, <Type, ExtensionDescriptor>{ | ||
| Node: ExtensionDescriptor(KhrNodeVisibility.fromMap), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "node": { | ||
| "name": "node.KHR_node_visibility", | ||
| "tests": { | ||
| "custom_property.gltf": "Custom property", | ||
| "unexpected_extension.gltf": "Unexpected extension object location", | ||
| "valid.gltf": "Valid" | ||
| } | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
test/ext/KHR_node_visibility/data/node/custom_property.gltf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "asset": { "version": "2.0" }, | ||
| "extensionsUsed": ["KHR_node_visibility"], | ||
| "nodes": [ | ||
| { | ||
| "extensions": { | ||
| "KHR_node_visibility": { | ||
| "customProperty": true | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } |
41 changes: 41 additions & 0 deletions
41
test/ext/KHR_node_visibility/data/node/custom_property.gltf.report.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| { | ||
| "uri": "test/ext/KHR_node_visibility/data/node/custom_property.gltf", | ||
| "mimeType": "model/gltf+json", | ||
| "issues": { | ||
| "numErrors": 0, | ||
| "numWarnings": 1, | ||
| "numInfos": 1, | ||
| "numHints": 0, | ||
| "messages": [ | ||
| { | ||
| "code": "UNEXPECTED_PROPERTY", | ||
| "message": "Unexpected property.", | ||
| "severity": 1, | ||
| "pointer": "/nodes/0/extensions/KHR_node_visibility/customProperty" | ||
| }, | ||
| { | ||
| "code": "UNUSED_OBJECT", | ||
| "message": "This object may be unused.", | ||
| "severity": 2, | ||
| "pointer": "/nodes/0" | ||
| } | ||
| ], | ||
| "truncated": false | ||
| }, | ||
| "info": { | ||
| "version": "2.0", | ||
| "extensionsUsed": ["KHR_node_visibility"], | ||
| "animationCount": 0, | ||
| "materialCount": 0, | ||
| "hasMorphTargets": false, | ||
| "hasSkins": false, | ||
| "hasTextures": false, | ||
| "hasDefaultScene": false, | ||
| "drawCallCount": 0, | ||
| "totalVertexCount": 0, | ||
| "totalTriangleCount": 0, | ||
| "maxUVs": 0, | ||
| "maxInfluences": 0, | ||
| "maxAttributes": 0 | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
test/ext/KHR_node_visibility/data/node/unexpected_extension.gltf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "asset": { "version": "2.0" }, | ||
| "extensionsUsed": ["KHR_node_visibility"], | ||
| "materials": [ | ||
| { | ||
| "extensions": { | ||
| "KHR_node_visibility": { | ||
| "visible": true | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } |
41 changes: 41 additions & 0 deletions
41
test/ext/KHR_node_visibility/data/node/unexpected_extension.gltf.report.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| { | ||
| "uri": "test/ext/KHR_node_visibility/data/node/unexpected_extension.gltf", | ||
| "mimeType": "model/gltf+json", | ||
| "issues": { | ||
| "numErrors": 1, | ||
| "numWarnings": 0, | ||
| "numInfos": 1, | ||
| "numHints": 0, | ||
| "messages": [ | ||
| { | ||
| "code": "UNEXPECTED_EXTENSION_OBJECT", | ||
| "message": "Unexpected location for this extension.", | ||
| "severity": 0, | ||
| "pointer": "/materials/0/extensions/KHR_node_visibility" | ||
| }, | ||
| { | ||
| "code": "UNUSED_OBJECT", | ||
| "message": "This object may be unused.", | ||
| "severity": 2, | ||
| "pointer": "/materials/0" | ||
| } | ||
| ], | ||
| "truncated": false | ||
| }, | ||
| "info": { | ||
| "version": "2.0", | ||
| "extensionsUsed": ["KHR_node_visibility"], | ||
| "animationCount": 0, | ||
| "materialCount": 1, | ||
| "hasMorphTargets": false, | ||
| "hasSkins": false, | ||
| "hasTextures": false, | ||
| "hasDefaultScene": false, | ||
| "drawCallCount": 0, | ||
| "totalVertexCount": 0, | ||
| "totalTriangleCount": 0, | ||
| "maxUVs": 0, | ||
| "maxInfluences": 0, | ||
| "maxAttributes": 0 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "asset": { "version": "2.0" }, | ||
| "extensionsUsed": ["KHR_node_visibility"], | ||
| "nodes": [ | ||
| { "extensions": { "KHR_node_visibility": { "visible": false } }, "name": "InvisibleCube" }, | ||
| { "extensions": { "KHR_node_visibility": { "visible": true } }, "name": "VisibleCube" }, | ||
| { "extensions": { "KHR_node_visibility": {} }, "name": "EmptyExtensionObject" } | ||
| ] | ||
| } |
47 changes: 47 additions & 0 deletions
47
test/ext/KHR_node_visibility/data/node/valid.gltf.report.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| { | ||
| "uri": "test/ext/KHR_node_visibility/data/node/valid.gltf", | ||
| "mimeType": "model/gltf+json", | ||
| "issues": { | ||
| "numErrors": 0, | ||
| "numWarnings": 0, | ||
| "numInfos": 3, | ||
| "numHints": 0, | ||
| "messages": [ | ||
| { | ||
| "code": "UNUSED_OBJECT", | ||
| "message": "This object may be unused.", | ||
| "severity": 2, | ||
| "pointer": "/nodes/0" | ||
| }, | ||
| { | ||
| "code": "UNUSED_OBJECT", | ||
| "message": "This object may be unused.", | ||
| "severity": 2, | ||
| "pointer": "/nodes/1" | ||
| }, | ||
| { | ||
| "code": "UNUSED_OBJECT", | ||
| "message": "This object may be unused.", | ||
| "severity": 2, | ||
| "pointer": "/nodes/2" | ||
| } | ||
| ], | ||
| "truncated": false | ||
| }, | ||
| "info": { | ||
| "version": "2.0", | ||
| "extensionsUsed": ["KHR_node_visibility"], | ||
| "animationCount": 0, | ||
| "materialCount": 0, | ||
| "hasMorphTargets": false, | ||
| "hasSkins": false, | ||
| "hasTextures": false, | ||
| "hasDefaultScene": false, | ||
| "drawCallCount": 0, | ||
| "totalVertexCount": 0, | ||
| "totalTriangleCount": 0, | ||
| "maxUVs": 0, | ||
| "maxInfluences": 0, | ||
| "maxAttributes": 0 | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
test/ext/KHR_node_visibility/khr_node_visibility_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * # Copyright (c) 2016-2026 The Khronos Group Inc. | ||
| * # | ||
| * # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * # you may not use this file except in compliance with the License. | ||
| * # You may obtain a copy of the License at | ||
| * # | ||
| * # http://www.apache.org/licenses/LICENSE-2.0 | ||
| * # | ||
| * # Unless required by applicable law or agreed to in writing, software | ||
| * # distributed under the License is distributed on an "AS IS" BASIS, | ||
| * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * # See the License for the specific language governing permissions and | ||
| * # limitations under the License. | ||
| */ | ||
|
|
||
| import 'dart:async'; | ||
|
|
||
| import 'package:gltf/gltf.dart'; | ||
| import 'package:test/test.dart'; | ||
|
|
||
| import '../../utils.dart'; | ||
|
|
||
| Future main() async { | ||
| await compareReports('test/ext/KHR_node_visibility'); | ||
|
|
||
| group('Evaluate valid objects', () { | ||
| test('node.KHR_node_visibility', () async { | ||
| final gltf = (await read('ext/KHR_node_visibility/data/node/valid.gltf', | ||
| ignoreUnused: true)) | ||
| .gltf; | ||
|
|
||
| final invisibleNodeVisibility = | ||
| gltf.nodes[0].extensions['KHR_node_visibility'] as KhrNodeVisibility; | ||
| expect(invisibleNodeVisibility.visible, isFalse); | ||
|
|
||
| final visibleNodeVisibility = | ||
| gltf.nodes[1].extensions['KHR_node_visibility'] as KhrNodeVisibility; | ||
| expect(visibleNodeVisibility.visible, isTrue); | ||
|
|
||
| final emptyExtensionObject = | ||
| gltf.nodes[2].extensions['KHR_node_visibility'] as KhrNodeVisibility; | ||
| expect(emptyExtensionObject.visible, isTrue); | ||
| }); | ||
| }); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.