Types
Camera
interface Camera
From @phaser-ae/kernel
The camera RECORD. The kernel holds it and interpolates it; a world pack installs the transform (toWorld,
toScreen, project); a rig pack or the game moves it. The game writes the simulation fields in a step, and the
kernel rolls them each step and resolves render/render3d once a frame, so the camera moves as smoothly as the
objects do.
x: number— Camera x in world units; the point at the screen centre. A 2D world starts it at half the screen width, so world (0, 0) is the screen's top-left corner until the camera moves. 3D worlds: default 0.y: number— Camera y in world units; the point at the screen centre. A 2D world starts it at half the screen height, so world (0, 0) is the screen's top-left corner until the camera moves. 3D worlds: default 0.z: number— Camera z in world units; 3D worlds only. Default 0.zoom: number— Scale: 1 = one world unit per logical pixel; 2 = twice as large. Default 1.rot: number— Roll in radians. Default 0. Stored and reported byinspect; the bundled worlds do not draw with it.yaw: number— 3D worlds: look yaw in radians. 2D worlds ignore. Default 0.pitch: number— 3D worlds: look pitch in radians. 2D worlds ignore. Default 0.fov: number— 3D worlds: vertical field of view in radians. 2D worlds ignore. Default π/3.distance: number— 3D worlds: how far the eye sits BEHINDx y zalong the look direction. 0 makesx y zthe eye itself (first person, free fly); above 0 makes it the point the camera orbits (orbit, chase). 2D worlds ignore. Default 0.bounds: { x: number; y: number; w: number; h: number } | null— World bounds the camera should stay inside, or null. The kernel only stores it; a rig that honours it (rig-follow) clamps to it. A scene's change is undone when the scene exits.toWorld(screenX: number, screenY: number): { x: number; y: number }— Logical screen pixels → world units at the simulation camera (not the interpolated one). Identity until a world installs its transform. A 3D world answers where the screen point meets the ground plane y = 0, as{ x, y: z }.toScreen(worldX: number, worldY: number): { x: number; y: number }— World units → logical screen pixels at the simulation camera. Identity until a world installs its transform. In a 3D world it takeszas a third argument and puts a point behind the camera far off-screen.readonly render: { readonly x: number; readonly y: number; readonly zoom: number }— The 2D camera as DRAWN this frame: prev→curr at the clock's alpha.readonly render3d: { readonly x: number; readonly y: number; readonly z: number; readonly yaw: number; readonly pitch: number; readonly fov: number; readonly distance: number }— The 3D camera as DRAWN this frame: every pose component at the same prev→curr alpha as 3D objects.shakeX: number— Added to the RENDERED x only (afeelpack's shake): the sim never sees it, nothing drifts. World units; default 0.shakeY: number— Added to the RENDERED y only. World units; default 0.zoomPunch: number— Multiplied into the rendered zoom only (a zoom punch). Default 1.project(worldX: number, worldY: number): { x: number; y: number }— World point → logical screen pixels at the RENDERED camera, shake included: for passes that place things in screen space.snap(x: number, y: number, zoom?: number): void— Move the 2D camera without interpolating (a respawn, a level change, a cut), and set the zoom if given.readonly wrap: { readonly w: number; readonly h: number } | null— Set by a wrapping world; a rig measurestarget − camerathrough it.
