FERRETGame engine over Babylon.js
Ferret

@ferret/game

createGame: wires platform, Babylon engine, scene, world, display, input and physics into a running game.

3 exports · source in packages/game/src

Functions

createGame function

function createGame(opts: GameOptions): Game

Wire the usual pieces for a game: platform (OS Beroun or browser), Babylon engine, scene, world, display (render scale, quality, FOV), input and physics. The game then adds its own services, levels and entities and calls start(). On OS Beroun the engine is made the way /lib/beroun-3d.js does it (the console's 640x480 at density 1, no antialiasing).

packages/game/src/index.ts:50

Interfaces

Game interface

interface Game
engine: BABYLON.AbstractEngine
scene: BABYLON.Scene
world: World
host: SceneHostthe scene host: second worlds on the shared engine (a game's interlude during a travel)
platform: FerretPlatform
display: Display
input: InputService
physics: PhysicsService
touch?: TouchControls
xr?: XrServicethe VR session service, once loaded: only when xr was set and the browser has WebXR (the package is fetched then, not before)
xrReady: Promise<XrService | undefined>resolves when the VR service is added (or at once when it is not wanted)
start(): voidRun the render loop (and with it the fixed-step simulation).
stop(): void
dispose(): void

packages/game/src/index.ts:24

GameOptions interface

interface GameOptions
canvas: HTMLCanvasElement
input: Omit<InputOptions, 'defaultKind'> & { defaultKind?: InputOptions['defaultKind'] }
platform?: FerretPlatform
storageKey?: stringkey for browser storage (one per game)
physicsLayers?: string[]
tier?: QualityTier
touchControls?: booleanTouch controls on phones and tablets (default true)
clearColor?: [number, number, number]
fov?: { baseVertical?: number; minHorizontal?: number }the camera's field of view: the vertical one (radians) at wide aspects, and the horizontal one it never falls below (a game that matches another engine's 90 degrees passes both)
xr?: XrOptionsVR through WebXR: { enabled: true } adds the xr service where the browser has WebXR; elsewhere (OS Beroun) nothing is added

packages/game/src/index.ts:7