Skip to content

3D Primitives

3D primitive methods allow you to render simple geometric shapes directly into a display’s 3D scene.

Before drawing 3D objects, ensure that the display camera has been configured using setupCamera.

Method
clear3D(displayId : DisplayID) : ()
drawCube(displayId : DisplayID, x : number, y : number, z : number, size : number, rotX : number, rotY : number, rotZ : number, r : number, g : number, b : number) : ()
drawPyramid(displayId : DisplayID, x : number, y : number, z : number, size : number, rotX : number, rotY : number, rotZ : number, r : number, g : number, b : number) : ()
drawSphere(displayId : DisplayID, x : number, y : number, z : number, radius : number, segments : number, r : number, g : number, b : number, textureNameObj : table) : ()

Clears all 3D rendering state for the display.

Use this when resetting a 3D scene.

Requires: DisplayID

gpu.clear3D(displayId)

Draws a colored cube in 3D space.

Rotation values are specified in degrees:

  • rotX - rotation around the X axis
  • rotY - rotation around the Y axis
  • rotZ - rotation around the Z axis

Requires: DisplayID, position, size, rotation, and RGB color values.

gpu.drawCube(
displayId,
0,
0,
0,
2,
0,
45,
0,
255,
100,
100
)

Draws a colored pyramid in 3D space.

Rotation values are specified in degrees:

  • rotX - rotation around the X axis
  • rotY - rotation around the Y axis
  • rotZ - rotation around the Z axis

Requires: DisplayID, position, size, rotation, and RGB color values.

gpu.drawPyramid(
displayId,
0,
0,
0,
2,
0,
45,
0,
255,
255,
0
)

Draws a sphere in 3D space.

The segments parameter controls sphere detail:

  • lower values use fewer polygons and render faster
  • higher values create smoother spheres but require more rendering work

textureNameObj is used for texture-related rendering if supported.

Requires: DisplayID, position, radius, segments, RGB color values, texture object.

gpu.drawSphere(
displayId,
0,
0,
0,
1,
16,
100,
180,
255,
nil
)