Skip to content

ThreeplayOpts

Defined in: packages/threeplay/src/core/types.ts:176

Options of threeplay(). Plugins extend this interface with their own options through declaration merging (there is no catch-all index signature, so a typo like widht is a type error):

declare module "threeplay" {
interface ThreeplayOpts { myPluginSpeed?: number }
}

optional antialias?: boolean

Defined in: packages/threeplay/src/plugins/render/types.ts:58

Antialiasing (default true).

RenderOpts.antialias


optional background?: ColorLike | null

Defined in: packages/threeplay/src/plugins/render/types.ts:52

Clear color (default a soft sky blue). null keeps the canvas transparent.

RenderOpts.background


optional buttons?: Record<string, ButtonBinding>

Defined in: packages/threeplay/src/plugins/input/types.ts:40

Virtual buttons: { jump: { keyboard: ["space", "w"], gamepad: "south" } }. Merged over the defaults, which exist even if you pass nothing: left (arrows, A), right (arrows, D), up (arrows, W), down (arrows, S) and jump (space), each with its d-pad / south gamepad button. Redefining a name replaces its default binding entirely.

InputOpts.buttons


optional canvas?: HTMLCanvasElement

Defined in: packages/threeplay/src/plugins/render/types.ts:48

Draw into this canvas instead of creating one.

RenderOpts.canvas


optional debug?: boolean

Defined in: packages/threeplay/src/plugins/debug/types.ts:12

Start with the inspector on.

DebugOpts.debug


optional debugKey?: string | false

Defined in: packages/threeplay/src/plugins/debug/types.ts:10

Key that toggles the inspector (default "f1"; false disables it). Needs the input plugin (an optional dependency: without it the key does nothing). The browser default of the key is prevented while the canvas has focus (F1 would open help on Windows).

DebugOpts.debugKey


optional fixedHz?: number

Defined in: packages/threeplay/src/core/types.ts:182

Fixed update rate in Hz, used by physics (default 50).


optional global?: boolean

Defined in: packages/threeplay/src/core/types.ts:178

Put the API on window like kaplay does (default true).


optional height?: number

Defined in: packages/threeplay/src/plugins/render/types.ts:44

RenderOpts.height


optional letterbox?: boolean

Defined in: packages/threeplay/src/plugins/render/types.ts:46

Keep the aspect ratio with bars when scaling (default true with width/height).

RenderOpts.letterbox


optional lighting?: "none" | "default"

Defined in: packages/threeplay/src/plugins/render/types.ts:62

"default" adds a hemisphere light and a sun with shadows; "none" adds nothing.

RenderOpts.lighting


optional loop?: "auto" | "manual"

Defined in: packages/threeplay/src/core/types.ts:184

"auto" drives the loop with requestAnimationFrame; "manual" waits for k.step(dt).


optional maxDt?: number

Defined in: packages/threeplay/src/core/types.ts:186

Largest frame delta in seconds; longer frames are clamped (default 0.1).


optional physics?: boolean | { gravity?: number | Vec3Like; }

Defined in: packages/threeplay/src/plugins/physics/types.ts:189

false disables physics (Rapier is not downloaded). Default true.

PhysicsOpts.physics


optional pixelRatio?: number

Defined in: packages/threeplay/src/plugins/render/types.ts:56

Device pixel ratio cap (default Math.min(devicePixelRatio, 2)).

RenderOpts.pixelRatio


optional plugins?: PluginLike[]

Defined in: packages/threeplay/src/core/types.ts:180

Extra plugins, installed after the built-in ones.


optional renderer?: "auto" | RendererKind

Defined in: packages/threeplay/src/plugins/render/types.ts:54

"auto" (WebGPU with WebGL2 fallback, default), "webgpu", "webgl" or "none" (headless).

RenderOpts.renderer


optional root?: HTMLElement

Defined in: packages/threeplay/src/plugins/render/types.ts:50

Element that receives the canvas and overlays (default document.body).

RenderOpts.root


optional shadows?: boolean

Defined in: packages/threeplay/src/plugins/render/types.ts:60

Shadow maps (default true).

RenderOpts.shadows


optional width?: number

Defined in: packages/threeplay/src/plugins/render/types.ts:43

Logical width. With width and height the game thinks in a fixed size (HUD coordinates, aspect) and the canvas is scaled to the container. Without them the canvas fills the container and the logical size follows it.

RenderOpts.width