model/gltf: mesh.extras.targetNames from and to glTF mesh extras; ops/MeshOps.merge: targets = true concatenates morph targets by name

This commit is contained in:
4DBug committed 2026-11-02 21:53:22 -06:00
1 parent 835ddde65b
commit 4231149f3e
6 files changed
+148 -2

No files matched your search

+5
View File
@@ -229,6 +229,11 @@ do
t:check(#skin.animations == 1 and skin.animations[1].channels[1].path == "rotation", "skin animation")
local morph = load("SimpleMorph/glTF")
t:check(#morph.meshes[1].primitives[1].targets == 2 and morph.meshes[1].weights[1] == 0.5, "morph targets, weights")
-- mesh.extras.targetNames: written as glTF mesh extras, read back from them
morph.meshes[1].extras = { targetNames = { "first", "second" } }
local named = decode(Gltf.encode(morph, { binary = true }) :: buffer) :: any
local tn = named and named.meshes[1].extras and named.meshes[1].extras.targetNames
t:check(tn and tn[1] == "first" and tn[2] == "second", "targetNames round trip")
local q = load("AnimatedMorphCube/glTF-Quantized")
local qp = q.meshes[1].primitives[1]
t:check(qp.attributes.NORMAL.type == "snorm8" and qp.targets and qp.targets[1].POSITION.type == "i16", "quantized normals / target deltas")