PlatformerModel
const PlatformerModel = { name: 'platformer', targetTickRate: 600, config: { gravity: 35, gravityRising: 35, gravityFalling: 35, maxSpeed: 7,...Platformer Physics Model
Tight platformer physics inspired by games like Celeste and Hollow Knight:
- Fixed gravity (consistent jump arc)
- High air control for precision movement
- Snappy ground acceleration with instant stops
- Higher ground angle threshold (can walk on steeper slopes)
Uses the two-state architecture tuned for precision 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 ); // 11
console.log( PlatformerModel.config.gravity ); // 35 (consistent)
console.log( PlatformerModel.config.airAccel ); // 8 (high precision control)
Members
targetTickRate#
Target physics tick rate in Hz. 600 Hz prevents tunneling through contactSkin zone at high gravity. Without this, the 35 m/s² gravity can move the body ~0.01m/frame at 60Hz, which equals the contactSkin thickness and causes intermittent ground detection.
config#
Configuration - Tight platformer physics (Celeste/Hollow Knight style)
Methods
isGround#
isGround(surfaceAngle : number) : booleanDetermine if surface is walkable ground Platformer characters can walk on steeper slopes than FPS characters
Parameters
surfaceAnglenumberReturns
boolean — - True if walkable ground
groundMove#
groundMove(velocity : THREE.Vector3, wishDir : THREE.Vector3, wishSpeed : number, delta : number)Ground movement physics Snappy acceleration with high friction for instant stops
Parameters
velocityTHREE.Vector3wishDirTHREE.Vector3wishSpeednumberdeltanumberairMove#
airMove(velocity : THREE.Vector3, wishDir : THREE.Vector3, wishSpeed : number, delta : number)Air movement physics Fixed gravity with good air control for precision platforming
Parameters
velocityTHREE.Vector3wishDirTHREE.Vector3wishSpeednumberdeltanumberclipVelocity#
clipVelocity(velocity : THREE.Vector3, normal : THREE.Vector3)Clip velocity against surface Standard clip without overbounce
Parameters
velocityTHREE.Vector3normalTHREE.Vector3jump#
jump(velocity : THREE.Vector3, onGround : boolean) : booleanHandle jump Higher jump for platformer gameplay
Parameters
velocityTHREE.Vector3onGroundbooleanReturns
boolean — - True if jump was executed