-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug_glb_export.gd
More file actions
34 lines (29 loc) · 1.43 KB
/
Copy pathdebug_glb_export.gd
File metadata and controls
34 lines (29 loc) · 1.43 KB
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
## Debug: build a character, export to GLB, re-import and count meshes.
extends SceneTree
func _init() -> void:
call_deferred("_run")
func _run() -> void:
var recipe := SKRecipe.load_from_file("res://synty_assets/characters/Starter_01.sk")
var library := SKPartLibrary.new()
library.scan()
var colors := SKColorEngine.new()
colors.setup()
var builder := SKCharacterBuilder.new(library, colors)
var character := builder.build(recipe)
print("meshes in character: %d" % character.find_children("*", "MeshInstance3D", true, false).size())
# Try export exactly like the dock does (node not in tree).
var document := GLTFDocument.new()
var state := GLTFState.new()
var error := document.append_from_scene(character, state)
print("append (out of tree): %s, state meshes: %d, nodes: %d" % [error_string(error), state.meshes.size(), state.nodes.size()])
# Try again with the node inside the tree.
root.add_child(character)
var document2 := GLTFDocument.new()
var state2 := GLTFState.new()
var error2 := document2.append_from_scene(character, state2)
print("append (in tree): %s, state meshes: %d, nodes: %d" % [error_string(error2), state2.meshes.size(), state2.nodes.size()])
if error2 == OK:
error2 = document2.write_to_filesystem(state2, "user://debug_export.glb")
print("write: %s size: %d" % [error_string(error2), FileAccess.get_file_as_bytes("user://debug_export.glb").size()])
quit(0)
# (appended check runs via separate script below)