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

USDZExporter: Fix opacity regression. (#33580)

Michael Herzog 1 месяц назад
Родитель
Сommit
5a86ea8560
1 измененных файлов с 4 добавлено и 3 удалено
  1. 4 3
      examples/jsm/exporters/USDZExporter.js

+ 4 - 3
examples/jsm/exporters/USDZExporter.js

@@ -855,7 +855,8 @@ function buildMaterial( material, textures, quickLookCompatible = false ) {
 
 		if ( color !== undefined ) {
 
-			textureNode.addProperty( `float4 inputs:scale = ${buildColor4( color )}` );
+			const alpha = ( mapType === 'diffuse' ) ? material.opacity : 1;
+			textureNode.addProperty( `float4 inputs:scale = ${buildColor4( color, alpha )}` );
 
 		}
 
@@ -1146,9 +1147,9 @@ function buildColor( color ) {
 
 }
 
-function buildColor4( color ) {
+function buildColor4( color, alpha = 1 ) {
 
-	return `(${color.r}, ${color.g}, ${color.b}, 1.0)`;
+	return `(${color.r}, ${color.g}, ${color.b}, ${alpha})`;
 
 }
 

粤ICP备19079148号