Small World Engine API Reference - v0.78.00
    Preparing search index...

    Class HingeJoint

    A revolute hinge connecting two bodies at a shared anchor point. The hinge keeps the anchors coincident (3 linear DOFs) and keeps both hinge axes parallel (2 rotational DOFs), leaving a single rotational DOF around the hinge axis. A torque-capped motor can drive that DOF, and optional min/max angle limits bound it.

    The hinge angle is measured geometrically from the current body frames (never accumulated), so it stays correct even after many full rotations and never drifts. Relative angular speeds in this file always use angVel = (omegaB - omegaA) dot axis, i.e. the rate at which getRelativeAngle() grows.

    Hierarchy (View Summary)

    Index
    anchorA: Vector3D

    Local anchor offset on bodyA.

    anchorB: Vector3D

    Local anchor offset on bodyB, or world-space anchor if bodyB is null.

    axisA: Vector3D

    Local hinge axis on bodyA.

    axisB: Vector3D

    Local hinge axis on bodyB.

    bodyA: Object3D

    The primary Object3D entity constrained by this joint.

    bodyB: Object3D | null

    The secondary Object3D entity, or null to anchor bodyA to static world space.

    breakForce: number

    Maximum force or impulse threshold before joint rupture.

    collideConnected: boolean

    Whether collision response between bodyA and bodyB is enabled.

    enabled: boolean = true

    Whether the joint is actively evaluated during physics simulation ticks.

    enableLimit: boolean

    Whether the rotational angle limits are enforced.

    enableMotor: boolean

    Whether the motor is active.

    isBroken: boolean = false

    Whether the joint has exceeded breakForce and ruptured.

    maxAngle: number

    Upper rotation limit in radians.

    maxMotorTorque: number

    Maximum motor torque in N*m.

    minAngle: number

    Lower rotation limit in radians.

    motorSpeed: number

    Target rotation speed in rad/s.

    • get isFullyAsleep(): boolean

      True when every dynamic body connected by this joint is currently asleep (static bodies do not count). A fully-asleep joint has nothing to solve: both endpoints are frozen, so the solve can be skipped without waking them. This mirrors the collision solver, which only applies impulses to approaching contacts and therefore never re-wakes settled bodies.

      Returns boolean

    • Optional pre-solve hook to accumulate continuous forces (e.g. Hookean spring tension).

      Parameters

      • dt: number

        Fixed substep delta time in seconds.

      Returns void

    • Measured hinge angle between bodyB and bodyA around the hinge axis, in [-PI, PI]. Built fresh from the current body frames each call: no accumulation, so the value is always the actual relative rotation (mod 2-PI) and never drifts.

      When bodyB is absent the hinge is anchored to a fixed world frame and this returns the rotation of bodyA relative to that frame. Returns NaN if no usable reference could be built (every canonical axis is parallel to the hinge axis).

      Returns number

    • Solves velocity constraints using Projected Gauss-Seidel iterations.

      Parameters

      • dt: number

        Fixed substep delta time in seconds.

      Returns void