A Model is defined as a number indexed table containing one or more elements of type Polygon.

Generate simple models

If you wish to generate simple models, such as a cube, sphere, icosphere, plane, or mountains, visit the ModelGenerator page.

Loading .obj models

If you wish to create or load .obj models, please take a look at the Creating Models guide.

Transforms

Any of the Model methods can be used to make changes to the Model
-- load pineapple model
local pineapple = Pine3D.loadModel("models/pineapple")

-- set the outline to green for lime polygons
pineapple = pineapple:setOutline({
  [colors.lime] = colors.green,
})

-- these can be chained as well:
pineapple = pineapple:rotate(math.pi*0.5):scale(2):mapColor({
  [colors.yellow] = colors.lightBlue,
  [colors.orange] = colors.pink,
})

-- simply create a new object using the created model
local pineappleObject = ThreeDFrame:newObject(pineapple, 0, 0, 0)


Model:
invertTriangles()

Returns: model with polygons facing the other direction: Model

Model:
setOutline(options)

Returns: new model with changed outline colors: Model
Name Type Description
options color or table if color, will set the outline color for each polygon. If table, it is a mapping of triangle colors to the outline color they should have

Model:
mapColor(options)

Returns: new model with updated colors: Model
Name Type Description
options color or table if color, will set the color for each polygon. If table, it is a mapping of triangle colors to the color they should have

Model:
center()

Returns: new centered model: Model

Model:
normalizeScale()

Returns: new model: Model

Model:
normalizeScaleY()

Returns: new model: Model

Model:
scale(scale)

Returns: new model: Model
Name Type Description
scale number factor to scale the model with

Model:
translate(dx, dy, dz)

Returns: new model: Model
Name Type Description
dx number translation amount for the x-axis (optional)
dy number translation amount for the y-axis (optional)
dz number translation amount for the z-axis (optional)

Model:
rotate(rotX, rotY, rotZ)

Returns: new model: Model
Name Type Description
rotX number rotation around the x-axis (optional, radians)
rotY number rotation around the y-axis (optional, radians)
rotZ number rotation around the z-axis (optional, radians)

Model:
alignBottom()

Returns: new model: Model

Model:
decimate(quality, mode)

Returns: model with reduced quality: Model
Name Type Description
quality number ratio of polys to keep if mode is "ratio", number of polys to reduce to if mode is "polys"
mode number "ratio" / "polys", (optional) default: ratio

Model:
toLoD(options (optional))

Returns: model that can render at lower quality further away from the camera: LoDModel
Name Type Description
options (optional) table Default values: {minQuality: number = 0.1, variantCount: number = 4, qualityHalvingDistance: number = 5, quickInitWorseRuntime: boolean = false}