PlatformerModel

@three-blocks/proPresetPlatformerMovement
const PlatformerModel = { name: 'platformer', targetTickRate: 600, config: { gravity: 35, gravityRising: 35, gravityFalling: 35, maxSpeed: 7,...
Value
{ name: 'platformer', targetTickRate: 600, config: { gravity: 35, gravityRising: 35, gravityFalling: 35, maxSpeed: 7, groundAccel: 30, airAccel: 8, friction: 10, stopSpeed: 1, jumpVelocity: 11, groundAngleThreshold: 1.047, }, isGround( s...

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) : boolean

Determine if surface is walkable ground Platformer characters can walk on steeper slopes than FPS characters

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 Snappy acceleration with high friction for instant 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 Fixed gravity with good air control for precision platforming

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 Higher jump for platformer gameplay

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