CubeTexture with different sized Images

It seems like each image passed into the image array for a CubeTexture must be the same size. Does three.js have any built in functions I can use to resize images before adding them to the images array? Or if anyone has any examples of implementations to do this?

Use Case: Want to allow users to change each face of scene.background which I have set as a CubeTexture. Right now if a user uses an image that’s not exactly the same size as the default image, the following error comes up “GL ERROR :GL_INVALID_OPERATION : glGenerateMipmap: Can not generate mips”

If there’s no easy way to handle this, I might be better off creating a large Box Mesh with 6 materials, but I’d prefer to use scene.background as it won’t be affected by the camera’s far frustum plane. Also being able handle non-square images would be nice, but that’s less of a concern for me and I don’t mind forcing the square requirement on users

use a html canvas & fit or fill the input image on a fixed resolution square area ,
& use canvasDataURL to create a new texture.

1 Like

Ah great idea, thank you so much! This even allows me to use non-square photos :smiley: Ended up being able to just pass a list of 6 canvases to CubeTexture map since it converts it to a data url behind the scenes