From 40d73f259012fc83ee347a7728df552e816af193 Mon Sep 17 00:00:00 2001 From: kookroach Date: Tue, 3 Jan 2023 23:28:43 +0100 Subject: [PATCH] improve runtimeloader for glb files --- scripts/utils/runtimeloader.gd | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/utils/runtimeloader.gd b/scripts/utils/runtimeloader.gd index 4e1bcb2..7055aca 100644 --- a/scripts/utils/runtimeloader.gd +++ b/scripts/utils/runtimeloader.gd @@ -35,19 +35,26 @@ func load_gltf(file, parent = self, hasCollision = false, trimesh = false): print("Loading ", EXTERNAL_PATH + file) var node = gltf.generate_scene(gltf_state) + parent.add_child(node) + + var entity_count = 0; + if not hasCollision: + get_all_entities(node) + return node + for o in get_all_children(node): if o.name.begins_with("entity_") && not o.name.ends_with("_geometry"): print("Loading entity ", o.name) if loadEntity(o): entity_count += 1; - elif o is MeshInstance3D: - if hasCollision: - if(trimesh): - o.create_trimesh_collision() - else: - o.create_convex_collision() - parent.add_child(node) + + if o is MeshInstance3D: + if(trimesh): + o.create_trimesh_collision() + else: + o.create_convex_collision() + if(entity_count > 0): print("Loaded ", entity_count, " entities.") return node