Global env context struct. This updates every frame and includes input data, time data, and more.

const env: FrameContext
const PI: float
module bezier
cubic2( a: float2,b: float2,c: float2,d: float2,t: float ) -> float2
cubic3( a: float3,b: float3,c: float3,d: float3,t: float ) -> float3
quadratic2( a: float2,b: float2,c: float2,t: float ) -> float2
quadratic3( a: float3,b: float3,c: float3,t: float ) -> float3

3d triangle patch evaulation with barycentric coordinates.

patch( a: float3,ab: float3,b: float3,bc: float3,c: float3,ca: float3,barycentricT: float3 ) -> int
easing( controlA: float2,controlB: float2,t: float ) -> float
clone( ) -> bezier
module color
clone( ) -> color
module matrix
lookAt( from: float3,to: float3,up: float3 ) -> float4x4
perspective( fov: float,aspect: float,near: float,far: float ) -> float4x4
perspectiveReverseZ( fov: float,aspect: float,near: float ) -> float4x4
clone( ) -> matrix
module mesh
rect( pos: float2,size: float2 ) -> Mesh
box( pos: float3,size: float3 ) -> Mesh
uvSphere( pos: float3,radius: float,vertices: int,rings: int ) -> Mesh
icoSphere( pos: float3,radius: float,subdivisions: int ) -> Mesh
plane( pos: float3,size: float2,subdivisions: int2 ) -> Mesh

Returns a [-1, 1] position for a given index.

triangleFromIndex( index: int ) -> float2
circleFromIndex( vertexIndex: int,vertices: int ) -> float2
rectFromIndex( index: int,vertices: int ) -> float2
empty( numVerts: int ) -> Mesh
join( mesh1: Mesh,mesh2: Mesh ) -> Mesh
clone( ) -> mesh
module noise
gaussian3( v: float3 ) -> float
gaussian2( v: float2 ) -> float
noise1( x: float ) -> float
noise2( x: float2 ) -> float
fmb1( x: float ) -> float
fbm2( x: float2 ) -> float
fbm3( x: float3 ) -> float
noise3( x: float3 ) -> float
simplex2( v: float2 ) -> float
perlin2( v: float2 ) -> float
perlin3( v: float3 ) -> float

Returns 3 values: distance to closest cell, random value of closest cell, distance to closest edge.

voronoi2( v: float2 ) -> float3
simplex3( v: float3 ) -> float
clone( ) -> noise
module physics
engine2d( ) -> PhysicsEngine2d
module PhysicsEngine3d
module quat

Creates a quaternion from an angle and axis.

fromAngleAxis( angle: float,axis: float3 ) -> float4

Rotates a vector by a quaternion and returns the rotated vector.

rotate( quaternion: float4,vector: float3 ) -> float3

Returns the conjugate of the input quaternion.

The conjugate of a quaternion number is a quaternion with the same magnitudes but with the sign of the imaginary parts changed

conjugate( quaternion: float4 ) -> float4

Returns the inverse of the input quaternion.

inverse( quaternion: float4 ) -> float4

Generates a quaternion that rotates from one direction to another via the shortest path.

fromToRotation( from: float3,to: float3 ) -> float4
diff( a: float4,b: float4 ) -> float4

Generates lookAt quaternion.

lookAt( forward: float3,up: float3 ) -> float4

Smooth interpolation between two quaternions.

slerp( a: float4,b: float4,t: float ) -> float4

Converts quaternion to matrix.

toMatrix( quaternion: float4 ) -> float4x4
fromEulerAngles( angles: float3 ) -> float4
clone( ) -> quat
module sdf
sphere( samplePosition: float3,sphereCenter: float3,radius: float ) -> float
box( samplePosition: float3,boxCenter: float3,boxSize: float3 ) -> float
roundBox( samplePosition: float3,boxCenter: float3,boxSize: float3,cornerRadius: float ) -> float
boxFrame( samplePosition: float3,boxCenter: float3,boxSize: float3,frameThickness: float ) -> float
torus( samplePosition: float3,torusCenter: float3,torusSize: float2 ) -> float
cappedTorus( samplePosition: float3,torusCenter: float3,torusSize: float2,ra: float,rb: float ) -> float
infinteCylinder( samplePosition: float3,cylinderCenter: float3,cylinderSize: float3 ) -> float
cone( samplePosition: float3,coneCenter: float3,c: float2,coneHeight: float ) -> float
plane( samplePosition: float3,planeCenter: float3,planeNormal: float3,planeHeight: float ) -> float
hexPrism( samplePosition: float3,hexCenter: float3,hexSize: float2 ) -> float
triPrism( samplePosition: float3,triCenter: float3,triSize: float2 ) -> float
capsuleLine( samplePosition: float3,lineStart: float3,lineEnd: float3,capsuleRadius: float ) -> float
capsule( samplePosition: float3,capsuleCenter: float3,height: float,radius: float ) -> float
cylinder( samplePosition: float3,cylinderCenter: float3,height: float,radius: float ) -> float
cylinderLine( samplePosition: float3,lineStart: float3,lineEnd: float3,radius: float ) -> float
roundedCylinder( samplePosition: float3,cylinderCenter: float,cylinderRadius: float,cornerRadius: float,height: float ) -> float
cappedCone( samplePosition: float3,coneCenter: float3,height: float,r1: float,r2: float ) -> float
solidAngle( samplePosition: float3,solidCenter: float3,size: float2,radius: float ) -> float
cutSphere( samplePosition: float3,sphereCenter: float3,radius: float,height: float ) -> float
cutHollowSphere( samplePosition: float3,sphereCenter: float3,radius: float,height: float,thickness: float ) -> float
roundCone( samplePosition: float3,coneCenter: float3,coneRadius: float,cornerRadius: float,height: float ) -> float
ellipsoid( samplePosition: float3,center: float3,radius: float3 ) -> float
rhombus( samplePosition: float3,rhombusCenter: float3,la: float,lb: float,height: float,ra: float ) -> float
octahedron( samplePosition: float3,center: float3,size: float ) -> float
pyramid( samplePosition: float3,pyramidCenter: float3,height: float ) -> float
udTriangle( samplePosition: float3,a: float3,b: float3,c: float3 ) -> float
udQuad( samplePosition: float3,a: float3,b: float3,c: float3,d: float3 ) -> float

Returns the intersection of two SDFs = max(a, b)

intersect( a: float,b: float ) -> float

Returns the union of two SDFs = min(a, b)

union( a: float,b: float ) -> float
subtract( a: float,b: float ) -> float
smoothIntersect( a: float,b: float,k: float ) -> float

Smoothly joins two SDFs using blending distance k

smoothUnion( a: float,b: float,k: float ) -> float
smoothSubtract( a: float,b: float,k: float ) -> float

Blends between two SDFs using interpolation

blend( a: float,b: float,t: float ) -> float
round( a: float,r: float ) -> float

Carve out the interior of an SDF

onion( a: float,thickness: float ) -> float
grad( p: float3,sampler: (pos: float3) => float ) -> float3

Poorly returns the closest point on the surface of an SDF This is an inaccurate method

closest( position: float3,sampler: (pos: float3) => float ) -> float3
normal( position: float3,sampler: (pos: float3) => float ) -> float3
vizRings( d: float ) -> float4
march( position: float3,direction: float3,sampler: (pos: float3) => float ) -> float

See: https://iquilezles.org/articles/distfunctions/ Infinitely repeats an SDF with space in between. This returns an updated position

Example:

sdf::sphere(sdf::repeat(p, 100.xyz), 0.xyz, 50.0);
repeat( position: float3,space: float3 ) -> float3

See: https://iquilezles.org/articles/distfunctions/ Repeats an SDF with space in between upto the limit. This returns an updated position

Example:

sdf::sphere(sdf::repeatLimited(p, 100, 10.xyz), 0.xyz, 50.0);
repeatLimited( position: float3,space: float,limit: float3 ) -> float3
clone( ) -> sdf

Provides space related utilities like z-order curves and quadtrees.

module spatial
cantorPair( v: int2 ) -> int
cantorUnpair( v: int ) -> int2
hilbertRotate( n: int,b: int2,r: int2 ) -> int2
hilbertUncurve( n: int,v: int2 ) -> int
hilbertCurve( n: int,v: int ) -> int2
mortonDecode( p: uint ) -> uint2
mortonEncode( p: uint2 ) -> uint
clone( ) -> spatial
module time

Saves the current time with a key of name

start( name: string | undefined ) -> void

Returns the difference in milliseconds between a start with the same key

stop( name: string | undefined ) -> float

This returns a decimal resolution time in milliseconds since the page started. Useful for measuring time differences

This uses performance.now() under the hood: The performance.now() method returns a high resolution timestamp in milliseconds. It represents the time elapsed since Performance.timeOrigin

now( ) -> float
module ui
puck( position: float2 ) -> float2
draggable( position: float2,radius: float ) -> float2
textbox( value: string ) -> string
slider( value: float,min: float,max: float ) -> float
label( text: string ) -> void
checkbox( value: bool ) -> bool
combo( value: string,options: string[] ) -> string
group( text: string ) -> void
button( text: string ) -> bool
pop( ) -> void
struct atomic
Properties
__type: T
__value: number
$mutate: ((to: value) => void) | undefined
Methods
load( ) -> T
store( value: T ) -> void
max( value: T ) -> T
min( value: T ) -> T
xor( value: T ) -> T
exchange( value: T ) -> T
compareExchangeWeak( compare: T,value: T ) -> { old_value: T; exchanged: boolean; }
struct buffer
Properties
__opaque_buffer: true = true
structArray: T[] | null = null
floatArray: Float32Array | null = null
intArray: Int32Array | null = null
uintArray: Uint32Array | null = null
arrayBuffer: ArrayBuffer | null = null
vectorSize: int = 0
typeName: string
platformPayload: any = null
adapter: any = null
dirty: boolean = false
pendingWrites: number = 0
cpuReadDirty: boolean = false
cpuWriteDirty: boolean = false
elementCount: int = 0
elementBytes: int = 0
structured: boolean = false
fastIndex: (index: int) => T
fastIndexAssign: (index: int, value: T) => void
watchMutation: boolean = false
symbol: Symbol = Symbol()
Methods
destroy( ) -> void
__index( index: int | uint ) -> T
__index_assign( index: int | uint,value: T ) -> void
__index_assign_op( op_fn: (a: T, b: T) => T,index: int | uint,value: T ) -> void
len( ) -> int

Returns the underlying cpu buffer as a typed array.

[!NOTE] This is considerably faster than using the raw index [] operator.

[!NOTE] If the buffer contents are structured (atomic, or a struct), this will return a normal array

let buf = buffer<uint>();
let data = buf.getData();

for (let i = 0; i < data.length; i += 4) {
    // Do something with data[i]
}
getData( ) -> T[] | Float32Array | Int32Array | Uint32Array | Uint8Array
write( other: buffer_internal<T> ) -> void
download( ) -> Promise<void>
downloadAsync( ) -> Promise<void>
upload( ) -> void
struct Camera
Properties
position: float3
rotation: float4
width: float
height: float
fov: float
near: float
far: float
Methods
getRay( screen: float2 ) -> float3
getTransformToViewMatrix( position: float3,scale: float3,rotation: float4 ) -> float4x4
getCombinedMatrix( ) -> float4x4
getCombinedMatrixReverseZ( ) -> float4x4
getWorldToViewMatrix( ) -> float4x4
getPerspectiveMatrixReverseZ( ) -> float4x4
getPerspectiveMatrix( ) -> float4x4
getOrthographicMatrix( ) -> float4x4
clone( ) -> Camera
struct Camera2d
Properties
position: float2
zoom: float
Methods
transform( position: float2 ) -> float2

Moves and zooms the camera to fit the given size. (centers the camera in the viewport)

fit( size: float2 ) -> void
clone( ) -> Camera2d
struct FrameContext
Properties

Delta between the previous frame's time and this frame (in seconds

deltaTime: float

Current time in seconds from the start of the renderer

time: float

Canvas size in pixels

screenSize: float2

Current frame index

frame: int

Mouse/touch screen input state for this frame

mouse: MouseInputState = new MouseInputState()

Keyboard input state for this frame

keyboard: KeyboardInputState = new KeyboardInputState()

Controllable camera (Hold right click and use WASD to move)

camera: Camera = new Camera()
camera2d: Camera2d = new Camera2d()
Methods
configureCamera( options: { mode?: "free" | "orbit" | "orbit-free" | undefined; spinning?: boolean | undefined; initialPosition?: float3 | undefined; initialPitch?: float | undefined; initialYaw?: float | undefined; ... 8 more ...; orbitMaxPitch?: float | undefined; } ) -> void

Use external values from the host JavaScript environment.

input < T > ( key: string,defaultValue: T ) -> T

Send values to the host JavaScript environment.

output < T > ( key: string,value: T ) -> void
struct GeoPoly
Properties
segments: GeoSegment[]
Methods
area( ) -> float
perimeter( ) -> float
discretize( ) -> GeoPoly
clone( ) -> GeoPoly
struct GeoSegment
Properties
start: float2
end: float2
kind: int
arcRadius: float
arcStart: float
arcEnd: float
Methods
clone( ) -> GeoSegment
struct KeyboardInputState
Properties

Is key down this frame

backspace: boolean

Is key down this frame

tab: boolean

Is key down this frame

enter: boolean

Is key down this frame

shiftLeft: boolean

Is key down this frame

shiftRight: boolean

Is key down this frame

controlLeft: boolean

Is key down this frame

controlRight: boolean

Is key down this frame

altLeft: boolean

Is key down this frame

altRight: boolean

Is key down this frame

pause: boolean

Is key down this frame

capsLock: boolean

Is key down this frame

escape: boolean

Is key down this frame

space: boolean

Is key down this frame

pageUp: boolean

Is key down this frame

pageDown: boolean

Is key down this frame

end: boolean

Is key down this frame

home: boolean

Is key down this frame

arrowLeft: boolean

Is key down this frame

arrowUp: boolean

Is key down this frame

arrowRight: boolean

Is key down this frame

arrowDown: boolean

Is key down this frame

printScreen: boolean

Is key down this frame

insert: boolean

Is key down this frame

delete: boolean

Is key down this frame

digit0: boolean

Is key down this frame

digit1: boolean

Is key down this frame

digit2: boolean

Is key down this frame

digit3: boolean

Is key down this frame

digit4: boolean

Is key down this frame

digit5: boolean

Is key down this frame

digit6: boolean

Is key down this frame

digit7: boolean

Is key down this frame

digit8: boolean

Is key down this frame

digit9: boolean

Is key down this frame

keyA: boolean

Is key down this frame

keyB: boolean

Is key down this frame

keyC: boolean

Is key down this frame

keyD: boolean

Is key down this frame

keyE: boolean

Is key down this frame

keyF: boolean

Is key down this frame

keyG: boolean

Is key down this frame

keyH: boolean

Is key down this frame

keyI: boolean

Is key down this frame

keyJ: boolean

Is key down this frame

keyK: boolean

Is key down this frame

keyL: boolean

Is key down this frame

keyM: boolean

Is key down this frame

keyN: boolean

Is key down this frame

keyO: boolean

Is key down this frame

keyP: boolean

Is key down this frame

keyQ: boolean

Is key down this frame

keyR: boolean

Is key down this frame

keyS: boolean

Is key down this frame

keyT: boolean

Is key down this frame

keyU: boolean

Is key down this frame

keyV: boolean

Is key down this frame

keyW: boolean

Is key down this frame

keyX: boolean

Is key down this frame

keyY: boolean

Is key down this frame

keyZ: boolean

Is key down this frame

metaLeft: boolean

Is key down this frame

metaRight: boolean

Is key down this frame

contextMenu: boolean

Is key down this frame

numpad0: boolean

Is key down this frame

numpad1: boolean

Is key down this frame

numpad2: boolean

Is key down this frame

numpad3: boolean

Is key down this frame

numpad4: boolean

Is key down this frame

numpad5: boolean

Is key down this frame

numpad6: boolean

Is key down this frame

numpad7: boolean

Is key down this frame

numpad8: boolean

Is key down this frame

numpad9: boolean

Is key down this frame

numpadMultiply: boolean

Is key down this frame

numpadAdd: boolean

Is key down this frame

numpadSubtract: boolean

Is key down this frame

numpadDecimal: boolean

Is key down this frame

numpadDivide: boolean

Is key down this frame

f1: boolean

Is key down this frame

f2: boolean

Is key down this frame

f3: boolean

Is key down this frame

f4: boolean

Is key down this frame

f5: boolean

Is key down this frame

f6: boolean

Is key down this frame

f7: boolean

Is key down this frame

f8: boolean

Is key down this frame

f9: boolean

Is key down this frame

f10: boolean

Is key down this frame

f11: boolean

Is key down this frame

f12: boolean

Is key down this frame

numLock: boolean

Is key down this frame

scrollLock: boolean

Is key down this frame

semicolon: boolean

Is key down this frame

equal: boolean

Is key down this frame

comma: boolean

Is key down this frame

minus: boolean

Is key down this frame

period: boolean

Is key down this frame

slash: boolean

Is key down this frame

backquote: boolean

Is key down this frame

bracketLeft: boolean

Is key down this frame

backslash: boolean

Is key down this frame

bracketRight: boolean

Is key down this frame

quote: boolean

Key pressed, triggered once until released

pressedBackspace: boolean

Key pressed, triggered once until released

pressedTab: boolean

Key pressed, triggered once until released

pressedEnter: boolean

Key pressed, triggered once until released

pressedShiftLeft: boolean

Key pressed, triggered once until released

pressedShiftRight: boolean

Key pressed, triggered once until released

pressedControlLeft: boolean

Key pressed, triggered once until released

pressedControlRight: boolean

Key pressed, triggered once until released

pressedAltLeft: boolean

Key pressed, triggered once until released

pressedAltRight: boolean

Key pressed, triggered once until released

pressedPause: boolean

Key pressed, triggered once until released

pressedCapsLock: boolean

Key pressed, triggered once until released

pressedEscape: boolean

Key pressed, triggered once until released

pressedSpace: boolean

Key pressed, triggered once until released

pressedPageUp: boolean

Key pressed, triggered once until released

pressedPageDown: boolean

Key pressed, triggered once until released

pressedEnd: boolean

Key pressed, triggered once until released

pressedHome: boolean

Key pressed, triggered once until released

pressedArrowLeft: boolean

Key pressed, triggered once until released

pressedArrowUp: boolean

Key pressed, triggered once until released

pressedArrowRight: boolean

Key pressed, triggered once until released

pressedArrowDown: boolean

Key pressed, triggered once until released

pressedPrintScreen: boolean

Key pressed, triggered once until released

pressedInsert: boolean

Key pressed, triggered once until released

pressedDelete: boolean

Key pressed, triggered once until released

pressedDigit0: boolean

Key pressed, triggered once until released

pressedDigit1: boolean

Key pressed, triggered once until released

pressedDigit2: boolean

Key pressed, triggered once until released

pressedDigit3: boolean

Key pressed, triggered once until released

pressedDigit4: boolean

Key pressed, triggered once until released

pressedDigit5: boolean

Key pressed, triggered once until released

pressedDigit6: boolean

Key pressed, triggered once until released

pressedDigit7: boolean

Key pressed, triggered once until released

pressedDigit8: boolean

Key pressed, triggered once until released

pressedDigit9: boolean

Key pressed, triggered once until released

pressedKeyA: boolean

Key pressed, triggered once until released

pressedKeyB: boolean

Key pressed, triggered once until released

pressedKeyC: boolean

Key pressed, triggered once until released

pressedKeyD: boolean

Key pressed, triggered once until released

pressedKeyE: boolean

Key pressed, triggered once until released

pressedKeyF: boolean

Key pressed, triggered once until released

pressedKeyG: boolean

Key pressed, triggered once until released

pressedKeyH: boolean

Key pressed, triggered once until released

pressedKeyI: boolean

Key pressed, triggered once until released

pressedKeyJ: boolean

Key pressed, triggered once until released

pressedKeyK: boolean

Key pressed, triggered once until released

pressedKeyL: boolean

Key pressed, triggered once until released

pressedKeyM: boolean

Key pressed, triggered once until released

pressedKeyN: boolean

Key pressed, triggered once until released

pressedKeyO: boolean

Key pressed, triggered once until released

pressedKeyP: boolean

Key pressed, triggered once until released

pressedKeyQ: boolean

Key pressed, triggered once until released

pressedKeyR: boolean

Key pressed, triggered once until released

pressedKeyS: boolean

Key pressed, triggered once until released

pressedKeyT: boolean

Key pressed, triggered once until released

pressedKeyU: boolean

Key pressed, triggered once until released

pressedKeyV: boolean

Key pressed, triggered once until released

pressedKeyW: boolean

Key pressed, triggered once until released

pressedKeyX: boolean

Key pressed, triggered once until released

pressedKeyY: boolean

Key pressed, triggered once until released

pressedKeyZ: boolean

Key pressed, triggered once until released

pressedMetaLeft: boolean

Key pressed, triggered once until released

pressedMetaRight: boolean

Key pressed, triggered once until released

pressedContextMenu: boolean

Key pressed, triggered once until released

pressedNumpad0: boolean

Key pressed, triggered once until released

pressedNumpad1: boolean

Key pressed, triggered once until released

pressedNumpad2: boolean

Key pressed, triggered once until released

pressedNumpad3: boolean

Key pressed, triggered once until released

pressedNumpad4: boolean

Key pressed, triggered once until released

pressedNumpad5: boolean

Key pressed, triggered once until released

pressedNumpad6: boolean

Key pressed, triggered once until released

pressedNumpad7: boolean

Key pressed, triggered once until released

pressedNumpad8: boolean

Key pressed, triggered once until released

pressedNumpad9: boolean

Key pressed, triggered once until released

pressedNumpadMultiply: boolean

Key pressed, triggered once until released

pressedNumpadAdd: boolean

Key pressed, triggered once until released

pressedNumpadSubtract: boolean

Key pressed, triggered once until released

pressedNumpadDecimal: boolean

Key pressed, triggered once until released

pressedNumpadDivide: boolean

Key pressed, triggered once until released

pressedF1: boolean

Key pressed, triggered once until released

pressedF2: boolean

Key pressed, triggered once until released

pressedF3: boolean

Key pressed, triggered once until released

pressedF4: boolean

Key pressed, triggered once until released

pressedF5: boolean

Key pressed, triggered once until released

pressedF6: boolean

Key pressed, triggered once until released

pressedF7: boolean

Key pressed, triggered once until released

pressedF8: boolean

Key pressed, triggered once until released

pressedF9: boolean

Key pressed, triggered once until released

pressedF10: boolean

Key pressed, triggered once until released

pressedF11: boolean

Key pressed, triggered once until released

pressedF12: boolean

Key pressed, triggered once until released

pressedNumLock: boolean

Key pressed, triggered once until released

pressedScrollLock: boolean

Key pressed, triggered once until released

pressedSemicolon: boolean

Key pressed, triggered once until released

pressedEqual: boolean

Key pressed, triggered once until released

pressedComma: boolean

Key pressed, triggered once until released

pressedMinus: boolean

Key pressed, triggered once until released

pressedPeriod: boolean

Key pressed, triggered once until released

pressedSlash: boolean

Key pressed, triggered once until released

pressedBackquote: boolean

Key pressed, triggered once until released

pressedBracketLeft: boolean

Key pressed, triggered once until released

pressedBackslash: boolean

Key pressed, triggered once until released

pressedBracketRight: boolean

Key pressed, triggered once until released

pressedQuote: boolean

2D vector that encodes the arrow keys and WASD aligned with the screen (e.g. up arrow = (0, -1))

arrowVector: float2
Methods
struct map
Properties
pairs: Map<string, [K, V]> = new Map<string, [K, V]>()
Methods
__index( key: K ) -> V
__index_assign( key: K,value: V ) -> void
__index_assign_op( op_fn: (a: V, b: V) => V,key: K,value: V ) -> void
delete( key: K ) -> void
has( key: K ) -> boolean
keys( ) -> K[]
values( ) -> V[]
new < K ,V > ( entries: [K, V][] | undefined ) -> map<K, V>
struct Material
Properties
baseColor: float4
color: texture2d<float4>
normal: texture2d<float4>
normalScale: float2
roughness: texture2d<float4>
emissive: texture2d<float4>
metallic: texture2d<float4>
Methods
clone( ) -> Material
struct Mesh
Properties
vertices: float3[] = []
triangles: int[] = []
normals: float3[] = []
tangents: float3[] = []
bitangents: float3[] = []
uvs: float2[] = []
colors: float4[] = []
symbol: Symbol
Methods
getVertices( ) -> float3[]
getTriangles( ) -> int[]
getNormals( ) -> float3[]
getTangents( ) -> float3[]
getBitangents( ) -> float3[]
getUVs( ) -> float2[]
getColors( ) -> float4[]
struct Model
Properties
parts: ModelPart[]
Methods
clone( ) -> Model
struct ModelPart
Properties
mesh: Mesh
material: Material
transform: float4x4
Methods
clone( ) -> ModelPart
struct MouseInputState
Properties

Current mouse position relative to canvas in pixels ((0, 0) is the top left

screen: float2

Current mouse position mapped from 0-1 in canvas space ((0, 0) is the top left while (1, 1) is the bottom right

uv: float2

Caches the mouse position relative to canvas in pixels when any mouse button is pressed (resets after subsequent presses

startScreen: float2

Caches the mouse position mapped from 0-1 in canvas space when any mouse button is pressed (resets after subsequent presses

startUv: float2

If dragging, this will be the delta between the start and current mouse position

deltaUv: float2

If dragging, this will be the delta between the mouse position last frame and the current mouse position

frameDeltaUv: float2

If dragging, this will be the delta between the start and current mouse position

deltaScreen: float2

If dragging, this will be the delta between the mouse position last frame and the current mouse position

frameDeltaScreen: float2

, Some("Mouse button down state for buttons 0-3 (left, middle, right

button: [boolean, boolean, boolean] = [false, false, false]

Mouse button pressed state for buttons 0-3 (left, middle, right)

clicked: [boolean, boolean, boolean] = [false, false, false]

If currently dragging

dragging: boolean

Accumulated mouse wheel movement for this frame in the range of -1 to 1

wheel: float

Rate of change

velocity: float

Is the mouse focused within the screen

focused: boolean
Methods
struct PaintingContext
Properties
markDirtyCallback: () => void = () => {}
__ctx: any = null
__gl: GraphicsAdapter | null = null
__offscreen_canvas: any = null
__program: any = null
stagedChanges: boolean = false
dirty: boolean = false
fastPoints: boolean = false
fastPointsBuffer: any = null
__currentColor: number[] | null = null
pointsCounter: number = 0
cacheSize: [number, number] = [0, 0]
Methods
flush( ) -> void
__beforeDraw( ) -> void
__afterDraw( ) -> void
__setColor( color: any ) -> void
fillRect( pos: float2,size: float2,color: any ) -> void
fillCircle( pos: float2,radius: number,color: any ) -> void
fillArc( pos: float2,radius: number,startAngle: number,endAngle: number,color: any ) -> void
line( pos1: float2,pos2: float2,color: any,width: number ) -> void
circle( pos: float2,radius: number,color: any,width: number ) -> void
arc( pos: float2,radius: number,startAngle: number,endAngle: number,color: any,width: number ) -> void
text( pos: float2,text: string,color: any ) -> void
startPath( pos: float2 ) -> void
lineTo( pos: float2 ) -> void
strokePath( color: any,width: number ) -> void
fillPath( color: any ) -> void
setStrokeWidth( width: number ) -> void
setFont( font: string ) -> void
setFontSize( size: number ) -> void
setTextAlign( align: CanvasTextAlign ) -> void
setTextBaseline( baseline: CanvasTextBaseline ) -> void
setLineCap( cap: "butt" | "round" | "square" ) -> void
setLineJoin( join: CanvasLineJoin ) -> void
setMiterLimit( limit: number ) -> void
setShadowColor( color: float4 ) -> void
setShadowBlur( blur: number ) -> void
setShadowOffset( offset: float2 ) -> void
setGlobalAlpha( alpha: number ) -> void
setGlobalCompositeOperation( op: string ) -> void
setImageSmoothingEnabled( enabled: boolean ) -> void
setImageSmoothingQuality( quality: ImageSmoothingQuality ) -> void
setLineDash( dash: number[] ) -> void
setLineDashOffset( offset: number ) -> void
setTransform( a: number,b: number,c: number,d: number,e: number,f: number ) -> void
resetTransform( ) -> void
scale( v: float2 ) -> void
rotate( angle: number ) -> void
translate( v: float2 ) -> void
flushPoints( ) -> void
point( pos: float2,color: any ) -> void
vector( pos: float2,dir: float2,color: float4,width: number ) -> void
grid( center: float2,count: float2,gap: float2,color: float4,width: number ) -> void
struct PhysicsCollider2d
Properties
rapier: any
world: RAPIER2DNamespace.World
collider: RAPIER2DNamespace.Collider
Methods
setTranslation( position: float2 ) -> void
setRotation( rotation: float ) -> void
setSensor( isSensor: boolean ) -> void
setCollisionGroups( groups: int ) -> void
setCollidesWith( groups: int ) -> void
setFriction( friction: float ) -> void
setRestitution( restitution: float ) -> void
setDensity( density: float ) -> void
setMass( mass: float ) -> void
setRadius( radius: float ) -> void
setHalfExtents( halfExtents: float2 ) -> void
struct PhysicsEngine2d
Properties
rapier: any
world: RAPIER2DNamespace.World
Methods
step( ) -> void
createRigidBody( position: float2,rotation: float,mode: "dynamic" | "fixed" ) -> PhysicsRigidBody2d
bodies( ) -> PhysicsRigidBody2d[]
castRay( start: float2,end: float2,maxi: int ) -> PhysicsRigidBody2d | null
setGravity( gravity: float2 ) -> void
struct PhysicsRayCastResult2d
Properties
rapier: any
result: RAPIER2DNamespace.RayIntersection
Methods
struct PhysicsRigidBody2d
Properties
rapier: any
world: RAPIER2DNamespace.World
body: RAPIER2DNamespace.RigidBody
Methods
addBallCollider( radius: float ) -> PhysicsCollider2d
addBoxCollider( halfExtents: float2 ) -> PhysicsCollider2d
addCapsuleCollider( radius: float,halfHeight: float ) -> PhysicsCollider2d
addTriangleCollider( a: float2,b: float2,c: float2 ) -> PhysicsCollider2d
addConvexCollider( points: float2[] ) -> PhysicsCollider2d
addHeightfieldCollider( heights: float[],scale: float2 ) -> PhysicsCollider2d
setTranslation( position: float2 ) -> void
setRotation( rotation: float ) -> void
setVelocity( velocity: float2 ) -> void
setAngularVelocity( velocity: float ) -> void
addForce( force: float2 ) -> void
addForceAtPoint( force: float2,point: float2 ) -> void
addTorque( torque: float ) -> void
setAdditionalMass( mass: float ) -> void
setEnabled( enabled: boolean ) -> void
sleep( ) -> void
wakeUp( ) -> void
setGravityScale( scale: float ) -> void
setLinearDamping( damping: float ) -> void
setAngularDamping( damping: float ) -> void
isSleeping( ) -> boolean
mass( ) -> float
translation( ) -> float2
rotation( ) -> float
velocity( ) -> float2
angularVelocity( ) -> float
isMoving( ) -> boolean
collider( index: int ) -> PhysicsCollider2d
applyImpulse( impulse: float2 ) -> void
applyTorqueImpulse( impulse: float ) -> void
struct ShaderInput
Properties

Interpolated world position (available in fragment, and vertex)

position: float3 = float3(0, 0, 0)

Interpolated normal (fragment), Source mesh normal (vertex)

normal: float3 = float3(0, 0, 0)

Interpolated tangent (fragment), Source mesh tangent (vertex)

tangent: float3 = float3(0, 0, 0)

Interpolated bitangent (fragment), Source mesh bitangent (vertex)

bitangent: float3 = float3(0, 0, 0)

Vertex shader output position

clipPosition: float4 = float4(0, 0, 0, 0)
realPosition: float4 = float4(0, 0, 0, 0)

UV channel 0 input (available in fragment, and vertex)

uv: float2 = float2(0, 0)

Screen position in pixels (available in fragment, and vertex)

screen: float2 = float2(0, 0)

Interpolated vertex color (available in fragment, and vertex)

color: float4 = float4(0, 0, 0, 0)

Group ID (available in compute)

groupId: int3 = int3(0, 0, 0)

Group size (available in compute)

groupSize: int3 = int3(0, 0, 0)

Global id (groupId * groupSize + localId) (available in compute)

globalId: int3 = int3(0, 0, 0)

Local id (available in compute)

localId: int3 = int3(0, 0, 0)

Instance index (available in fragment, and vertex)

instanceIndex: int = 0

Vertex index (available in vertex)

vertexIndex: int = 0
Methods
attr < T > ( index: int,interpolation: "flat" | "linear" | "perspective" | undefined ) -> T
struct ShaderOutput
Properties

Vertex output position

position: float4 = float4(0, 0, 0, 0)

Vertex output normal

normal: float3 = float3(0, 0, 0)

Vertex output tangent

tangent: float3 = float3(0, 0, 0)

Vertex output bitangent

bitangent: float3 = float3(0, 0, 0)

UV channel 0 output

uv: float2 = float2(0, 0)

Pixel color output

color: float4 = float4(0, 0, 0, 0)
Methods
attr < T > ( index: int,value: T,interpolation: "flat" | "linear" | "perspective" | undefined ) -> void
struct texture2d
Properties
__opaque_texture2d: true = true
size: float2 = [0, 0]
paint: PaintingContext = null as any
draw: { (geometry: Mesh, vertexShader: shader<ShaderInput, ShaderOutput, 0>, pixelShader: shader<ShaderInput, ShaderOutput, 0>): void; (fullScreenPixelShader: shader<...>): void; }
drawIndexed: (indexBuffer: buffer<uint>, vertexShader: shader<ShaderInput, ShaderOutput, 0>, pixelShader: shader<ShaderInput, ShaderOutput, 0>) => void
drawAdvanced: { <A0, A1, A2, A3, A4, A5, A6, A7>(descriptor: DrawDescriptorBase & AttachmentBindings8<A0, A1, A2, A3, A4, A5, A6, A7>): void; <A0, A1, A2, A3, A4, A5, A6>(descriptor: DrawDescriptorBase & AttachmentBindings7<...>): void; <A0, A1, A2, A3, A4, A5>(descriptor: DrawDescriptorBase & AttachmentBindings6<...>): void; <A0...
drawInstanced: (mesh: Mesh, instanceCount: int, vertexShader: shader<ShaderInput, ShaderOutput, 0>, pixelShader: shader<ShaderInput, ShaderOutput, 0>) => void
Methods
__index( index: int2 | uint2 ) -> T
__index_assign( index: int2 | uint2,value: T ) -> void
getFast( index: int2 | uint2 ) -> T
setFast( index: int2 | uint2,value: T ) -> void
download( ) -> void
downloadAsync( ) -> Promise<void>

Returns the underlying cpu buffer as a typed array.

Note that this is considerably faster than using the raw index [] operator.

let tex = texture2d<float4>();
let data = tex.getData();

for (let i = 0; i < data.length; i += 4) {
    let r = data[i];
    let g = data[i + 1];
    let b = data[i + 2];
    let a = data[i + 3];

    // Do something with the pixel
}
getData( ) -> Float32Array | Int32Array | Uint32Array | Uint8Array
upload( ) -> void
sample( position: float2 ) -> float4
clear( color: float4 | float | "auto" ) -> void
flush( ) -> void

Release the texture

destroy( ) -> void
struct texture3d
Properties
__opaque_texture3d: true = true
size: float3 = [0, 0, 0]
Methods
__index( index: int3 ) -> T
__index_assign( index: int3,value: T ) -> void
sample( position: float3 ) -> float4
__deepClone( value: any ) -> any
__makeMap < V > ( initial: { [key: number]: V; } ) -> map<number, V>
__makeMap < V > ( initial: { [key: string]: V; } ) -> map<string, V>
_smoothstep( a: any,b: any,x: any ) -> number
abs( a: vec | scalar ) -> vec | scalar
acos( a: vec | scalar ) -> vec | scalar
acosh( a: vec | scalar ) -> vec | scalar
array < T > ( count: number,initializer: any ) -> array<T>
asin( a: vec | scalar ) -> vec | scalar
asinh( a: vec | scalar ) -> vec | scalar
atan( a: vec | scalar ) -> vec | scalar
atan2( dy: float,dx: float ) -> float
atanh( a: vec | scalar ) -> vec | scalar
atomic < T > ( value: T ) -> atomic<T>
bilerp( a: float,b: float,c: float,d: float,u: float,v: float ) -> float
bilerp( a: float2,b: float2,c: float2,d: float2,u: float,v: float ) -> float2
bilerp( a: float3,b: float3,c: float3,d: float3,u: float,v: float ) -> float3
bilerp( a: float4,b: float4,c: float4,d: float4,u: float,v: float ) -> float4
bilerp( a: float2x2,b: float2x2,c: float2x2,d: float2x2,u: float,v: float ) -> float2x2
bilerp( a: float3x3,b: float3x3,c: float3x3,d: float3x3,u: float,v: float ) -> float3x3
bilerp( a: float4x4,b: float4x4,c: float4x4,d: float4x4,u: float,v: float ) -> float4x4
binarySubdivide( aX: float,aA: float,aB: float ) -> float

Creates a new buffer.

let buf = buffer<float>(100);
buffer < T > ( data: T[],typeName: string,structure: object | undefined ) -> buffer<T>
buffer < T > ( size: int,typeName: string,structure: object | undefined ) -> buffer<T>
calcBezier( aT: float,aA1: float,aA2: float ) -> float
ceil( a: vec | scalar ) -> vec | scalar
clamp( arg: int,min: int,max: int ) -> int
clamp( arg: int2,min: int,max: int ) -> int2
clamp( arg: int3,min: int,max: int ) -> int3
clamp( arg: int4,min: int,max: int ) -> int4
clamp( arg: int2,min: int2,max: int2 ) -> int2
clamp( arg: int3,min: int3,max: int3 ) -> int3
clamp( arg: int4,min: int3,max: int3 ) -> int4
clamp( arg: float,min: float,max: float ) -> float
clamp( arg: float2,min: float,max: float ) -> float2
clamp( arg: float3,min: float,max: float ) -> float3
clamp( arg: float4,min: float,max: float ) -> float4
clamp( arg: float2,min: float2,max: float2 ) -> float2
clamp( arg: float3,min: float3,max: float3 ) -> float3
clamp( arg: float4,min: float4,max: float4 ) -> float4
cmyk( v: float4 ) -> float4
cmykFromColor( c: float4 ) -> float4
compute( workgroups: int3,computeShader: shader<any, any, any> ) -> void
computeIndirect( indirectBuffer: buffer<uint> | buffer<atomic<uint>>,indirectOffset: int,computeShader: shader<any, any, any> ) -> void
cos( a: vec | scalar ) -> vec | scalar
cos1( v: float ) -> float
cosh( a: vec | scalar ) -> vec | scalar
cross( a: float2,b: float2 ) -> float
cross( a: float3,b: float3 ) -> float3
cross( a: int2,b: int2 ) -> int
cross( a: int3,b: int3 ) -> int3
cross( a: float2,b: int2 ) -> float
cross( a: float3,b: int3 ) -> float3
cross( a: int2,b: float2 ) -> float
cross( a: int3,b: float3 ) -> float3
Date( ) -> string

Returns the derivative of the input value with respect to the window-space x coordinate.

ddx < T > ( value: T ) -> T
ddxCoarse < T > ( value: T ) -> T
ddxFine < T > ( value: T ) -> T

Returns the derivative of the input value with respect to the window-space y coordinate.

ddy < T > ( value: T ) -> T
ddyCoarse < T > ( value: T ) -> T
ddyFine < T > ( value: T ) -> T

Gets the unencoded version of an encoded Uniform Resource Identifier (URI).

decodeURI( encodedURI: string ) -> string

Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI).

decodeURIComponent( encodedURIComponent: string ) -> string
degrees( a: float ) -> float

Discards the current fragment.

A discard statement converts the invocation into a helper invocation and throws away the fragment. The discard statement must only be used in a fragment shader stage.

See: https://www.w3.org/TR/WGSL/#discard-statement

discard( ) -> void
dist( a: float,b: float ) -> float
dist( a: float2,b: float2 ) -> float
dist( a: float3,b: float3 ) -> float
dist( a: float4,b: float4 ) -> float
distance( a: float,b: float ) -> float
distance( a: float2,b: float2 ) -> float
distance( a: float3,b: float3 ) -> float
distance( a: float4,b: float4 ) -> float
dot( a: float2,b: float2 ) -> float
dot( a: float3,b: float3 ) -> float
dot( a: float4,b: float4 ) -> float
dot( a: int2,b: int2 ) -> int
dot( a: int3,b: int3 ) -> int
dot( a: int4,b: int4 ) -> int
dot( a: float2,b: int2 ) -> float
dot( a: float3,b: int3 ) -> float
dot( a: float4,b: int4 ) -> float
dot( a: int2,b: float2 ) -> float
dot( a: int3,b: float3 ) -> float
dot( a: int4,b: float4 ) -> float
draw( geometry: Mesh,vertexShader: shader<ShaderInput, ShaderOutput, 0>,pixelShader: shader<ShaderInput, ShaderOutput, 0> ) -> void
draw( fullScreenPixelShader: shader<ShaderInput, ShaderOutput, 0> ) -> void

Normal:

drawAdvanced({
mesh: mesh::box(0.xyz, 100.xyz),
vertex: shader {
    // ...
},
fragment: shader {
     // ...
},
});

Instancing:

drawAdvanced({
mesh: mesh::box(0.xyz, 100.xyz),
vertex: shader {
    in.instanceIndex;
},
fragment: shader {
     // ...
},
 instances: 100,
});

Indirect:

let mesh = mesh::box(0.xyz, 100.xyz);

let indirectBuffer = buffer<uint>(5);
indirectBuffer[0] = uint(m.getTriangles().len()); // indexCount
indirectBuffer[1] = 1; // instanceCount
indirectBuffer[2] = 0; // firstIndex
indirectBuffer[3] = 0; // vertexOffset
indirectBuffer[4] = 0; // firstInstance

drawAdvanced({
mesh: mesh::box(0.xyz, 100.xyz),
vertex: shader {
    // ...
},
fragment: shader {
     // ...
},
 indirect: indirectBuffer,
});

Attachments:

let mesh = mesh::box(0.xyz, 100.xyz);
let color = texture2d<float4>(100.xy);
let normal = texture2d<float3>(100.xy);
let depth = texture2d<float>(100.xy, "depth");

drawAdvanced({
    mesh: mesh,
    vertex: shader {
     // ...
    },
    fragment: shader {
     out.attachment0 = float4(1, 0, 0, 1);
     out.attachment1 = float3(0, 0, 1);
    },
    depth: depth, // Override depth buffer
    attachments: [color, normal],
});
drawAdvanced < A0 ,A1 ,A2 ,A3 ,A4 ,A5 ,A6 ,A7 > ( descriptor: DrawDescriptorBase & AttachmentBindings8<A0, A1, A2, A3, A4, A5, A6, A7> ) -> void
drawAdvanced < A0 ,A1 ,A2 ,A3 ,A4 ,A5 ,A6 > ( descriptor: DrawDescriptorBase & AttachmentBindings7<A0, A1, A2, A3, A4, A5, A6> ) -> void
drawAdvanced < A0 ,A1 ,A2 ,A3 ,A4 ,A5 > ( descriptor: DrawDescriptorBase & AttachmentBindings6<A0, A1, A2, A3, A4, A5> ) -> void
drawAdvanced < A0 ,A1 ,A2 ,A3 ,A4 > ( descriptor: DrawDescriptorBase & AttachmentBindings5<A0, A1, A2, A3, A4> ) -> void
drawAdvanced < A0 ,A1 ,A2 ,A3 > ( descriptor: DrawDescriptorBase & AttachmentBindings4<A0, A1, A2, A3> ) -> void
drawAdvanced < A0 ,A1 ,A2 > ( descriptor: DrawDescriptorBase & AttachmentBindings3<A0, A1, A2> ) -> void
drawAdvanced < A0 ,A1 > ( descriptor: DrawDescriptorBase & AttachmentBindings2<A0, A1> ) -> void
drawAdvanced < A0 > ( descriptor: DrawDescriptorBase & AttachmentBindings1<A0> ) -> void
drawAdvanced( descriptor: DrawDescriptorBase & { vertex: shader<ShaderInput, ShaderOutput, 0>; fragment: shader<ShaderInput, ShaderOutput, 0>; } ) -> void
drawAttributes < T ,X ,Y > ( indexBuffer: buffer<uint>,buffers: any,vertexShader: shader<T, X, 0>,pixelShader: shader<X, Y, 0> ) -> void
drawCount( triCount: number,vertexShader: shader<ShaderInput, ShaderOutput, 0>,pixelShader: shader<ShaderInput, ShaderOutput, 0> ) -> void
drawIndexed( indexBuffer: buffer<uint>,vertexShader: shader<ShaderInput, ShaderOutput, 0>,pixelShader: shader<ShaderInput, ShaderOutput, 0> ) -> void
drawIndexedIndirect( indirectBuffer: buffer<int> | buffer<atomic<int>>,vertexShader: shader<ShaderInput, ShaderOutput, 0>,pixelShader: shader<ShaderInput, ShaderOutput, 0> ) -> void
drawIndirect( mesh: Mesh,indirectBuffer: buffer<int> | buffer<atomic<int>>,vertexShader: shader<ShaderInput, ShaderOutput, 0>,pixelShader: shader<ShaderInput, ShaderOutput, 0> ) -> void
drawInstanced( mesh: Mesh,instanceCount: int,vertexShader: shader<ShaderInput, ShaderOutput, 0>,pixelShader: shader<ShaderInput, ShaderOutput, 0> ) -> void
drawInstancedIndexed( indexBuffer: buffer<uint>,instanceCount: int,vertexShader: shader<ShaderInput, ShaderOutput, 0>,pixelShader: shader<ShaderInput, ShaderOutput, 0> ) -> void
easeA( aA1: float,aA2: float ) -> float
easeB( aA1: float,aA2: float ) -> float
easeC( aA1: float ) -> float

Encodes a text string as a valid Uniform Resource Identifier (URI)

encodeURI( uri: string ) -> string

Encodes a text string as a valid component of a Uniform Resource Identifier (URI).

encodeURIComponent( uriComponent: string | number | boolean ) -> string
eq < T > ( a: T,b: T ) -> boolean
Error( message: string | undefined ) -> Error

Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence.

escape( string: string ) -> string
EvalError( message: string | undefined ) -> EvalError
EvalError( message: string | undefined ) -> Error
exp( a: vec | scalar ) -> vec | scalar
float( x: number ) -> float
float2( x: number,y: number ) -> float2
float2( xy: vector2 ) -> float2
float2x2( ) -> float2x2
float2x2( m00: number,m01: number,m10: number,m11: number ) -> float2x2
float3( x: number,y: number,z: number ) -> float3
float3( xy: vector2,z: number ) -> float3
float3( x: number,yz: vector2 ) -> float3
float3( xyz: vector3 ) -> float3
float3x3( ) -> float3x3
float3x3( m00: number,m01: number,m02: number,m10: number,m11: number,m12: number,m20: number,m21: number,m22: number ) -> float3x3
float4( x: number,y: number,z: number,w: number ) -> float4
float4( x: number,yz: vector2,w: number ) -> float4
float4( xy: vector2,z: number,w: number ) -> float4
float4( x: number,y: number,zw: vector2 ) -> float4
float4( xy: vector2,zw: vector2 ) -> float4
float4( xyz: vector3,w: number ) -> float4
float4( x: number,yzw: vector3 ) -> float4
float4( xyzw: int4 ) -> float4
float4( xyzw: float4 ) -> float4
float4x4( ) -> float4x4
float4x4( m00: number,m01: number,m02: number,m03: number,m10: number,m11: number,m12: number,m13: number,m20: number,m21: number,m22: number,m23: number,m30: number,m31: number,m32: number,m33: number ) -> float4x4
floor( a: vec | scalar ) -> vec | scalar

Flushes (executes) all queued compute or draw calls

flush( ) -> Promise<any>
frac( a: vec | scalar ) -> vec | scalar
Function( args: string[] ) -> Function
getSlope( aT: float,aA1: float,aA2: float ) -> float
getSwizIndexFast( swiz: string ) -> 2 | 3 | 0 | 1 | undefined
getTForX( aX: float,mX1: float,mX2: float ) -> float
globalVarGet( fileName: any,varName: any ) -> any
globalVarInit < T > ( fileName: string,varName: string,initFn: () => T,getterFn: any ) -> T
hash( n: float ) -> float
hash2( p: float2 ) -> float
hash3( p: float3 ) -> float
hashableTypeToString( k: HashableType ) -> any
hex( v: int ) -> float4
hexFromColor( c: float4 ) -> int
hsl( v: float3 ) -> float4
hsla( v: float4 ) -> float4
hslaFromColor( c: float4 ) -> float4
hslFromColor( c: float4 ) -> float3
hsv( v: float3 ) -> float4
hsva( val: float4 ) -> float4
hsvaFromColor( c: float4 ) -> float4
hsvFromColor( c: float4 ) -> float3
infer < I ,O ,C > ( fn: (a: I, b: O) => void ) -> shader<I, O, C>
int( x: number ) -> int
int2( x: number,y: number ) -> int2
int2( xy: vector2 ) -> int2
int3( x: number,y: number,z: number ) -> int3
int3( xy: vector2,z: number ) -> int3
int3( x: number,yz: vector2 ) -> int3
int3( xyz: vector3 ) -> int3
int4( x: number,y: number,z: number,w: number ) -> int4
int4( x: number,yz: vector2,w: number ) -> int4
int4( xy: vector2,z: number,w: number ) -> int4
int4( x: number,y: number,zw: vector2 ) -> int4
int4( xy: vector2,zw: vector2 ) -> int4
int4( xyz: vector3,w: number ) -> int4
int4( x: number,yzw: vector3 ) -> int4
int4( xyzw: float4 ) -> int4
int4( xyzw: int4 ) -> int4
intifyVector( v: vector ) -> number[]
inverse( a: float2x2 ) -> float2x2
inverse( a: float3x3 ) -> float3x3
inverse( a: float4x4 ) -> float4x4
inversesqrt( a: vec | scalar ) -> vec | scalar

Determines whether a supplied number is finite.

isFinite( number: number ) -> boolean
isMatrix( v: number[] ) -> boolean

Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number).

isNaN( number: number ) -> boolean
isScalar( v: vectorOrScalar ) -> boolean
isVector( v: vectorOrScalar ) -> boolean
length( a: float ) -> float
length( a: float2 ) -> float
length( a: float3 ) -> float
length( a: float4 ) -> float
lerp( a: float,b: float,t: float ) -> float
lerp( a: float2,b: float2,t: float ) -> float2
lerp( a: float3,b: float3,t: float ) -> float3
lerp( a: float4,b: float4,t: float ) -> float4
lerp( a: float2x2,b: float2x2,t: float ) -> float2x2
lerp( a: float3x3,b: float3x3,t: float ) -> float3x3
lerp( a: float4x4,b: float4x4,t: float ) -> float4x4
lerp2x2( a: float2x2,b: float2x2,t: float ) -> float2x2
lerp3x3( a: float3x3,b: float3x3,t: float ) -> float3x3
lerp4( a: float4,b: float4,t: float ) -> float4
lerp4x4( a: float4x4,b: float4x4,t: float ) -> float4x4
log( a: vec | scalar ) -> vec | scalar
log10( a: vec | scalar ) -> vec | scalar
log2( a: vec | scalar ) -> vec | scalar
max( a: int,b: int[] ) -> int
max( a: float,b: int[] ) -> float
max( a: int,b: float[] ) -> float
max( a: int2,b: int2[] ) -> int2
max( a: int3,b: int3[] ) -> int3
max( a: int4,b: int4[] ) -> int4
max( a: float,b: float[] ) -> float
max( a: float2,b: float2[] ) -> float2
max( a: float3,b: float3[] ) -> float3
max( a: float4,b: float4[] ) -> float4
max < T > ( a: float,b: T ) -> T
max < T > ( a: T,b: float ) -> T
max < T > ( a: int,b: T ) -> T
max < T > ( a: T,b: int ) -> T
min( a: int,b: int[] ) -> int
min( a: int2,b: int2[] ) -> int2
min( a: int3,b: int3[] ) -> int3
min( a: int4,b: int4[] ) -> int4
min( a: float,b: float[] ) -> float
min( a: float2,b: float2[] ) -> float2
min( a: float3,b: float3[] ) -> float3
min( a: float4,b: float4[] ) -> float4
min < T > ( a: float,b: T ) -> T
min < T > ( a: T,b: float ) -> T
min < T > ( a: int,b: T ) -> T
min < T > ( a: T,b: int ) -> T
mod( a: uint,b: uint ) -> uint
mod( a: uint2,b: uint2 ) -> uint2
mod( a: uint3,b: uint3 ) -> uint3
mod( a: uint4,b: uint4 ) -> uint4
mod( a: uint2,b: uint ) -> uint2
mod( a: uint3,b: uint ) -> uint3
mod( a: uint4,b: uint ) -> uint4
mod( a: int,b: int ) -> int
mod( a: int2,b: int2 ) -> int2
mod( a: int3,b: int3 ) -> int3
mod( a: int4,b: int4 ) -> int4
mod( a: int2,b: int ) -> int2
mod( a: int3,b: int ) -> int3
mod( a: int4,b: int ) -> int4
mod( a: float,b: float ) -> float
mod( a: float2,b: float2 ) -> float2
mod( a: float3,b: float3 ) -> float3
mod( a: float4,b: float4 ) -> float4
mod( a: float2,b: float ) -> float2
mod( a: float3,b: float ) -> float3
mod( a: float4,b: float ) -> float4
mortonCode2( x: uint ) -> uint
mulFunc( a: any,b: any ) -> any
ndot( a: float2,b: float2 ) -> float
newtonRaphsonIterate( aX: float,aGuessT: float,mX1: float,mX2: float ) -> float
normalize( a: float2 ) -> float2
normalize( a: float3 ) -> float3
normalize( a: float4 ) -> float4
not( a: boolean ) -> boolean

Converts a string to a floating-point number.

parseFloat( string: string ) -> number

Converts a string to an integer.

parseInt( string: string,radix: number | undefined ) -> number
perm( x: float4 ) -> float4
permute( x: float3 ) -> float3
pingpong( x: float,length: float ) -> float
pixelToClip( pixelPosition: float2 ) -> float2
positive( a: vec | scalar ) -> vec | scalar
pow( a: int,b: int ) -> int
pow( a: int2,b: int2 ) -> int2
pow( a: int3,b: int3 ) -> int3
pow( a: int4,b: int4 ) -> int4
pow( a: int,b: float ) -> float
pow( a: float,b: int ) -> float
pow( a: float,b: float ) -> float
pow( a: float2,b: float ) -> float2
pow( a: float3,b: float ) -> float3
pow( a: float4,b: float ) -> float4
pow( a: int2,b: int ) -> int2
pow( a: int3,b: int ) -> int3
pow( a: int4,b: int ) -> int4
pow( a: int2,b: float ) -> float2
pow( a: int3,b: float ) -> float3
pow( a: int4,b: float ) -> float4
pow( a: float2,b: int ) -> float2
pow( a: float3,b: int ) -> float3
pow( a: float4,b: int ) -> float4
pow( a: float2,b: float ) -> float2
pow( a: float,b: float2 ) -> float2
pow( a: float,b: float3 ) -> float3
pow( a: float,b: float4 ) -> float4
pow( a: int,b: int2 ) -> int2
pow( a: int,b: int3 ) -> int3
pow( a: int,b: int4 ) -> int4
pow( a: float,b: int2 ) -> float2
pow( a: float,b: int3 ) -> float3
pow( a: float,b: int4 ) -> float4
pow( a: int,b: float2 ) -> float2
pow( a: int,b: float3 ) -> float3
pow( a: int,b: float4 ) -> float4
pow( a: float2,b: float2 ) -> float2
pow( a: float3,b: float3 ) -> float3
pow( a: float4,b: float4 ) -> float4
pow( a: float2,b: int2 ) -> float2
pow( a: float3,b: int3 ) -> float3
pow( a: float4,b: int4 ) -> float4
pow( a: int2,b: float2 ) -> float2
pow( a: int3,b: float3 ) -> float3
pow( a: int4,b: float4 ) -> float4
pow( a: uint,b: uint ) -> uint
pow( a: uint2,b: uint2 ) -> uint2
pow( a: uint3,b: uint3 ) -> uint3
pow( a: uint4,b: uint4 ) -> uint4

Prints a set of value(s) to the console. Values will be converted to strings before printing.

print( args: any[] ) -> void
radians( a: float ) -> float

Returns a deterministic (same seed = same output) random float between 0-1

Note: See the noise package for more advanced random functions

rand( seed: float | undefined ) -> float

Returns a deterministic (same seed = same output) random float between 0-1

Note: See the noise package for more advanced random functions

rand2( seed: float2 ) -> float

Returns a deterministic (same seed = same output) random float between 0-1

Note: See the noise package for more advanced random functions

rand3( seed: float3 ) -> float
randColor( seed: float ) -> float4
randColor2( seed: float2 ) -> float4
reflect( a: float2,b: float2 ) -> float2
reflect( a: float3,b: float3 ) -> float3
reflect( a: float4,b: float4 ) -> float4
reflect2( b: any,a: any ) -> number[]
reflect3( b: any,a: any ) -> number[]
reflect4( b: any,a: any ) -> number[]
refract( a: float2,b: float2,eta: float ) -> float2
refract( a: float3,b: float3,eta: float ) -> float3
refract( a: float4,b: float4,eta: float ) -> float4
remap( v: float,low1: float,high1: float,low2: float,high2: float ) -> float
remap1( v: float,low: float,high: float ) -> float
reverseMortonCode2( x: uint ) -> uint
rgb( v: float3 ) -> float4
rgba( v: float4 ) -> float4
rgbaFromColor( c: float4 ) -> float4
rgbFromColor( c: float4 ) -> float3
round( a: vec | scalar ) -> vec | scalar
saturate( arg: float ) -> float
saturate( arg: float2 ) -> float2
saturate( arg: float3 ) -> float3
saturate( arg: float4 ) -> float4
scaled_cosine( i: float ) -> float

Uses Super Sampling Anti Aliasing to smooth out the image.

screenAA( inScreenPos: float2,gridSize: int,func: (screenPos: float2) => float4 ) -> float4
sign( a: vec | scalar ) -> vec | scalar
sin( a: float ) -> float
sin( a: float2 ) -> float2
sin( a: float3 ) -> float3
sin( a: float4 ) -> float4
sin1( v: float ) -> float
sinh( a: vec | scalar ) -> vec | scalar
sleep( seconds: float ) -> any
smoothstep( a: float,b: float,x: float ) -> float
smoothstep( a: float2,b: float2,x: float2 ) -> float2
smoothstep( a: float3,b: float3,x: float3 ) -> float3
smoothstep( a: float4,b: float4,x: float4 ) -> float4
sqrt( a: vec | scalar ) -> vec | scalar

Displays a single value in the stats panel at the top right

stat( name: string,value: any ) -> void

Display a graph of a numeric value over time

statGraph( name: string,value: float,sampleRate: int ) -> void
step( edge: float,x: float ) -> float
step( edge: int,x: float ) -> float
step < T > ( edge: T,x: T ) -> T
step < T > ( edge: float,x: T ) -> T
step < T > ( edge: int,x: T ) -> T

Executes a storage barrier synchronization function that affects memory and atomic operations in the workgroup address space.

See: https://www.w3.org/TR/WGSL/#storageBarrier-builtin

storageBarrier( ) -> void
tan( a: vec | scalar ) -> vec | scalar
tan1( v: float ) -> float
tanh( a: vec | scalar ) -> vec | scalar
taylorInvSqrt( r: float3 ) -> float3
texture2d < T > ( size: float2,format: TextureFormat,type: string ) -> texture2d<T>
texture3d < T > ( size: float3,type: string ) -> texture3d<T>
toVec2( v: float2 ) -> RAPIER2DNamespace.Vector2
toVec3( v: float3 ) -> RAPIER3DNamespace.Vector
transpose( a: float2x2 ) -> float2x2
transpose( a: float3x3 ) -> float3x3
transpose( a: float4x4 ) -> float4x4
uint( x: number ) -> uint
uint2( x: number,y: number ) -> uint2
uint2( xy: vector2 ) -> uint2
uint3( x: number,y: number,z: number ) -> uint3
uint3( xy: vector2,z: number ) -> uint3
uint3( x: number,yz: vector2 ) -> uint3
uint3( xyz: vector3 ) -> uint3
uint4( x: number,y: number,z: number,w: number ) -> uint4
uint4( x: number,yz: vector2,w: number ) -> uint4
uint4( xy: vector2,z: number,w: number ) -> uint4
uint4( x: number,y: number,zw: vector2 ) -> uint4
uint4( xy: vector2,zw: vector2 ) -> uint4
uint4( xyz: vector3,w: number ) -> uint4
uint4( x: number,yzw: vector3 ) -> uint4
uint4( xyzw: float4 ) -> uint4
uint4( xyzw: uint4 ) -> uint4
uint8( x: number ) -> uint8

Computes a new string in which hexadecimal escape sequences are replaced with the character that it represents.

unescape( string: string ) -> string
URIError( message: string | undefined ) -> URIError
URIError( message: string | undefined ) -> Error
vectorMath_2to1_3to1_4to1( cb2: (a: vector2, b: vector2) => scalar,cb3: (a: vector3, b: vector3) => scalar,cb4: (a: vector4, b: vector4) => scalar ) -> vectorOverload_2to1_3to1_4to1
vectorMath_2to1_3to3( cb2: (a: vector2, b: vector2) => scalar,cb3: (a: vector3, b: vector3) => vector3 ) -> vectorOverload_2to1_3to3
vectorMath_2to1_3to3_4to4( cb2: (a: vector2, b: vector2) => scalar,cb3: (a: vector3, b: vector3) => vector3,cb4: (a: vector4, b: vector4) => vector4 ) -> vectorOverload_2to1_3to3_4to4

Executes a control barrier synchronization function that affects memory and atomic operations in the workgroup address space.

See: https://www.w3.org/TR/WGSL/#workgroupBarrier-builtin

workgroupBarrier( ) -> void
workgroupUniformLoad < T > ( p: T ) -> T
wrap( x: float,low: float,high: float ) -> float
wrap2( value: float2,low: float,high: float ) -> float2
wrap3( value: float3,low: float,high: float ) -> float3
wrap4( value: float4,low: float,high: float ) -> float4