Skip to content

Documentation / scene / CCDSolver

Class: CCDSolver ​

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:34

CCD (Cyclic Coordinate Descent) IK solver.

Remarks ​

CCD is an iterative IK algorithm that works by:

  1. Starting from the joint closest to the end effector
  2. Rotating each joint to point the end effector toward the target
  3. Moving backward through the chain to the root
  4. Repeating until convergence or max iterations

CCD is generally faster than FABRIK and works well for chains of any length. It's particularly good for tentacles, tails, and other flexible chains.

Supports multiple pole vectors to control the bending direction of different joints.

Extends ​

Constructors ​

Constructor ​

new CCDSolver(chain, maxIterations?, tolerance?): CCDSolver

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:47

Create a CCD solver.

Parameters ​

chain ​

IKChain

The IK chain to solve

maxIterations? ​

number = 10

Maximum number of iterations (default: 10)

tolerance? ​

number = 0.001

Convergence tolerance in world units (default: 0.001)

Returns ​

CCDSolver

Overrides ​

IKSolver.constructor

Properties ​

_chain ​

protected _chain: IKChain

Defined in: libs/scene/src/animation/ik/ik_solver.ts:11

The IK chain to solve

Inherited from ​

IKSolver._chain


_maxIterations ​

protected _maxIterations: number

Defined in: libs/scene/src/animation/ik/ik_solver.ts:13

Maximum number of iterations

Inherited from ​

IKSolver._maxIterations


_tolerance ​

protected _tolerance: number

Defined in: libs/scene/src/animation/ik/ik_solver.ts:15

Convergence tolerance (distance threshold)

Inherited from ​

IKSolver._tolerance

Accessors ​

chain ​

Get Signature ​

get chain(): IKChain

Defined in: libs/scene/src/animation/ik/ik_solver.ts:33

Get the IK chain.

Returns ​

IKChain

Inherited from ​

IKSolver.chain

Methods ​

setTwistConstraint() ​

setTwistConstraint(jointIndex, minTwist, maxTwist, smoothFactor?): void

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:72

Set twist constraint for a specific joint.

Parameters ​

jointIndex ​

number

Index of the joint

minTwist ​

number

Minimum twist angle in radians

maxTwist ​

number

Maximum twist angle in radians

smoothFactor? ​

number = 0.3

Smoothing factor [0-1] (default: 0.3)

Returns ​

void


getTwistConstraint() ​

getTwistConstraint(jointIndex): TwistConstraint

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:95

Get twist constraint for a specific joint.

Parameters ​

jointIndex ​

number

Index of the joint

Returns ​

TwistConstraint

Twist constraint or undefined if not set


removeTwistConstraint() ​

removeTwistConstraint(jointIndex): boolean

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:105

Remove twist constraint for a specific joint.

Parameters ​

jointIndex ​

number

Index of the joint

Returns ​

boolean

True if a constraint was removed


clearTwistConstraints() ​

clearTwistConstraints(): void

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:112

Clear all twist constraints.

Returns ​

void


setPoleVector() ​

setPoleVector(jointIndex, poleVector, weight?): void

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:123

Set pole vector for a specific joint.

Parameters ​

jointIndex ​

number

Index of the joint to apply pole vector to

poleVector ​

Vector3

Pole vector position in world space

weight? ​

number = 1

Weight of the pole vector constraint (0-1, default: 1)

Returns ​

void


removePoleVector() ​

removePoleVector(jointIndex): boolean

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:140

Remove pole vector for a specific joint.

Parameters ​

jointIndex ​

number

Index of the joint to remove pole vector from

Returns ​

boolean

True if a pole vector was removed, false if none existed


clearPoleVectors() ​

clearPoleVectors(): void

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:147

Clear all pole vectors.

Returns ​

void


getPoleVector() ​

getPoleVector(jointIndex): object

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:157

Get pole vector configuration for a specific joint.

Parameters ​

jointIndex ​

number

Index of the joint

Returns ​

object

Pole vector configuration or undefined if not set

position ​

position: Vector3

weight ​

weight: number


hasPoleVector() ​

hasPoleVector(jointIndex): boolean

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:174

Check if a joint has a pole vector.

Parameters ​

jointIndex ​

number

Index of the joint

Returns ​

boolean

True if the joint has a pole vector


solve() ​

solve(target): boolean

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:184

Solve the IK chain to reach the target position using CCD algorithm.

Parameters ​

target ​

Vector3

Target position for the end effector

Returns ​

boolean

True if converged within tolerance, false otherwise

Overrides ​

IKSolver.solve


applyToNodes() ​

applyToNodes(weight?): void

Defined in: libs/scene/src/animation/ik/ccd_solver.ts:402

Apply the solved joint positions to scene nodes as rotations.

Parameters ​

weight? ​

number = 1

Blend weight (0 = original, 1 = full IK, default: 1)

Returns ​

void

Overrides ​

IKSolver.applyToNodes


setMaxIterations() ​

setMaxIterations(value): void

Defined in: libs/scene/src/animation/ik/ik_solver.ts:40

Set maximum number of iterations.

Parameters ​

value ​

number

Returns ​

void

Inherited from ​

IKSolver.setMaxIterations


getMaxIterations() ​

getMaxIterations(): number

Defined in: libs/scene/src/animation/ik/ik_solver.ts:47

Get maximum number of iterations.

Returns ​

number

Inherited from ​

IKSolver.getMaxIterations


setTolerance() ​

setTolerance(value): void

Defined in: libs/scene/src/animation/ik/ik_solver.ts:54

Set convergence tolerance.

Parameters ​

value ​

number

Returns ​

void

Inherited from ​

IKSolver.setTolerance


getTolerance() ​

getTolerance(): number

Defined in: libs/scene/src/animation/ik/ik_solver.ts:61

Get convergence tolerance.

Returns ​

number

Inherited from ​

IKSolver.getTolerance

Released under the MIT License.