rhodonite
    Preparing search index...

    Class VRMSpringBonePhysicsStrategy

    Physics strategy implementation for VRM spring bone simulation.

    This class handles the physics simulation of VRM spring bones, which are used to create realistic secondary animation for hair, clothing, accessories, and other flexible parts of VRM models. The simulation includes:

    • Inertia and drag forces
    • Gravity effects
    • Stiffness constraints
    • Collision detection and response
    • Bone length normalization

    The physics simulation runs per frame and updates the rotation of spring bone nodes based on physical forces and constraints.

    Implements

    Index

    Constructors

    Methods

    • Handles collision detection and response for the spring bone.

      This method checks for collisions between the spring bone and all colliders in the provided collision groups. It supports both sphere and capsule colliders. When a collision is detected, the bone's tail position is adjusted to resolve the collision, and the bone length is re-normalized.

      Parameters

      • collisionGroups: VRMColliderGroup[]

        Array of collision groups containing colliders

      • nextTail: Vector3

        The target tail position to check for collisions

      • boneHitRadius: number

        The radius of the bone for collision detection

      • bone: VRMSpringBone

        The spring bone being tested for collisions

      • worldSpacePosition: Vector3

      Returns Vector3

      The adjusted tail position after collision resolution

    • Normalizes the bone length to maintain the original bone length constraint.

      This method ensures that the spring bone maintains its original length regardless of the forces applied during simulation. It calculates the direction from the bone's head to the target tail position and scales it to match the original bone length.

      Parameters

      • nextTail: Vector3

        The target tail position before normalization

      • worldSpacePosition: Vector3
      • bone: VRMSpringBone

        The spring bone to normalize

      Returns IMutableVector3

      The normalized tail position maintaining the original bone length

    • Processes the physics simulation for a single spring bone.

      This method performs the complete physics simulation pipeline:

      1. Calculates inertia from previous frame movement
      2. Applies stiffness forces to maintain bone orientation
      3. Applies external forces (gravity)
      4. Normalizes bone length to maintain constraints
      5. Handles collision detection and response
      6. Updates bone position and rotation

      Parameters

      • config: Config

        The configuration for the physics simulation

      • collisionGroups: VRMColliderGroup[]

        Array of collision groups for collision detection

      • bone: VRMSpringBone

        The spring bone to process

      • Optionalcenter: SceneGraphComponent

        Optional center transform for coordinate space conversion

      Returns void