vec2
On this page

vec2

Function

Builds a vec2 from two scalars or broadcasts a single scalar to both components.

The signature and the sentence under each name are the compiler's own text at commit 26de7be8.

Syntax

declare function vec2<T = f32>(): VecFor2<T>
declare function vec2<T = f32>(x: number, y: number): VecFor2<T>
declare function vec2<T = f32>(scalar: number): VecFor2<T>
declare function vec2<T = f32>(v: vec2): VecFor2<T>
declare function vec2<T>(x: bool, y: bool): VecFor2<T>
declare function vec2<T>(scalar: bool): VecFor2<T>
declare function vec2<T = f32>(v: vec2i): VecFor2<T>
declare function vec2<T = f32>(v: vec2u): VecFor2<T>
declare function vec2<T = f32>(v: vec2b): VecFor2<T>
declare function vec2(v: vec2f64): vec2

A number in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.

type f32 = number & { readonly [f32Tag]?: true }

A declaration you write still needs a width, and a bare number on a field or a parameter is refused; the TypeScript constructs page carries that row with the compiler's own message.

A signature may name a type the ambient file declares for its own use. These are those declarations.

VecFor2
type VecFor2<T> = VecElemOf<T, vec2u, vec2i, vec2f64, vec2b, vec2>

Parameters

Return value

VecFor2<T>vec2

Examples

See also

Edit this page Report a problem