@@ -580,7 +580,11 @@ export function UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBuffer
580
580
const irradianceTexture = info . irradiance ?. irradianceTexture ;
581
581
if ( irradianceTexture ) {
582
582
const irradianceImageData = CreateIrradianceImageDataArrayBufferViews ( data , info ) ;
583
- promises . push ( UploadIrradianceLevelsAsync ( texture , irradianceImageData , irradianceTexture . size , info . imageType ) ) ;
583
+ let dominantDirection = null ;
584
+ if ( info . irradiance ?. irradianceTexture ?. dominantDirection ) {
585
+ dominantDirection = Vector3 . FromArray ( info . irradiance . irradianceTexture . dominantDirection ) ;
586
+ }
587
+ promises . push ( UploadIrradianceLevelsAsync ( texture , irradianceImageData , irradianceTexture . size , info . imageType , dominantDirection ) ) ;
584
588
}
585
589
586
590
return Promise . all ( promises ) ;
@@ -679,20 +683,22 @@ export async function UploadRadianceLevelsAsync(texture: InternalTexture, imageD
679
683
* @param imageData defines the array buffer views of image data [mipmap][face]
680
684
* @param size defines the size of the texture faces
681
685
* @param imageType the mime type of the image data
686
+ * @param dominantDirection the dominant direction of light in the environment texture, if available
682
687
* @returns a promise
683
688
*/
684
689
export async function UploadIrradianceLevelsAsync (
685
690
mainTexture : InternalTexture ,
686
691
imageData : ArrayBufferView [ ] ,
687
692
size : number ,
688
- imageType : string = DefaultEnvironmentTextureImageType
693
+ imageType : string = DefaultEnvironmentTextureImageType ,
694
+ dominantDirection : Nullable < Vector3 > = null
689
695
) : Promise < void > {
690
696
// Gets everything ready.
691
697
const engine = mainTexture . getEngine ( ) as Engine ;
692
698
const texture = new InternalTexture ( engine , InternalTextureSource . RenderTarget ) ;
693
699
const baseTexture = new BaseTexture ( engine , texture ) ;
694
700
mainTexture . _irradianceTexture = baseTexture ;
695
-
701
+ baseTexture . _dominantDirection = dominantDirection ;
696
702
texture . isCube = true ;
697
703
texture . format = Constants . TEXTUREFORMAT_RGBA ;
698
704
texture . type = Constants . TEXTURETYPE_UNSIGNED_BYTE ;
@@ -1076,6 +1082,7 @@ export const EnvironmentTextureTools = {
1076
1082
* @param texture defines the internal texture to upload to
1077
1083
* @param imageData defines the array buffer views of image data [mipmap][face]
1078
1084
* @param imageType the mime type of the image data
1085
+ * @param dominantDirection the dominant direction of light in the environment texture, if available
1079
1086
* @returns a promise
1080
1087
*/
1081
1088
UploadIrradianceLevelsAsync,
0 commit comments