isVec
On this page

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

t ShaderType

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) // true
isVec(f32T) // false

See also

Source

src/core/ir/types.ts, line 1072, at commit 26de7be8

Edit this page Report a problem