RealisticModel
const RealisticModel = { name: 'realistic', config: { gravity: 15, maxSpeed: 14, groundAccel: 25, airAccel: 0.2, friction: 4, stopSpeed: 0.1...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) : booleanDetermine if surface is walkable ground
Parameters
surfaceAnglenumberAngle 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.Vector3Current velocity (modified in place)
wishDirTHREE.Vector3Input direction
wishSpeednumberInput magnitude (0-1)
deltanumberTime 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.Vector3Current velocity (modified in place)
wishDirTHREE.Vector3Input direction
wishSpeednumberInput magnitude (0-1)
deltanumberTime step
clipVelocity#
clipVelocity(velocity : THREE.Vector3, normal : THREE.Vector3)Clip velocity against surface Standard clip without overbounce
Parameters
velocityTHREE.Vector3Current velocity (modified in place)
normalTHREE.Vector3Surface normal
jump#
jump(velocity : THREE.Vector3, onGround : boolean) : booleanHandle jump Lower, more realistic jump
Parameters
velocityTHREE.Vector3Current velocity (modified in place)
onGroundbooleanWhether 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.Vector3Current velocity (modified in place)
deltanumberTime step