Data Schema Cheatsheet
Scalar data types
Section titled “Scalar data types”Schema | JavaScript | WGSL |
---|---|---|
| number | f32 |
| number | f16 |
| number | i32 |
| number | u32 |
| boolean | bool |
Vector and matrix types
Section titled “Vector and matrix types”Schema | Value constructors | WGSL equivalents |
---|---|---|
vec2u |
| vec2u, vec2<u32> |
vec2f |
| vec2f, vec2<f32> |
vec2i |
| vec2i, vec2<i32> |
vec2h |
| vec2h, vec2<f16> |
vec2b |
| vec2<bool> |
vec3u |
| vec3u, vec3<u32> |
vec3f |
| vec3f, vec3<f32> |
vec3i |
| vec3i, vec3<i32> |
vec3h |
| vec3h, vec3<f16> |
vec3b |
| vec3<bool> |
vec4u |
| vec4u, vec4<u32> |
vec4f |
| vec4f, vec4<f32> |
vec4i |
| vec4i, vec4<i32> |
vec4h |
| vec4h, vec4<f16> |
vec4b |
| vec4<bool> |
mat2x2f |
| mat2x2f, mat2x2<f32> |
mat3x3f |
| mat3x3f, mat3x3<f32> |
mat4x4f |
| mat4x4f, mat4x4<f32> |
Apart from the listed constructors, all vectors can be created from any mix of other vectors and numbers, like this:
import { vec2f, vec3f, vec4f } from 'typegpu/data';
const a = vec2f(1, 2); // 1, 2const b = vec3f(0, a); // 0, 1, 2const c = vec4f(b.xz, a.xx); // 0, 2, 1, 1