Fix: ModelCache gives actionable error when OBJ/non-GLB file is loaded
Shows the first 20 printable bytes and explains that only binary .glb is supported at runtime, with a Blender re-export hint. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -134,11 +134,19 @@ func _download(url: String, disk: String) -> void:
|
||||
# Parse GLB/GLTF bytes using GLTFDocument.append_from_buffer.
|
||||
# Returns a PackedScene ready for instantiation, or null on failure.
|
||||
func _parse_gltf(data: PackedByteArray) -> PackedScene:
|
||||
# Validate GLB magic bytes ("glTF").
|
||||
# Validate GLB magic bytes ("glTF" = 0x46546C67 little-endian).
|
||||
if data.size() >= 4:
|
||||
var magic := data.decode_u32(0)
|
||||
if magic != 0x46546C67: # little-endian "glTF"
|
||||
push_warning("ModelCache: not a GLB file (bad magic 0x%X)" % magic)
|
||||
if magic != 0x46546C67:
|
||||
# Try to give a human-readable diagnosis.
|
||||
var preview := ""
|
||||
for i in mini(20, data.size()):
|
||||
var b := data[i]
|
||||
preview += char(b) if b >= 0x20 and b < 0x7F else "."
|
||||
push_warning(
|
||||
"ModelCache: not a GLB file — expected 'glTF' magic, got 0x%X ('%s'). " \
|
||||
+ "Only binary .glb format is supported at runtime. " \
|
||||
+ "Re-export from Blender as glTF 2.0 Binary (.glb)." % [magic, preview])
|
||||
return null
|
||||
|
||||
var doc := GLTFDocument.new()
|
||||
|
||||
Reference in New Issue
Block a user