DefaultModel
const DefaultModel = { name: 'default', config: { gravity: 20, gravityFalling: 35, maxSpeed: 10, groundAccel: 12, airAccel: 1, airDrag: 2,...Default Physics Model
Balanced physics suitable for third-person action games:
- Moderate air control (less than ground)
- Slightly faster fall for snappy landing
- Standard ground friction
Uses the Quake-style architecture with balanced parameters.
Usage
Example
import { Physics, DefaultModel, PresetNames } from '@three-blocks/pro';
// Using the preset name (recommended)
const physics = new Physics( { physicsModel: PresetNames.DEFAULT } );
// Or using the model directly
const physics = new Physics( {
physicsModel: 'custom',
customPhysicsModel: DefaultModel
} );
// Access configuration
console.log( DefaultModel.config.maxSpeed ); // 10
console.log( DefaultModel.config.jumpVelocity ); // 10
Members
config#
Configuration - balanced third-person 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, isJumping : boolean)Ground movement physics Responsive acceleration with standard friction
Parameters
velocityTHREE.Vector3Current velocity (modified in place)
wishDirTHREE.Vector3Input direction
wishSpeednumberInput magnitude (0-1)
deltanumberTime step
isJumpingbooleanWhether player is jumping this frame (for bhop friction bypass)
airMove#
airMove(velocity : THREE.Vector3, wishDir : THREE.Vector3, wishSpeed : number, delta : number)Air movement physics Normal gravity when rising, faster fall for snappy landing
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
Parameters
velocityTHREE.Vector3Current velocity (modified in place)
onGroundbooleanWhether player is on ground
Returns
boolean — - True if jump was executed
clampVelocity#
clampVelocity(velocity : THREE.Vector3, maxVelocity : number)Clamp velocity - separate horizontal and vertical This prevents moving while jumping from reducing jump height
Parameters
velocityTHREE.Vector3Current velocity (modified in place)
maxVelocitynumberMaximum velocity cap