Skip to content

Documentation / scene / SpringChain

Class: SpringChain

Defined in: libs/scene/src/animation/spring/spring_chain.ts:13

Manages a chain of spring particles and constraints

Constructors

Constructor

new SpringChain(): SpringChain

Defined in: libs/scene/src/animation/spring/spring_chain.ts:19

Returns

SpringChain

Properties

particles

particles: SpringParticle[]

Defined in: libs/scene/src/animation/spring/spring_chain.ts:15

Array of particles in the chain


constraints

constraints: SpringConstraint[]

Defined in: libs/scene/src/animation/spring/spring_chain.ts:17

Array of constraints between particles

Methods

fromBoneChain()

static fromBoneChain(startNode, endNode?, options?): SpringChain

Defined in: libs/scene/src/animation/spring/spring_chain.ts:31

Creates a spring chain from a bone hierarchy

Parameters

startNode

SceneNode

Root node of the bone chain

endNode?

SceneNode = null

End node of the bone chain (optional, if null uses all descendants)

options?

Additional options

mass?

number

damping?

number

stiffness?

number

Returns

SpringChain

A new SpringChain instance


addParticle()

addParticle(particle): number

Defined in: libs/scene/src/animation/spring/spring_chain.ts:100

Adds a particle to the chain

Parameters

particle

SpringParticle

The particle to add

Returns

number

The index of the added particle


addConstraint()

addConstraint(constraint): void

Defined in: libs/scene/src/animation/spring/spring_chain.ts:109

Adds a constraint to the chain

Parameters

constraint

SpringConstraint

The constraint to add

Returns

void


addCrossConstraints()

addCrossConstraints(stiffness?, skipDistance?): void

Defined in: libs/scene/src/animation/spring/spring_chain.ts:118

Adds cross constraints between particles for cloth-like behavior

Parameters

stiffness?

number = 0.6

Stiffness of the cross constraints

skipDistance?

number = 2

Distance between particles to connect (default: 2)

Returns

void


reset()

reset(): void

Defined in: libs/scene/src/animation/spring/spring_chain.ts:131

Resets all particles to their original positions

Returns

void

Released under the MIT License.