aboutsummaryrefslogtreecommitdiff
path: root/scripts/load_shapes.gd
blob: 308f11164d16cdc6b7d6ce9090c4dec64bddc2f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
extends Node

var saveload : Node
var models : Dictionary

var loaded = false
signal done_loading
	
func get_saveload():
	if saveload == null: saveload = get_tree().root.get_node("world").get_node("saveload")
	
func _ready():
	get_saveload()
	load_models()
	emit_signal("done_loading")
	loaded = true
	
func load_models():
	models = {}
	var dir = Directory.new()
	dir.open("res://assets/models/shapes")
	dir.list_dir_begin(true)
	var shape = dir.get_next()
	while shape != "":
		if (shape.ends_with(".glb")):
			var model = load("res://assets/models/shapes/" + shape)
			var sname = shape.substr(0, shape.length()-4)
			models[sname] = model
		shape = dir.get_next()