mirror of
https://github.com/visgl/luma.gl.git
synced 2025-12-08 17:36:19 +00:00
2.2 KiB
2.2 KiB
Texture3D (WebGL2)
3D textures hold basic volumetric textures and can be thought of 3-dimentional arrays with a width, height and depth. They hold image memory of a certain format and size, determined at initialization time. They can be sampled in shaders using the texture function with a 3D texture coordinate.
Most texture related functionality is implemented by and documented on the Texture base class. For additional information, see OpenGL Wiki.
Usage
Create a new 3D texture
if (Texture3D.isSupported()) {
texture3D = new Texture3D(gl, {...});
}
Members
handle- The underlyingWebGLTexturetarget- AlwaysGL.TEXTURE_3Dwidth- width of textureheight- height of texturedepth- depth of the textureformat- format of texture
Methods
Texture3D is a subclass of the Texture and Resource classes and inherit all methods and members of those classes. Note that setSubImageData is not currently supported for 3D textures.
Texture3D.isSupported(gl)
Returns true if the context supports creation of Texture3Ds.
constructor
new Texture3D(gl, {parameters});
const texture = new Texture3D(gl, {
width: TEXTURE_DIMENSIONS,
height: TEXTURE_DIMENSIONS,
depth: TEXTURE_DIMENSIONS,
data: textureData,
format: gl.RED,
dataFormat: gl.R8
});
gl(WebGLRenderingContext) - gl contextdata=null(*) - See below.width=0(Number) - The width of the texture.height=0(Number) - The height of the texture.depth=0(Number) - The depth of the texture.mipmaps=true(Boolean) - whether to generate mipmapsformat(enum, defaultGL.RGBA) - internal format that WebGL should use.type(enum, default is autodeduced from format) - type of pixel data (GL.UNSIGNED_BYTE, GL.FLOAT etc).dataFormat(enum, default is autodeduced fromformat) - internal format that WebGL should use.parameters={}(object) - texture
Limits
- The maximum size of a
Texture3D(width/height/depth) is implementation defined, it can be queried viaGL.MAX_3D_TEXTURE_SIZE(at least 256).