How to set CubeTexture's mipmaps manually?(edited)

Hi,
I load my mipmap datas into a 2D array:

const mipmaps = new Array<THREE.DataTexture[]>(8);

But DataTexture's mipmaps only takes ImageData[] (I’m using TypeScript).

In setTextureCube I see

var mipmap = mipmaps[ j ];
var mipmapImage = mipmap.image[ i ].image;

I can’t figure out what mipmap's type is. What kind of data should I put into CubeTexture's mipmaps?

I tried this and it works. :blush:

const mipmaps = new Array<THREE.CubeTexture>(8);
// ...load textures
envMapSpecular.mipmaps = mipmaps as any;

There’s no error and I can use textureCubeLodEXT in shader so I thought it works.
However, I find that my own mipmaps are not really used, the mipmaps rendered are ones generated automatically by ThreeJS or WebGL. What should I do to use my own mipmaps? :cold_face:

There are two things to notice when set mipmaps matually:

  1. Set texture.generateMipmaps to false;
  2. Do not put the origin image in mipmaps array, start with the second level.
2 Likes