Skip to content

Documentation / scene / SkinBinding

Class: SkinBinding

Defined in: libs/scene/src/animation/skeleton.ts:393

Skin binding for skinned animation.

Responsibilities:

  • References a shared SkeletonRig.
  • Maintains inverse bind and current skinning matrices for one skin.
  • Provides a texture containing joint matrices for GPU skinning.
  • Applies skinning state to associated meshes each frame.
  • Computes animated axis-aligned bounding boxes using representative skinned vertices.

Joint matrix texture layout:

  • Texture format: rgba32f.
  • Stored as a 2-layered ring buffer: current and previous joint transforms to support temporal addressing if needed. Offsets are tracked in _jointOffsets[0] (current) and _jointOffsets[1] (previous).

Usage:

  • Construct with a rig, bind data, meshes and submesh bounding info.
  • Call apply() each frame to update joint texture, bind to meshes, and update bounds.
  • Call reset() to clear skinning on meshes.

Extends

  • Disposable

Extended by

Constructors

Constructor

new SkinBinding(rig, inverseBindMatrices, joints?, bindPose?): SkinBinding

Defined in: libs/scene/src/animation/skeleton.ts:424

Create a skin binding instance.

Parameters

rig

SkeletonRig

Shared skeleton rig that owns animated joint transforms.

inverseBindMatrices

Matrix4x4[]

Inverse bind matrices for each joint.

joints?

SceneNode[]

Joint scene nodes (one per joint), ordered to match skin data.

bindPose?

SkeletonBindPose[]

Returns

SkinBinding

Overrides

Disposable.constructor

Accessors

disposed

Get Signature

get disposed(): boolean

Defined in: libs/base/dist/index.d.ts:6065

Returns

boolean

Inherited from

Disposable.disposed


rig

Get Signature

get rig(): SkeletonRig

Defined in: libs/scene/src/animation/skeleton.ts:468

Returns

SkeletonRig


joints

Get Signature

get joints(): SceneNode[]

Defined in: libs/scene/src/animation/skeleton.ts:472

Gets joint nodes

Returns

SceneNode[]


humanoidJointMapping

Get Signature

get humanoidJointMapping(): HumanoidJointMapping<SceneNode>

Defined in: libs/scene/src/animation/skeleton.ts:476

Gets the humanoid joint mapping

Returns

HumanoidJointMapping<SceneNode>


humanoidRootRotation

Get Signature

get humanoidRootRotation(): Quaternion

Defined in: libs/scene/src/animation/skeleton.ts:480

Root rotation of humanoid hips bone

Returns

Quaternion


playing

Get Signature

get playing(): boolean

Defined in: libs/scene/src/animation/skeleton.ts:491

Returns

boolean

Set Signature

set playing(b): void

Defined in: libs/scene/src/animation/skeleton.ts:494

Parameters
b

boolean

Returns

void


persistentId

Get Signature

get persistentId(): string

Defined in: libs/scene/src/animation/skeleton.ts:497

Returns

string

Set Signature

set persistentId(val): void

Defined in: libs/scene/src/animation/skeleton.ts:500

Parameters
val

string

Returns

void


jointTexture

Get Signature

get jointTexture(): Texture2D<unknown>

Defined in: libs/scene/src/animation/skeleton.ts:516

Texture containing joint matrices for GPU skinning.

Each matrix is stored in 4 texels (one row per texel, RGBA = 4 floats).

Returns

Texture2D<unknown>


modifiers

Get Signature

get modifiers(): SkeletonModifier[]

Defined in: libs/scene/src/animation/skeleton.ts:606

Get all modifiers attached to this skeleton.

Returns

SkeletonModifier[]

Methods

on()

on<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:594

IEventTarget.on

Type Parameters

K

K extends "dispose"

Parameters

type

K

listener

EventListener<{ dispose: []; }, K>

context?

unknown

Returns

void

Inherited from

Disposable.on


once()

once<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:598

IEventTarget.once

Type Parameters

K

K extends "dispose"

Parameters

type

K

listener

EventListener<{ dispose: []; }, K>

context?

unknown

Returns

void

Inherited from

Disposable.once


off()

off<K>(type, listener?, context?): void

Defined in: libs/base/dist/index.d.ts:602

IEventTarget.off

Type Parameters

K

K extends "dispose"

Parameters

type

K

listener?

EventListener<{ dispose: []; }>

context?

unknown

Returns

void

Inherited from

Disposable.off


dispatchEvent()

dispatchEvent<K>(type, ...args): void

Defined in: libs/base/dist/index.d.ts:606

IEventTarget.dispatchEvent

Type Parameters

K

K extends "dispose"

Parameters

type

K

args

...object[K]

Returns

void

Inherited from

Disposable.dispatchEvent


dispose()

dispose(): void

Defined in: libs/base/dist/index.d.ts:6066

Returns

void

Inherited from

Disposable.dispose


findSkeletonById()

static findSkeletonById(id): SkinBinding

Defined in: libs/scene/src/animation/skeleton.ts:465

Parameters

id

string

Returns

SkinBinding


getJointIndex()

getJointIndex(joint): number

Defined in: libs/scene/src/animation/skeleton.ts:524

Get joint index by joint node

Parameters

joint

SceneNode

joint node

Returns

number

The index of the joint


getJointIndexByName()

getJointIndexByName(jointName): number

Defined in: libs/scene/src/animation/skeleton.ts:532

Get joint index by joint name

Parameters

jointName

string

joint name

Returns

number

The index of the joint


onDispose()

protected onDispose(): void

Defined in: libs/scene/src/animation/skeleton.ts:656

Dispose GPU resources and references held by the skeleton.

  • Disposes the joint texture.
  • Clears matrix arrays and joint references.

Returns

void

Overrides

Disposable.onDispose


getBoundingInfo()

getBoundingInfo(data): SkinnedBoundingBox

Defined in: libs/scene/src/animation/skeleton.ts:714

Build representative skinned bounding data for a submesh.

Strategy:

  • For all vertices, compute their skinned position (using current ring buffer slot).
  • Track the indices of the min/max extents along x, y, z (6 indices total).
  • Store:
    • The 6 representative positions in object space.
    • Their 4 joint indices and weights (flattened).
    • An empty BoundingBox to be filled during animation.

Parameters

data
positions

Float32Array

blendIndices

TypedArray

weights

TypedArray

Returns

SkinnedBoundingBox

Skinned bounding box info used during per-frame updates.


tryExtractHumanoidJoints()

static tryExtractHumanoidJoints<T>(root): HumanoidJointMapping<T>

Defined in: libs/scene/src/animation/skeleton.ts:1656

Attempt to extract humanoid joint mappings from the skeleton's joints based on their names.

This method looks for joints with names matching the standardized HumanoidBodyRig and HumanoidHandRig enums. If a complete mapping is found, it returns an object containing the mapped joints for the body and hands. If any required joint is missing, it returns null.

This method tries to find the best match for humanoid rigs, designed to work with Mixamo, VRoid, Unity Humanoid, Biped, and similar skeletons. It is not guaranteed to work with all models, and may require manual adjustments or custom modifiers for non-standard rigs.

Type Parameters

T

T extends object

Parameters

root

T

The root scene node to search for humanoid joints.

Returns

HumanoidJointMapping<T>

An object containing the mapped body and hand joints if a complete humanoid rig is detected, otherwise null.


tryExtractHumanoidJointsMixamo()

static tryExtractHumanoidJointsMixamo<T>(root): HumanoidJointMapping<T>

Defined in: libs/scene/src/animation/skeleton.ts:1666

Type Parameters

T

T extends object

Parameters

root

T

Returns

HumanoidJointMapping<T>


tryExtractHumanoidJointsVRM()

static tryExtractHumanoidJointsVRM<T>(root): HumanoidJointMapping<T>

Defined in: libs/scene/src/animation/skeleton.ts:1671

Type Parameters

T

T extends object

Parameters

root

T

Returns

HumanoidJointMapping<T>


tryExtractHumanoidJointsUnityHumanoid()

static tryExtractHumanoidJointsUnityHumanoid<T>(root): HumanoidJointMapping<T>

Defined in: libs/scene/src/animation/skeleton.ts:1676

Type Parameters

T

T extends object

Parameters

root

T

Returns

HumanoidJointMapping<T>


tryExtractHumanoidJointsBiped()

static tryExtractHumanoidJointsBiped<T>(root): HumanoidJointMapping<T>

Defined in: libs/scene/src/animation/skeleton.ts:1681

Type Parameters

T

T extends object

Parameters

root

T

Returns

HumanoidJointMapping<T>

Released under the MIT License.