Skip to content

@vaguevoid/fiasco / math/coordinates / screenToWorld

Function: screenToWorld()

screenToWorld(screenPosition, screenDimensions, camera): Vec3

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

Convert the given screen-space screenPosition using the given camera and screenDimensions into a world-space position.

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

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

Parameters

screenPosition

Vec2

screenDimensions

Vec2

camera

Camera

Returns

Vec3