|
@@ -1185,12 +1185,21 @@ class GLTFWriter {
|
|
|
|
|
|
if ( material.emissive ) {
|
|
|
|
|
|
- // note: `emissive` is not scaled by `material.emissiveIntensity` for now to accommodate glTF spec. see #21849.
|
|
|
- const emissive = material.emissive.toArray();
|
|
|
+ // note: emissive components are limited to stay within the 0 - 1 range to accommodate glTF spec. see #21849 and #22000.
|
|
|
+ const emissive = material.emissive.clone().multiplyScalar( material.emissiveIntensity );
|
|
|
+ const maxEmissiveComponent = Math.max( emissive.r, emissive.g, emissive.b );
|
|
|
|
|
|
- if ( ! equalArray( emissive, [ 0, 0, 0 ] ) ) {
|
|
|
+ if ( maxEmissiveComponent > 1 ) {
|
|
|
|
|
|
- materialDef.emissiveFactor = emissive;
|
|
|
+ emissive.multiplyScalar( 1 / maxEmissiveComponent );
|
|
|
+
|
|
|
+ console.warn( 'THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited' );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( maxEmissiveComponent > 0 ) {
|
|
|
+
|
|
|
+ materialDef.emissiveFactor = emissive.toArray();
|
|
|
|
|
|
}
|
|
|
|