distance()
Function in Builtins
distance(a, b): |a − b|, vector to scalar; the built-in form of length(a.sub(b)).
import { distance } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
function distance<K extends `vec${number}<f64>`>( a: ReadonlyNode<K>, b: NoInfer<ReadonlyNode<K>>,): Node<'f64'>;function distance<K extends `vec${number}<f32>`>( a: ReadonlyNode<K>, b: NoInfer<ReadonlyNode<K>>,): Node<'f32'>;Parameters
aReadonlyNode<K>bNoInfer<ReadonlyNode<K>>
Return value
Node<'f64'>
Description
Returns f32 for f32 vectors and f64 for emulated-double vectors.
Targets
| Target | Support | Notes |
|---|---|---|
| WGSL (WebGPU) | Supported |
|
| GLSL ES 3.00 (WebGL2) | Supported |
|
| CPU oracle | Supported | Evaluated in f64 by the oracle. |
In the guide
Source
src/core/ir/node.ts, line 1853, at commit 26de7be8