Strata - v1.4.10
    Preparing search index...

    Class SpringChain

    Multi-Segment Spring Chain System.

    Simulates a chain of connected springs (like a rope, tail, or hair strand) where each segment follows the one before it with spring physics. Creates realistic swaying, dragging motion.

    Use Cases:

    • Character tails (dragon, cat, lizard)
    • Hair strands or ponytails
    • Ropes, chains, vines
    • Tentacles with secondary motion
    • Cloth strips or ribbons

    Features:

    • Automatic length constraints
    • Gravity influence
    • Progressive stiffness (base is stiffer than tip)
    • Progressive damping (tip has more drag)
    // Dragon tail with 8 segments
    const tail = new SpringChain(
    8, // Number of segments
    {
    stiffness: 100, // Base stiffness
    damping: 10, // Base damping
    mass: 1
    },
    0.4 // Segment length
    );

    // In update loop
    function animate(deltaTime: number) {
    const rootPos = dragon.tailRoot.position;
    const rootQuat = dragon.tailRoot.quaternion;
    const gravity = new THREE.Vector3(0, -9.8, 0);

    const positions = tail.update(rootPos, rootQuat, deltaTime, gravity);

    // Position tail segments
    positions.forEach((pos, i) => {
    if (tailSegments[i]) {
    tailSegments[i].position.copy(pos);
    }
    });
    }
    // Rope hanging from ceiling (stronger gravity)
    const rope = new SpringChain(10, { stiffness: 80, damping: 8 }, 0.3);
    const strongGravity = new THREE.Vector3(0, -20, 0);
    const positions = rope.update(ceilingPos, ceilingQuat, deltaTime, strongGravity);
    Index

    Constructors

    Methods

    Constructors

    • Create a new spring chain.

      Parameters

      • nodeCount: number

        Number of segments in the chain

      • config: Partial<SpringConfig> = {}

        Spring configuration for the chain

      • restLength: number = 0.5

        Length of each segment

      Returns SpringChain

    Methods

    • Parameters

      • rootPosition: Vector3
      • rootRotation: Quaternion
      • deltaTime: number
      • gravity: Vector3 = ...

      Returns Vector3[]