engine: github.com/g3n/engine/animation Index | Files

package animation

import "github.com/g3n/engine/animation"

Package animation


Package Files

animation.go channel.go logger.go


const (
    STEP        = InterpolationType("STEP")        // The animated values remain constant to the output of the first keyframe, until the next keyframe.
    LINEAR      = InterpolationType("LINEAR")      // The animated values are linearly interpolated between keyframes. Spherical linear interpolation (slerp) is used to interpolate quaternions.
    CUBICSPLINE = InterpolationType("CUBICSPLINE") // TODO

The various interpolation types.

type Animation Uses

type Animation struct {
    // contains filtered or unexported fields

Animation is a keyframe animation, containing channels. Each channel animates a specific property of an object. Animations can span multiple objects and properties.

func NewAnimation Uses

func NewAnimation() *Animation

NewAnimation creates and returns a pointer to a new Animation object.

func (*Animation) AddChannel Uses

func (anim *Animation) AddChannel(ch IChannel)

AddChannel adds a channel to the animation.

func (*Animation) Loop Uses

func (anim *Animation) Loop() bool

Loop returns whether the animation is looping.

func (*Animation) Name Uses

func (anim *Animation) Name() string

Name returns the animation name.

func (*Animation) Paused Uses

func (anim *Animation) Paused() bool

Paused returns whether the animation is paused.

func (*Animation) Reset Uses

func (anim *Animation) Reset()

Reset resets the animation to the beginning.

func (*Animation) SetLoop Uses

func (anim *Animation) SetLoop(state bool)

SetLoop sets whether the animation is looping.

func (*Animation) SetName Uses

func (anim *Animation) SetName(name string)

SetName sets the animation name.

func (*Animation) SetPaused Uses

func (anim *Animation) SetPaused(state bool)

SetPaused sets whether the animation is paused.

func (*Animation) SetSpeed Uses

func (anim *Animation) SetSpeed(speed float32)

SetSpeed sets the animation speed.

func (*Animation) SetStart Uses

func (anim *Animation) SetStart(v float32)

SetStart sets the initial time offset value.

func (*Animation) Speed Uses

func (anim *Animation) Speed() float32

Speed returns the animation speed.

func (*Animation) Update Uses

func (anim *Animation) Update(delta float32)

Update interpolates and updates the target values for each channel. If the animation is paused, returns false. If the animation is not paused, returns true if the input value is inside the key frames ranges or false otherwise.

type Channel Uses

type Channel struct {
    // contains filtered or unexported fields

A Channel associates an animation parameter channel to an interpolation sampler

func (*Channel) InterpolationTangents Uses

func (c *Channel) InterpolationTangents() (inTangent, outTangent math32.ArrayF32)

InterpolationTangents sets the interpolation tangents

func (*Channel) InterpolationType Uses

func (c *Channel) InterpolationType() InterpolationType

InterpolationType returns the current interpolation type.

func (*Channel) Keyframes Uses

func (c *Channel) Keyframes() math32.ArrayF32

Keyframes returns the keyframe buffer.

func (*Channel) SetBuffers Uses

func (c *Channel) SetBuffers(keyframes, values math32.ArrayF32)

SetBuffers sets the keyframe and value buffers.

func (*Channel) SetInterpolationTangents Uses

func (c *Channel) SetInterpolationTangents(inTangent, outTangent math32.ArrayF32)

SetInterpolationTangents sets the interpolation tangents.

func (*Channel) SetInterpolationType Uses

func (c *Channel) SetInterpolationType(it InterpolationType)

SetInterpolationType sets the interpolation type for this channel.

func (*Channel) Update Uses

func (c *Channel) Update(time float32)

Update finds the keyframe preceding the specified time. Then, calls a stored function to interpolate the relevant values and update the target.

func (*Channel) Values Uses

func (c *Channel) Values() math32.ArrayF32

Values returns the value buffer.

type IChannel Uses

type IChannel interface {
    Update(time float32)
    SetBuffers(keyframes, values math32.ArrayF32)
    Keyframes() math32.ArrayF32
    Values() math32.ArrayF32
    SetInterpolationType(it InterpolationType)

IChannel is the interface for all channel types.

type InterpolationType Uses

type InterpolationType string

InterpolationType specifies the interpolation type.

type MorphChannel Uses

type MorphChannel struct {
    // contains filtered or unexported fields

MorphChannel is the IChannel for morph geometries.

func NewMorphChannel Uses

func NewMorphChannel(mg *geometry.MorphGeometry) *MorphChannel

type NodeChannel Uses

type NodeChannel struct {
    // contains filtered or unexported fields

NodeChannel is the IChannel for all node transforms.

type PositionChannel Uses

type PositionChannel NodeChannel

PositionChannel is the animation channel for a node's position.

func NewPositionChannel Uses

func NewPositionChannel(node core.INode) *PositionChannel

type RotationChannel Uses

type RotationChannel NodeChannel

RotationChannel is the animation channel for a node's rotation.

func NewRotationChannel Uses

func NewRotationChannel(node core.INode) *RotationChannel

type ScaleChannel Uses

type ScaleChannel NodeChannel

ScaleChannel is the animation channel for a node's scale.

func NewScaleChannel Uses

func NewScaleChannel(node core.INode) *ScaleChannel

Package animation imports 4 packages (graph) and is imported by 3 packages. Updated 2018-08-23. Refresh now. Tools for package owners.