Skip to content

Commit

Permalink
rename Channel to AnimationChannel and make Sampler mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal committed Jun 24, 2024
1 parent 887e847 commit fa84d75
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
18 changes: 9 additions & 9 deletions gltf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand All @@ -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"`
Expand Down

0 comments on commit fa84d75

Please sign in to comment.