isVec()
Function in Types
Narrows a ShaderType to the native { kind: 'vec' } arm, whose elem is 'f32' | 'i32' | 'u32'.
import { isVec } from 'typeshade'import { isVec } from 'typeshade/core/ir'
The signature, the description and the examples come from the compiler's own source at commit af54ddad5.
Syntax
const isVec: (t: ShaderType) => t is Extract<ShaderType, { kind: "vec"; }>Parameters
Return value
t is Extract<ShaderType, { kind: 'vec' }>
Description
The emulated-double vector is the separate 'vec64' kind; test for it with
isVec64. Binary-op type resolution uses it (isMat(a) && isVec(b), isVec(a) && isScalar(b)) to decide between a vector-scalar broadcast, a matrix-vector product and a
same-kind op, and the .x/.y/.r/.g swizzle guards use it to reject a non-vector
receiver.
Examples
Example
import { isVec } from 'typeshade'import { vec3fT, f32T } from 'typeshade/core/ir'
isVec(vec3fT) // trueisVec(f32T) // falseSee also
Source
src/core/ir/types/predicates.ts, line 21, at commit af54ddad5