Skip to content

@vaguevoid/fiasco / math/coordinates / worldToScreen

Function: worldToScreen()

worldToScreen(position, screenDimensions, camera): Vec2

Defined in: src/math/coordinates.ts:60

Convert the given world-space position into the screen space of the given camera at the given screenDimensions in pixels.

ts
import { Coords, Aspect, Camera, Query } from '@vaguevoid/fiasco'

function system(cameras: Query<[Camera]>, aspect: Aspect) {
  for (const [camera] of cameras) {
    const result = Coords.worldToScreen({ x: 0, y: 0, z: 0}, aspect.xy, camera)
  }
}

Parameters

position

Vec3

screenDimensions

Vec2

camera

Camera

Returns

Vec2