From edaace4a0db6d714244a4b6dd0580e731fcd5c86 Mon Sep 17 00:00:00 2001 From: IzzyBoris Date: Sat, 30 Mar 2024 23:14:45 -0400 Subject: [PATCH] Always make texture paths relative in 'ref' mode --- blend2bam/blender_scripts/exportgltf.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/blend2bam/blender_scripts/exportgltf.py b/blend2bam/blender_scripts/exportgltf.py index 17a716d..3914279 100644 --- a/blend2bam/blender_scripts/exportgltf.py +++ b/blend2bam/blender_scripts/exportgltf.py @@ -92,7 +92,7 @@ def export_physics(gltf_data, settings): del gltf_node["mesh"] -def fix_image_uri(gltf_data): +def fix_image_uri(gltf_data, dstdir): blender_imgs = { (os.path.basename(i.filepath) or i.name).rsplit('.', 1)[0]: i for i in bpy.data.images @@ -107,7 +107,8 @@ def fix_image_uri(gltf_data): if filepath: if filepath.startswith('//'): filepath = filepath[2:] - img['uri'] = filepath + relpath = os.path.relpath(filepath, dstdir) + img['uri'] = relpath def add_actions_to_nla(): @@ -231,7 +232,7 @@ def export_gltf(settings, src, dst): export_physics(gltf_data, settings) if settings['textures'] == 'ref': - fix_image_uri(gltf_data) + fix_image_uri(gltf_data, dstdir) if not settings['allow_double_sided_materials']: force_single_sided_materials(gltf_data) with open(dst, 'w') as gltf_file: