pxlAnim

pxlAnim

new pxlAnim()

Description:
  • Animation handling

Source:

Methods

(static) Animation#addClips(animName, clipName, animFbx)

Description:
  • Add a clip to an object Use pxlFile.loadAnimFBX() to load your animation clips

Source:
Example
// Add a clip to an object
pxlAnim.addClips( "myAnim", "myClip", fbxLoader_animationCycleRoot );
Parameters:
Name Type Description
animName string

The name of the animation object

clipName string

The name of the clip to add

animFbx Object

The FBX object to animate

(static) Animation#destroy(animName)

Description:
  • Destroy a rig + animation objects of the provided animation name

Source:
Example
// Destroy a rig + animation objects of the provided animation name
this.pxlAnim.destroy( "myAnim" );
Parameters:
Name Type Description
animName string

The name of the animation object

(static) Animation#getMesh(animName) → {Object}

Description:
  • Get mesh of the rigged object

Source:
Example
// Get mesh of the rigged object
let mesh = this.pxlAnim.getMesh( this.animRigName );
console.log( mesh );
Parameters:
Name Type Description
animName string

The name of the animation object

Returns:
  • The mesh object of the animation object
Type
Object

(static) Animation#getMixer(animName) → {string}

Description:
  • Get the current state of an object

Source:
Example
// Get the current state of an object
let curState = this.pxlAnim.getMixer( this.animRigName );
console.log( curState );
Parameters:
Name Type Description
animName string

The name of the animation object

Returns:
  • The current state of the object
Type
string

(static) Animation#getRig(animName) → {Object}

Description:
  • Get animation rig of an object

Source:
Example
// Get animation rig of an object
let rig = this.pxlAnim.getRig( this.animRigName );
console.log( rig );
Parameters:
Name Type Description
animName string

The name of the animation object

Returns:
  • The rig object of the animation object
Type
Object

(static) Animation#hasClip(animName, clipName) → {boolean}

Description:
  • Check if an object has a clip

Source:
Example
// Check if an object has a clip
let hasClip = this.pxlAnim.hasClip( this.animRigName, "myClipName" );
console.log( hasClip );
Parameters:
Name Type Description
animName string

The name of the animation object

clipName string

The name of the clip to check for

Returns:
  • True if the object has the clip
Type
boolean

(static) Animation#initObject(animName, animFbx)

Description:
  • Initialize an object for animation

Source:
Parameters:
Name Type Description
animName string

The name of the animation object

animFbx Object

The FBX object to animate

(static) Animation#playClip(animName, clipName)

Description:
  • Play a clip on an object

Source:
Example
// Play a clip on an object
this.pxlAnim.playClip( this.animRigName, "myClipName" );
Parameters:
Name Type Description
animName string

The name of the animation object

clipName string

The name of the clip to play

(static) Animation#setStateConnections(animName, clipName, speed)

Description:
  • Set animation cycle speed in the mixer

    This is handled when the FBX is loaded, this is visible for the example

Source:
Example
// Set animation cycle speed in the mixer
constructor(){
    this.animSource = {
      "RabbitDruidA" : {
        "rig" : this.assetPath+"RabbitDruidA/RabbitDruidA_rig.fbx",
        "anim" : {
          "Sit_Idle" : this.assetPath+"RabbitDruidA/RabbidDruidA_anim_sit_idle.fbx",
          "Sit_Stoke" : this.assetPath+"RabbitDruidA/RabbidDruidA_anim_sit_stoke.fbx",
          "Sit_Look" : this.assetPath+"RabbitDruidA/RabbidDruidA_anim_sit_look.fbx"
        },
        "stateConnections"  : {
          // Non existing states will be ignored and loop'ed, ie "Walk"
          "Sit_Idle" : [ ...Array(6).fill("Sit_Idle"), ...Array(6).fill("Sit_Stoke"), ...Array(5).fill("Sit_Look")],
          "Sit_Stoke" : ["Sit_Idle"],
          "Sit_Look" : ["Sit_Idle"]
        }
      }
    };
  }
Parameters:
Name Type Description
animName string

The name of the animation object

clipName string

The name of the clip to set speed for

speed number

The speed to set

(static) Animation#setWeight(animName, clipName, weight, disableOthers)

Description:
  • Set blend weights of animation cycle in the mixer

Source:
Example
// Set blend weights of animation cycle in the mixer
//this.pxlAnim.setWeight( this.animRigName, "myClipName", 1, true );
this.pxlAnim.setWeight( this.animRigName, "myClipName", 0.5, false );
//this.pxlAnim.setWeight( this.animRigName, "myClipName", 0.25, true );
Parameters:
Name Type Default Description
animName string

The name of the animation object

clipName string

The name of the clip to set weight for

weight number

The weight to set

disableOthers boolean false

Disable other clips in the mixer