isVec()
Function in Types
Narrows a ShaderType to the native { kind: 'vec' } arm, whose elem is 'f32' | 'i32' | 'u32'.
import { isVec } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
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, vec3fT, f32T } from 'typeshade'
isVec(vec3fT) // trueisVec(f32T) // falseSee also
Source
src/core/ir/types.ts, line 1072, at commit 26de7be8