PlatformerModel
const PlatformerModel = { name: 'platformer', config: { gravity: 25, gravityRising: 18, gravityFalling: 45, maxSpeed: 8, groundAccel: 14, air...Platformer Physics Model
Classic platformer physics inspired by games like Super Mario:
- Variable gravity (floaty peak, fast fall)
- Limited air control (commits to jump direction)
- Momentum-based ground movement (slightly slippery)
- Higher ground angle threshold (can walk on steeper slopes)
Uses the Quake-style architecture but tuned for platformer feel.
Usage
Example
import { Physics, PlatformerModel, PresetNames } from '@three-blocks/pro';
// Using the preset name
const physics = new Physics( { physicsModel: PresetNames.PLATFORMER } );
// Or using the model directly
const physics = new Physics( {
physicsModel: 'custom',
customPhysicsModel: PlatformerModel
} );
// Access configuration
console.log( PlatformerModel.config.jumpVelocity ); // 14
console.log( PlatformerModel.config.gravityRising ); // 18 (floaty)
console.log( PlatformerModel.config.gravityFalling ); // 45 (fast fall)
Members
config#
Configuration - Platformer-style physics
Methods
isGround#
isGround(surfaceAngle : number) : booleanDetermine if surface is walkable ground Platformer characters can walk on steeper slopes than FPS characters
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 slightly slippery friction for momentum
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 Variable gravity (floaty peak, fast fall) + limited air control
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 Higher jump for platformer gameplay
Parameters
velocityTHREE.Vector3Current velocity (modified in place)
onGroundbooleanWhether player is on ground
Returns
boolean — - True if jump was executed