CubeTexture

Class for creating a cube texture

Hierarchy

Index

Constructors

constructor

Find examples in Playground
  • new CubeTexture(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<function>, onError?: Nullable<function>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number): CubeTexture
  • Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well as prefiltered data.

    Parameters

    • rootUrl: string

      defines the url of the texture or the root name of the six images

    • scene: Scene

      defines the scene the texture is attached to

    • Optional extensions: Nullable<string[]>

      defines the suffixes add to the picture name in case six images are in use like _px.jpg...

    • Optional noMipmap: boolean

      defines if mipmaps should be created or not

    • Optional files: Nullable<string[]>

      defines the six files to load for the different faces

    • Optional onLoad: Nullable<function>

      defines a callback triggered at the end of the file load if no errors occured

    • Optional onError: Nullable<function>

      defines a callback triggered in case of error during load

    • Optional format: number

      defines the internal format to use for the texture once loaded

    • Optional prefiltered: boolean

      defines whether or not the texture is created from prefiltered data

    • Optional forcedExtension: any

      defines the extensions to use (force a special type of file to load) in case it is different from the file name

    • Optional createPolynomials: boolean

      defines whether or not to create polynomial harmonics from the texture data if necessary

    • Optional lodScale: number

      defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness

    • Optional lodOffset: number

      defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness

    Returns CubeTexture

    the cube texture

Properties

animations

Find examples in Playground
animations: Animation[]

Define the list of animation attached to the texture.

anisotropicFilteringLevel

Find examples in Playground
anisotropicFilteringLevel: number

With compliant hardware and browser (supporting anisotropic filtering) this defines the level of anisotropic filtering in the texture. The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.

boundingBoxPosition

Find examples in Playground
boundingBoxPosition: Vector3

Gets or sets the center of the bounding box associated with the cube texture. It must define where the camera used to render the texture was set

see

http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode

boundingBoxSize

Find examples in Playground
boundingBoxSize: Vector3

canRescale

Find examples in Playground
canRescale: boolean

Get if the texture can rescale.

coordinatesIndex

Find examples in Playground
coordinatesIndex: number

Define the UV chanel to use starting from 0 and defaulting to 0. This is part of the texture as textures usually maps to one uv set.

coordinatesMode

Find examples in Playground
coordinatesMode: number

How a texture is mapped.

Value Type Description
0 EXPLICIT_MODE
1 SPHERICAL_MODE
2 PLANAR_MODE
3 CUBIC_MODE
4 PROJECTION_MODE
5 SKYBOX_MODE
6 INVCUBIC_MODE
7 EQUIRECTANGULAR_MODE
8 FIXED_EQUIRECTANGULAR_MODE
9 FIXED_EQUIRECTANGULAR_MIRRORED_MODE

delayLoadState

Find examples in Playground
delayLoadState: number

Define the current state of the loading sequence when in delayed load mode.

gammaSpace

Find examples in Playground
gammaSpace: boolean

Define if the texture contains data in gamma space (most of the png/jpg aside bump). HDR texture are usually stored in linear space. This only impacts the PBR and Background materials

getAlphaFromRGB

Find examples in Playground
getAlphaFromRGB: boolean

Defines if the alpha value should be determined via the rgb values. If true the luminance of the pixel might be used to find the corresponding alpha value.

hasAlpha

Find examples in Playground
hasAlpha: boolean

Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).

invertZ

Find examples in Playground
invertZ: boolean

Is Z inverted in the texture (useful in a cube texture).

is3D

Find examples in Playground
is3D: boolean

Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.

isBlocking

Find examples in Playground
isBlocking: boolean

Define if the texture is preventinga material to render or not. If not and the texture is not ready, the engine will use a default black texture instead.

isCube

Find examples in Playground
isCube: boolean

Define if the texture is a cube texture or if false a 2d texture.

isRGBD

Find examples in Playground
isRGBD: boolean

Gets whether or not the texture contains RGBD data.

isRenderTarget

Find examples in Playground
isRenderTarget: boolean

Define if the texture is a render target.

level

Find examples in Playground
level: number

Intensity or strength of the texture. It is commonly used by materials to fine tune the intensity of the texture

lodGenerationOffset

Find examples in Playground
lodGenerationOffset: number

With prefiltered texture, defined the offset used during the prefiltering steps.

lodGenerationScale

Find examples in Playground
lodGenerationScale: number

With prefiltered texture, defined the scale used during the prefiltering steps.

name

Find examples in Playground
name: string

Define the name of the texture.

onDispose

Find examples in Playground
onDispose: function

Callback triggered when the texture has been disposed. Kept for back compatibility, you can use the onDisposeObservable instead.

Type declaration

    • (): void
    • Returns void

onDisposeObservable

Find examples in Playground
onDisposeObservable: Observable<BaseTexture>

An event triggered when the texture is disposed.

rotationY

Find examples in Playground
rotationY: number

Gets texture matrix rotation angle around Y axis radians.

sphericalPolynomial

Find examples in Playground
sphericalPolynomial: Nullable<SphericalPolynomial>

Get the polynomial representation of the texture data. This is mainly use as a fast way to recover IBL Diffuse irradiance data.

see

https://learnopengl.com/PBR/IBL/Diffuse-irradiance

textureFormat

Find examples in Playground
textureFormat: number

Get the texture underlying format (RGB, RGBA...)

textureType

Find examples in Playground
textureType: number

Get the texture underlying type (INT, FLOAT...)

uid

Find examples in Playground
uid: string

Define the unique id of the texture in the scene.

url

Find examples in Playground
url: string

The url of the texture

wrapR

Find examples in Playground
wrapR: number
Value Type Description
0 CLAMP_ADDRESSMODE
1 WRAP_ADDRESSMODE
2 MIRROR_ADDRESSMODE

wrapU

Find examples in Playground
wrapU: number
Value Type Description
0 CLAMP_ADDRESSMODE
1 WRAP_ADDRESSMODE
2 MIRROR_ADDRESSMODE

wrapV

Find examples in Playground
wrapV: number
Value Type Description
0 CLAMP_ADDRESSMODE
1 WRAP_ADDRESSMODE
2 MIRROR_ADDRESSMODE

Static DEFAULT_ANISOTROPIC_FILTERING_LEVEL

Find examples in Playground
DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number

Default anisotropic filtering level for the application. It is set to 4 as a good tradeoff between perf and quality.

Methods

clone

Find examples in Playground

delayLoad

Find examples in Playground
  • delayLoad(): void

dispose

Find examples in Playground
  • dispose(): void
  • Dispose the texture and release its associated resources.

    Returns void

getBaseSize

Find examples in Playground
  • Get the base size of the texture. It can be different from the size if the texture has been resized for POT for instance

    Returns ISize

    the base size

getClassName

Find examples in Playground
  • getClassName(): string

getInternalTexture

Find examples in Playground

getReflectionTextureMatrix

Find examples in Playground
  • getReflectionTextureMatrix(): Matrix

getScene

Find examples in Playground

getSize

Find examples in Playground

getTextureMatrix

Find examples in Playground

isReady

Find examples in Playground
  • isReady(): boolean
  • Get if the texture is ready to be used (downloaded, converted, mip mapped...).

    Returns boolean

    true if fully ready

isReadyOrNotBlocking

Find examples in Playground
  • isReadyOrNotBlocking(): boolean
  • Get if the texture is ready to be consumed (either it is ready or it is not blocking)

    Returns boolean

    true if ready or not blocking

readPixels

Find examples in Playground
  • readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>
  • Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer. This will returns an RGBA array buffer containing either in values (0-255) or float values (0-1) depending of the underlying buffer type.

    Parameters

    • Optional faceIndex: number

      defines the face of the texture to read (in case of cube texture)

    • Optional level: number

      defines the LOD level of the texture to read (in case of Mip Maps)

    • Optional buffer: Nullable<ArrayBufferView>

      defines a user defined buffer to fill with data (can be null)

    Returns Nullable<ArrayBufferView>

    The Array buffer containing the pixels data.

releaseInternalTexture

Find examples in Playground
  • releaseInternalTexture(): void

scale

Find examples in Playground
  • scale(ratio: number): void
  • Scales the texture if is canRescale()

    Parameters

    • ratio: number

      the resize factor we want to use to rescale

    Returns void

serialize

Find examples in Playground
  • serialize(): any
  • Serialize the texture into a JSON representation that can be parsed later on.

    Returns any

    the JSON representation of the texture

setReflectionTextureMatrix

Find examples in Playground
  • setReflectionTextureMatrix(value: Matrix): void
  • Sets the reflection texture matrix

    Parameters

    • value: Matrix

      Reflection texture matrix

    Returns void

toString

Find examples in Playground
  • toString(): string
  • Return a string representation of the texture.

    Returns string

    the texture as a string

Static CreateFromImages

Find examples in Playground
  • CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture
  • Creates a cube texture from an array of image urls

    Parameters

    • files: string[]

      defines an array of image urls

    • scene: Scene

      defines the hosting scene

    • Optional noMipmap: boolean

      specifies if mip maps are not used

    Returns CubeTexture

    a cube texture

Static CreateFromPrefilteredData

Find examples in Playground
  • CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture
  • Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.

    Parameters

    • url: string

      defines the url of the prefiltered texture

    • scene: Scene

      defines the scene the texture is attached to

    • Optional forcedExtension: any

      defines the extension of the file if different from the url

    • Optional createPolynomials: boolean

      defines whether or not to create polynomial harmonics from the texture data if necessary

    Returns CubeTexture

    the prefiltered texture

Static Parse

Find examples in Playground
  • Parses text to create a cube texture

    Parameters

    • parsedTexture: any

      define the serialized text to read from

    • scene: Scene

      defines the hosting scene

    • rootUrl: string

      defines the root url of the cube texture

    Returns CubeTexture

    a cube texture

Static WhenAllReady

Find examples in Playground
  • WhenAllReady(textures: BaseTexture[], callback: function): void
  • Helper function to be called back once a list of texture contains only ready textures.

    Parameters

    • textures: BaseTexture[]

      Define the list of textures to wait for

    • callback: function

      Define the callback triggered once the entire list will be ready

        • (): void
        • Returns void

    Returns void

Generated using TypeDoc