-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial KHR_animation_pointer support (#230)
- Loading branch information
1 parent
95ed362
commit 4dcb6a3
Showing
26 changed files
with
958 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
76 changes: 76 additions & 0 deletions
76
lib/src/ext/KHR_animation_pointer/khr_animation_pointer.dart
This file contains 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,76 @@ | ||
// Copyright 2024 The Khronos Group Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
library gltf.extensions.khr_animation_pointer; | ||
|
||
import 'package:gltf/src/base/gltf_property.dart'; | ||
import 'package:gltf/src/ext/extensions.dart'; | ||
|
||
const String KHR_ANIMATION_POINTER = 'KHR_animation_pointer'; | ||
|
||
const String POINTER = 'pointer'; | ||
|
||
const List<String> KHR_ANIMATION_POINTER_MEMBERS = <String>[ | ||
POINTER, | ||
]; | ||
|
||
class KhrAnimationPointer extends GltfProperty { | ||
final String pointer; | ||
|
||
KhrAnimationPointer._( | ||
this.pointer, Map<String, Object> extensions, Object extras) | ||
: super(extensions, extras); | ||
|
||
static final RegExp _pointerRegExp = RegExp(r'^(?:\/(?:[^/~]|~0|~1)*)*$'); | ||
|
||
static KhrAnimationPointer fromMap(Map<String, Object> map, Context context) { | ||
if (context.validate) { | ||
checkMembers(map, KHR_ANIMATION_POINTER_MEMBERS, context); | ||
} | ||
|
||
final pointer = | ||
getString(map, POINTER, context, req: true, regexp: _pointerRegExp); | ||
|
||
final extensions = getExtensions(map, KhrAnimationPointer, context); | ||
|
||
return KhrAnimationPointer._(pointer, extensions, getExtras(map, context)); | ||
} | ||
|
||
@override | ||
void link(Gltf gltf, Context context) { | ||
// TODO: | ||
// * pointer existence | ||
// * channel target uniqueness | ||
// * output accessor compatibility | ||
context.addIssue(LinkError.incompleteExtensionSupport); | ||
|
||
Object o = this; | ||
while (o != null) { | ||
o = context.owners[o]; | ||
if (o is AnimationChannelTarget) { | ||
if (o.node != null) { | ||
context.addIssue( | ||
SemanticError.khrAnimationPointerAnimationChannelTargetNode); | ||
} | ||
if (o.path != POINTER) { | ||
context.addIssue( | ||
SemanticError.khrAnimationPointerAnimationChannelTargetPath, | ||
args: [o.path]); | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
const Extension khrAnimationPointerExtension = Extension( | ||
KHR_ANIMATION_POINTER, | ||
<Type, ExtensionDescriptor>{ | ||
AnimationChannelTarget: ExtensionDescriptor(KhrAnimationPointer.fromMap) | ||
}, | ||
init: _init); | ||
|
||
void _init(Context context) { | ||
context.animationChannelTargetPaths.add(POINTER); | ||
} |
This file contains 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 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,15 @@ | ||
{ | ||
"animation/channel/target": { | ||
"name": "animation.channel.target.KHR_animation_pointer", | ||
"tests": { | ||
"invalid_channel_target_node.gltf": "Invalid channel target node", | ||
"invalid_channel_target_path.gltf": "Invalid channel target path", | ||
"invalid_pointer_syntax.gltf": "Invalid pointer syntax", | ||
"missing_extension_declaration.gltf": "Missing extension declaration", | ||
"missing_pointer.gltf": "Missing pointer string", | ||
"custom_property.gltf": "Custom property", | ||
"unexpected_extension.gltf": "Unexpected extension object location", | ||
"valid.gltf": "Valid" | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
test/ext/KHR_animation_pointer/data/animation/channel/target/custom_property.gltf
This file contains 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,51 @@ | ||
{ | ||
"asset": { | ||
"version": "2.0" | ||
}, | ||
"extensionsUsed": [ | ||
"KHR_animation_pointer" | ||
], | ||
"materials": [ | ||
{ | ||
"pbrMetallicRoughness": { } | ||
} | ||
], | ||
"accessors": [ | ||
{ | ||
"count": 2, | ||
"type": "SCALAR", | ||
"componentType": 5126, | ||
"min": [ 0 ], | ||
"max": [ 1 ] | ||
}, | ||
{ | ||
"count": 2, | ||
"type": "VEC4", | ||
"componentType": 5126 | ||
} | ||
], | ||
"animations": [ | ||
{ | ||
"channels": [ | ||
{ | ||
"target": { | ||
"path": "pointer", | ||
"extensions": { | ||
"KHR_animation_pointer": { | ||
"pointer": "/materials/0/pbrMetallicRoughness/baseColorFactor", | ||
"customProperty": true | ||
} | ||
} | ||
}, | ||
"sampler": 0 | ||
} | ||
], | ||
"samplers": [ | ||
{ | ||
"input": 0, | ||
"output": 1 | ||
} | ||
] | ||
} | ||
] | ||
} |
50 changes: 50 additions & 0 deletions
50
.../ext/KHR_animation_pointer/data/animation/channel/target/custom_property.gltf.report.json
This file contains 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,50 @@ | ||
{ | ||
"uri": "test/ext/KHR_animation_pointer/data/animation/channel/target/custom_property.gltf", | ||
"mimeType": "model/gltf+json", | ||
"validatorVersion": "2.0.0-dev.3.10", | ||
"issues": { | ||
"numErrors": 0, | ||
"numWarnings": 1, | ||
"numInfos": 2, | ||
"numHints": 0, | ||
"messages": [ | ||
{ | ||
"code": "UNEXPECTED_PROPERTY", | ||
"message": "Unexpected property.", | ||
"severity": 1, | ||
"pointer": "/animations/0/channels/0/target/extensions/KHR_animation_pointer/customProperty" | ||
}, | ||
{ | ||
"code": "INCOMPLETE_EXTENSION_SUPPORT", | ||
"message": "Validation support for this extension is incomplete; the asset may have undetected issues.", | ||
"severity": 2, | ||
"pointer": "/animations/0/channels/0/target/extensions/KHR_animation_pointer" | ||
}, | ||
{ | ||
"code": "UNUSED_OBJECT", | ||
"message": "This object may be unused.", | ||
"severity": 2, | ||
"pointer": "/materials/0" | ||
} | ||
], | ||
"truncated": false | ||
}, | ||
"info": { | ||
"version": "2.0", | ||
"extensionsUsed": [ | ||
"KHR_animation_pointer" | ||
], | ||
"animationCount": 1, | ||
"materialCount": 1, | ||
"hasMorphTargets": false, | ||
"hasSkins": false, | ||
"hasTextures": false, | ||
"hasDefaultScene": false, | ||
"drawCallCount": 0, | ||
"totalVertexCount": 0, | ||
"totalTriangleCount": 0, | ||
"maxUVs": 0, | ||
"maxInfluences": 0, | ||
"maxAttributes": 0 | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
.../ext/KHR_animation_pointer/data/animation/channel/target/invalid_channel_target_node.gltf
This file contains 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,49 @@ | ||
{ | ||
"asset": { | ||
"version": "2.0" | ||
}, | ||
"extensionsUsed": [ | ||
"KHR_animation_pointer" | ||
], | ||
"accessors": [ | ||
{ | ||
"count": 2, | ||
"type": "SCALAR", | ||
"componentType": 5126, | ||
"min": [ 0 ], | ||
"max": [ 1 ] | ||
}, | ||
{ | ||
"count": 2, | ||
"type": "VEC4", | ||
"componentType": 5126 | ||
} | ||
], | ||
"nodes": [ | ||
{ } | ||
], | ||
"animations": [ | ||
{ | ||
"channels": [ | ||
{ | ||
"target": { | ||
"node": 0, | ||
"path": "pointer", | ||
"extensions": { | ||
"KHR_animation_pointer": { | ||
"pointer": "/nodes/0/rotation" | ||
} | ||
} | ||
}, | ||
"sampler": 0 | ||
} | ||
], | ||
"samplers": [ | ||
{ | ||
"input": 0, | ||
"output": 1 | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.