# Reference

## Primitives

**Block**

`block(l:number, w:number, h:number): node`

A block with dimension `l`

along the X-axis, `w`

along the Y-axis and `h`

along the Z-axis.

**Wedge**

`wedge(l:number, w:number, h:number): node`

A wedge with dimension `l`

along the X-axis, `w`

along the Y-axis and `h`

along the Z-axis.

**Cylinder**

`cylinder(d:number, h:number): node`

A cylinder with diameter `d`

and heigth `h`

in Z-direction.

**Cone**

`cone(d1:number, d2:number, h:number): node`

A cone with bottom diameter `d1`

, top diameter `d2`

and heigth `h`

in Z-direction.

**Sphere**

`sphere(d:number): node`

A sphere with diameter `d`

centered around the current position.

**Torus**

`torus(d:number, h:number, angle?:number)`

A torus with outer diameter `d`

, tube diameter `h`

and optional angle in degrees.

## Extrusions and sweeps

**Extrude**

`extrude(points:[], h:number)`

Extrusion of profile defined by the array of points along the Z-axis with height `h`

. Each point is defined by an array of two numbers.

**Wall**

`wall(points2D:[], w:number, h:number, options?: {floor:boolean, roof: boolean})`

Wall defined by an array of points in the XY-plane, with wall thickness `w`

and height `h`

and optional option to define if a floor or roof should be added.

**Sweep**

`sweep(points2D:[], angle?:number)`

Sweep of profile defined by the array of points in XY-plane along the X-axis. The angle in degrees is optional.

**Tube**

`tube(points3D:[], d:number)`

Tube through array of 3D points with diameter `d`

.

**Part**

`part(name: string, parameters...)`

Include another object defined by `name`

and optional parameters defined in the first lines of the object.

## Transformations

**Move**

`move(x:number, y:number, z:number)`

Translate the current position along the XYZ-axis. All subsequent objects and transformations will be affected.

**Turn**

`turn(x:number, y:number, z:number)`

Rotate the current position along the XYZ-axis. All subsequent objects and transformations will be affected.

**Scale**

`scale(x:number, y:number, z:number)`

Scale the current position along the XYZ-axis. All subsequent objects and transformations will be affected.

## Combine objects

**Add**

`add(a?: function, b?: function)`

Add two objects defined by optional functions `a()`

and `b()`

. If no arguments are provided the last two objects are added. Example:

`cylinder(10, 20)`

block(10,10)

add()

**Subtract**

`subtract(a?: function, b?: function)`

Subtract object defined by functions `b()`

from object defined by function `a()`

. If no arguments are provided the last objects is subtracted from the previous object. Example:

`function a(size) {`

block(size, size, size)

}

const b = () => {

move(5, 0, 5)

color("red")

sphere(10)

cylinder(10, 20)

}

subtract(a(15), b())

**Intersect**

`intersect(a?: function, b?: function)`

Take the common part of two objects defined by optional functions `a()`

and `b()`

. If no arguments are provided the last two objects are united.
Example:

`{`

block(10, 10, 10);

}

{

move(4, 0, 5);

color(10027008);

cylinder(8, 10);

}

intersect();

**Hull**

`hull(a?:function)`

Create a convex hull that encloses the geometry. If no arguments are provided the geometry of the last object is used. Example:

`{`

cylinder(15, 10);

move(30, 0, 0);

cylinder(5, 2);

}

hull();

## Materials

**Color**

`color(color: string)`

Set the current color. The color can be a named color like 'red' or a hexadecimal value such as `#ff0000`

**Transparency**

`transparency(transparency: number)`

Set the current transparency to a value between `0`

and `100`

. A high value is more transparent.

**Shininess**

`shininess(shininess: number)`

Set the current shininess to a value between `0`

and `100`

. A high value is more glossy.

**Emissive**

`emissive(emissive: number)`

Set the current emission of light of the object to a value between `0`

and `100`

. A high value radiates more light.

**Texture**

`texture(name: string, s?: number, t?: number)`

Apply the texture defined by `name`

to the following objects. Optionally specify the number of repetitions in both directions with `s`

and `t`

.

## Lighting

**Light**

`light(type: 'ambient' | 'point' |'spot', options: { color?: string, intensity?: number, power?: number, position?: [number, number, number], target?: [number, number, number], angle?:number)`

When you add a light to the scene this replaces the default lighting settings. You can combine multiple lights in a single scene. The `position`

is only applicable for `point`

and `spot`

lights. For `spot`

lights you can define the `target`

point to which the light is aimed and the `angle`

of the light beam in degrees. Examples:

`light('ambient', {color: 'red', intensity: 3})`

light('point', {color: '#FFFF00', intensity: 1, position: [10,3,20]})

light('spot', {color: '#FFFF00', intensity: 1, position: [30,10,20], target:[0,0,5], angle: 10})

## Animation

**Animate**

`animate(keyframe:[], options?: {type: "rotate"|"translate"})`

Animate the last object using an array of keyframe. Each keyframe is an array of 4 numbers where this first number is the time defined in seconds and the following three numbers the 3D position or rotation at that time. Example:

`{`

block(10,10,10)

cylinder(10, 50)

}

animate([[1, 0, 0,10],[2, 0, 10,10]], {type: 'translate'})