Просмотр исходного кода

GLTFExporter: Preventing to write `null` for `attenuationDistance`. (#29035)

* 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.

* Update GLTFExporter.js

Clean up.

---------

Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>
Cold5tar 1 год назад
Родитель
Сommit
02c1580799
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      examples/jsm/exporters/GLTFExporter.js

+ 6 - 1
examples/jsm/exporters/GLTFExporter.js

@@ -2837,7 +2837,12 @@ class GLTFMaterialsVolumeExtension {
 
 		}
 
-		extensionDef.attenuationDistance = material.attenuationDistance;
+		if ( material.attenuationDistance !== Infinity ) {
+
+			extensionDef.attenuationDistance = material.attenuationDistance;
+
+		}
+
 		extensionDef.attenuationColor = material.attenuationColor.toArray();
 
 		materialDef.extensions = materialDef.extensions || {};

粤ICP备19079148号