Strata - v1.4.10
    Preparing search index...

    Class SpringDynamics

    Physical Spring Dynamics System.

    Simulates realistic spring-mass-damper physics for secondary motion like hair, cloth, tails, and dangling objects. Based on Hooke's law with velocity damping.

    Use Cases:

    • Hair strands that bounce and sway
    • Cape/cloth simulation (combine multiple springs)
    • Antenna, tails, ears that react to movement
    • Camera shake with spring return
    • UI elements with springy feedback

    Physics Parameters:

    • Stiffness: How strongly the spring returns to rest (higher = stiffer, snappier)
    • Damping: How quickly oscillations decay (higher = less bounce, more drag)
    • Mass: Inertia of the object (higher = more momentum, slower response)
    // Bouncy ponytail
    const ponytail = new SpringDynamics({
    stiffness: 150, // Medium stiffness
    damping: 5, // Low damping = bouncy
    mass: 1 // Medium mass
    });

    // In update loop
    const headPos = character.head.position;
    const targetPos = headPos.clone().add(new THREE.Vector3(0, -0.5, 0));
    const hairPos = ponytail.update(targetPos, deltaTime);
    hairMesh.position.copy(hairPos);
    // Stiff antenna that snaps back quickly
    const antenna = new SpringDynamics({
    stiffness: 500, // Very stiff
    damping: 25, // High damping = no bounce
    mass: 0.3 // Light mass = fast response
    });

    // React to head movement
    const restPos = head.position.clone().add(new THREE.Vector3(0, 0.2, 0));
    const antennaPos = antenna.update(restPos, deltaTime);
    // Gravity-affected cape
    const cape = new SpringDynamics({
    stiffness: 80,
    damping: 6,
    mass: 2 // Heavier = more droop
    });

    const gravity = new THREE.Vector3(0, -9.8, 0);
    const shoulderPos = character.shoulder.position;
    const targetPos = shoulderPos.clone().add(
    gravity.clone().multiplyScalar(0.02) // Add gravity influence
    );
    const capePos = cape.update(targetPos, deltaTime);
    Index

    Constructors

    Methods

    • Update spring physics for one time step.

      Computes spring force, damping force, and updates position based on physics simulation.

      Parameters

      • targetPosition: Vector3

        The position the spring is attached to (moves with parent object)

      • deltaTime: number

        Time step in seconds (typically frame delta)

      Returns Vector3

      New position of the spring

      const spring = new SpringDynamics({ stiffness: 100, damping: 10, mass: 1 });

      // In render loop
      function animate(deltaTime: number) {
      const targetPos = parentObject.position;
      const springPos = spring.update(targetPos, deltaTime);
      childObject.position.copy(springPos);
      }