From ef41bed7d58966a22459f31b88fe1f31b0ae5eff Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Fri, 27 Jan 2023 15:23:13 -0500 Subject: [PATCH] Use KHR_materials_unlit extension, add draco CESIUM_RTC support --- SuperBuild/CMakeLists.txt | 4 ++-- opendm/gltf.py | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index 4d9435b5..9793cddb 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -247,9 +247,9 @@ externalproject_add(lastools ) externalproject_add(draco - GIT_REPOSITORY https://github.com/google/draco + GIT_REPOSITORY https://github.com/OpenDroneMap/draco GIT_SHALLOW ON - GIT_TAG 1.5.5 + GIT_TAG 304 PREFIX ${SB_BINARY_DIR}/draco SOURCE_DIR ${SB_SOURCE_DIR}/draco CMAKE_ARGS -DDRACO_TRANSCODER_SUPPORTED=ON diff --git a/opendm/gltf.py b/opendm/gltf.py index e54969b2..df13bf48 100644 --- a/opendm/gltf.py +++ b/opendm/gltf.py @@ -9,6 +9,7 @@ from opendm import io warnings.filterwarnings("ignore", category=rasterio.errors.NotGeoreferencedWarning) + def load_obj(obj_path, _info=print): if not os.path.isfile(obj_path): raise IOError("Cannot open %s" % obj_path) @@ -253,8 +254,13 @@ def obj2glb(input_obj, output_glb, rtc=(None, None), draco_compression=True, _in images += [pygltflib.Image(bufferView=textureBufferView, mimeType="image/jpeg")] textures += [pygltflib.Texture(source=len(images) - 1, sampler=0)] - materials += [pygltflib.Material(pbrMetallicRoughness=pygltflib.PbrMetallicRoughness(baseColorTexture=pygltflib.TextureInfo(index=len(textures) - 1), metallicFactor=0, roughnessFactor=1), - alphaMode=pygltflib.MASK)] + + mat = pygltflib.Material(pbrMetallicRoughness=pygltflib.PbrMetallicRoughness(baseColorTexture=pygltflib.TextureInfo(index=len(textures) - 1), metallicFactor=0, roughnessFactor=1), + alphaMode=pygltflib.MASK) + mat.extensions = { + 'KHR_materials_unlit': {} + } + materials += [mat] gltf = pygltflib.GLTF2( scene=0, @@ -272,8 +278,10 @@ def obj2glb(input_obj, output_glb, rtc=(None, None), draco_compression=True, _in buffers=[pygltflib.Buffer(byteLength=len(binary))], ) + gltf.extensionsRequired = ['KHR_materials_unlit'] + if rtc != (None, None) and len(rtc) >= 2: - gltf.extensionsUsed = ['CESIUM_RTC'] + gltf.extensionsUsed = ['CESIUM_RTC', 'KHR_materials_unlit'] gltf.extensions = { 'CESIUM_RTC': { 'center': [float(rtc[0]), float(rtc[1]), 0.0]