-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathomi_spawn_point.gd
36 lines (28 loc) · 1.13 KB
/
omi_spawn_point.gd
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
30
31
32
33
34
35
36
@tool
class_name GLTFDocumentExtensionOMISpawnPoint
extends GLTFDocumentExtension
func _import_preflight(_state: GLTFState, extensions: PackedStringArray) -> Error:
if extensions.has("OMI_spawn_point"):
return OK
return ERR_SKIP
func _get_supported_extensions() -> PackedStringArray:
return PackedStringArray(["OMI_spawn_point"])
func _import_node(_state: GLTFState, _gltf_node: GLTFNode, json: Dictionary, node: Node) -> Error:
if not json.has("extensions"):
return OK
var extensions = json.get("extensions")
if not extensions is Dictionary:
printerr("Error: GLTF file is invalid, extensions should be a Dictionary.")
return ERR_FILE_CORRUPT
if not extensions.has("OMI_spawn_point"):
return OK
var spawn_point = extensions.get("OMI_spawn_point")
if not spawn_point is Dictionary:
printerr("Error: OMI_spawn_point extension should be a Dictionary.")
return ERR_FILE_CORRUPT
node.set_meta(&"OMI_spawn_point", spawn_point)
return OK
func _import_post(state: GLTFState, root: Node) -> Error:
# The true doesn't actually matter, we later just check if the key exists.
root.set_meta(&"has_omi_spawn_points", true)
return OK