Documentation
    Preparing search index...

    Class SpringJoint

    A spring-damper between the anchors (§28). Both dimensions.

    Constrains nothing rigidly — it applies a restoring force — so it has neither limits nor a motor, and its parameters are frozen after construction (a solver cannot re-tune a live spring here; remove and re-add).

    Hierarchy (View Summary)

    Index
    bodyA: RigidBody

    First constrained body (§28).

    bodyB: RigidBody

    Second constrained body (§28).

    broken: boolean = false

    Set once when a §28 break threshold is exceeded; never cleared.

    damping: number

    Damping coefficient in newton-seconds per metre.

    id: number | undefined = undefined

    The world's monotonic id while registered, undefined otherwise.

    restLength: number

    Distance at which the spring exerts no force, in metres.

    stiffness: number

    Spring constant in newtons per metre.

    type: "spring" = ...

    Which §28 constraint this is — the descriptor's discriminant.

    • get breakable(): boolean

      Whether either §28 break threshold is set, so the world must monitor it.

      Returns boolean

    • get breakForce(): number | undefined

      Reaction force in newtons above which this joint breaks (§28), or undefined for a joint that never breaks.

      Settable at any time, registered or not: the threshold is compared by the world after each step and never reaches the solver, so there is nothing to reconfigure. Setting one on a registered joint whose adapter cannot report reactions is not rejected here — the check belongs where the adapter is known, at world.addJoint.

      Returns number | undefined

    • set breakForce(value: number | undefined): void

      Parameters

      • value: number | undefined

      Returns void

    • get breakTorque(): number | undefined

      Reaction torque in N·m above which this joint breaks (§28).

      Returns number | undefined

    • set breakTorque(value: number | undefined): void

      Parameters

      • value: number | undefined

      Returns void

    • get collisionEnabled(): boolean

      Whether the two bodies still collide with each other (§28).

      Live since PH-22f (2026-08-08). Setting it on a registered joint queues the change, exactly as HingeJoint.setLimits does, and the world drains it into SolverJointAccess.setJointCollisionEnabled at the top of the next fixed step (§26's commands-not-mutations rule — the solver may be mid-step, and §6b forbids physics work during dispatch). Writing the value it already holds queues nothing.

      Anchors joined it as the other live §28 property every shipped solver can change — see Joint.setAnchors. Axis, rope length, spring terms and the spherical swing cone stay frozen; see the module header's table.

      Returns boolean

    • set collisionEnabled(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get disposed(): boolean

      Whether Joint.dispose has run. Disposal is terminal (§83): a disposed joint refuses world registration with INVALID_APPLICATION_STATE (§89) rather than silently working.

      Returns boolean

    • get registered(): boolean

      Whether a world currently holds this joint (its Joint.id is set).

      Returns boolean

    • Drops every listener (§83). Removing the joint from its world is the world's business, exactly as it is for RigidBody.

      Returns void

    • Delivers event to the listeners registered for type in registration order. Re-entrant emission of type is deferred (rule 4).

      Type Parameters

      • K extends "jointbreak"

      Parameters

      Returns void

    • Number of live registrations for type (diagnostics, §83).

      Type Parameters

      • K extends "jointbreak"

      Parameters

      • type: K

      Returns number

    • Number of live listener registrations across every event type (§83).

      Used by teardown diagnostics — a detached node that still holds listeners pins its subtree until those listeners are removed.

      Returns number

    • Removes the earliest still-registered registration of listener for type. Removing a listener that is not registered is a no-op.

      Type Parameters

      • K extends "jointbreak"

      Parameters

      Returns void

    • Registers listener for type. Returns a function that removes it.

      The same listener may be registered more than once; each registration is independent and is delivered once per dispatch.

      Type Parameters

      • K extends "jointbreak"

      Parameters

      Returns Unsubscribe

    • Removes every listener, or every listener of one type. Used by teardown paths that must not leave detached nodes retaining listeners (§83).

      Type Parameters

      • K extends "jointbreak"

      Parameters

      • Optionaltype: K

      Returns void

    • Replaces both attachment points with body-local vectors and queues them for the solver (§28, PH-22f).

      The frames are the same ones stored after world.addJoint converts the world-space constructor options. They are not re-measured against the current world poses and not re-measured against the authoring poses — the caller supplies local-space points. undefined means that body's origin.

      Takes effect at the next fixed step, like HingeJoint.setLimits. Writing the values already stored queues nothing. Unregistered, the write is immediate and the next addJoint uses these locals as-is (it does not convert them as world-space).

      Parameters

      Returns void

    • Returns number

    • Writes this joint's world-space axis into out, or zeroes it when the type has none (§28).

      dimension is passed because the default differs: a hinge in a "2d" world has exactly one possible axis (+Z, §21) and needs no author to say so, while a hinge in a "3d" world must name one — an unnamed 3D hinge leaves the axis zero, which validateJointDescriptor then rejects with the message that explains it.

      Parameters

      Returns Vector3