You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
889 B
GDScript

2 years ago
@tool
extends Node3D
class_name MeshLib
var block_full = preload("res://resource/mesh_library/block_full.tscn")
var block_half = preload("res://resource/mesh_library/block_half.tscn")
var block_empty = preload("res://resource/mesh_library/block_empty.tscn")
func add(file_name_full:String,file_name:String):
if not file_name.ends_with(".vox"):
return
var resource_name = file_name.trim_suffix('.vox')
if find_child(resource_name,false,false):
return
var template:MeshInstance3D
if file_name.begins_with("f_"):
template = block_full.instantiate() as MeshInstance3D
elif file_name.begins_with("h_"):
template = block_half.instantiate() as MeshInstance3D
else:
template = block_empty.instantiate() as MeshInstance3D
var mesh = load(file_name_full) as Mesh
template.name = resource_name
template.mesh = mesh
add_child(template)
2 years ago
template.owner = self
2 years ago
print(file_name)