Model
EditModels are 3D model assets loaded from files. Currently, OBJ, glTF, and binary STL files are supported.
A model can be drawn using Pass:draw
.
The raw CPU data for a model is held in a ModelData
object, which can be loaded on threads or reused for multiple Model instances.
Models have a hierarchy of nodes which can have their transforms modified. Meshes are attached to these nodes. The same mesh can be attached to multiple nodes, allowing it to be drawn multiple times while only storing a single copy of its data.
Models can have animations. Animations have keyframes which affect the transforms of nodes. Right now each model can only be drawn with a single animated pose per frame.
Models can have materials, which are collections of properties and textures that define how its surface is affected by lighting. Each mesh in the model can use a single material.
Constructors
lovr.graphics.newModel | Create a new Model. |
lovr.headset.newModel | Get a Model for a device. |
Methods
Model:animate | Animate the Model. |
Model:clone | Return a lightweight copy of the Model with its own animation state. |
Model:getAnimationCount | Get the number of animations in the Model. |
Model:getAnimationDuration | Get the duration of an animation in the Model. |
Model:getAnimationName | Get the name of an animation in the Model. |
Model:getBlendShapeCount | Get the number of blend shapes in the model. |
Model:getBlendShapeName | Get the name of a blend shape in the model. |
Model:getBlendShapeWeight | Get the weight of a blend shape. |
Model:getBoundingBox | Get the bounding box of the Model. |
Model:getBoundingSphere | Get the bounding sphere of the Model. |
Model:getCenter | Get the center of the Model's bounding box. |
Model:getData | Get the ModelData backing the Model. |
Model:getDepth | Get the depth of the Model. |
Model:getDimensions | Get the dimensions of the Model. |
Model:getHeight | Get the height of the Model. |
Model:getIndexBuffer | Get a Buffer containing the triangle indices in the Model. |
Model:getMaterial | Get a Material from the Model. |
Model:getMaterialCount | Get the number of materials in the Model. |
Model:getMaterialName | Get the name of a material in the Model. |
Model:getMesh | Get a Mesh from the Model. |
Model:getMeshCount | Get the number of meshes in the Model. |
Model:getMetadata | Get extra information from the model file. |
Model:getNodeChildren | Get the children of a node. |
Model:getNodeCount | Get the number of nodes in the model. |
Model:getNodeName | Get the name of a node in the Model. |
Model:getNodeOrientation | Get the orientation of a node. |
Model:getNodeParent | Get the parent of a node. |
Model:getNodePose | Get the pose of a node. |
Model:getNodePosition | Get the position of a node. |
Model:getNodeScale | Get the scale of a node. |
Model:getNodeTransform | Get the transform of a node. |
Model:getRootNode | Get the index of the root node. |
Model:getTexture | Get one of the textures in the Model. |
Model:getTextureCount | Get the number of textures in the Model. |
Model:getTriangleCount | Get the total number of triangles in the Model. |
Model:getTriangles | Get all the triangles in the Model. |
Model:getVertexBuffer | Get a Buffer containing the vertices in the Model. |
Model:getVertexCount | Get the total vertex count of the Model. |
Model:getWidth | Get the width of the Model. |
Model:hasJoints | Check if the Model uses joints for skeletal animation. |
Model:resetBlendShapes | Reset blend shape weights. |
Model:resetNodeTransforms | Reset node transforms. |
Model:setBlendShapeWeight | Set the weight of a blend shape. |
Model:setNodeOrientation | Set or blend the orientation of a node. |
Model:setNodePose | Set or blend the pose of a node. |
Model:setNodePosition | Set or blend the position of a node. |
Model:setNodeScale | Set or blend the scale of a node. |
Model:setNodeTransform | Set or blend the transform of a node. |