Fix: 3D model loading for units/tiles + tile model server pipeline

- ModelCache: switch GLTFDocument.append_from_buffer (was append_from_file
  which returned ERR_BUSY/43); validate GLB magic bytes; explicit signal
  disconnect before queue_free to avoid freed-lambda errors
- ContentCache: add tile model fetch (content.tile_models), disk cache at
  user://content/tile_models.json, get_tile_model_url() API
- game_screen: _add_tile now loads tile CDN model via ModelCache when bound
- Server: ContentGetTileModelsHandler (content.tile_models msg), registered
  in ServiceRegistration; TileModelDto / GetTileModelsResponse added to
  ContentMessages

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:
dingo
2026-03-09 13:34:17 -04:00
co-authored by Claude Happy
parent e815dd708f
commit 6dda0edf17
7 changed files with 200 additions and 32 deletions
@@ -408,6 +408,7 @@ func _add_tile(x: int, y: int, affinity: String) -> void:
shape.shape = box
body.add_child(shape)
# Placeholder: affinity-coloured flat box, swapped out if a 3D model loads.
var mi := MeshInstance3D.new()
var bm := BoxMesh.new()
bm.size = Vector3(0.98, 0.5, 0.98)
@@ -421,6 +422,29 @@ func _add_tile(x: int, y: int, affinity: String) -> void:
_tiles_root.add_child(body)
_tile_bodies["%d,%d" % [x, y]] = body
# ── Try to load a 3D tile model for this affinity ──────────────────────
var model_url := ContentCache.get_tile_model_url(affinity, "Square")
if model_url.is_empty():
return
ModelCache.load_model(model_url, func(model_node: Node3D) -> void:
if not is_instance_valid(body):
if model_node != null:
model_node.queue_free()
return
if model_node == null:
return
# Remove the placeholder MeshInstance3D.
for child in body.get_children():
if child is MeshInstance3D:
child.queue_free()
# Tile body sits at wp + (0, 0.25, 0); model should author its
# centre at y = 0 so it fills the same space as the box placeholder.
body.add_child(model_node)
)
func _update_tile_affinity(x: int, y: int, affinity: String) -> void:
var body = _tile_bodies.get("%d,%d" % [x, y])