Skip to main content

3D objects


Image3D


A plane with an image texture applied.

image3d = ObjectFactory.Image3D(
"../assets/sprites/explosion_a.png", -- file path
Vertex3D.new(10, 10, 10), -- position
150, -- width
200 -- height
)

Mesh3D


A 3D model that includes geometry and textures.

ObjectFactory.Mesh3D(
"../assets/models/Capsule.fbx", -- file path
Vertex3D.new(x, y, z) -- position
)

Mesh3D objects provide some advanced features, such as Grid3D and Octrees, which will be covered in the scripting chapter.

Mesh3DAnimation


An animated 3D model loaded from an FBX file containing skeletal animations.

man = ObjectFactory.Mesh3DAnimation(
"../assets/animations/walking.fbx", -- file path
Vertex3D.new(0, -10, 40) -- position
)

Mesh3DAnimation Methods

MethodParametersReturnDescription
setIndexCurrentAnimation()int indexvoidChanges the active animation by index
setAnimationByName()string namevoidChanges the active animation by name
setAnimationSpeed()float speedvoidSets playback speed (0.0 - 1.0)
isAnimationEnds()-boolReturns true if the current animation has finished
setLoop()bool loopvoidEnables or disables animation looping
isLoop()-boolReturns whether the animation loops

Change Current Animation

If the model contains more than one animation, the first one will be selected by default. You can choose a different active animation from the GUI or via LUA scripts:

man:setIndexCurrentAnimation(2)                         -- change animation by index
man:setAnimationByName("Run") -- change animation by name

Change Animation Speed

To modify the animation playback speed:

man:setAnimationSpeed(0.5)                              -- 50% speed
man:setAnimationSpeed(1.0) -- normal speed

Animation Looping and Completion

man:setLoop(false)                                      -- disable looping

function onUpdate()
if man:isAnimationEnds() then
print("Animation finished!")
man:setIndexCurrentAnimation(0) -- switch to idle
end
end

Drawing Lines


You can draw 3D lines using the Render component.

Components:Render():DrawLine(
this:getPosition(), -- from position
this:getPosition() + this:AxisUp():getScaled(2) -- to position
)