A LoDModel can be used to create a PineObject in the same way as a normal Model and can be created from a Model. However, the difference is that the LoDModel stores lower quality (fewer polys) versions of the initial Model. It uses the lower quality versions of the model for when the camera is further away to increase the performance, without sacrificing quality when close to the camera.
Creating an LoDModel
-- load pinetree model
local pinetree = Pine3D.loadModel("models/pinetree"):alignBottom():normalizeScaleY()
-- we can easily convert the model to an LoDModel:
-- local pinetreeLoD = pinetree:toLoD()
-- or we can specify settings for the Level of Detail:
local pinetreeLoD = pinetree:toLoD({
minQuality = 0.1, -- default: 0.1 (optional)
variantCount = 5, -- default: 4 (optional)
qualityHalvingDistance = 8, -- default: 5 (optional)
quickInitWorseRuntime = false, -- default: false (optional)
})
-- we create a table for our objects
local objects = {}
-- simply create a new objects with the LoDModel
for i = 1, 100 do -- how many pinetrees
local x = math.random(1, 20)
local z = math.random(1, 20)
local pinetree = ThreeDFrame:newObject(pinetreeLoD, x, 0, z)
objects[i] = pinetree
end
Type: number
(default: 0.1) quality used for the lowest-quality model variant, can't be changed
Type: number
(default: 4) how many new lower-quality variants of the model are used, can't be changed
Type: number
(default: 5) the distance from the camera at which the quality should be halved, can be set to any value at any time
Type: number
(default: false) use the same
CollapsedModel for each variant, making initialization of new
PineObject s nearly instant, but lowers runtime performance quite a bit, can be set to any value at any time
Returns:
void
Name |
Type |
Description |
object |
PineObject |
the object for which to update the model variant of the LoDModel |
camera |
CollapsedCamera |
the camera to use for calculating the distance from the object, used for quality calculation |