CameraViewAPI
Defined in: camera/Camera.ts:21
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CameraViewAPI(
app_):CameraViewAPI
Defined in: camera/Camera.ts:24
Parameters
Section titled “Parameters”Returns
Section titled “Returns”CameraViewAPI
Methods
Section titled “Methods”clipSegment()
Section titled “clipSegment()”Defined in: camera/Camera.ts:88
The part of segment
Parameters
Section titled “Parameters”Returns
Section titled “Returns”a →
b that can be drawn, cut at the near plane.
Details
Section titled “Details”One end behind the eye still leaves a visible part, and dropping the whole segment is what makes a wireframe come apart as the eye moves into it. Null when none of it is in front.
getWorldBounds()
Section titled “getWorldBounds()”getWorldBounds(): {
bottom:number;left:number;right:number;top:number; } |null
Defined in: camera/Camera.ts:130
Returns
Section titled “Returns”{ bottom: number; left: number; right: number; top: number; } | null
getWorldMousePosition()
Section titled “getWorldMousePosition()”getWorldMousePosition(): {
x:number;y:number; } |null
Defined in: camera/Camera.ts:124
Returns
Section titled “Returns”{ x: number; y: number; } | null
projectDirectionAt()
Section titled “projectDirectionAt()”projectDirectionAt(
at,dir): {x:number;y:number; } |null
Defined in: camera/Camera.ts:114
Where a world DIRECTION points on screen at
Parameters
Section titled “Parameters”Returns
Section titled “Returns”{ x: number; y: number; } | null
at — px per world unit, y-up.
Details
Section titled “Details”Null when
at has no projection. Perspective makes this a fact about the POINT: an arm drawn on something asks here, where a basis read off the camera answers only for the centre of the view.
screenRay()
Section titled “screenRay()”screenRay(
screenX,screenY):WorldRay|null
Defined in: camera/Camera.ts:54
The world ray a screen point names — what screenToWorld intersects with
the z plane. Callers that drag along an arbitrary plane (an editor moving
along a world axis, a pick against the ground) need the ray itself: a
z-keyed answer cannot express a plane that is not z-keyed.
Parameters
Section titled “Parameters”screenX
Section titled “screenX”number
screenY
Section titled “screenY”number
Returns
Section titled “Returns”WorldRay | null
screenToWorld()
Section titled “screenToWorld()”screenToWorld(
screenX,screenY,planeZ?): {x:number;y:number; } |null
Defined in: camera/Camera.ts:40
Where a screen point lands on the world plane at
Parameters
Section titled “Parameters”screenX
Section titled “screenX”number
screenY
Section titled “screenY”number
planeZ?
Section titled “planeZ?”number = 0
Returns
Section titled “Returns”{ x: number; y: number; } | null
planeZ.
A screen point is a ray. Orthographically its x/y do not vary along it, so the plane is irrelevant and the default answers for everyone. Under a perspective camera it decides the answer, and the right plane is the one the thing being hit or dragged actually sits on — z = 0 would place a sprite at z = -400 wherever its shadow on the 2D plane happens to fall.
worldToScreen()
Section titled “worldToScreen()”worldToScreen(
worldX,worldY,worldZ?): {x:number;y:number; } |null
Defined in: camera/Camera.ts:73
Where the world point lands on screen — the inverse of screenToWorld,
taking the same third dimension. Under a perspective camera a point at
Parameters
Section titled “Parameters”worldX
Section titled “worldX”number
worldY
Section titled “worldY”number
worldZ?
Section titled “worldZ?”number = 0
Returns
Section titled “Returns”{ x: number; y: number; } | null
worldZ projects nowhere near its shadow on the 2D plane, so anything drawing an overlay ON an entity (an outline, a gizmo, a screen rect) has to pass the entity’s z or it draws where the entity is not.
Null means the point has NO screen position: no camera, or it stands at or behind the eye, where the divide mirrors it to the far side of the view. Outside the viewport is NOT that, and keeps its coordinates.