From 2577a51f3a737181b7ebc935e8e909ee5c276b04 Mon Sep 17 00:00:00 2001 From: Cold5tar <58589094+Cold5tar@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:34:33 +0200 Subject: [PATCH 1/2] Fix GLTFExporter.js by checking if attenuation distance is set Having no attenuation distance set in the project/code, defaults to infitity. This property then cannot be set in GLTF file and automatically sets to NULL. NULL property cannot be read by various softwares, for example - Blender 4 - > onwards. By adding check if distance is !== infinity we either send that parameter if its set, or don't send it if its default. --- examples/jsm/exporters/GLTFExporter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/jsm/exporters/GLTFExporter.js b/examples/jsm/exporters/GLTFExporter.js index 4257b411855a64..2aba26154413b3 100644 --- a/examples/jsm/exporters/GLTFExporter.js +++ b/examples/jsm/exporters/GLTFExporter.js @@ -2837,7 +2837,9 @@ class GLTFMaterialsVolumeExtension { } - extensionDef.attenuationDistance = material.attenuationDistance; + if (material.attenuationDistance !== Infinity) { + extensionDef.attenuationDistance = material.attenuationDistance; + } extensionDef.attenuationColor = material.attenuationColor.toArray(); materialDef.extensions = materialDef.extensions || {}; From d6e27e207f06e23e01975461fc790ee0ba378ba3 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Wed, 31 Jul 2024 15:56:03 +0200 Subject: [PATCH 2/2] Update GLTFExporter.js Clean up. --- examples/jsm/exporters/GLTFExporter.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/jsm/exporters/GLTFExporter.js b/examples/jsm/exporters/GLTFExporter.js index 2aba26154413b3..52cc3c1c82ccf0 100644 --- a/examples/jsm/exporters/GLTFExporter.js +++ b/examples/jsm/exporters/GLTFExporter.js @@ -2837,9 +2837,12 @@ class GLTFMaterialsVolumeExtension { } - if (material.attenuationDistance !== Infinity) { + if ( material.attenuationDistance !== Infinity ) { + extensionDef.attenuationDistance = material.attenuationDistance; + } + extensionDef.attenuationColor = material.attenuationColor.toArray(); materialDef.extensions = materialDef.extensions || {};