bits

bit_and

bit_and ( a : Any | Numeric , b : Any | Numeric ) : Int
Bitwise AND operation of two integers (`a & b`)
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
bit_and ( a : Mesh | Any , b : Mesh | Any ) : Mesh
Returns the boolean intersection of two meshes (`a & b`)
Arguments:
  • a : Mesh | Any
  • b : Mesh | Any

bit_or

bit_or ( a : Any | Numeric , b : Any | Numeric ) : Int
Bitwise OR operation of two integers (`a | b`)
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
bit_or ( a : Mesh | Any , b : Mesh | Any ) : Mesh
Returns the boolean union of two meshes (`a | b`)
Arguments:
  • a : Mesh | Any
  • b : Mesh | Any

core

assert

assert ( condition : Bool | Any , message : String | Any String(Assertion failed) ) : Nil
Raises an error if `condition` is false, optionally including `message` in the error
Arguments:
  • condition : Bool | Any
  • message : String | Any String(Assertion failed) - Optional message to include in the error if the assertion fails

float

float ( value : String | Any | Numeric ) : Float
Converts a value to a float
Arguments:
  • value : String | Any | Numeric

int

int ( value : String | Any | Numeric ) : Int
Converts a value to an int
Arguments:
  • value : String | Any | Numeric

len

aliases: magnitude, length, mag
len ( v : Vec3 | Any ) : Float
Returns the length/magnitude of a Vec3
Arguments:
  • v : Vec3 | Any
len ( v : Vec2 | Any ) : Float
Returns the length/magnitude of a Vec2
Arguments:
  • v : Vec2 | Any
len ( v : String | Any ) : Int
Returns the number of unicode characters in a string
Arguments:
  • v : String | Any
len ( v : Sequence | Any ) : Int
Returns the number of elements in a sequence. This will fully evaluate the sequence. Calling this with an infinite sequence will result in the program hanging or crashing.
Arguments:
  • v : Sequence | Any

print

print ( ... Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric ) : Nil
Prints all provided args and kwargs to the console
Arguments:
  • ...

render

render ( mesh : Mesh | Any ) : Nil
Renders a mesh to the scene
Arguments:
  • mesh : Mesh | Any
render ( light : Light | Any ) : Nil
Renders a light to the scene
Arguments:
  • light : Light | Any
render ( meshes : Sequence | Any ) : Nil
Renders a sequence of entities to the scene. The sequence can contain a heterogeneous mix of meshes, lights, and paths (`Seq<Vec3>`). Each entity will be rendered separately.
Arguments:
  • meshes : Sequence | Any - Either: - `Seq<Mesh | Light | Seq<Vec3>>` of objects to render to the scene, or - `Seq<Vec3>` of points representing a path to render

str

alias: string
str ( value : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric ) : String
Converts a value to a string. For simple types like numbers and booleans, this performs the basic conversion as you'd expect. For more complicated or internal types like meshes, lights, sequences, etc., the format is not defined and may change at a later time.
Arguments:
  • value : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric

vec2

alias: v2
vec2 ( x : Any | Numeric , y : Any | Numeric ) : Vec2
Creates a Vec2 given x, y
Arguments:
  • x : Any | Numeric
  • y : Any | Numeric
vec2 ( value : Any | Numeric ) : Vec2
Creates a Vec2 with both components set to `value`
Arguments:
  • value : Any | Numeric

vec3

alias: v3
vec3 ( x : Any | Numeric , y : Any | Numeric , z : Any | Numeric ) : Vec3
Creates a Vec3 given x, y, z
Arguments:
  • x : Any | Numeric
  • y : Any | Numeric
  • z : Any | Numeric
vec3 ( xy : Vec2 | Any , z : Any | Numeric ) : Vec3
Creates a Vec3 from a Vec2 and a z component
Arguments:
  • xy : Vec2 | Any
  • z : Any | Numeric
vec3 ( x : Any | Numeric , yz : Vec2 | Any ) : Vec3
Creates a Vec3 from an x component and a Vec2
Arguments:
  • x : Any | Numeric
  • yz : Vec2 | Any
vec3 ( value : Any | Numeric ) : Vec3
Creates a Vec3 with all components set to `value`
Arguments:
  • value : Any | Numeric

fn

call

call ( fn : Callable | Any ) : Any
Calls `fn` with no arguments, returning its return value
Arguments:
  • fn : Callable | Any
call ( fn : Callable | Any , args : Sequence | Any ) : Any
Calls `fn` with the provided arguments, returning its return value
Arguments:
  • fn : Callable | Any
  • args : Sequence | Any

compose

Example
move_and_scale = compose( translate(3, 3, 0), scale(0.5), ) cube = box(2) cube | set_material('blue') | render cube | move_and_scale | set_material('red') | render
compose ( ... Sequence | Any ) : Callable
Composes all arguments, returning a callable like `|x| arg1(arg2(arg3(x)))`
Arguments:
  • ...
compose ( callables : Sequence | Any ) : Callable
Composes a sequence of callables, returning a callable like `|x| callables[0](callables[1](...callables[n](x)))`
Arguments:
  • callables : Sequence | Any - Sequence of callables to compose

light

ambient_light

ambient_light ( color : Vec3 | Any | Numeric Int(16777215) , intensity : Any | Numeric Float(1.8) ) : Light
Creates an ambient light. Note: This will not do anything until it is added to the scene via `render`
Arguments:
  • color : Vec3 | Any | Numeric Int(16777215) - Color of the light in hex format (like 0xffffff) or webgl format (like `vec3(1., 1., 1.)`)
  • intensity : Any | Numeric Float(1.8)

dir_light

Example
box(8) | render; (sphere(radius=5, resolution=4) + v3(8, 8, -4)) | render light_pos = v3(10, 13, -10) sphere(radius=0.5, resolution=4) | trans(light_pos * 1.1) | set_material('light_marker') | render dir_light(intensity=25, color=0xff00ff) | trans(light_pos) | render
dir_light ( target : Vec3 | Any Vec3(0, 0, 0) , color : Vec3 | Any | Numeric Int(16777215) , intensity : Any | Numeric Float(5) , cast_shadow : Bool | Any Bool(true) , shadow_map_size : Map | Any | Numeric {"width": Int(4096), "height": Int(4096)} , shadow_map_radius : Any | Numeric Float(4) , shadow_map_blur_samples : Any | Numeric Int(16) , shadow_map_type : String | Any String(vsm) , shadow_map_bias : Any | Numeric Float(-0.0001) , shadow_camera : Map | Any {"far": Float(300), "bottom": Float(-140), "left": Float(-300), "near": Float(8), "right": Float(380), "top": Float(94)} ) : Light
Creates a directional light. Note: This will not do anything until it is added to the scene via `render`
Arguments:
  • target : Vec3 | Any Vec3(0, 0, 0) - Target point that the light is pointing at. If the light as at the same position as the target, it will point down towards negative Y
  • color : Vec3 | Any | Numeric Int(16777215) - Color of the light in hex format (like 0xffffff) or webgl format (like `vec3(1., 1., 1.)`)
  • intensity : Any | Numeric Float(5)
  • cast_shadow : Bool | Any Bool(true)
  • shadow_map_size : Map | Any | Numeric {"width": Int(4096), "height": Int(4096)} - Size of the shadow map. Allowed keys: `width`, `height`. OR, a single integer value that will be used for both width and height.
  • shadow_map_radius : Any | Numeric Float(4) - Radius for shadow map filtering
  • shadow_map_blur_samples : Any | Numeric Int(16) - Number of samples for shadow map blur
  • shadow_map_type : String | Any String(vsm) - Allowed values: `vsm`
  • shadow_map_bias : Any | Numeric Float(-0.0001)
  • shadow_camera : Map | Any {"far": Float(300), "bottom": Float(-140), "left": Float(-300), "near": Float(8), "right": Float(380), "top": Float(94)} - Camera parameters for the shadow map. Allowed keys: `near`, `far`, `left`, `right`, `top`, `bottom`

logic

and

and ( a : Bool | Any , b : Bool | Any ) : Bool
Logical AND operation of two booleans
Arguments:
  • a : Bool | Any
  • b : Bool | Any

not

not ( value : Bool | Any ) : Bool
Inverts the boolean value (logical NOT)
Arguments:
  • value : Bool | Any

or

or ( a : Bool | Any , b : Bool | Any ) : Bool
Logical OR operation of two booleans
Arguments:
  • a : Bool | Any
  • b : Bool | Any

xor

xor ( a : Bool | Any , b : Bool | Any ) : Bool
Logical XOR operation of two booleans
Arguments:
  • a : Bool | Any
  • b : Bool | Any

math

abs

abs ( value : Any | Numeric ) : Int
Absolute Value
Arguments:
  • value : Any | Numeric
abs ( value : Any | Numeric ) : Float
Absolute Value
Arguments:
  • value : Any | Numeric
abs ( value : Vec3 | Any ) : Vec3
Component-wise absolute value of a Vec3
Arguments:
  • value : Vec3 | Any
abs ( value : Vec2 | Any ) : Vec2
Component-wise absolute value of a Vec2
Arguments:
  • value : Vec2 | Any

acos

acos ( value : Any | Numeric ) : Float
Returns the arccosine of a numeric value
Arguments:
  • value : Any | Numeric
acos ( value : Vec3 | Any ) : Vec3
Returns a Vec3 with the arccosine of each component
Arguments:
  • value : Vec3 | Any
acos ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the arccosine of each component
Arguments:
  • value : Vec2 | Any

add

add ( a : Vec3 | Any , b : Vec3 | Any ) : Vec3
Adds two Vec3s component-wise
Arguments:
  • a : Vec3 | Any
  • b : Vec3 | Any
add ( a : Any | Numeric , b : Any | Numeric ) : Float
a + b
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
add ( a : Any | Numeric , b : Any | Numeric ) : Float
a + b
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
add ( a : Any | Numeric , b : Any | Numeric ) : Int
a + b
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
add ( a : Mesh | Any , b : Mesh | Any ) : Mesh
Combines two meshes into one mesh containing all geometry from both inputs. This does NOT perform a boolean union; for that, use the `union` function or the `|` operator.
Arguments:
  • a : Mesh | Any
  • b : Mesh | Any
add ( mesh : Mesh | Any , offset : Vec3 | Any ) : Mesh
Translates the given mesh by a Vec3 offset
Arguments:
  • mesh : Mesh | Any
  • offset : Vec3 | Any
add ( vec : Vec3 | Any , num : Any | Numeric ) : Vec3
Adds a numeric value to each component of a Vec3
Arguments:
  • vec : Vec3 | Any
  • num : Any | Numeric
add ( a : Vec2 | Any , b : Vec2 | Any ) : Vec2
Adds two Vec2s component-wise
Arguments:
  • a : Vec2 | Any
  • b : Vec2 | Any
add ( a : Vec2 | Any , b : Any | Numeric ) : Vec2
Adds a numeric value to each component of a Vec2
Arguments:
  • a : Vec2 | Any
  • b : Any | Numeric
add ( a : String | Any , b : String | Any ) : String
Concatenates two strings
Arguments:
  • a : String | Any
  • b : String | Any

asin

asin ( value : Any | Numeric ) : Float
Returns the arcsine of a numeric value
Arguments:
  • value : Any | Numeric
asin ( value : Vec3 | Any ) : Vec3
Returns a Vec3 with the arcsine of each component
Arguments:
  • value : Vec3 | Any
asin ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the arcsine of each component
Arguments:
  • value : Vec2 | Any

atan

atan ( value : Any | Numeric ) : Float
Returns the arctangent of a numeric value
Arguments:
  • value : Any | Numeric
atan ( value : Vec3 | Any ) : Vec3
Returns a Vec3 with the arctangent of each component
Arguments:
  • value : Vec3 | Any
atan ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the arctangent of each component
Arguments:
  • value : Vec2 | Any

atan2

atan2 ( y : Any | Numeric , x : Any | Numeric ) : Float
Returns the arctangent of `y / x`, using the signs of both arguments to determine the correct quadrant.
Arguments:
  • y : Any | Numeric
  • x : Any | Numeric
atan2 ( xy : Vec2 | Any ) : Float
Returns the arctangent of `y / x` for a Vec2, using the signs of both components to determine the correct quadrant.
Arguments:
  • xy : Vec2 | Any

ceil

ceil ( value : Any | Numeric ) : Float
Rounds a numeric value up to the nearest integer
Arguments:
  • value : Any | Numeric
ceil ( value : Vec3 | Any ) : Vec3
Rounds each component of a Vec3 up to the nearest integer
Arguments:
  • value : Vec3 | Any
ceil ( value : Vec2 | Any ) : Vec2
Rounds each component of a Vec2 up to the nearest integer
Arguments:
  • value : Vec2 | Any

clamp

clamp ( min : Any | Numeric , max : Any | Numeric , value : Any | Numeric ) : Int
Clamps a value between min and max
Arguments:
  • min : Any | Numeric
  • max : Any | Numeric
  • value : Any | Numeric
clamp ( min : Any | Numeric , max : Any | Numeric , value : Any | Numeric ) : Float
Clamps a value between min and max
Arguments:
  • min : Any | Numeric
  • max : Any | Numeric
  • value : Any | Numeric
clamp ( min : Any | Numeric , max : Any | Numeric , value : Vec3 | Any ) : Vec3
Clamps each component of a Vec3 between min and max
Arguments:
  • min : Any | Numeric
  • max : Any | Numeric
  • value : Vec3 | Any
clamp ( min : Any | Numeric , max : Any | Numeric , value : Vec2 | Any ) : Vec2
Clamps each component of a Vec2 between min and max
Arguments:
  • min : Any | Numeric
  • max : Any | Numeric
  • value : Vec2 | Any

cos

cos ( value : Any | Numeric ) : Float
Cosine
Arguments:
  • value : Any | Numeric
cos ( value : Vec3 | Any ) : Vec3
Returns a Vec3 with the cosine of each component
Arguments:
  • value : Vec3 | Any
cos ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the cosine of each component
Arguments:
  • value : Vec2 | Any

cosh

cosh ( value : Any | Numeric ) : Float
Returns the hyperbolic cosine of a numeric value
Arguments:
  • value : Any | Numeric
cosh ( value : Vec3 | Any ) : Vec3
Returns a Vec3 with the hyperbolic cosine of each component
Arguments:
  • value : Vec3 | Any
cosh ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the hyperbolic cosine of each component
Arguments:
  • value : Vec2 | Any

deg2rad

deg2rad ( value : Any | Numeric ) : Float
Converts degrees to radians
Arguments:
  • value : Any | Numeric

distance

alias: dist
distance ( a : Vec3 | Any , b : Vec3 | Any ) : Float
`sqrt((a.x - b.x)^2 + (a.y - b.y)^2 + (a.z - b.z)^2)`
Arguments:
  • a : Vec3 | Any
  • b : Vec3 | Any
distance ( a : Vec2 | Any , b : Vec2 | Any ) : Float
`sqrt((a.x - b.x)^2 + (a.y - b.y)^2`
Arguments:
  • a : Vec2 | Any
  • b : Vec2 | Any

div

div ( a : Vec3 | Any , b : Vec3 | Any ) : Vec3
Returns the component-wise division of two Vec3 values
Arguments:
  • a : Vec3 | Any
  • b : Vec3 | Any
div ( a : Vec3 | Any , b : Any | Numeric ) : Vec3
Divides each element of a Vec3 by a scalar
Arguments:
  • a : Vec3 | Any
  • b : Any | Numeric
div ( a : Any | Numeric , b : Any | Numeric ) : Float
a / b
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
div ( a : Any | Numeric , b : Any | Numeric ) : Float
a / b
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
div ( a : Any | Numeric , b : Any | Numeric ) : Float
Divides two integers a / b and returns a float. The integers are converted to floats before division. If you need true integer division, use the `mod` function or `%` operator instead.
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
div ( a : Vec2 | Any , b : Vec2 | Any ) : Vec2
Returns the component-wise division of two `Vec2`s
Arguments:
  • a : Vec2 | Any
  • b : Vec2 | Any
div ( a : Vec2 | Any , b : Any | Numeric ) : Vec2
Divides each component of a Vec2 by a scalar
Arguments:
  • a : Vec2 | Any
  • b : Any | Numeric

eq

eq ( a : Any | Numeric , b : Any | Numeric ) : Bool
`a == b`
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
eq ( a : Any | Numeric , b : Any | Numeric ) : Bool
`a == b`
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
eq ( a : Nil | Any , b : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric ) : Bool
`a == b`
Arguments:
  • a : Nil | Any
  • b : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric
eq ( a : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric , b : Nil | Any ) : Bool
`a == b`
Arguments:
  • a : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric
  • b : Nil | Any
eq ( a : Bool | Any , b : Bool | Any ) : Bool
`a == b`
Arguments:
  • a : Bool | Any
  • b : Bool | Any
eq ( a : String | Any , b : String | Any ) : Bool
`a == b`
Arguments:
  • a : String | Any
  • b : String | Any

exp

exp ( value : Any | Numeric ) : Float
Returns the exponential of a numeric value
Arguments:
  • value : Any | Numeric
exp ( value : Vec3 | Any ) : Vec3
Returns a Vec3 with the exponential of each component
Arguments:
  • value : Vec3 | Any
exp ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the exponential of each component
Arguments:
  • value : Vec2 | Any

fix_float

fix_float ( value : Any | Numeric ) : Float
If the provided float is NaN, non-infinite, or subnormal, returns 0.0. Otherwise, returns the float unchanged.
Arguments:
  • value : Any | Numeric
fix_float ( value : Vec3 | Any ) : Vec3
For each component of the Vec3, if it is NaN, non-infinite, or subnormal, returns 0.0. Otherwise, returns the component unchanged.
Arguments:
  • value : Vec3 | Any - Vec3 value to fix
fix_float ( value : Vec2 | Any ) : Vec2
For each component of the Vec2, if it is NaN, non-infinite, or subnormal, returns 0.0. Otherwise, returns the component unchanged.
Arguments:
  • value : Vec2 | Any - Vec2 value to fix

floor

floor ( value : Any | Numeric ) : Float
Rounds a numeric value down to the nearest integer
Arguments:
  • value : Any | Numeric
floor ( value : Vec3 | Any ) : Vec3
Rounds each component of a Vec3 down to the nearest integer
Arguments:
  • value : Vec3 | Any
floor ( value : Vec2 | Any ) : Vec2
Rounds each component of a Vec2 down to the nearest integer
Arguments:
  • value : Vec2 | Any

fract

fract ( value : Any | Numeric ) : Float
Returns the fractional part of a numeric value
Arguments:
  • value : Any | Numeric
fract ( value : Vec3 | Any ) : Vec3
Returns a Vec3 with the fractional part of each component
Arguments:
  • value : Vec3 | Any
fract ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the fractional part of each component
Arguments:
  • value : Vec2 | Any

gt

gt ( a : Any | Numeric , b : Any | Numeric ) : Bool
`a > b`
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
gt ( a : Any | Numeric , b : Any | Numeric ) : Bool
`a > b`
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric

gte

gte ( a : Any | Numeric , b : Any | Numeric ) : Bool
`a >= b`
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
gte ( a : Any | Numeric , b : Any | Numeric ) : Bool
`a >= b`
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric

lerp

alias: mix
lerp ( t : Any | Numeric , a : Vec3 | Any , b : Vec3 | Any ) : Vec3
Linearly interpolates between two Vec3 values `a` and `b` by a factor `t`
Arguments:
  • t : Any | Numeric
  • a : Vec3 | Any
  • b : Vec3 | Any
lerp ( t : Any | Numeric , a : Any | Numeric , b : Any | Numeric ) : Float
Linearly interpolates between two numeric values `a` and `b` by a factor `t`
Arguments:
  • t : Any | Numeric
  • a : Any | Numeric
  • b : Any | Numeric

linearstep

linearstep ( edge0 : Any | Numeric , edge1 : Any | Numeric , x : Any | Numeric ) : Float
Same as `smoothstep` but with simple linear interpolation instead of Hermite interpolation. It returns 0 if `x < edge0`, 1 if `x > edge1`, and a linear interpolation between 0 and 1 for values of `x` between `edge0` and `edge1`.
Arguments:
  • edge0 : Any | Numeric
  • edge1 : Any | Numeric
  • x : Any | Numeric

ln

ln ( value : Any | Numeric ) : Float
Returns the natural logarithm of a numeric value
Arguments:
  • value : Any | Numeric
ln ( value : Vec3 | Any ) : Vec3
Returns a Vec3 with the natural logarithm of each component
Arguments:
  • value : Vec3 | Any
ln ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the natural logarithm of each component
Arguments:
  • value : Vec2 | Any

log10

log10 ( value : Any | Numeric ) : Float
Returns the base-10 logarithm of a numeric value
Arguments:
  • value : Any | Numeric
log10 ( value : Vec3 | Any ) : Vec3
Returns a Vec3 with the base-10 logarithm of each component
Arguments:
  • value : Vec3 | Any
log10 ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the base-10 logarithm of each component
Arguments:
  • value : Vec2 | Any

log2

log2 ( value : Any | Numeric ) : Float
Returns the base-2 logarithm of a numeric value
Arguments:
  • value : Any | Numeric
log2 ( value : Vec3 | Any ) : Vec3
Returns a Vec3 with the base-2 logarithm of each component
Arguments:
  • value : Vec3 | Any
log2 ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the base-2 logarithm of each component
Arguments:
  • value : Vec2 | Any

look_at

look_at ( pos : Vec3 | Any , target : Vec3 | Any ) : Vec3
TODO: this is currently broken
Arguments:
  • pos : Vec3 | Any - Source position
  • target : Vec3 | Any - Target position
look_at ( mesh : Mesh | Any , target : Vec3 | Any , up : Vec3 | Any Vec3(0, 1, 0) ) : Vec3
Orients a mesh to look at a target point. This replaces any currently applied rotation. There's a good chance this implementation is broken too...
Arguments:
  • mesh : Mesh | Any
  • target : Vec3 | Any
  • up : Vec3 | Any Vec3(0, 1, 0)

lt

lt ( a : Any | Numeric , b : Any | Numeric ) : Bool
`a < b`
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
lt ( a : Any | Numeric , b : Any | Numeric ) : Bool
`a < b`
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric

lte

lte ( a : Any | Numeric , b : Any | Numeric ) : Bool
`a <= b`
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
lte ( a : Any | Numeric , b : Any | Numeric ) : Bool
`a <= b`
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric

max

max ( a : Any | Numeric , b : Any | Numeric ) : Int
Returns the minimum of the provided arguments
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
max ( a : Any | Numeric , b : Any | Numeric ) : Float
Returns maximum of the provided arguments
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
max ( a : Vec3 | Any , b : Vec3 | Any ) : Vec3
Component-wise maximum of two Vec3s
Arguments:
  • a : Vec3 | Any
  • b : Vec3 | Any
max ( a : Vec2 | Any , b : Vec2 | Any ) : Vec2
Component-wise maximum of two Vec2s
Arguments:
  • a : Vec2 | Any
  • b : Vec2 | Any

min

min ( a : Any | Numeric , b : Any | Numeric ) : Int
Returns the minimum of the provided arguments
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
min ( a : Any | Numeric , b : Any | Numeric ) : Float
Returns minimum of the provided arguments
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
min ( a : Vec3 | Any , b : Vec3 | Any ) : Vec3
Component-wise minimum of two Vec3s
Arguments:
  • a : Vec3 | Any
  • b : Vec3 | Any
min ( a : Vec2 | Any , b : Vec2 | Any ) : Vec2
Component-wise minimum of two Vec2s
Arguments:
  • a : Vec2 | Any
  • b : Vec2 | Any

mod

mod ( a : Any | Numeric , b : Any | Numeric ) : Int
a % b
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
mod ( a : Any | Numeric , b : Any | Numeric ) : Float
Floating point modulus (`a % b`)
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric

mul

mul ( a : Vec3 | Any , b : Vec3 | Any ) : Vec3
Returns the component-wise product of two Vec3 values
Arguments:
  • a : Vec3 | Any
  • b : Vec3 | Any
mul ( a : Vec3 | Any , b : Any | Numeric ) : Vec3
Multiplied each element of a Vec3 by a scalar
Arguments:
  • a : Vec3 | Any
  • b : Any | Numeric
mul ( a : Any | Numeric , b : Any | Numeric ) : Float
a * b
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
mul ( a : Any | Numeric , b : Any | Numeric ) : Float
a * b
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
mul ( a : Any | Numeric , b : Any | Numeric ) : Int
a * b
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
mul ( mesh : Mesh | Any , factor : Any | Numeric ) : Mesh
Uniformly scales a mesh by a scalar factor
Arguments:
  • mesh : Mesh | Any - Mesh to scale
  • factor : Any | Numeric - Uniform scale to apply to the mesh
mul ( mesh : Mesh | Any , factor : Vec3 | Any ) : Mesh
Scales `mesh` by `factor` along each axis
Arguments:
  • mesh : Mesh | Any
  • factor : Vec3 | Any
mul ( a : Vec2 | Any , b : Vec2 | Any ) : Vec2
Returns the component-wise product of two Vec2 values
Arguments:
  • a : Vec2 | Any
  • b : Vec2 | Any
mul ( a : Vec2 | Any , b : Any | Numeric ) : Vec2
Multiplied each element of a Vec2 by a scalar
Arguments:
  • a : Vec2 | Any
  • b : Any | Numeric

neg

neg ( value : Any | Numeric ) : Int
Negates an integer
Arguments:
  • value : Any | Numeric
neg ( value : Any | Numeric ) : Float
Negates a float
Arguments:
  • value : Any | Numeric
neg ( value : Vec3 | Any ) : Vec3
Negates each component of a Vec3
Arguments:
  • value : Vec3 | Any
neg ( value : Bool | Any ) : Bool
Inverts a boolean (logical NOT)
Arguments:
  • value : Bool | Any
neg ( value : Vec2 | Any ) : Vec2
Negates each component of a Vec2
Arguments:
  • value : Vec2 | Any

neq

neq ( a : Any | Numeric , b : Any | Numeric ) : Bool
`a != b`
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
neq ( a : Any | Numeric , b : Any | Numeric ) : Bool
`a != b`
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
neq ( a : Nil | Any , b : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric ) : Bool
`a != b`
Arguments:
  • a : Nil | Any
  • b : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric
neq ( a : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric , b : Nil | Any ) : Bool
`a != b`
Arguments:
  • a : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric
  • b : Nil | Any
neq ( a : Bool | Any , b : Bool | Any ) : Bool
`a != b`
Arguments:
  • a : Bool | Any
  • b : Bool | Any
neq ( a : String | Any , b : String | Any ) : Bool
`a != b`
Arguments:
  • a : String | Any
  • b : String | Any

normalize

normalize ( v : Vec3 | Any ) : Vec3
Returns a normalized Vec3 (length 1) in the same direction as the input vector
Arguments:
  • v : Vec3 | Any
normalize ( v : Vec2 | Any ) : Vec2
Returns a normalized Vec2 (length 1) in the same direction as the input vector
Arguments:
  • v : Vec2 | Any

pos

pos ( value : Any | Numeric ) : Numeric
Passes through the input unchanged (implementation detail of the unary `+` operator)
Arguments:
  • value : Any | Numeric - h
pos ( value : Vec3 | Any ) : Vec3
Passes through the input unchanged (implementation detail of the unary `+` operator)
Arguments:
  • value : Vec3 | Any
pos ( value : Vec2 | Any ) : Vec2
Passes through the input unchanged (implementation detail of the unary `+` operator)
Arguments:
  • value : Vec2 | Any

pow

pow ( base : Any | Numeric , exponent : Any | Numeric ) : Numeric
`Returns `base` raised to the power of `exponent``
Arguments:
  • base : Any | Numeric
  • exponent : Any | Numeric
pow ( base : Vec3 | Any , exponent : Any | Numeric ) : Vec3
Returns a Vec3 with each component raised to the power of `exponent`
Arguments:
  • base : Vec3 | Any
  • exponent : Any | Numeric
pow ( base : Vec3 | Any , exponent : Any | Numeric ) : Vec3
Returns a Vec3 with each component raised to the power of `exponent`
Arguments:
  • base : Vec3 | Any
  • exponent : Any | Numeric

rad2deg

rad2deg ( value : Any | Numeric ) : Float
Converts radians to degrees
Arguments:
  • value : Any | Numeric

round

round ( value : Any | Numeric ) : Float
Rounds a numeric value to the nearest integer
Arguments:
  • value : Any | Numeric
round ( value : Vec3 | Any ) : Vec3
Rounds each component of a Vec3 to the nearest integer
Arguments:
  • value : Vec3 | Any
round ( value : Vec2 | Any ) : Vec2
Rounds each component of a Vec2 to the nearest integer
Arguments:
  • value : Vec2 | Any

signum

alias: sign
signum ( x : Any | Numeric ) : Float
Returns -1, 0, or 1 depending on the sign of the input. For infinity, NaN, etc, the behavior is undefined.
Arguments:
  • x : Any | Numeric
signum ( x : Any | Numeric ) : Int
Returns -1, 0, or 1 depending on the sign of the input
Arguments:
  • x : Any | Numeric
signum ( x : Vec2 | Any ) : Vec2
Returns -1, 0, or 1 depending on the sign of the input element-wise
Arguments:
  • x : Vec2 | Any
signum ( x : Vec3 | Any ) : Vec3
Returns -1, 0, or 1 depending on the sign of the input element-wise
Arguments:
  • x : Vec3 | Any

sin

sin ( value : Any | Numeric ) : Float
Returns the sine of a numeric value
Arguments:
  • value : Any | Numeric
sin ( value : Vec3 | Any ) : Vec3
Returns the sine of each component of a Vec3
Arguments:
  • value : Vec3 | Any

sinh

sinh ( value : Any | Numeric ) : Float
Returns the hyperbolic sine of a numeric value
Arguments:
  • value : Any | Numeric
sinh ( value : Vec3 | Any ) : Vec3
Returns a Vec3 with the hyperbolic sine of each component
Arguments:
  • value : Vec3 | Any
sinh ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the hyperbolic sine of each component
Arguments:
  • value : Vec2 | Any

smoothstep

smoothstep ( edge0 : Any | Numeric , edge1 : Any | Numeric , x : Any | Numeric ) : Float
Works the same as `smoothstep` in GLSL. It returns 0 if `x < edge0`, 1 if `x > edge1`, and a smooth Hermite interpolation between 0 and 1 for values of `x` between `edge0` and `edge1`.
Arguments:
  • edge0 : Any | Numeric
  • edge1 : Any | Numeric
  • x : Any | Numeric

sqrt

sqrt ( value : Any | Numeric ) : Float
Square Root
Arguments:
  • value : Any | Numeric
sqrt ( value : Vec3 | Any ) : Vec3
Component-wise square root of a Vec3
Arguments:
  • value : Vec3 | Any
sqrt ( value : Vec2 | Any ) : Vec2
Component-wise square root of a Vec2
Arguments:
  • value : Vec2 | Any

sub

sub ( a : Vec3 | Any , b : Vec3 | Any ) : Vec3
Component-wise subtraction of two Vec3s
Arguments:
  • a : Vec3 | Any
  • b : Vec3 | Any
sub ( a : Any | Numeric , b : Any | Numeric ) : Float
a -b
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
sub ( a : Any | Numeric , b : Any | Numeric ) : Float
a - b
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
sub ( a : Any | Numeric , b : Any | Numeric ) : Int
a - b
Arguments:
  • a : Any | Numeric
  • b : Any | Numeric
sub ( a : Mesh | Any , b : Mesh | Any ) : Mesh
Returns the boolean difference of two meshes (`a - b`). This is equivalent to the `difference` function.
Arguments:
  • a : Mesh | Any - Base mesh
  • b : Mesh | Any - Mesh to subtract
sub ( mesh : Mesh | Any , offset : Vec3 | Any ) : Mesh
Translates the mesh by (`-offset`)
Arguments:
  • mesh : Mesh | Any
  • offset : Vec3 | Any
sub ( vec : Vec3 | Any , num : Any | Numeric ) : Vec3
Subtracts a numeric value from each component of a Vec3
Arguments:
  • vec : Vec3 | Any
  • num : Any | Numeric
sub ( a : Vec2 | Any , b : Vec2 | Any ) : Vec2
Subtracts two Vec2s component-wise
Arguments:
  • a : Vec2 | Any
  • b : Vec2 | Any
sub ( a : Vec2 | Any , b : Any | Numeric ) : Vec2
Subtracts a numeric value from each component of a Vec2
Arguments:
  • a : Vec2 | Any
  • b : Any | Numeric

tan

tan ( value : Any | Numeric ) : Float
Tangent
Arguments:
  • value : Any | Numeric
tan ( value : Vec3 | Any ) : Vec3
Returns the tangent of each component of a Vec3
Arguments:
  • value : Vec3 | Any
tan ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the tangent of each component
Arguments:
  • value : Vec2 | Any

tanh

tanh ( value : Any | Numeric ) : Float
Returns the hyperbolic tangent of a numeric value
Arguments:
  • value : Any | Numeric
tanh ( value : Vec3 | Any ) : Vec3
Returns a Vec3 with the hyperbolic tangent of each component
Arguments:
  • value : Vec3 | Any
tanh ( value : Vec2 | Any ) : Vec2
Returns a Vec2 with the hyperbolic tangent of each component
Arguments:
  • value : Vec2 | Any

trunc

trunc ( value : Any | Numeric ) : Float
Truncates a numeric value to its integer part
Arguments:
  • value : Any | Numeric
trunc ( value : Vec3 | Any ) : Vec3
Truncates each component of a Vec3 to its integer part
Arguments:
  • value : Vec3 | Any
trunc ( value : Vec2 | Any ) : Vec2
Truncates each component of a Vec2 to its integer part
Arguments:
  • value : Vec2 | Any

mesh

alpha_wrap

Example
distance_to_circle = |p: vec3, radius: num| sqrt(p.y*p.y + pow(sqrt(p.x*p.x + p.z*p.z) - radius, 2)); radius = 8 0.. -> || { randv(-radius*1.1, radius*1.1) } | filter(|p| distance_to_circle(p, radius) < 2) | take(1550) | alpha_wrap(alpha=1/100, offset=1/100) | smooth(iterations=2) | simplify(tolerance=0.01) | render
alpha_wrap ( mesh : Mesh | Any , alpha : Any | Numeric Float(0.033333335) , offset : Any | Numeric Float(0.03) ) : Mesh
Computes an alpha-wrap of a mesh. This is kind of like a concave version of a convex hull. This function is guaranteed to produce watertight/2-manifold outputs. For more details, see here: https://doc.cgal.org/latest/Alpha_wrap_3/index.html
Arguments:
  • mesh : Mesh | Any
  • alpha : Any | Numeric Float(0.033333335) - Controls the feature size of the computed wrapping. Smaller values will capture more detail and produce more faces. This value is relative to the bounding box of the input mesh. Values should be in the range (0, 1).
  • offset : Any | Numeric Float(0.03) - Controls the offset distance between the the input and the wrapped output mesh surfaces. Larger values will result in simpler outputs with better triangle quality, potentially at the cost of sharp edges and fine details. This value is relative to the bounding box of the input mesh. Values should be in the range (0, 1).
alpha_wrap ( points : Sequence | Any , alpha : Any | Numeric Float(0.033333335) , offset : Any | Numeric Float(0.03) ) : Mesh
Computes an alpha-wrap of a sequence of points. This is kind of like a concave version of a convex hull. This function is guaranteed to produce watertight/2-manifold outputs. For more details, see here: https://doc.cgal.org/latest/Alpha_wrap_3/index.html
Arguments:
  • points : Sequence | Any
  • alpha : Any | Numeric Float(0.033333335) - Controls the feature size of the computed wrapping. Smaller values will capture more detail and produce more faces. This value is relative to the bounding box of the input points. Values should be in the range (0, 1).
  • offset : Any | Numeric Float(0.03) - Controls the offset distance between the the input and the wrapped output mesh surfaces. Larger values will result in simpler outputs with better triangle quality, potentially at the cost of sharp edges and fine details. This value is relative to the bounding box of the input points. Values should be in the range (0, 1).

apply_transforms

apply_transforms ( mesh : Mesh | Any ) : Mesh
Applies rotation, translation, and scale transforms to the vertices of a mesh, resetting the transforms to identity
Arguments:
  • mesh : Mesh | Any

box

box ( width : Any | Numeric , height : Any | Numeric , depth : Any | Numeric ) : Mesh
Creates a rectangular prism mesh with the specified width, height, and depth
Arguments:
  • width : Any | Numeric - Width along the X axis
  • height : Any | Numeric - Height along the Y axis
  • depth : Any | Numeric - Depth along the Z axis
box ( size : Vec3 | Any | Numeric Vec3(1, 1, 1) ) : Mesh
Creates a box using a uniform or vector size
Arguments:
  • size : Vec3 | Any | Numeric Vec3(1, 1, 1) - Size of the box as a Vec3, or a single numeric value for a cube

connected_components

Example
0..10 -> || { sphere(radius=1.15, resolution=2) | trans(randv(-3, 3)) } | union | connected_components -> |component: mesh, i: int| { component | set_material(str(i)) } | render
connected_components ( mesh : Mesh | Any ) : Sequence
Splits a mesh into its connected components, returning a sequence of meshes where each mesh is a connected component of the input mesh. The sequence of connected components is sorted by vertex count from highest to lowest. This is NOT lazy; the connected components are computed at the time this function is called.
Arguments:
  • mesh : Mesh | Any

convex_hull

Example
// pick 50,000 random points within 1 unit of the origin points = 0..100000000 -> || { randv(0, 1) } | filter(|v| len(v) < 1) | take(50000) // Create a mesh bounded by the convex hull of all those // points. This is the smallest convex shape that contains // all of the points. points | convex_hull | render
convex_hull ( points : Sequence | Any ) : Mesh
Computes the convex hull of a sequence of points, returning a mesh representing the convex hull
Arguments:
  • points : Sequence | Any
convex_hull ( mesh : Mesh | Any ) : Mesh
Computes the convex hull of a mesh, returning a mesh representing the convex hull. This will apply all transforms on the mesh, and the returned mesh will have an identity transform.
Arguments:
  • mesh : Mesh | Any

cylinder

alias: cyl
cylinder ( radius : Any | Numeric , height : Any | Numeric , radial_segments : Any | Numeric , height_segments : Any | Numeric Int(1) ) : Mesh
Generates a cylinder mesh
Arguments:
  • radius : Any | Numeric
  • height : Any | Numeric
  • radial_segments : Any | Numeric
  • height_segments : Any | Numeric Int(1)

delaunay_remesh

delaunay_remesh ( mesh : Mesh | Any , facet_distance : Any | Numeric Float(0.14) , target_edge_length : Any | Numeric Float(0.2) , protect_sharp_edges : Bool | Any Bool(true) , sharp_angle_threshold_degrees : Any | Numeric Float(30) ) : Mesh
Remeshes a mesh using a Delaunay refinement of a restricted Delaunay triangulation. TODO improve docs once we understand the behavior of this function better. See the docs for the underlying CGAL function for more details: https://doc.cgal.org/latest/Polygon_mesh_processing/index.html - Section 2.1.2 Remeshing
Arguments:
  • mesh : Mesh | Any
  • facet_distance : Any | Numeric Float(0.14) - This controls the precision of the output mesh. Smaller values will produce meshes that more closely approximate the input, but will also produce more faces. This value represents units in the local space of the mesh, so it must be chosen relative to the size of the input mesh.
  • target_edge_length : Any | Numeric Float(0.2) - This serves as an upper bound for the lengths of curve edges in the underlying Delaunay triangulation. Smaller values will produce more faces. This value represents units in the local space of the mesh, so it must be chosen relative to the size of the input mesh.
  • protect_sharp_edges : Bool | Any Bool(true) - If true, edges with angles >= the `sharp_angle_threshold_degrees` will not be modified.
  • sharp_angle_threshold_degrees : Any | Numeric Float(30) - Angle threshold in degrees for edges to be considered sharp. Only used if `protect_sharp_edges` is true.

difference

Example
a = box(size=8) b = icosphere(radius=5, resolution=5) // subtract the space inside the sphere from the cube core = sub(a, b) // You can also just use `-` instead. The following is // equivalent to the previous: core = a - b core | render
difference ( a : Mesh | Any , b : Mesh | Any ) : Mesh
Returns the boolean difference of two meshes (`a - b`)
Arguments:
  • a : Mesh | Any - Base mesh
  • b : Mesh | Any - Mesh to subtract
difference ( meshes : Sequence | Any ) : Mesh
Returns the boolean difference of a sequence of meshes (`meshes[0] - meshes[1] - ...`)
Arguments:
  • meshes : Sequence | Any - Sequence of meshes to subtract in order

extrude

extrude ( up : Vec3 | Callable | Any , mesh : Mesh | Any ) : Mesh
Extrudes a mesh in the direction of `up` by displacing each vertex along that direction. This is designed to be used with 2D meshes; using it on meshes with volume or thickness will probably not work.
Arguments:
  • up : Vec3 | Callable | Any - Direction to extrude the mesh. Each vertex will be displaced by this amount. If a callable is provided, it should have signature `|vertex_pos: vec3|: vec3` and return the displacement for each vertex.
  • mesh : Mesh | Any

extrude_pipe

Example
spiral = |count, height_factor, radius, resolution| { 0..count -> |i| { t = i * (1. / resolution) vec3( sin(t) * radius, i * height_factor, cos(t) * radius ) } } spiral(count=400, height_factor=0.1, radius=5.5, resolution=4) | extrude_pipe(radius=0.5, resolution=8, close_ends=true) | render
Example
// demo of `extrude_pipe` with a dynamic radius for each // vertex of the pipe's rings resolution = 12 get_radius = |segment_ix: int, center: vec3| { 0..resolution -> |i| { if segment_ix % 12 < 6 { if i % 2 == 0 { 2 } else { 1 } } else { 0.5 } } } 0..78 -> |i| { vec3(i * 0.15, 0, 0) } | extrude_pipe(resolution=resolution, radius=get_radius) | simplify(tolerance=0.1) | render
extrude_pipe ( radius : Callable | Any | Numeric , resolution : Any | Numeric Int(8) , path : Sequence | Any , close_ends : Bool | Any Bool(true) , connect_ends : Bool | Any Bool(false) , twist : Callable | Any | Numeric Float(0) ) : Mesh
Extrudes a pipe along a sequence of points. The radius can be constant or vary along the path using a callable.
Arguments:
  • radius : Callable | Any | Numeric - Radius of the pipe or a callable with signature `|point_ix: int, path_point: vec3|: float | seq` that returns the radius at each point along the path. If a sequence is returned by the callback, its length must match the resolution and it should contain the distance of each point along the ring from the pipe's center.
  • resolution : Any | Numeric Int(8) - Number of segments to use for the pipe's circular cross-section
  • path : Sequence | Any - Sequence of Vec3 points defining the path of the pipe. Often the output of a function like `bezier3d`.
  • close_ends : Bool | Any Bool(true) - Whether to close the ends of the pipe with triangle fans
  • connect_ends : Bool | Any Bool(false) - Whether the pipe should be a closed loop, connecting the last point back to the first. If true, the first and last points of the path will be connected with triangles.
  • twist : Callable | Any | Numeric Float(0) - Twist angle in radians to apply along the path, or a callable with signature `|point_ix: int, path_point: vec3|: float` that returns the twist angle at each point along the path. A value of 0 means no twist.

fan_fill

Example
// create a path defining the outline of a circle circle_path = 0..100 -> |i| { t = i / 100 vec3(cos(t * pi * 2), 0, sin(t * pi * 2)) } // fill the outline into a flat mesh circle = fan_fill( circle_path, // flip the direction the triangles are facing so that // it is visible when looking from the top down flipped=true ) circle | render
fan_fill ( path : Sequence | Any , closed : Bool | Any Bool(true) , flipped : Bool | Any Bool(false) , center : Vec3 | Nil | Any Nil ) : Mesh
Builds a fan of triangles from a sequence of points, filling the area inside them. One triangle will be built for each pair of adjacent points in the path, connecting them to the center point.
Arguments:
  • path : Sequence | Any - A sequence of Vec3 points representing the path to fill
  • closed : Bool | Any Bool(true) - If true, the path will be treated as closed - connecting the last point to the first.
  • flipped : Bool | Any Bool(false) - If true, the winding order of the triangles generated will be flipped - inverting the inside/outside of the generated mesh.
  • center : Vec3 | Nil | Any Nil - If provided, the center point for the fan will be placed at this position. Otherwise, the center will be computed as the average of the points in the path.

flip_normals

flip_normals ( mesh : Mesh | Any ) : Mesh
Flips the normals of a mesh, returning a new mesh with inverted normals. This actually flips the winding order of the mesh's triangles under the hood and re-computes normals based off that.
Arguments:
  • mesh : Mesh | Any

grid

grid ( size : Vec2 | Any | Numeric , divisions : Vec2 | Any | Numeric Vec2(1, 1) , flipped : Bool | Any Bool(false) ) : Mesh
Generates a flat grid mesh in the XZ plane centered at the origin with the specified size and number of subdivisions.
Arguments:
  • size : Vec2 | Any | Numeric - Size of the grid along the X and Z axes (providing a number will set the same size for both axes). The grid is centered at the origin, so a size of `vec2(1, 1)` will produce a grid that extends from -0.5 to +0.5 along both axes.
  • divisions : Vec2 | Any | Numeric Vec2(1, 1) - Number of subdivisions along each axis. If an integer is provided, it will be used for both axes.
  • flipped : Bool | Any Bool(false) - If true, the winding order of the triangles will be flipped - making the front side face downwards (negative Y).

icosphere

alias: sphere
icosphere ( radius : Any | Numeric , resolution : Any | Numeric ) : Mesh
Generates an icosphere mesh
Arguments:
  • radius : Any | Numeric
  • resolution : Any | Numeric - Number of subdivisions to apply when generating the icosphere. 0 -> 20 faces, 1 -> 80 faces, 2 -> 320 faces, ...

intersect

Example
a = cylinder(radius=6, height=20, radial_segments=20) b = icosphere(radius=10, resolution=5) // only keep the area that exists inside both the sphere // and the cylinder, kind of like cutting out the core // of an apple core = intersect(a, b) // `intersect` also has a dedicated operator. The // following is equivalent to the previous: core = a & b core | render
intersect ( a : Mesh | Any , b : Mesh | Any ) : Mesh
Returns the boolean intersection of two meshes (`a & b`)
Arguments:
  • a : Mesh | Any
  • b : Mesh | Any
intersect ( meshes : Sequence | Any ) : Mesh
Returns the boolean intersection of a sequence of meshes (`meshes[0] & meshes[1] & ...`)
Arguments:
  • meshes : Sequence | Any - Sequence of meshes to intersect

intersects

intersects ( a : Mesh | Any , b : Mesh | Any ) : Bool
Returns true if the two meshes intersect, false otherwise
Arguments:
  • a : Mesh | Any
  • b : Mesh | Any

intersects_ray

Example
// generate a 3D matrix of cubes filling all the space 0..10 -> |y_ix| { y = y_ix - 5 0..10 -> |x_ix| { x = x_ix - 5 0..10 -> |z_ix| { z = z_ix - 5 box(0.9) | trans(x, y, z) } } } | flatten | flatten -> |cube| { has_hit = cube | intersects_ray( ray_origin=v3(-10, -10, -5), ray_direction=vec3(1, 1, 0.5) ) if has_hit { return cube } cube | scale(0.2) | set_material('red') } | render
intersects_ray ( ray_origin : Vec3 | Any , ray_direction : Vec3 | Any , mesh : Mesh | Any , max_distance : Nil | Any | Numeric Nil ) : Bool
Casts a ray from `ray_origin` in `ray_direction` and checks if it intersects `mesh` within `max_distance` (or any distance if `max_distance` is `nil`)
Arguments:
  • ray_origin : Vec3 | Any
  • ray_direction : Vec3 | Any
  • mesh : Mesh | Any
  • max_distance : Nil | Any | Numeric Nil - Max distance to check for intersection (`nil` considers intersections at any distance). If the intersection occurs at a distance greater than this, `false` will be returned.

isotropic_remesh

isotropic_remesh ( target_edge_length : Any | Numeric , mesh : Mesh | Any , iterations : Any | Numeric Int(1) , protect_borders : Bool | Any Bool(true) , protect_sharp_edges : Bool | Any Bool(true) , sharp_angle_threshold_degrees : Any | Numeric Float(30) ) : Mesh
Remeshes a mesh to have more uniform edge lengths, targeting the specified edge length. See the docs for the underlying CGAL function for more details: https://doc.cgal.org/5.6.3/Polygon_mesh_processing/index.html - Section 2.1.2 Remeshing
Arguments:
  • target_edge_length : Any | Numeric - Target edge length for the remeshed output. Edges will be split or collapsed to try to achieve this length.
  • mesh : Mesh | Any
  • iterations : Any | Numeric Int(1) - Number of remeshing iterations to perform. Typical values are between 1 and 5.
  • protect_borders : Bool | Any Bool(true) - If true, edges on the border of the mesh will not be modified.
  • protect_sharp_edges : Bool | Any Bool(true) - If true, edges with angles >= the `sharp_angle_threshold_degrees` will not be modified.
  • sharp_angle_threshold_degrees : Any | Numeric Float(30) - Angle threshold in degrees for edges to be considered sharp. Only used if `protect_sharp_edges` is true.

join

Example
cubes: mesh = 0..10 -> |i| { box(1) | trans(0, i * 1.5, 0) | rot(0, i * 0.2, 0) } | join cubes | render
join ( meshes : Sequence | Any ) : Mesh
Combines a sequence of meshes into one mesh containing all geometry from the inputs. This does NOT perform a boolean union; for that, use the `union` function or the `|` operator to create a union over a sequence of meshes.
Arguments:
  • meshes : Sequence | Any
join ( separator : String | Any , strings : Sequence | Any ) : String
Joins a sequence of strings into a single string, inserting the `separator` between each element
Arguments:
  • separator : String | Any - String to insert between each mesh
  • strings : Sequence | Any - Sequence of strings to join

mesh

Example
// builds a cube mesh from scratch verts = [ v3(-1, -1, -1), v3(1, -1, -1), v3(1, 1, -1), v3(-1, 1, -1), v3(-1, -1, 1), v3(1, -1, 1), v3(1, 1, 1), v3(-1, 1, 1) ] indices = [ 0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 0, 1, 5, 0, 5, 4, 2, 3, 7, 2, 7, 6, 0, 7, 3, 0, 4, 7, 1, 2, 6, 1, 6, 5, ] mesh(verts, indices) | render
mesh ( verts : Sequence | Any , indices : Sequence | Any ) : Mesh
Creates a mesh from a sequence of vertices and indices
Arguments:
  • verts : Sequence | Any - Sequence of Vec3 vertices, pointed into by `faces`
  • indices : Sequence | Any - A flag sequence of integer indices corresponding to triangles. Must have `length % 3 == 0`
mesh ( ) : Mesh
Creates an empty mesh with no vertices or indices. This can be useful as the initial value for `fold` or and other situations like that.

origin_to_geometry

origin_to_geometry ( mesh : Mesh | Any ) : Mesh
Moves the mesh so that its origin is at the center of its geometry (averge of all its vertices), returning a new mesh. This will actually modify the vertex positions and preserve any existing transforms.
Arguments:
  • mesh : Mesh | Any

point_distribute

Example
base = torus_knot_path( radius=12, tube_radius=7, p=3, q=4, point_count=400 ) | extrude_pipe( radius=2, resolution=12, connect_ends=true ) | set_material('base') base | render surface_points = base | point_distribute(count=500) -> |pos: vec3| { icosphere(radius=0.6, resolution=1) | trans(pos) } surface_points | render
point_distribute ( count : Nil | Any | Numeric , mesh : Mesh | Any , seed : Any | Numeric Int(0) , cb : Callable | Nil | Any Nil , world_space : Bool | Any Bool(true) ) : Sequence
Distributes a specified number of points uniformly across the surface of a mesh returned as a sequence. If `cb` is Nil or not provided, a sequence of vec3 positions will be returned. If `cb` is provided, the sequence will consist of the return values from calling `cb(pos, normal)` for each sampled point. This is lazy; the points will not be generated until the sequence is consumed.
Arguments:
  • count : Nil | Any | Numeric - The number of points to distribute across the mesh. If `nil`, returns an infinite sequence.
  • mesh : Mesh | Any
  • seed : Any | Numeric Int(0)
  • cb : Callable | Nil | Any Nil - Optional callable with signature `|point: vec3, normal: vec3|: any`. If provided, this function will be called for each generated point and normal and whatever it returns will be included in the output sequence instead of the point.
  • world_space : Bool | Any Bool(true) - If true, points and normals will be returned in world space. If false, they will be returned in the local space of the mesh.

remesh_planar_patches

remesh_planar_patches ( mesh : Mesh | Any , max_angle_deg : Any | Numeric Float(5) , max_offset : Nil | Any | Numeric Nil ) : Mesh
Remeshes a mesh by identifying planar regions and simplifying them into a simpler set of triangles. This is useful for optimizing meshes produced by a variety of other built-in methods that tend to produce a lot of small triangles in flat areas. See the docs for the underlying CGAL function for more details: https://doc.cgal.org/5.6.3/Polygon_mesh_processing/index.html - Section 2.1.2 Remeshing
Arguments:
  • mesh : Mesh | Any
  • max_angle_deg : Any | Numeric Float(5) - Maximum angle in degrees between face normals for faces to be considered coplanar
  • max_offset : Nil | Any | Numeric Nil - Maximum distance from the plane for faces to be considered coplanar. This is an absolute distance in the mesh's local space. If not provided or set to `nil`, it will default to 1% of the diagonal length of the mesh's bounding box.

rot

rot ( rotation : Vec3 | Any , mesh : Mesh | Any ) : Mesh
Rotates a mesh using a Vec3 of Euler angles (radians)
Arguments:
  • rotation : Vec3 | Any - Rotation defined by Euler angles in radians
  • mesh : Mesh | Any - Mesh to rotate
rot ( x : Any | Numeric , y : Any | Numeric , z : Any | Numeric , mesh : Mesh | Any ) : Mesh
Rotates a mesh using individual Euler angle components in radians
Arguments:
  • x : Any | Numeric - Rotation about X axis (radians)
  • y : Any | Numeric - Rotation about Y axis (radians)
  • z : Any | Numeric - Rotation about Z axis (radians)
  • mesh : Mesh | Any - Mesh to rotate
rot ( rotation : Vec3 | Any , light : Light | Any ) : Light
Rotates a light using a Vec3 of Euler angles (radians)
Arguments:
  • rotation : Vec3 | Any - Rotation defined by Euler angles in radians
  • light : Light | Any - Light to rotate
rot ( x : Any | Numeric , y : Any | Numeric , z : Any | Numeric , light : Light | Any ) : Light
Rotates a light using individual Euler angle components in radians
Arguments:
  • x : Any | Numeric - Rotation about X axis (radians)
  • y : Any | Numeric - Rotation about Y axis (radians)
  • z : Any | Numeric - Rotation about Z axis (radians)
  • light : Light | Any - Light to rotate

sample_voxels

sample_voxels ( dims : Vec3 | Any , cb : Callable | Any , materials : Sequence | Nil | Any Nil , cgal_remesh : Bool | Nil | Any Nil , fill_internal_voids : Bool | Any Bool(false) ) : Mesh |Sequence
Generates a mesh or sequence of meshes by sampling a 3D grid defined by `dims`. For each voxel in the grid, the provided callback will be called with the voxel's coordinate. If the callback returns 0, false, or nil, the voxel will be left empty. If it returns true or any non-zero integer, the voxel will be filled. Values > 1 will use material `n - 1` from the `materials` argument. A separate mesh will be generated for each unique material used. The generated meshes are guaranteed to be 2-manifold/watertight, meaning that they can be further processed by other builtins like `smooth`, `simplify`, CSG (`union`/`intersect`/etc.).
Arguments:
  • dims : Vec3 | Any - The bounds of the voxel grid to sample
  • cb : Callable | Any - A callable with signature `|x_ix: int, y_ix: int, z_ix: int|: bool | int | nil` that will be called for each voxel in the grid. Returning 0, false, or nil will leave the voxel empty. Returning true or any non-zero integer will fill the voxel. Values > 1 will use material `n - 1` from the `materials` argument. The maximum material index is 254.
  • materials : Sequence | Nil | Any Nil - An optional sequence of materials to assign to filled voxels. The first material in the sequence will be used for voxels where the callback returns true or 1, the second material for voxels where the callback returns 2, and so on. If not provided or set to `nil`, all filled voxels will use the default material. The maximum number of materials is 254.
  • cgal_remesh : Bool | Nil | Any Nil - Determines whether the generated mesh(es) will be remeshed using CGAL's `remesh_planar_patches` function. This produces better outputs with fewer faces and vertices, but takes more time to compute. If not provided or set to `nil`, this will be dynamically enabled/disabled for each output mesh depending on its vertex count.
  • fill_internal_voids : Bool | Any Bool(false) - If true, internal voids in the generated meshes will be filled. This can help reduce face/vertex counts, but requires extra computation.

scale

scale ( x : Any | Numeric , y : Any | Numeric , z : Any | Numeric , mesh : Mesh | Any ) : Mesh
Scales a mesh by separate factors along each axis
Arguments:
  • x : Any | Numeric
  • y : Any | Numeric
  • z : Any | Numeric
  • mesh : Mesh | Any
scale ( scale : Vec3 | Any | Numeric , mesh : Mesh | Any ) : Mesh
Scales a mesh
Arguments:
  • scale : Vec3 | Any | Numeric
  • mesh : Mesh | Any

set_default_material

set_default_material ( material : Material | Any ) : Nil
Sets the default material for all meshes that do not have a specific material set
Arguments:
  • material : Material | Any - Can be either a `Material` value or a string specifying the name of an externally defined material

set_material

Example
box(5) | trans(5, 0, 0) // This requires a material called "red" to have been // defined in the material editor for the scene. // // This can be found in the hamburger menu next to the // home button. | set_material('red') | render icosphere(radius=3, resolution=4) | trans(-5, 0, 0) // same for this one | set_material('blue') | render
set_material ( material : String | Material | Any , mesh : Mesh | Any ) : Mesh
Sets the material for a mesh
Arguments:
  • material : String | Material | Any - Can be either a `Material` value or a string specifying the name of an externally defined material
  • mesh : Mesh | Any

set_sharp_angle_threshold

set_sharp_angle_threshold ( angle_degrees : Any | Numeric ) : Nil
Sets the sharp angle threshold for computing auto-smooth-shaded normals (specified in degrees). If the angle between two adjacent faces is greater than this angle, the edge will be considered sharp.
Arguments:
  • angle_degrees : Any | Numeric - The angle at which edges are considered sharp, in degrees

simplify

simplify ( tolerance : Any | Numeric Float(0.01) , mesh : Mesh | Any ) : Mesh
Simplifies a mesh, reducing the number of vertices. Maintains manifold-ness.
Arguments:
  • tolerance : Any | Numeric Float(0.01) - The maximum distance between the original and simplified meshes. 0.01 is a good starting point.
  • mesh : Mesh | Any

smooth

smooth ( mesh : Mesh | Any , type : String | Any String(catmullclark) , iterations : Any | Numeric Int(1) ) : Mesh
Smooths a mesh using the specified algorithm (defaults to catmullclark). More iterations result in a smoother mesh.
Arguments:
  • mesh : Mesh | Any
  • type : String | Any String(catmullclark) - Type of smoothing to perform. Supported values are "catmullclark", "loop", "doosabin", and "sqrt".
  • iterations : Any | Numeric Int(1) - Number of smoothing iterations to perform

split_by_plane

Example
shape = box(10, 5, 10) | union(cyl(radius=4, height=8, radial_segments=40)) pieces: seq = shape | split_by_plane( plane_normal=vec3(1, -1, 1), plane_offset=0 ) pieces = pieces -> |piece: mesh, i: int| { if i == 0 { piece | set_material('red') } else { piece | set_material('blue') | trans(0, 1, 0) } } render(pieces)
split_by_plane ( plane_normal : Vec3 | Any , plane_offset : Any | Numeric , mesh : Mesh | Any ) : Sequence
Splits a mesh by a plane, returning a sequence containing two meshes: the part in front of the plane and the part behind the plane. This will apply all transforms on the mesh, and the returned meshes will have an identity transform.
Arguments:
  • plane_normal : Vec3 | Any - Normal vector of the plane to cut the mesh with
  • plane_offset : Any | Numeric - Offset of the plane from the origin along the plane normal
  • mesh : Mesh | Any

stanford_bunny

alias: bunny
Example
stanford_bunny() | render
stanford_bunny ( ) : Mesh
Generates a Stanford bunny mesh, a well-known 3D model often used in computer graphics as a test object. This mesh IS manifold, so it can be used with functions that require a manifold mesh such as mesh boolean ops, `trace_geodesic_path`, and others.

stitch_contours

Example
example for the `stitch_contours` function
height_segments = 40 resolution = 100 radius = 5 // creates a sequence of contours which encode the profile // of the shape we're building from bottom to top contours = 0..height_segments -> |y_ix| { 0..resolution -> |i| { t = i / resolution // bulge the radius out, but at a different spot // depending on how far up the shape we are radius = radius + sin(y_ix * 0.5 + t * pi * 4) * 4 // construct a path tracing the radius of the shape // at this height, basing it off the parametric // equation for a circle vec3( cos(t * pi * 2) * radius, y_ix * 2.25, sin(t * pi * 2) * radius ) } } // join the contours into a closed 3D mesh by connecting // them with a strip of triangles between each one. contours // default options shown | stitch_contours(closed=true, cap_ends=true) | render
stitch_contours ( contours : Sequence | Any , flipped : Bool | Any Bool(false) , closed : Bool | Any Bool(true) , cap_start : Bool | Any Bool(false) , cap_end : Bool | Any Bool(false) , cap_ends : Bool | Any Bool(false) ) : Mesh
Stitches together a sequence of contours into a single mesh. The contours should be closed loops.
Arguments:
  • contours : Sequence | Any - A `Seq<Seq<Vec3>>`, where each inner sequence contains points representing a contour that will be stitched together into a mesh
  • flipped : Bool | Any Bool(false) - If true, the winding order of the triangles generated will be flipped - inverting the inside/outside of the generated mesh.
  • closed : Bool | Any Bool(true) - If true, the contours will be stitched together as closed loops - connecting the last point to the first for each one.
  • cap_start : Bool | Any Bool(false) - If true, a triangle fan will be created to cap the first contour
  • cap_end : Bool | Any Bool(false) - If true, a triangle fan will be created to cap the last contour
  • cap_ends : Bool | Any Bool(false) - shorthand for `cap_start=true, cap_end=true`

subdivide_by_plane

subdivide_by_plane ( plane_normal : Vec3 | Any , plane_offset : Any | Numeric , mesh : Mesh | Any ) : Sequence
Subdivides a mesh by a plane, splitting all edges and faces that intersect the plane.
Arguments:
  • plane_normal : Vec3 | Any - Normal vector of the plane to cut the mesh with
  • plane_offset : Any | Numeric - Offset of the plane from the origin along the plane normal
  • mesh : Mesh | Any
subdivide_by_plane ( plane_normals : Sequence | Any , plane_offsets : Sequence | Any , mesh : Mesh | Any ) : Sequence
Subdivides a mesh by a sequence of planes, splitting all edges and faces that intersect any of the planes. This is more efficient than repeatedly subdividing by a single plane multiple times.
Arguments:
  • plane_normals : Sequence | Any - Sequence of normal vectors of the planes to cut the mesh with
  • plane_offsets : Sequence | Any - Sequence of offsets of the planes from the origin along the plane normals
  • mesh : Mesh | Any

tessellate

aliases: tess, subdivide
tessellate ( target_edge_length : Any | Numeric , mesh : Mesh | Any ) : Mesh
Tessellates a mesh, splitting edges to achieve a target edge length.
Arguments:
  • target_edge_length : Any | Numeric
  • mesh : Mesh | Any

text_to_mesh

Example
text = text_to_mesh( "Vanadium", font_weight=700, depth=200, font_family="IBM Plex Sans", height=7.5 ) | rot(pi/2, 0, 0) | trans(-21, 1.5, -100); (bunny() | scale(4)) - text | render
text_to_mesh ( text : String | Any , font_family : String | Any String(IBM Plex Sans) , font_size : Any | Numeric Float(24) , font_weight : String | Nil | Any | Numeric Nil , font_style : String | Nil | Any Nil , letter_spacing : Nil | Any | Numeric Nil , width : Nil | Any | Numeric Nil , height : Nil | Any | Numeric Nil , depth : Nil | Any | Numeric Float(0.2) ) : Mesh
Generates a 2D path representing the given text string, triangulates it into a mesh, and optionally extrudes it into 3D. The generated mesh lies in the XZ plane, with Y being the up direction.
Arguments:
  • text : String | Any
  • font_family : String | Any String(IBM Plex Sans) - Font family to use for the text. Must exist on Google Fonts.
  • font_size : Any | Numeric Float(24)
  • font_weight : String | Nil | Any | Numeric Nil
  • font_style : String | Nil | Any Nil - Must be one of "normal", "italic", or "oblique". If nil, defaults to "normal".
  • letter_spacing : Nil | Any | Numeric Nil
  • width : Nil | Any | Numeric Nil - Width of the generated mesh in world units along the X axis. If only one of `width` or `height` is provided, the other dimension will be scaled to maintain the aspect ratio of the text.
  • height : Nil | Any | Numeric Nil - Height of the generated mesh in world units along the Z axis. If only one of `width` or `height` is provided, the other dimension will be scaled to maintain the aspect ratio of the text.
  • depth : Nil | Any | Numeric Float(0.2) - Depth to extrude the text into a 3D mesh. If 0 or nil, will produce a flat 2D mesh in the XZ plane.

trace_geodesic_path

Example
c = cyl(radius=6, height=20, radial_segments=40) // sequence of steps deltas to talk along the surface of // the mesh path = 0..20 -> || v2(3, 1); surface_points: seq = trace_geodesic_path( path, c, full_path=false, start_pos_local_space=v3(10, -8, 0) ) // cut out a cube from the surface of the mesh at each // step of the walk fold( c, |c: mesh, pt: vec3| c - (box(2) + pt), surface_points ) | render // adds a red directional light to better show off the // carved out sections dir_light(intensity=12, color=v3(1,0.3,0.1)) | trans(40, 20, -10) | render
trace_geodesic_path ( path : Sequence | Any , mesh : Mesh | Any , world_space : Bool | Any Bool(true) , full_path : Bool | Any Bool(true) , start_pos_local_space : Vec3 | Nil | Any Nil , up_dir_world_space : Vec3 | Any Vec3(0, 1, 0) ) : Sequence
Traces a geodesic path across the surface of a mesh, following a sequence of 2D points. The mesh must be manifold. Returns a `Seq<Vec3>` of points on the surface of the mesh that were visited during the walk.
Arguments:
  • path : Sequence | Any - A sequence of `Vec2` points representing movements to take across the surface of the mesh relative to the current position. For example, a sequence of `[vec2(0, 1), vec2(1, 0)]` would move 1 unit up and then 1 unit right.
  • mesh : Mesh | Any
  • world_space : Bool | Any Bool(true) - If true, points will be returned in world space. If false, they will be returned in the local space of the mesh.
  • full_path : Bool | Any Bool(true) - This controls behavior when the path crosses between faces in the mesh. If true, intermediate points will be included in the output for whenever the path hits an edge. This can result in the output sequence having more elements than the input sequence, and it will ensure that all generated edges in the output path lie on the surface of the mesh.
  • start_pos_local_space : Vec3 | Nil | Any Nil - If provided, the starting position for the path will be snapped to the surface of the mesh at this position. If `nil`, the walk will start at an arbitrary point on the mesh surface.
  • up_dir_world_space : Vec3 | Any Vec3(0, 1, 0) - When the walk starts, it will be oriented such that the positive Y axis of the local tangent space is aligned as closely as possible with this up direction at the starting position. Another way of saying this is that it lets you set what direction is north when first starting the walk on the mesh's surface.

translate

alias: trans
Example
box(1) | render box(1) | translate(0, 2, 0) | render // you can also use a shorthand for translating meshes box(1) + vec3(2, 0, 0) | render
translate ( translation : Vec3 | Any , mesh : Mesh | Light | Any ) : Mesh
Translates a mesh or light
Arguments:
  • translation : Vec3 | Any
  • mesh : Mesh | Light | Any
translate ( x : Any | Numeric , y : Any | Numeric , z : Any | Numeric , object : Mesh | Light | Any ) : Mesh
Translates a mesh or light
Arguments:
  • x : Any | Numeric
  • y : Any | Numeric
  • z : Any | Numeric
  • object : Mesh | Light | Any

union

union ( a : Mesh | Any , b : Mesh | Any ) : Mesh
Returns the boolean union of two meshes (`a | b`)
Arguments:
  • a : Mesh | Any
  • b : Mesh | Any
union ( meshes : Sequence | Any ) : Mesh
Returns the boolean union of a sequence of meshes (`meshes[0] | meshes[1] | ...`)
Arguments:
  • meshes : Sequence | Any - Sequence of meshes to union

utah_teapot

alias: teapot
Example
utah_teapot() | render
utah_teapot ( ) : Mesh
Generates a Utah teapot mesh, a well-known 3D model often used in computer graphics as a test object. Note that the teapot is NOT manifold, so it cannot be used with functions that require a manifold mesh such as mesh boolean ops, `trace_geodesic_path`, and others.

verts

verts ( mesh : Mesh | Any , world_space : Bool | Any Bool(false) ) : Sequence
Returns a sequence of all vertices in a mesh in an arbitrary order
Arguments:
  • mesh : Mesh | Any
  • world_space : Bool | Any Bool(false) - If true, the vertices will be returned in world space coordinates. If false, they will be returned in the local space of the mesh.

warp

Example
icosphere(radius=8, resolution=4) // the position of each vertex in the mesh is set to // whatever this function returns. | warp(|pos: vec3, normal: vec3| { if pos.y >= 0 { return pos } // elongate and distort the bottom half of the sphere vec3( pos.x + sin(pos.y) * 1.5, pos.y * 2, pos.z + sin(pos.y) * 1.5 ) }) | render // warp also has a dedicated shorthand operator. The // following two statements are equivalent: box(4) | warp(|pos| pos * 2) box(4) -> |pos| pos * 2
warp ( fn : Callable | Any , mesh : Mesh | Any ) : Mesh
Applies a warp function to each vertex of the mesh, returning a new mesh with each vertex transformed by `fn`.
Arguments:
  • fn : Callable | Any - Callable with signature `|pos: vec3, normal: vec3|: vec3`. Given the position and normal of each vertex in the mesh, returns a new position for that vertex in the output mesh.
  • mesh : Mesh | Any

path

bezier3d

alias: bezier
bezier3d ( p0 : Vec3 | Any , p1 : Vec3 | Any , p2 : Vec3 | Any , p3 : Vec3 | Any , count : Any | Numeric ) : Sequence
Generates a sequence of `count` evenly-spaced points along a cubic Bezier curve defined by four control points
Arguments:
  • p0 : Vec3 | Any
  • p1 : Vec3 | Any
  • p2 : Vec3 | Any
  • p3 : Vec3 | Any
  • count : Any | Numeric

lissajous_knot_path

Example
lissajous_knot_path( amp=vec3(18), freq=vec3(3, 5, 7), phase=vec3(0,pi/2,pi/5), count=500 ) | extrude_pipe(radius=1,connect_ends=true, resolution=8) | render
lissajous_knot_path ( amp : Vec3 | Any Vec3(1, 1, 1) , freq : Vec3 | Any Vec3(3, 5, 7) , phase : Vec3 | Any Vec3(0, 1.5707964, 0.62831855) , count : Any | Numeric ) : Sequence
Generates a sequence of points defining a Lissajous knot path
Arguments:
  • amp : Vec3 | Any Vec3(1, 1, 1) - Amplitude of the Lissajous curve in each axis
  • freq : Vec3 | Any Vec3(3, 5, 7) - Frequency of the Lissajous curve in each axis. These should be "pairwise-coprime" integers, meaning that the ratio of any two frequencies should not be reducible to a simpler fraction.
  • phase : Vec3 | Any Vec3(0, 1.5707964, 0.62831855) - Phase offset of the Lissajous curve in each axis
  • count : Any | Numeric - Number of points to sample along the path

superellipse_path

aliases: superellipse, rounded_rectangle, rounded_rect
superellipse_path ( width : Any | Numeric , height : Any | Numeric , n : Any | Numeric , point_count : Any | Numeric ) : Sequence
Generates a sequence of points defining a superellipse, or rounded rectangle. Returns a sequence of `point_count` `Vec2` points
Arguments:
  • width : Any | Numeric
  • height : Any | Numeric
  • n : Any | Numeric - Exponent that controls the shape of the superellipse. A value of 2 produces an ellipse, higher values produce more rectangular shapes, and lower values produce diamond and star-like shapes.
  • point_count : Any | Numeric - Number of points to generate along the path

torus_knot_path

Example
ambient_light(color=0xffffff, intensity=1.8) | render dir_light( color=0xffffff, intensity=5, cast_shadow=true, shadow_map_size={width: 2048*2, height: 2048*2}, shadow_map_radius=4, shadow_map_blur_samples=16, shadow_map_type="vsm", shadow_map_bias=-0.0001, shadow_camera={near: 1, far: 25, left: -20, right: 20, top: 20, bottom: -20}, ) | trans(-10, 10, 0) | render; //-- end prelude path = torus_knot_path( radius=5, tube_radius=2, p=3, q=4, point_count=400 ) path | extrude_pipe(radius=1, resolution=12, connect_ends=true) | simplify(tolerance=0.05) | render
torus_knot_path ( radius : Any | Numeric , tube_radius : Any | Numeric , p : Any | Numeric , q : Any | Numeric , point_count : Any | Numeric ) : Sequence
Generates a sequence of points defining a torus knot path
Arguments:
  • radius : Any | Numeric
  • tube_radius : Any | Numeric
  • p : Any | Numeric - Number of times the knot wraps around the torus in the longitudinal direction
  • q : Any | Numeric - Number of times the knot wraps around the torus in the meridional direction
  • point_count : Any | Numeric - Number of points to generate along the path

rand

curl_noise

Example
noise_scale = 0.001 noise_gain = 0.175 origin_bias = 0.0002 step_size = 0.1 seed_offset = v3(-4) build_path = |count: int| { scan({ dir: normalize(randv(-1, 1)) * 50., pos: v3(0) }, |{ dir, pos }, i| { field_p = seed_offset + pos * noise_scale noise = curl_noise(field_p) dir = dir * 0.9 dir = dir + noise * noise_gain dir = dir + -pos * pow((distance(pos, vec3(0)) * origin_bias), 3) pos = pos + dir * step_size { dir: dir, pos: pos } }, 0..count) -> |{ pos }| pos } paths = 0..800 -> || { build_path(2500) | filter(|_, i| i % 4 == 0) | extrude_pipe(radius=1, resolution=8) } paths | for_each(render) // paths // | flatten // | alpha_wrap(alpha=1/500, offset=1/700) // | simplify(tolerance=0.0125) // | smooth(iterations=1) // | simplify(tolerance=0.0125) // | render
curl_noise ( pos : Vec3 | Any ) : Vec3
Samples 3D curl noise at a given position using default parameters
Arguments:
  • pos : Vec3 | Any
curl_noise ( seed : Any | Numeric Int(0) , octaves : Any | Numeric Int(4) , frequency : Any | Numeric Float(1) , lacunarity : Any | Numeric Float(2) , persistence : Any | Numeric Float(0.5) , pos : Vec3 | Any ) : Vec3
Samples 3D curl noise at a given position using the specified parameters
Arguments:
  • seed : Any | Numeric Int(0)
  • octaves : Any | Numeric Int(4)
  • frequency : Any | Numeric Float(1)
  • lacunarity : Any | Numeric Float(2)
  • persistence : Any | Numeric Float(0.5)
  • pos : Vec3 | Any
curl_noise ( pos : Vec2 | Any ) : Vec2
Samples 2D curl noise at a given position using default parameters
Arguments:
  • pos : Vec2 | Any
curl_noise ( seed : Any | Numeric Int(0) , octaves : Any | Numeric Int(4) , frequency : Any | Numeric Float(1) , lacunarity : Any | Numeric Float(2) , persistence : Any | Numeric Float(0.5) , pos : Vec2 | Any ) : Vec2
Samples 2D curl noise at a given position using the specified parameters
Arguments:
  • seed : Any | Numeric Int(0)
  • octaves : Any | Numeric Int(4)
  • frequency : Any | Numeric Float(1)
  • lacunarity : Any | Numeric Float(2)
  • persistence : Any | Numeric Float(0.5)
  • pos : Vec2 | Any

fbm

Example
grid(size=300, divisions=300) -> |v| { noise = fbm(octaves=8, pos=v*0.01, lacunarity=1.8) vec3(v.x, noise * 36, v.z) } | render
fbm ( pos : Vec3 | Any ) : Float
Samples 3D fractal Brownian motion (FBM) at a given position using default parameters
Arguments:
  • pos : Vec3 | Any
fbm ( seed : Any | Numeric Int(0) , octaves : Any | Numeric Int(4) , frequency : Any | Numeric Float(1) , lacunarity : Any | Numeric Float(2) , persistence : Any | Numeric Float(0.5) , pos : Vec3 | Any ) : Float
Samples 3D fractal Brownian motion (FBM) at a given position using the specified parameters
Arguments:
  • seed : Any | Numeric Int(0)
  • octaves : Any | Numeric Int(4)
  • frequency : Any | Numeric Float(1)
  • lacunarity : Any | Numeric Float(2)
  • persistence : Any | Numeric Float(0.5)
  • pos : Vec3 | Any
fbm ( pos : Vec2 | Any ) : Float
Samples 2D fractal Brownian motion (FBM) at a given position using default parameters
Arguments:
  • pos : Vec2 | Any
fbm ( seed : Any | Numeric Int(0) , octaves : Any | Numeric Int(4) , frequency : Any | Numeric Float(1) , lacunarity : Any | Numeric Float(2) , persistence : Any | Numeric Float(0.5) , pos : Vec2 | Any ) : Float
Samples 2D fractal Brownian motion (FBM) at a given position using the specified parameters
Arguments:
  • seed : Any | Numeric Int(0)
  • octaves : Any | Numeric Int(4)
  • frequency : Any | Numeric Float(1)
  • lacunarity : Any | Numeric Float(2)
  • persistence : Any | Numeric Float(0.5)
  • pos : Vec2 | Any
fbm ( pos : Any | Numeric ) : Float
Samples 1D fractal Brownian motion (FBM) at a given position using default parameters
Arguments:
  • pos : Any | Numeric
fbm ( seed : Any | Numeric Int(0) , octaves : Any | Numeric Int(4) , frequency : Any | Numeric Float(1) , lacunarity : Any | Numeric Float(2) , persistence : Any | Numeric Float(0.5) , pos : Any | Numeric ) : Float
Samples 1D fractal Brownian motion (FBM) at a given position using the specified parameters
Arguments:
  • seed : Any | Numeric Int(0)
  • octaves : Any | Numeric Int(4)
  • frequency : Any | Numeric Float(1)
  • lacunarity : Any | Numeric Float(2)
  • persistence : Any | Numeric Float(0.5)
  • pos : Any | Numeric

randf

randf ( min : Any | Numeric , max : Any | Numeric ) : Float
Returns a random float between `min` and `max`
Arguments:
  • min : Any | Numeric
  • max : Any | Numeric
randf ( ) : Float
Returns a random float between 0. and 1.

randi

randi ( min : Any | Numeric , max : Any | Numeric ) : Int
Returns a random integer between `min` and `max` (inclusive)
Arguments:
  • min : Any | Numeric
  • max : Any | Numeric
randi ( ) : Int
Returns a random integer. Any 64-bit integer is equally possible, positive or negative.

randv

alias: randv3
randv ( min : Vec3 | Any , max : Vec3 | Any ) : Vec3
Returns a random Vec3 where each component is between the corresponding components of `min` and `max`
Arguments:
  • min : Vec3 | Any
  • max : Vec3 | Any
randv ( min : Any | Numeric , max : Any | Numeric ) : Vec3
Returns a random Vec3 where each component is between `min` and `max`
Arguments:
  • min : Any | Numeric
  • max : Any | Numeric
randv ( ) : Vec3
Returns a random Vec3 where each component is between 0. and 1.

ridged_multifractal

ridged_multifractal ( pos : Vec3 | Any ) : Float
Samples 3D ridged multifractal noise at a given position using default parameters
Arguments:
  • pos : Vec3 | Any
ridged_multifractal ( seed : Any | Numeric Int(0) , octaves : Any | Numeric Int(4) , frequency : Any | Numeric Float(1) , lacunarity : Any | Numeric Float(2) , persistence : Any | Numeric Float(0.5) , gain : Any | Numeric Float(2) , pos : Vec3 | Any ) : Float
Samples 3D ridged multifractal noise at a given position using the specified parameters
Arguments:
  • seed : Any | Numeric Int(0)
  • octaves : Any | Numeric Int(4)
  • frequency : Any | Numeric Float(1)
  • lacunarity : Any | Numeric Float(2)
  • persistence : Any | Numeric Float(0.5)
  • gain : Any | Numeric Float(2)
  • pos : Vec3 | Any
ridged_multifractal ( pos : Vec2 | Any ) : Float
Samples 2D ridged multifractal noise at a given position using default parameters
Arguments:
  • pos : Vec2 | Any
ridged_multifractal ( seed : Any | Numeric Int(0) , octaves : Any | Numeric Int(4) , frequency : Any | Numeric Float(1) , lacunarity : Any | Numeric Float(2) , persistence : Any | Numeric Float(0.5) , gain : Any | Numeric Float(2) , pos : Vec2 | Any ) : Float
Samples 2D ridged multifractal noise at a given position using the specified parameters
Arguments:
  • seed : Any | Numeric Int(0)
  • octaves : Any | Numeric Int(4)
  • frequency : Any | Numeric Float(1)
  • lacunarity : Any | Numeric Float(2)
  • persistence : Any | Numeric Float(0.5)
  • gain : Any | Numeric Float(2)
  • pos : Vec2 | Any

set_rng_seed

set_rng_seed ( seed : Any | Numeric ) : Nil
Sets the seed for the shared PRNG used by functions like `randi`, `randf`, etc. This will reset the state of the RNG, so it will always return the same value the next time it's used after this is called.
Arguments:
  • seed : Any | Numeric

worley_noise

alias: worley
worley_noise ( pos : Vec3 | Any , seed : Any | Numeric Int(0) , range_fn : String | Any String(euclidean) , return_type : String | Any String(distance) ) : Float
Samples 3D Worley noise at a given position using default parameters
Arguments:
  • pos : Vec3 | Any
  • seed : Any | Numeric Int(0)
  • range_fn : String | Any String(euclidean) - Distance function used to sample the noise. Must be one of the following: "euclidean" (default), "euclidean_squared", "manhattan", "chebyshev", or "quadratic".
  • return_type : String | Any String(distance) - Flag to control whether distances or values are returned. Must be either "distance" (default) or "value".
worley_noise ( pos : Vec2 | Any , seed : Any | Numeric Int(0) , range_fn : String | Any String(euclidean) , return_type : String | Any String(distance) ) : Float
Samples 2D Worley noise at a given position using the specified parameters
Arguments:
  • pos : Vec2 | Any
  • seed : Any | Numeric Int(0)
  • range_fn : String | Any String(euclidean) - Distance function used to sample the noise. Must be one of the following: "euclidean" (default), "euclidean_squared", "manhattan", "chebyshev", or "quadratic".
  • return_type : String | Any String(distance) - Flag to control whether distances or values are returned. Must be either "distance" (default) or "value".

seq

all

all ( cb : Callable | Any , sequence : Sequence | Any ) : Bool
Returns true if all elements of the sequence make the callback return true
Arguments:
  • cb : Callable | Any - Callable with signature `|x|: bool`
  • sequence : Sequence | Any

any

any ( cb : Callable | Any , sequence : Sequence | Any ) : Bool
Returns true if any element of the sequence makes the callback return true
Arguments:
  • cb : Callable | Any - Callable with signature `|x|: bool`
  • sequence : Sequence | Any

append

alias: push
append ( val : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric , seq : Sequence | Any ) : Sequence
Appends a value to the end of a sequence, returning a new sequence. The old sequence is left unchanged. If the sequence is not eager (as produced by the `collect` function, an array literal, or similar), it will be collected into memory before this happens. Note that this isn't very efficient and requires collecting and/or cloning the underlying sequence. It's better to keep things lazy and use sequences and sequence combinators where possible.
Arguments:
  • val : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric - The value to add to the end of the sequence
  • seq : Sequence | Any - The sequence to which the value should be added

chain

chain ( sequences : Sequence | Any ) : Sequence
Returns a new sequence that concatenates all input sequences. This is lazy and will not evaluate the sequences until the output sequence is consumed.
Arguments:
  • sequences : Sequence | Any - Sequence of sequences to chain together

collect

collect ( sequence : Sequence | Any ) : Sequence
Makes the sequence eager, collecting all elements into memory. This will allow the sequence to indexed with `[]`.
Arguments:
  • sequence : Sequence | Any

filter

filter ( fn : Callable | Any , sequence : Sequence | Any ) : Sequence
Filters a sequence using a predicate function. This is lazy and will not evaluate the function until the output sequence is consumed.
Arguments:
  • fn : Callable | Any - Callable with signature `|x: T, ix: int|: bool`
  • sequence : Sequence | Any - Sequence to filter

first

first ( sequence : Sequence | Any ) : Any
Returns the first element of a sequence, or `Nil` if the sequence is empty.
Arguments:
  • sequence : Sequence | Any

flatten

flatten ( sequence : Sequence | Any ) : Sequence
Flattens a sequence of sequences into a single sequence. Any non-sequence elements are passed through unchanged. Note that only a single level of flattening is performed.
Arguments:
  • sequence : Sequence | Any

fold

fold ( initial_val : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric , fn : Callable | Any , sequence : Sequence | Any ) : Any
Same as `reduce` but with an explicit initial value
Arguments:
  • initial_val : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric
  • fn : Callable | Any - Callable with signature `|acc, x|: acc`
  • sequence : Sequence | Any

fold_while

fold_while ( initial_val : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric , fn : Callable | Any , sequence : Sequence | Any ) : Any
Same as `fold` but with the option early-exiting. If the provided callback returns `nil`, the final state of the accumulator passed into that iteration will be returned.
Arguments:
  • initial_val : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric
  • fn : Callable | Any - Callable with signature `|acc, x|: acc | nil`. If this callback returns `nil`, the final state of the accumulator passed into that iteration will be returned.
  • sequence : Sequence | Any

for_each

for_each ( cb : Callable | Any , sequence : Sequence | Any ) : Nil
Applies the callback to each element of the sequence, returning `nil`. This is useful for running side effects.
Arguments:
  • cb : Callable | Any - Callable with signature `|x|`
  • sequence : Sequence | Any

last

last ( sequence : Sequence | Any ) : Any
Returns the last element of a sequence, or `Nil` if the sequence is empty.
Arguments:
  • sequence : Sequence | Any

map

map ( fn : Callable | Any , sequence : Sequence | Any ) : Sequence
Applies a function to each element of a sequence and returns a new sequence. This is lazy and will not evaluate the function until the output sequence is consumed.
Arguments:
  • fn : Callable | Any - Callable with signature `|x: T, ix: int|: y`
  • sequence : Sequence | Any - Sequence to map over
map ( fn : Callable | Any , mesh : Mesh | Any ) : Mesh
Applies a function to each vertex in a mesh and returns a new mesh with the transformed vertices.
Arguments:
  • fn : Callable | Any - Callable with signature `|vtx: Vec3, normal: Vec3|: Vec3` that will be invoked for each vertex in the new mesh, returning a new position for that vertex
  • mesh : Mesh | Any

reduce

reduce ( fn : Callable | Any , sequence : Sequence | Any ) : Any
Same as `fold` but with the first element of the sequence as the initial value
Arguments:
  • fn : Callable | Any - Callable with signature `|acc, x|: acc`
  • sequence : Sequence | Any - Sequence to reduce

reverse

reverse ( sequence : Sequence | Any ) : Sequence
Returns a new sequence with the elements in reverse order. This is NOT lazy and will evaluate the entire sequence immediately and collect all of its elements into memory.
Arguments:
  • sequence : Sequence | Any

scan

Example
build_smooth_path = |smoothing: num| { // this is essentially applying a low-pass filter dirs = scan( initial=normalize(randv(-1, 1)), fn=|acc, _| { new_dir = mix(1 - smoothing, acc, randv(-1, 1)) normalize(new_dir) }, sequence=0..100 ) scan( initial=vec3(0), fn=|pos, dir| pos + dir, sequence=dirs ) } smooth_path = build_smooth_path(0.75) random_path = build_smooth_path(0) smooth_path | extrude_pipe(radius=0.2, resolution=8) | set_material('red') | render random_path | extrude_pipe(radius=0.2, resolution=8) | set_material('blue') | render
scan ( initial : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric , fn : Callable | Any , sequence : Sequence | Any ) : Sequence
Applies a function cumulatively to the elements of a sequence, returning a new sequence of intermediate results. Similar to the `Iterator::scan` function from Rust, but with a little less freedom in the way it can be used. This is lazy and will not evaluate the function until the output sequence is consumed. NOTE: This function may be subject to change in the future. It would be much better for it to return a tuple to allow de-coupling output sequence values from the retained state.
Arguments:
  • initial : Vec2 | Vec3 | Mesh | Light | Callable | Sequence | Map | Bool | String | Material | Nil | Any | Numeric - Initial value to seed the state with. This value will NOT be included in the output sequence.
  • fn : Callable | Any - Callable with signature `|acc, x, ix|: acc`
  • sequence : Sequence | Any - Sequence to scan

skip

skip ( count : Any | Numeric , sequence : Sequence | Any ) : Sequence
Returns a new sequence with the first `n` elements skipped. If `n` is greater than the length of the sequence, an empty sequence is returned. This is lazy and will not evaluate the sequence until the output sequence is consumed.
Arguments:
  • count : Any | Numeric - Number of elements to skip from the start of the sequence
  • sequence : Sequence | Any - Sequence to skip elements from

skip_while

skip_while ( fn : Callable | Any , sequence : Sequence | Any ) : Sequence
Returns a new sequence with elements skipped from the start of the input sequence until the predicate function returns false. This is lazy and will not evaluate the function until the output sequence is consumed.
Arguments:
  • fn : Callable | Any - Callable with signature `|x|: bool`
  • sequence : Sequence | Any

take

take ( count : Any | Numeric , sequence : Sequence | Any ) : Sequence
Returns a new sequence containing the first `n` elements of the input sequence. If `n` is greater than the length of the sequence, the entire sequence is returned. This is lazy and will not evaluate the sequence until the output sequence is consumed.
Arguments:
  • count : Any | Numeric - Number of elements to take from the start of the sequence
  • sequence : Sequence | Any - Sequence to take elements from

take_while

take_while ( fn : Callable | Any , sequence : Sequence | Any ) : Sequence
Returns a new sequence containing elements from the start of the input sequence until the predicate function returns false. This is lazy and will not evaluate the function until the output sequence is consumed.
Arguments:
  • fn : Callable | Any - Callable with signature `|x|: bool`
  • sequence : Sequence | Any - Sequence to take elements from

str

chars

chars ( s : String | Any ) : Sequence
Returns a sequence of the unicode characters in a string
Arguments:
  • s : String | Any