
Publisher
martcarrefour
MeshLibraryFrameInstance3D 3D
MeshLibraryFrameInstance3D is a Godot plugin that extends MeshInstance3D, enabling easy management of 3D meshes from a MeshLibrary. It allows users to switch between mesh frames dynamically using the current_frame property, making it perfect for animations or scenarios where frame-by-frame 3D model changes are needed.
This plugin has been mirrored from the Godot Asset Library.
The plugin author is in no way affiliated with Gadget.
If you are the author of this plugin and would like this mirror removed, please contact support@gadgetgodot.com.
MeshLibraryFrameInstance3D
MeshLibraryFrameInstance3D is a custom Godot class extending MeshInstance3D, designed to manage and display individual mesh frames from a MeshLibrary resource. This component is ideal for applications that need to dynamically select and render specific meshes from a collection by specifying an index.
Features
- Dynamically select and display a specific mesh from a
MeshLibrary. - Simplifies the process of managing multiple meshes within a
MeshLibrary. - Provides an easy interface for cycling through or displaying different 3D models.
Installation
- Download or clone the repository containing the
MeshLibraryFrameInstance3Dscript. - Place the script in your Godot project under the appropriate directory (e.g.,
scripts/).
Usage
Properties
mesh_library(MeshLibrary): The resource that contains the collection of mesh frames. Setting this property will initialize the first mesh in the library.current_frame(int): The index of the currently displayed mesh frame within theMeshLibrary. Changing this property will update the mesh instance to display the corresponding mesh.mesh_size(int): The total number of mesh frames available in the currentMeshLibrary. This is automatically updated when a newMeshLibraryis set.
Methods
_set_mesh_library(frames: MeshLibrary) -> void
Sets theMeshLibraryresource and initializes the first mesh frame.- If the provided
MeshLibraryis null, the mesh count is reset to 0, and the displayed mesh is cleared. - Otherwise, it retrieves the list of meshes from the
MeshLibraryand sets the first item as the current mesh.
- If the provided
_get_mesh_library() -> MeshLibrary
Returns the currentMeshLibraryresource._set_current_frame(frame: int) -> void
Sets the current frame index and updates the displayed mesh accordingly.- This function checks if the provided index is within the valid range (i.e., between 0 and
mesh_size - 1). If the index is valid, it updates the current frame and sets the corresponding mesh from theMeshLibrary.
- This function checks if the provided index is within the valid range (i.e., between 0 and
_get_current_frame() -> int
Returns the index of the currently displayed mesh frame.
Example
Here's a simple example of how you might use MeshLibraryFrameInstance3D in your Godot project:
@tool
extends MeshLibraryFrameInstance3D
func _ready():
var my_mesh_library = preload("res://path_to_your_mesh_library.meshlib")
mesh_library = my_mesh_library
current_frame = 0 # Start with the first mesh in the library
# Cycle through the meshes
for i in range(mesh_size):
set_current_frame(i)
yield(get_tree().create_timer(1.0), "timeout")