RealisticModel

@three-blocks/proPresetRealisticRAPIERSimulationMovement
const RealisticModel = { name: 'realistic', config: { gravity: 15, maxSpeed: 14, groundAccel: 25, airAccel: 0.2, friction: 4, stopSpeed: 0.1...
Value
{ name: 'realistic', config: { gravity: 15, maxSpeed: 14, groundAccel: 25, airAccel: 0.2, friction: 4, stopSpeed: 0.1, jumpVelocity: 6, groundAngleThreshold: 0.7854, contactSlop: 0.001, baumgarteBeta: 0.2, speculativeMargin: 0.002, maxBi...

Realistic Physics Model (RAPIER-aligned)

Simulation-style physics with exact RAPIER defaults:

  • Gravity: 9.81 m/s² (Earth gravity)
  • Coulomb friction model: max_friction = normal_force * coefficient
  • Implicit Euler damping: v = 1/(1 + dtdamping) - numerically stable
  • Almost no air control (committed movement)

Best for:

  • Rigid body simulation games
  • Physics-based puzzles
  • Realistic movement feel

Usage

Example
import { Physics, RealisticModel, PresetNames } from '@three-blocks/pro';

// Using the preset name
const physics = new Physics( { physicsModel: PresetNames.REALISTIC } );

// Or using the model directly
const physics = new Physics( {
  physicsModel: 'custom',
  customPhysicsModel: RealisticModel
} );

// Access configuration
console.log( RealisticModel.config.gravity ); // 9.81 (RAPIER default)
console.log( RealisticModel.config.friction ); // 0.5 (Coulomb friction)

Members

config#

Configuration - Realistic simulation physics

Movement parameters tuned for simulation-style games. Contact parameters match RAPIER/Box2D defaults for stable physics.

Methods

isGround#

isGround(surfaceAngle : number) : boolean

Determine if surface is walkable ground

Parameters
surfaceAnglenumber
Angle from up vector in radians
Returns
boolean
  • True if walkable ground

groundMove#

groundMove(velocity : THREE.Vector3, wishDir : THREE.Vector3, wishSpeed : number, delta : number)

Ground movement physics Higher friction for immediate stops

Parameters
velocityTHREE.Vector3
Current velocity (modified in place)
wishDirTHREE.Vector3
Input direction
wishSpeednumber
Input magnitude (0-1)
deltanumber
Time step

airMove#

airMove(velocity : THREE.Vector3, wishDir : THREE.Vector3, wishSpeed : number, delta : number)

Air movement physics Almost no air control - once you jump, you're committed

Parameters
velocityTHREE.Vector3
Current velocity (modified in place)
wishDirTHREE.Vector3
Input direction
wishSpeednumber
Input magnitude (0-1)
deltanumber
Time step

clipVelocity#

clipVelocity(velocity : THREE.Vector3, normal : THREE.Vector3)

Clip velocity against surface Standard clip without overbounce

Parameters
velocityTHREE.Vector3
Current velocity (modified in place)
normalTHREE.Vector3
Surface normal

jump#

jump(velocity : THREE.Vector3, onGround : boolean) : boolean

Handle jump Lower, more realistic jump

Parameters
velocityTHREE.Vector3
Current velocity (modified in place)
onGroundboolean
Whether player is on ground
Returns
boolean
  • True if jump was executed

applyDamping#

applyDamping(velocity : THREE.Vector3, delta : number)

Apply RAPIER-style linear damping (implicit Euler)

Formula: v *= 1 / (1 + dt * damping) This is numerically stable and won't cause velocity reversal at high damping values.

Parameters
velocityTHREE.Vector3
Current velocity (modified in place)
deltanumber
Time step