diff --git a/encode_test.go b/encode_test.go index 55e77c7..986ed23 100644 --- a/encode_test.go +++ b/encode_test.go @@ -166,13 +166,13 @@ func TestEncoder_Encode(t *testing.T) { }, }}}, false}, {"withAnimations", args{&Document{Animations: []*Animation{ - {Extras: 8.0, Name: "an_1", Channels: []*Channel{ - {Extras: 8.0, Sampler: Index(1), Target: ChannelTarget{Extras: 8.0, Node: Index(10), Path: TRSRotation}}, - {Extras: 8.0, Sampler: Index(2), Target: ChannelTarget{Extras: 8.0, Node: Index(10), Path: TRSScale}}, + {Extras: 8.0, Name: "an_1", Channels: []*AnimationChannel{ + {Extras: 8.0, Sampler: 1, Target: AnimationChannelTarget{Extras: 8.0, Node: Index(10), Path: TRSRotation}}, + {Extras: 8.0, Sampler: 2, Target: AnimationChannelTarget{Extras: 8.0, Node: Index(10), Path: TRSScale}}, }}, - {Extras: 8.0, Name: "an_2", Channels: []*Channel{ - {Extras: 8.0, Sampler: Index(1), Target: ChannelTarget{Extras: 8.0, Node: Index(3), Path: TRSWeights}}, - {Extras: 8.0, Sampler: Index(2), Target: ChannelTarget{Extras: 8.0, Node: Index(5), Path: TRSTranslation}}, + {Extras: 8.0, Name: "an_2", Channels: []*AnimationChannel{ + {Extras: 8.0, Sampler: 1, Target: AnimationChannelTarget{Extras: 8.0, Node: Index(3), Path: TRSWeights}}, + {Extras: 8.0, Sampler: 2, Target: AnimationChannelTarget{Extras: 8.0, Node: Index(5), Path: TRSTranslation}}, }}, {Extras: 8.0, Name: "an_3", Samplers: []*AnimationSampler{ {Extras: 8.0, Input: 1, Output: 1, Interpolation: InterpolationCubicSpline}, diff --git a/gltf.go b/gltf.go index 6639c8e..532a3ae 100644 --- a/gltf.go +++ b/gltf.go @@ -426,7 +426,7 @@ type Animation struct { Extensions Extensions `json:"extensions,omitempty"` Extras any `json:"extras,omitempty"` Name string `json:"name,omitempty"` - Channels []*Channel `json:"channels" validate:"required,gt=0,dive"` + Channels []*AnimationChannel `json:"channels" validate:"required,gt=0,dive"` Samplers []*AnimationSampler `json:"samplers" validate:"required,gt=0,dive"` } @@ -439,20 +439,20 @@ type AnimationSampler struct { Output uint32 `json:"output"` // The index of an accessor containing keyframe output values. } -// The Channel targets an animation's sampler at a node's property. -type Channel struct { - Extensions Extensions `json:"extensions,omitempty"` - Extras any `json:"extras,omitempty"` - Sampler *uint32 `json:"sampler,omitempty"` - Target ChannelTarget `json:"target"` +// The AnimationChannel targets an animation's sampler at a node's property. +type AnimationChannel struct { + Extensions Extensions `json:"extensions,omitempty"` + Extras any `json:"extras,omitempty"` + Sampler uint32 `json:"sampler"` + Target AnimationChannelTarget `json:"target"` } -// ChannelTarget describes the index of the node and TRS property that an animation channel targets. +// AnimationChannelTarget describes the index of the node and TRS property that an animation channel targets. // The Path represents 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. -type ChannelTarget struct { +type AnimationChannelTarget struct { Extensions Extensions `json:"extensions,omitempty"` Extras any `json:"extras,omitempty"` Node *uint32 `json:"node,omitempty"`