### KinematicCharacterController Set Up Direction Examples Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Illustrates setting the 'up' direction for the KinematicCharacterController, showing examples for standard downward gravity and a custom gravity vector. ```typescript // Standard gravity pointing down controller.setUp({x: 0, y: 1}); ``` ```typescript // Custom gravity direction controller.setUp({x: 0, y: 0, z: 1}); ``` -------------------------------- ### Utility Functions Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/overview.md Provides examples of utility functions available in the Rapier library, such as getting the library version and pre-allocating WASM memory. ```typescript RAPIER.version() // Get library version RAPIER.reserveMemory(n) // Pre-allocate WASM memory ``` -------------------------------- ### Example: Processing Contact Manifold Data Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md An example demonstrating how to use the `contactPair` method to retrieve and log contact normal and the number of contacts from a manifold. ```typescript world.narrowPhase.contactPair(h1, h2, (manifold, flipped) => { console.log('Contact normal:', manifold.contactNormal()); console.log('Num contacts:', manifold.numContacts()); }); ``` -------------------------------- ### InteractionGroups Example Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/types.md Example of creating an InteractionGroups mask where Group 1 (member) collides with groups 2 and 3. ```typescript // Group 1 (member) collides with groups 2 and 3 const groups = (1 << 0) | (0b110 << 16); ``` -------------------------------- ### Physics Simulation Setup Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/overview.md Initializes the physics world, creates bodies and colliders, and sets up an event queue for collision and intersection events. ```typescript const world = new World({x: 0, y: -9.81}); // Create bodies and colliders const body = world.createRigidBody(RigidBodyDesc.dynamic()); const collider = world.createCollider(ColliderDesc.ball(0.5), body); // Add events and joints const eventQueue = new EventQueue(true, true); ``` -------------------------------- ### JointAxesMask Example Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/joints.md Example demonstrating how to use JointAxesMask to define free translation axes in X and Y for a generic joint. ```typescript // Free to translate in X and Y, locked otherwise const mask = JointAxesMask.LinX | JointAxesMask.LinY; ``` -------------------------------- ### density() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Gets the density of the collider. ```APIDOC ## density() ### Description Gets the density. ### Method ```typescript density(): number ``` ### Returns - number - Density value ``` -------------------------------- ### Example: Configure and Add a Vehicle Wheel Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Demonstrates how to create and configure a WheelColliderDesc object with custom properties and then add it to a vehicle. This sets up a new wheel with specific physical characteristics. ```typescript const wheelConfig = new WheelColliderDesc(); wheelConfig.chassisLocalPos = {x: 1, y: -1, z: 0}; wheelConfig.wheelRadius = 0.4; wheelConfig.engineForce = 500; const wheelIndex = vehicle.addWheel(wheelConfig); ``` -------------------------------- ### Initialize Rapier World Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/overview.md Imports the Rapier library and initializes a new physics world with a specified gravity vector. This is a common starting point for using the physics engine. ```typescript import * as RAPIER from '@dimforge/rapier3d'; const world = new RAPIER.World({x: 0, y: -9.81, z: 0}); ``` -------------------------------- ### KinematicCharacterController Example Usage Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Demonstrates how to use the `move` method of the KinematicCharacterController to handle player input and apply gravity, including checking for ground contact and logging collision information. ```typescript const movement = {x: 0, y: 0, z: 0}; movement.x = input.right ? 5 : (input.left ? -5 : 0); movement.y = controller.isGrounded() ? 0 : movement.y - 9.81 * dt; const collision = controller.move(characterCollider, movement, world); if (collision) { console.log('Hit something at distance:', collision.toi); } ``` -------------------------------- ### friction() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Gets the friction coefficient of the collider. ```APIDOC ## friction() ### Description Gets the friction coefficient. ### Method ```typescript friction(): number ``` ### Returns - number - Friction coefficient (0-1) ``` -------------------------------- ### translation() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Gets the world-space position of the collider. ```APIDOC ## translation() ### Description Gets the world-space position. ### Method ```typescript translation(target?: Vector): Vector ``` ### Parameters #### Path Parameters - **target** (Vector) - Optional - Object to populate ### Returns - Vector - World position ``` -------------------------------- ### solverGroups() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Gets the solver groups, determining which pairs generate contact forces. ```APIDOC ## solverGroups() ### Description Gets the solver groups (which pairs generate contact forces). ### Method ```typescript solverGroups(): InteractionGroups ``` ### Returns - InteractionGroups - A bit mask representing the solver groups. ``` -------------------------------- ### Named Imports Example (TypeScript) Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/initialization.md Shows how to import specific components from Rapier.js using named imports in TypeScript. This allows for cleaner code by only importing the necessary modules. ```typescript import { World, RigidBody, RigidBodyDesc, Collider, ColliderDesc, Vector3, EventQueue } from '@dimforge/rapier3d'; const world = new World({x: 0, y: -9.81, z: 0}); ``` -------------------------------- ### Example: Select PID Controller Axes Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Shows how to combine PidAxesMask flags to specify that a PID controller should only manage the vertical position (LinY) and Z-axis rotation (AngZ). ```typescript // Only control vertical position and rotation const axes = PidAxesMask.LinY | PidAxesMask.AngZ; ``` -------------------------------- ### Set World Gravity with 2D Vector Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/configuration.md Example of setting world gravity using a 2D vector, suitable for 2D physics simulations. ```typescript const world = new World({x: 0, y: -9.81}); // All dynamic bodies experience this acceleration ``` -------------------------------- ### mass() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Gets the mass of the rigid body in kilograms. A mass of 0 indicates infinite mass. ```APIDOC ## mass() ### Description Gets the mass in kilograms (0 = infinite). ### Method GET (conceptual) ### Response #### Success Response - **number** - Mass ``` -------------------------------- ### Retrieving Rapier Version Source: https://github.com/dimforge/rapier.js/blob/master/CHANGELOG.md Get the version of the Rapier package as a string using the RAPIER.version() function. ```javascript RAPIER.version() ``` -------------------------------- ### Handle Character Collision Events Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Example of how to handle collision events for a character controller. This snippet shows how to log information when a character hits another collider. ```typescript controller.move(characterCollider, movement, world); eventQueue.drainCollisionEvents((h1, h2, started) => { if (started && h1 === characterCollider.handle) { console.log('Character hit', h2); } }); ``` -------------------------------- ### Initialize Rapier.js World and Simulation Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/initialization.md This snippet demonstrates the essential steps for initializing a Rapier.js physics world, including optional memory pre-allocation, creating the world, setting up an event queue, defining bodies and colliders, running the simulation loop, and cleaning up resources. ```typescript import * as RAPIER from '@dimforge/rapier3d'; // 1. Pre-allocate memory (optional) RAPIER.reserveMemory(10 * 1024 * 1024); // 2. Create world const world = new RAPIER.World({x: 0, y: -9.81, z: 0}); // 3. Create event queue const eventQueue = new RAPIER.EventQueue(true, true); // 4. Create bodies and colliders const bodyDesc = RAPIER.RigidBodyDesc.dynamic(); const body = world.createRigidBody(bodyDesc); const colliderDesc = RAPIER.ColliderDesc.ball(0.5); const collider = world.createCollider(colliderDesc, body); // 5. Run simulation loop let time = 0; while (time < 100) { world.step(eventQueue); time += world.integrationParameters.dt; } // 6. Clean up world.free(); ``` -------------------------------- ### Build Rapier.js Packages Manually Source: https://github.com/dimforge/rapier.js/blob/master/README.md Run these shell scripts from the repository root to build the Rapier.js packages. The prepare script only needs to be run once unless build preparation files are modified. ```shell ./builds/prepare_builds/prepare_all_projects.sh ./builds/prepare_builds/build_all_projects.sh ``` -------------------------------- ### Using EventQueue for Physics Events Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/event-queue.md Demonstrates how to create an EventQueue and process collision, sensor, and force events after each simulation step. Ensure the EventQueue is initialized with the desired event types enabled. ```typescript const eventQueue = new EventQueue(true, true, true); world.step(eventQueue); // Process collision events eventQueue.drainCollisionEvents((h1, h2, started) => { if (started) { console.log('Bodies collided:', h1, h2); } }); // Process sensor events eventQueue.drainIntersectionEvents((h1, h2, intersecting) => { if (intersecting) { console.log('Sensor activation:', h1, h2); } }); // Process force events eventQueue.drainContactForceEvents((event) => { const force = Math.sqrt( event.total_force.x ** 2 + event.total_force.y ** 2 ); if (force > 100) { console.log('High impact detected'); } }); ``` -------------------------------- ### RigidBodyDesc Constructor Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Creates a new rigid body descriptor with the specified body type. This is the starting point for configuring a new rigid body. ```APIDOC ## RigidBodyDesc Constructor **Description:** Creates a new rigid body descriptor with the specified body type. This is the starting point for configuring a new rigid body. **Parameters:** - **status** (RigidBodyType) - Required - The type of rigid body to create. **TypeScript Definition:** ```typescript constructor(status: RigidBodyType) ``` ``` -------------------------------- ### body2 Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/joints.md Gets the child body of a MultibodyJoint. ```APIDOC ## body2() ### Description Gets the child body. ### Method ```typescript body2(): RigidBody ``` ### Returns - RigidBody ``` -------------------------------- ### Create 3D Rotation (Quaternion) Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/types.md Shows how to create quaternion instances for 3D rotations using RotationOps, class constructors, or plain objects. ```typescript // Using RotationOps const identity = RotationOps.identity(); // {x: 0, y: 0, z: 0, w: 1} // Using class constructor const q = new Quaternion(0, 0, 0, 1); // Using plain objects const q2 = {x: 0, y: 0, z: 0, w: 1}; ``` -------------------------------- ### Create and Move a Character Controller Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/overview.md Initialize a character controller with a sliding speed and set its up direction. Then, use the `move` method to apply movement and handle collisions. ```typescript const controller = world.createCharacterController(0.01); controller.setUp({x: 0, y: 1}); const collision = controller.move(charCollider, movement, world); ``` -------------------------------- ### body1 Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/joints.md Gets the parent body of a MultibodyJoint. ```APIDOC ## body1() ### Description Gets the parent body. ### Method ```typescript body1(): RigidBody ``` ### Returns - RigidBody ``` -------------------------------- ### restitution() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Gets the restitution (bounciness) of the collider. ```APIDOC ## restitution() ### Description Gets the restitution (bounciness). ### Method ```typescript restitution(): number ``` ### Returns - number - Restitution value (0-1) ``` -------------------------------- ### Initialize Rapier.js World Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/README.md Pre-allocates memory and creates a new physics world with a specified gravity vector. This is the first step in using the physics engine. ```typescript import * as RAPIER from '@dimforge/rapier3d'; RAPIER.reserveMemory(10 * 1024 * 1024); // Optional: pre-allocate const world = new RAPIER.World({x: 0, y: -9.81, z: 0}); ``` -------------------------------- ### mass() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Gets the mass contributed by this collider. ```APIDOC ## mass() ### Description Gets the mass contributed by this collider. ### Method ```typescript mass(): number ``` ### Returns - number - Mass in kilograms ``` -------------------------------- ### NarrowPhase.free() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Releases the WASM resources associated with the NarrowPhase. ```APIDOC ## NarrowPhase.free() ### Description Releases WASM resources. ### Method ```typescript free(): void ``` ``` -------------------------------- ### rotation() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Gets the world-space orientation of the collider. ```APIDOC ## rotation() ### Description Gets the world-space orientation. ### Method ```typescript rotation(target?: Rotation): Rotation ``` ### Returns - Rotation - World orientation ``` -------------------------------- ### CCDSolver.free() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Releases the WASM resources associated with the CCDSolver. ```APIDOC ## CCDSolver.free() ### Description Releases WASM resources. ### Method ```typescript free(): void ``` ``` -------------------------------- ### Create 3D Vector Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/types.md Demonstrates various ways to create a 3D vector instance using VectorOps, class constructors, or plain objects. ```typescript // Using VectorOps const v = VectorOps.new(1, 2, 3); // Using class constructors const v2 = new Vector3(1, 2, 3); // Using plain objects const v3 = {x: 1, y: 2, z: 3}; ``` -------------------------------- ### volumeContactForces() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Gets the total contact force at this frame. ```APIDOC ## volumeContactForces() ### Description Gets the total contact force at this frame. ### Method N/A (This is a getter method) ### Returns - **number**: Force magnitude ``` -------------------------------- ### createCharacterController() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/world.md Creates a character controller for kinematic body movement within the physics world. ```APIDOC ## createCharacterController() ### Description Creates a character controller for kinematic body movement. ### Method `createCharacterController` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **offset** (number) - Required - Padding distance between character and obstacles ### Response #### Success Response (KinematicCharacterController) KinematicCharacterController ### Example ```typescript const controller = world.createCharacterController(0.01); controller.setOffset(0.01); ``` ``` -------------------------------- ### gravityScale() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Gets the gravity scale multiplier for the rigid body. ```APIDOC ## gravityScale() ### Description Gets the gravity scale multiplier. ### Method GET (conceptual) ### Response #### Success Response - **number** - Gravity scale ``` -------------------------------- ### Configure PID Controller for Position and Velocity Targets Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/configuration.md Initialize a PID controller and set target position, rotation, linear velocity, and angular velocity. ```typescript const controller = new PidController(); // Position target controller.setTargetPos({x: 0, y: 5}); controller.setTargetRot(0); // 2D angle or Quaternion (3D) // Velocity target controller.setTargetVel({x: 0, y: 0}); controller.setTargetAngvel(0); ``` -------------------------------- ### parent() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Gets the parent rigid body if the collider is attached. ```APIDOC ## parent() ### Description Gets the parent rigid body if attached. ### Method ```typescript parent(): RigidBody | null ``` ### Returns - RigidBody | null - The parent rigid body or null if not attached. ``` -------------------------------- ### numColliders() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Gets the total number of colliders attached to this rigid body. ```APIDOC ## numColliders() ### Description Gets the number of attached colliders. ### Method ```typescript numColliders(): number ``` ### Response #### Success Response (200) - **return value** (number) - The count of attached colliders. ``` -------------------------------- ### BroadPhase.free() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Releases the WASM resources associated with the BroadPhase. ```APIDOC ## BroadPhase.free() ### Description Releases WASM resources. ### Method ```typescript free(): void ``` ``` -------------------------------- ### serialize() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/world.md Serializes the current state of the physics world into a binary format. ```APIDOC ## serialize() ### Description Serializes the world state to binary format. ### Method `serialize` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response (Uint8Array) Uint8Array - Binary representation of the world ### Example ```typescript const binary = world.serialize(); // Save to file or send over network ``` ``` -------------------------------- ### PrismaticImpulseJoint.translation() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/joints.md Gets the current translation along the prismatic axis for a PrismaticImpulseJoint. ```APIDOC ## PrismaticImpulseJoint.translation() ### Description Gets the current translation along the prismatic axis. ### Method `translation(): number` ### Returns - **number**: The current translation along the prismatic axis. ``` -------------------------------- ### RigidBodyDesc Static Methods Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Factory methods for creating `RigidBodyDesc` instances for different body types. ```APIDOC ## RigidBodyDesc Static Methods **Description:** Factory methods for creating `RigidBodyDesc` instances for different body types. ### `dynamic()` Creates a descriptor for a dynamic rigid body. **Returns:** `RigidBodyDesc` **Example:** ```typescript const desc = RigidBodyDesc.dynamic() .setTranslation({x: 0, y: 5}) .setLinvel({x: 1, y: 0}); ``` ### `fixed()` Creates a descriptor for a fixed (immovable) rigid body. **Returns:** `RigidBodyDesc` ### `kinematicPositionBased()` Creates a descriptor for a position-based kinematic body. **Returns:** `RigidBodyDesc` ### `kinematicVelocityBased()` Creates a descriptor for a velocity-based kinematic body. **Returns:** `RigidBodyDesc` ``` -------------------------------- ### collisionGroups() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Gets the collision groups, determining which groups can collide with this collider. ```APIDOC ## collisionGroups() ### Description Gets the collision groups (which groups can collide with this). ### Method ```typescript collisionGroups(): InteractionGroups ``` ### Returns - InteractionGroups - A bit mask representing the collision groups. ``` -------------------------------- ### MultibodyJointSet.len() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Gets the total number of multibody joints currently managed. ```APIDOC ## MultibodyJointSet.len() ### Description Gets the number of multibody joints. ### Method ```typescript len(): number ``` ### Returns number - Joint count ``` -------------------------------- ### numWheels() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Gets the total number of wheels currently configured for the vehicle controller. ```APIDOC ## numWheels() ### Description Gets the number of wheels. ### Method ```typescript numWheels(): number ``` ### Returns number ``` -------------------------------- ### Simulate a Simple Falling Body Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/overview.md Create a dynamic rigid body and a collider, then step the physics world simulation over time. Log the body's translation after each step and free the world resources when done. ```typescript const world = new World({x: 0, y: -9.81}); const body = world.createRigidBody(RigidBodyDesc.dynamic()); const collider = world.createCollider(ColliderDesc.ball(0.5), body); for (let i = 0; i < 100; i++) { world.step(); console.log(body.translation()); } world.free(); ``` -------------------------------- ### World Constructor Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/world.md Creates a new physics world with the specified gravity vector. This is the primary way to initialize a physics simulation. ```APIDOC ## World Constructor ### Description Creates a new physics world with the specified gravity vector. ### Parameters #### Path Parameters - **gravity** (Vector) - Yes - The gravity acceleration vector applied to all dynamic bodies ``` -------------------------------- ### Get Collider Count Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Returns the total number of colliders managed by the set. ```typescript world.colliders.len() ``` -------------------------------- ### step() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/world.md Advances the physics simulation by one timestep. This method should be called repeatedly to update the physics state. It can optionally accept an event queue and physics hooks. ```APIDOC ## step() ### Description Advances the physics simulation by one timestep. ### Method ```typescript step(eventQueue?: EventQueue, hooks?: PhysicsHooks): void ``` ### Parameters #### Query Parameters - **eventQueue** (EventQueue) - No - Queue to collect contact and intersection events - **hooks** (PhysicsHooks) - No - Hooks to filter collisions and intersections ### Example ```typescript const world = new World({x: 0, y: -9.81}); const eventQueue = new EventQueue(true, true); // Simulate world.step(eventQueue); // Process events eventQueue.drainCollisionEvents((handle1, handle2, started) => { console.log('Collision between', handle1, handle2); }); ``` ``` -------------------------------- ### Importing Rapier.js Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/initialization.md Import the Rapier.js library for either 3D or 2D physics. All public API functions and classes are available directly on the imported RAPIER object. ```APIDOC ## Importing Rapier.js ### Description Import the Rapier.js library for either 3D or 2D physics. All public API functions and classes are available directly on the imported RAPIER object. ### Usage ```typescript // For 3D physics import * as RAPIER from '@dimforge/rapier3d'; // For 2D physics import * as RAPIER from '@dimforge/rapier2d'; ``` ``` -------------------------------- ### RevoluteImpulseJoint.angle() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/joints.md Gets the current rotation angle in radians for a RevoluteImpulseJoint. This method is specific to 2D physics. ```APIDOC ## RevoluteImpulseJoint.angle() (2D only) ### Description Gets the current rotation angle in radians. ### Method `angle(): number` ### Returns - **number**: The current rotation angle in radians. ``` -------------------------------- ### Create a new physics world Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/world.md Initializes a new physics world with a specified gravity vector. This is the primary entry point for any physics simulation. ```typescript constructor(gravity: Vector) ``` -------------------------------- ### Get Joint Type Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/joints.md Returns the type of the ImpulseJoint. This can be used to differentiate between various joint configurations. ```typescript type(): JointType ``` -------------------------------- ### Import Rapier.js Module Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/initialization.md Import the main rapier.js module for 3D or 2D physics simulations. All public API functions and classes are available directly on the imported RAPIER object. ```typescript import * as RAPIER from '@dimforge/rapier3d'; // or for 2D: import * as RAPIER from '@dimforge/rapier2d'; ``` -------------------------------- ### Get Rigid Body Gravity Scale Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Retrieves the gravity scale multiplier for the rigid body. ```typescript gravityScale(): number ``` -------------------------------- ### Get Number of Wheels in Vehicle Controller Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Retrieves the current number of wheels attached to the DynamicRayCastVehicleController. ```typescript numWheels(): number ``` -------------------------------- ### IslandManager.free() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Releases the WASM resources associated with the IslandManager. ```APIDOC ## IslandManager.free() ### Description Releases WASM resources. ### Method ```typescript free(): void ``` ``` -------------------------------- ### version() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/initialization.md Retrieves the semantic version string of the rapier.js library. ```APIDOC ## version() ### Description Returns the semantic version of the rapier.js library. ### Method ```typescript function version(): string ``` ### Returns - string: Version string (e.g., "0.20.0") ### Example ```typescript console.log('Rapier version:', RAPIER.version()); ``` ``` -------------------------------- ### Get Impulse Joint Count Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Returns the total number of impulse joints managed by the set. ```typescript world.impulseJoints.len() ``` -------------------------------- ### Get Rigid Body Count Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Returns the total number of rigid bodies managed by the set. ```typescript world.bodies.len() ``` -------------------------------- ### Configure KinematicCharacterController Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/configuration.md Set up a character controller with specific parameters like up direction, impulse application to dynamic bodies, and custom mass. ```typescript const controller = world.createCharacterController(0.01); controller.setUp({x: 0, y: 1}); controller.setApplyImpulsesToDynamicBodies(true); controller.setCharacterMass(80); ``` -------------------------------- ### Create a Character Controller Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/world.md Initializes a character controller for kinematic body movement. The `offset` parameter defines the padding distance between the character and obstacles. ```typescript const controller = world.createCharacterController(0.01); controller.setOffset(0.01); ``` -------------------------------- ### Get Collider by Handle Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Retrieves a collider using its unique handle. Returns null if the collider has been deleted. ```typescript const collider = world.colliders.get(colliderHandle); if (collider) { console.log(collider.translation()); } ``` -------------------------------- ### Get Number of Colliders Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Retrieves the total number of colliders attached to this rigid body. This can be used to iterate through all colliders. ```typescript numColliders(): number ``` -------------------------------- ### Full Physics Simulation Loop Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/README.md A comprehensive physics loop demonstrating applying forces, updating kinematic bodies, stepping the simulation, processing collision events, and reading transforms for rendering. Ensure to free world resources after the loop. ```typescript const world = new RAPIER.World(gravity); const eventQueue = new RAPIER.EventQueue(true, true); // Add bodies and colliders // ... // Simulation loop for (let frame = 0; frame < maxFrames; frame++) { // Apply forces body.applyForce(forceVector); // Update kinematic bodies kinematicBody.setTranslation(newPos, true); // Step physics world.step(eventQueue); // Process events eventQueue.drainCollisionEvents((h1, h2, started) => { // Handle collisions }); // Read transforms for rendering const pos = body.translation(); const rot = body.rotation(); // Update graphics... } world.free(); ``` -------------------------------- ### Get Second Attached Rigid Body Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/joints.md Retrieves the second rigid body connected to the ImpulseJoint. This is a read-only property. ```typescript body2(): RigidBody ``` -------------------------------- ### IntegrationParameters Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/initialization.md Defines simulation parameters such as time step and solver iterations. It can be initialized with raw parameters. ```APIDOC ## Class: IntegrationParameters ### Description Simulation parameters that control the physics simulation's behavior, including the time step (`dt`) and the number of solver iterations. ### Constructor - `constructor(raw?: RawIntegrationParameters)`: Initializes a new instance of `IntegrationParameters`. The `raw` parameter is an optional object containing initial values for the parameters. ### Properties - **dt** (number): The time step for the simulation. Determines the granularity of physics updates. - **numSolverIterations** (number): The number of iterations the physics solver will perform to resolve constraints. More iterations lead to higher accuracy but also increased computation time. ### Related See `Configuration` documentation for more details. ``` -------------------------------- ### Get First Attached Rigid Body Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/joints.md Retrieves the first rigid body connected to the ImpulseJoint. This is a read-only property. ```typescript body1(): RigidBody ``` -------------------------------- ### Get Collider Restitution Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Retrieve the restitution (bounciness) of a collider using the `restitution()` method. The value is between 0 and 1. ```typescript restitution(): number ``` -------------------------------- ### Initialize World with Gravity Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/configuration.md Configure the world's gravity during initialization. The gravity is a vector property on the World instance. ```typescript const world = new World({x: 0, y: -9.81, z: 0}); ``` -------------------------------- ### Create a Zero Vector Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/math.md Creates a vector with all components initialized to zero. Useful for starting points or reset states. ```typescript const v = VectorOps.zeros(); // {x: 0, y: 0} or {x: 0, y: 0, z: 0} ``` -------------------------------- ### Get Rapier.js Version Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/initialization.md Retrieve the semantic version of the currently used rapier.js library. This is useful for compatibility checks or logging. ```typescript function version(): string ``` ```typescript console.log('Rapier version:', RAPIER.version()); ``` -------------------------------- ### createRigidBody() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/world.md Creates a new rigid body in the world with the properties defined in the provided descriptor. Rigid bodies represent dynamic or static physical objects in the simulation. ```APIDOC ## createRigidBody() ### Description Creates a new rigid body in the world. ### Method ```typescript createRigidBody(desc: RigidBodyDesc): RigidBody ``` ### Parameters #### Path Parameters - **desc** (RigidBodyDesc) - Yes - The rigid body descriptor with initial properties ### Returns - **RigidBody** - The created rigid body ### Example ```typescript const bodyDesc = RigidBodyDesc.dynamic() .setTranslation({x: 0, y: 10}); const body = world.createRigidBody(bodyDesc); ``` ``` -------------------------------- ### Get Collider Friction Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Obtain the friction coefficient of a collider using the `friction()` method. The value ranges from 0 to 1. ```typescript friction(): number ``` -------------------------------- ### World Class Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/initialization.md The main physics simulation container. It manages the simulation steps, rigid body creation, and other physics-related operations. ```APIDOC ## World ### Description Main physics simulation container. ### Class Definition ```typescript class World { constructor(gravity: Vector) step(eventQueue?: EventQueue, hooks?: PhysicsHooks): void createRigidBody(desc: RigidBodyDesc): RigidBody // ... (see World documentation) } ``` ### Related `api-reference/world.md` ``` -------------------------------- ### Get Number of Multibody Joints Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Returns the total count of multibody joints currently managed. This is a simple numeric value. ```typescript len(): number ``` -------------------------------- ### RigidBodyDesc Methods Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Methods for configuring the properties of a `RigidBodyDesc`. ```APIDOC ## RigidBodyDesc Methods **Description:** Methods for configuring the properties of a `RigidBodyDesc`. ### `setTranslation(translation: Vector): RigidBodyDesc` Sets the initial world position. ### `setRotation(rotation: Rotation): RigidBodyDesc` Sets the initial world orientation. ### `setLinvel(linvel: Vector): RigidBodyDesc` Sets the initial linear velocity. ### `setAngvel(angvel: number | Vector): RigidBodyDesc` Sets the initial angular velocity. ### `setMass(mass: number): RigidBodyDesc` Sets the mass in kilograms (0 for infinite mass). ### `setGravityScale(gravityScale: number): RigidBodyDesc` Sets the gravity scale multiplier. ### `setLinearDamping(damping: number): RigidBodyDesc` Sets linear damping (0-1, typically). ### `setAngularDamping(damping: number): RigidBodyDesc` Sets angular damping (0-1, typically). ### `setCanSleep(can: boolean): RigidBodyDesc` Sets whether the body can sleep. ### `setCcdEnabled(enabled: boolean): RigidBodyDesc` Enables continuous collision detection. ``` -------------------------------- ### Create DynamicRayCastVehicleController Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Creates a new vehicle controller for a chassis rigid body using raycasts for suspension. This is for 3D environments only. ```typescript constructor(chassisBody: RigidBody) ``` -------------------------------- ### Get Multibody Joint by Handle Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Retrieves a multibody joint using its unique handle. Returns null if the joint has been deleted. ```typescript get(handle: MultibodyJointHandle): MultibodyJoint | null ``` -------------------------------- ### projectPoint() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Projects a point onto this collider to find the closest point on the surface. ```APIDOC ## projectPoint() ### Description Projects a point onto this collider. ### Method N/A (This is a method call) ### Parameters - **point** (Vector) - Yes - Point to project - **solid** (boolean) - Yes - If true, points inside are projected to surface ### Response #### Success Response - **PointColliderProjection | null**: The projection details or null if the point is outside the collider and not solid. ``` -------------------------------- ### Get Impulse Joint by Handle Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Retrieves an impulse joint using its unique handle. Returns null if the joint has been deleted. ```typescript world.impulseJoints.get(jointHandle) ``` -------------------------------- ### Get Rigid Body by Handle Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Retrieves a rigid body using its unique handle. Returns null if the body has been deleted. ```typescript const body = world.bodies.get(bodyHandle); if (body) { console.log(body.translation()); } ``` -------------------------------- ### Accessing and Modifying World and Body Properties Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/initialization.md Demonstrates how to read and write properties for world integration parameters and body transformations. Some properties use getters/setters, while others allow direct access. ```typescript // Reading const dt = world.integrationParameters.dt; const pos = body.translation(); // Writing world.integrationParameters.dt = 1/120; body.setTranslation({x: 0, y: 5}, true); ``` ```typescript // Direct access world.gravity = {x: 0, y: -20}; const g = world.gravity; ``` -------------------------------- ### free() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/queries.md Releases WASM resources associated with the geometry. ```APIDOC ## free() ### Description Releases WASM resources. ### Method `void` ### Signature ```typescript free(): void ``` ### Source `src.ts/geometry/broad_phase.ts` ``` -------------------------------- ### Get Collider Density Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Retrieve the density of a collider using the `density()` method. Density is defined as mass per unit volume. ```typescript density(): number ``` -------------------------------- ### Get Collider Mass Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Determine the mass contributed by a collider by calling the `mass()` method. The returned value represents the mass in kilograms. ```typescript mass(): number ``` -------------------------------- ### Vector and Rotation Math Utilities Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/initialization.md Provides classes for 2D and 3D vectors, quaternions, and operations for vector and rotation manipulation. Includes static methods for creating, initializing, and manipulating these math objects. ```typescript class Vector2 { constructor(x: number, y: number) } class Vector3 { constructor(x: number, y: number, z: number) } class Quaternion { constructor(x, y, z, w: number) } class VectorOps { static new(...): Vector static zeros(): Vector static fromBuffer(buffer: Float32Array, target?: Vector): Vector // ... (see Math documentation) } class RotationOps { static identity(): Rotation static fromBuffer(buffer: Float32Array, target?: Rotation): Rotation // ... (see Math documentation) } ``` -------------------------------- ### Get Collider Rotation Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Obtain the world-space orientation of a collider with the `rotation()` method. An optional `Rotation` object can be supplied to store the result. ```typescript rotation(target?: Rotation): Rotation ``` -------------------------------- ### wakeUp() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Wakes the rigid body up, enabling its simulation. This is typically called when an external force or collision occurs. ```APIDOC ## wakeUp() ### Description Wakes the body up (enables simulation). ### Method ```typescript wakeUp(): void ``` ``` -------------------------------- ### Get KinematicCharacterController Up Direction Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Retrieves the current 'up' direction vector used by the character controller for floor detection and gravity-relative operations. ```typescript up(): Vector ``` -------------------------------- ### Get KinematicCharacterController Offset Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Retrieves the current padding distance set for the character controller. This value determines the gap between the character and obstacles. ```typescript offset(): number ``` -------------------------------- ### RigidBodySet.forEachBody() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Iterates over all rigid bodies (both active and sleeping) in the set, executing a callback function for each. ```APIDOC ## RigidBodySet.forEachBody() ### Description Iterates through all bodies (active and sleeping). ### Method forEachBody ### Parameters #### Path Parameters - **callback** (function) - Required - Called for each body ``` -------------------------------- ### Perform a Raycast Query Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/README.md Initializes a query pipeline and performs a raycast to detect intersections with colliders in the world. It logs the hit distance if an intersection occurs. ```typescript const queryPipeline = new RAPIER.QueryPipeline(); const ray = new RAPIER.Ray({x: 0, y: 0, z: 0}, {x: 1, y: 0, z: 0}); const hit = queryPipeline.castRay( world.colliders, ray, 1000, false, 0xffffffff ); if (hit) { console.log('Hit at distance:', hit.toi); } ``` -------------------------------- ### drainCollisionEvents Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/event-queue.md Processes all queued collision events, invoking a callback for each event indicating whether a contact started or ended between two colliders. ```APIDOC ## drainCollisionEvents() ### Description Processes all queued collision events (contact started/stopped). ### Method ```typescript drainCollisionEvents(callback: (handle1: ColliderHandle, handle2: ColliderHandle, started: boolean) => void): void ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **callback** (function) - Required - Called for each collision event - **handle1** (ColliderHandle) - First collider identifier - **handle2** (ColliderHandle) - Second collider identifier - **started** (boolean) - true if contact started, false if ended ### Request Example ```typescript const eventQueue = new EventQueue(true, false); world.step(eventQueue); eventQueue.drainCollisionEvents((h1, h2, started) => { if (started) { console.log('Collision started between', h1, h2); } else { console.log('Collision ended between', h1, h2); } }); ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Create a Friction Platform Collider Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/configuration.md Use ColliderDesc.cuboid to create a platform with high friction. Set density to 0 for infinite mass. ```typescript const platform = ColliderDesc.cuboid(10, 0.5, 10) .setFriction(2.0) .setDensity(0); // Infinite mass const collider = world.createCollider(platform, groundBody); ``` -------------------------------- ### Configure Dynamic Rigid Body Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/overview.md Create a dynamic rigid body description, setting its mass, linear and angular damping, and enabling continuous collision detection (CCD) for more accurate collision handling. ```typescript const desc = RigidBodyDesc.dynamic() .setMass(10) .setLinearDamping(0.1) .setAngularDamping(0.1) .setCcdEnabled(true); // Continuous collision detection ``` -------------------------------- ### Get Total Contact Force Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Retrieves the total magnitude of contact forces acting on the collider at the current frame. This value is a scalar number. ```typescript volumeContactForces(): number ``` -------------------------------- ### reserveMemory() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/initialization.md Pre-allocates additional WebAssembly linear memory to reduce future allocation overhead during initialization. This is an experimental feature. ```APIDOC ## reserveMemory() ### Description Pre-allocates additional WebAssembly linear memory to reduce future allocation overhead. This is experimental and useful for applications with predictable memory requirements. Call once during initialization for best results. ### Method ```typescript function reserveMemory(extraBytesCount: number): void ``` ### Parameters #### Path Parameters - **extraBytesCount** (number) - Required - Number of extra bytes to reserve ### Notes - This is experimental and the allocator may perform additional allocations regardless. - Useful for applications with predictable memory requirements. - Call once during initialization for best results. ### Example ```typescript // Reserve 50MB of extra memory RAPIER.reserveMemory(50 * 1024 * 1024); const world = new RAPIER.World({x: 0, y: -9.81}); ``` ``` -------------------------------- ### Get Rigid Body Angular Velocity Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Retrieves the current angular velocity of the rigid body. Returns a number for 2D and a Vector for 3D. ```typescript angvel(target?: Rotation | number): Rotation | number ``` -------------------------------- ### Free physics world resources Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/world.md Releases all WASM memory occupied by the physics world and its child structures. This should be called to clean up resources when the world is no longer needed. ```typescript const world = new World({x: 0, y: -9.81}); // ... use world ... world.free(); // Clean up resources ``` -------------------------------- ### Set KinematicCharacterController Offset Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Updates the padding distance for the character controller. This affects how close the character can get to obstacles before collision response is triggered. ```typescript setOffset(offset: number): void ``` -------------------------------- ### deserialize() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/world.md Deserializes a physics world from a binary format. This is a static method. ```APIDOC ## deserialize() ### Description Deserializes a world from binary format. ### Method `static deserialize` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **data** (Uint8Array) - Required - Binary world data ### Response #### Success Response (World) World - Reconstructed physics world ### Example ```typescript const world = World.deserialize(binaryData); ``` ``` -------------------------------- ### Get Prismatic Joint Translation Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/joints.md Retrieves the current translation along the prismatic axis of a prismatic joint. This indicates the joint's linear position. ```typescript translation(): number ``` -------------------------------- ### Vector3 Constructor Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/math.md Creates a 3D vector with x, y, and z components. ```APIDOC ## Vector3 Constructor ### Description Creates a 3D vector. ### Method `constructor(x: number, y: number, z: number)` ### Parameters #### Path Parameters - **x** (number) - Required - The x component of the vector. - **y** (number) - Required - The y component of the vector. - **z** (number) - Required - The z component of the vector. ### Request Example ```typescript const v = new Vector3(1, 2, 3); console.log(v.x, v.y, v.z); // 1 2 3 ``` ``` -------------------------------- ### translation() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Gets the world-space position of the rigid body. An optional target object can be provided to populate with the position, otherwise a new Vector is created and returned. ```APIDOC ## translation() ### Description Gets the world-space position. ### Method GET (conceptual) ### Parameters #### Query Parameters - **target** (Vector) - Optional - Object to populate (creates new if omitted) ### Response #### Success Response - **Vector** - World position ### Response Example { "example": "Vector { x: number, y: number }" } ### Example: ```typescript const pos = body.translation(); console.log(pos.x, pos.y); ``` ``` -------------------------------- ### Get Collider Translation Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/collider.md Retrieve the world-space position of a collider using the `translation()` method. An optional `Vector` object can be provided to populate with the position data. ```typescript translation(target?: Vector): Vector ``` -------------------------------- ### KinematicCharacterController Constructor Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Creates a new character controller instance. Use this to initialize a controller for player characters. ```typescript constructor(offset: number) ``` -------------------------------- ### Get KinematicCharacterController Custom Mass Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Retrieves the custom mass value used for impulse resolution. Returns the set mass or null if auto-detection is active. ```typescript characterMass(): number | null ``` -------------------------------- ### RigidBodyDesc Static Methods and Properties Source: https://github.com/dimforge/rapier.js/blob/master/CHANGELOG.md Use new static methods like RigidBodyDesc.newStatic, .newDynamic, and .newKinematic for creating rigid bodies. Access and set gravity scale, linear damping, and angular damping. ```javascript RigidBodyDesc.newStatic() RigidBodyDesc.newDynamic() RigidBodyDesc.newKinematic() RigidBodyDesc.setGravityScale(scale) RigidBody.gravityScale RigidBody.setGravityScale(scale) RigidBody.setLinearDamping(damping) RigidBody.setAngularDamping(damping) ``` -------------------------------- ### Get Specific Collider by Index Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Retrieves a specific collider attached to the rigid body by its index. The index must be within the valid range of [0, numColliders()). ```typescript collider(index: number): Collider ``` -------------------------------- ### RigidBodySet.forEachActiveBody() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/sets.md Iterates over all active (non-sleeping) rigid bodies in the set, executing a callback function for each. ```APIDOC ## RigidBodySet.forEachActiveBody() ### Description Iterates through all non-sleeping bodies. ### Method forEachActiveBody ### Parameters #### Path Parameters - **callback** (function) - Required - Called for each active body ``` -------------------------------- ### Rapier.js File Organization Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/README.md This snippet shows the directory structure for the Rapier.js project, outlining the location of the main README, configuration files, type definitions, and API reference modules. ```tree output/ ├── README.md (this file) ├── overview.md ├── types.md ├── configuration.md └── api-reference/ ├── initialization.md ├── world.md ├── rigid-body.md ├── collider.md ├── shapes.md ├── joints.md ├── event-queue.md ├── queries.md ├── controllers.md ├── sets.md └── math.md ``` -------------------------------- ### Get Revolute Joint Angle (2D) Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/joints.md Retrieves the current rotation angle in radians for a revolute joint in a 2D physics simulation. This method is specific to 2D. ```typescript angle(): number ``` -------------------------------- ### Create PID Controller Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/controllers.md Creates a new PID (Proportional-Integral-Derivative) controller instance. This controller is used for smooth body dynamics. ```typescript constructor() ``` -------------------------------- ### rotation() Source: https://github.com/dimforge/rapier.js/blob/master/_autodocs/api-reference/rigid-body.md Gets the world-space orientation of the rigid body. An optional target object can be provided to populate with the orientation, otherwise a new Rotation object is created and returned. ```APIDOC ## rotation() ### Description Gets the world-space orientation. ### Method GET (conceptual) ### Parameters #### Query Parameters - **target** (Rotation) - Optional - Object to populate ### Response #### Success Response - **Rotation** - World orientation ### Response Example { "example": "Rotation { x: number, y: number, z: number, w: number }" } ```