Renderer · function

gizmoScaleFor

The world size that covers pixels screen pixels at the target's distance.

Explained in Hello world.

function gizmoScaleFor(camera: Camera, target: ArrayLike<number>, cssHeight: number, pixels: number): number
import { gizmoScaleFor } from '@driftengine/core';

Parameters

ParameterTypeDescription
cameraCamera
targetArrayLike<number>
cssHeightnumber
pixelsnumber

In depth

A separate function rather than a method, which is what keeps every intersection and every drag in this file testable against a bare ray: the gizmo never learns what a camera is. A caller assigns the result to size once a frame.

Perspective only, because Camera is. An orthographic camera's answer does not depend on distance at all, and the day one exists this grows a branch rather than a caller.