improve runtimeloader for glb files
This commit is contained in:
@@ -35,19 +35,26 @@ func load_gltf(file, parent = self, hasCollision = false, trimesh = false):
|
|||||||
|
|
||||||
print("Loading ", EXTERNAL_PATH + file)
|
print("Loading ", EXTERNAL_PATH + file)
|
||||||
var node = gltf.generate_scene(gltf_state)
|
var node = gltf.generate_scene(gltf_state)
|
||||||
|
parent.add_child(node)
|
||||||
|
|
||||||
|
|
||||||
var entity_count = 0;
|
var entity_count = 0;
|
||||||
|
if not hasCollision:
|
||||||
|
get_all_entities(node)
|
||||||
|
return node
|
||||||
|
|
||||||
for o in get_all_children(node):
|
for o in get_all_children(node):
|
||||||
if o.name.begins_with("entity_") && not o.name.ends_with("_geometry"):
|
if o.name.begins_with("entity_") && not o.name.ends_with("_geometry"):
|
||||||
print("Loading entity ", o.name)
|
print("Loading entity ", o.name)
|
||||||
if loadEntity(o):
|
if loadEntity(o):
|
||||||
entity_count += 1;
|
entity_count += 1;
|
||||||
elif o is MeshInstance3D:
|
|
||||||
if hasCollision:
|
if o is MeshInstance3D:
|
||||||
if(trimesh):
|
if(trimesh):
|
||||||
o.create_trimesh_collision()
|
o.create_trimesh_collision()
|
||||||
else:
|
else:
|
||||||
o.create_convex_collision()
|
o.create_convex_collision()
|
||||||
parent.add_child(node)
|
|
||||||
if(entity_count > 0):
|
if(entity_count > 0):
|
||||||
print("Loaded ", entity_count, " entities.")
|
print("Loaded ", entity_count, " entities.")
|
||||||
return node
|
return node
|
||||||
|
|||||||
Reference in New Issue
Block a user