PlatformerModel

@three-blocks/proPresetPlatformerMovement
const PlatformerModel = { name: 'platformer', config: { gravity: 25, gravityRising: 18, gravityFalling: 45, maxSpeed: 8, groundAccel: 14, air...
Value
{ name: 'platformer', config: { gravity: 25, gravityRising: 18, gravityFalling: 45, maxSpeed: 8, groundAccel: 14, airAccel: 2, friction: 3.2, stopSpeed: 1, jumpVelocity: 14, groundAngleThreshold: 1.047, bhopFrictionMultiplier: 1.0, }, is...

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

Ground movement physics Responsive acceleration with slightly slippery friction for momentum

Parameters
velocityTHREE.Vector3
Current velocity (modified in place)
wishDirTHREE.Vector3
Input direction
wishSpeednumber
Input magnitude (0-1)
deltanumber
Time step
isJumpingboolean
Whether 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.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