Skip to content

GpuVec3

1 min read

Import: import system.gpu;

This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation. Shader-only declarations can be used only inside shader entry points and helpers reached from them; using them elsewhere is a compile error.

GpuVec3

A vector of three floats, laid out like a GPU float3, for positions, directions, normals and RGB colors. Use it on the CPU and in shaders alike. Arithmetic works component by component, and a float operand applies to every component.

public struct GpuVec3

x

The first component.

public x: float

y

The second component.

public y: float

z

The third component.

public z: float

constructor

Creates the vector (x, y, z).

public constructor(x: float, y: float, z: float)

constructor

Creates a vector with every component equal to value.

public constructor(value: float)

xy

The first two components.

public get xy(): GpuVec2

dot

The dot product.

public fun dot(other: GpuVec3): float

cross

The cross product, perpendicular to both vectors, following the right-hand rule.

public fun cross(other: GpuVec3): GpuVec3

length

The vector's Euclidean length.

public fun length(): float

normalize

The vector scaled to length 1. A zero vector gives non-finite components.

public fun normalize(): GpuVec3