From 5dcf778b31d2b85cc448406291624ed606beebb6 Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Thu, 12 Mar 2020 22:08:32 +0900 Subject: [PATCH] Add feature to repace mesh.primitive.indices accessor. --- examples/mesh-conv/sandbox/replace_attrib.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/mesh-conv/sandbox/replace_attrib.py b/examples/mesh-conv/sandbox/replace_attrib.py index 3318f6d..c3afc6e 100644 --- a/examples/mesh-conv/sandbox/replace_attrib.py +++ b/examples/mesh-conv/sandbox/replace_attrib.py @@ -5,6 +5,7 @@ import json import sys, os +replace_indices = False attrib_names = ["TEXCOORD_0"] def check_accessor(src, target): @@ -70,9 +71,18 @@ def main(): source_mesh = gltf["meshes"][source_mesh_id] target_mesh = gltf["meshes"][target_mesh_id] + source_prim = source_mesh["primitives"][source_primid] target_prim = target_mesh["primitives"][target_primid] + if replace_indices: + target_indices_id = target_prim["indices"] + src_indices_id = source_prim["indices"] + + print("Replace vertex indices from {} to {}".format(target_indices_id, src_indices_id)) + gltf["meshes"][target_mesh_id]["primitives"][target_primid]["indices"] = gltf["meshes"][source_mesh_id]["primitives"][source_primid]["indices"] + + for attrib in target_prim["attributes"]: print("attrib ", attrib) if attrib in attrib_names: