CubeTexture

Class for creating a cube texture

Hierarchy

Index

Constructors

constructor

  • 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

animations: Animation[]

Define the list of animation attached to the texture.

anisotropicFilteringLevel

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

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

boundingBoxSize: Vector3

canRescale

canRescale: boolean

Get if the texture can rescale.

coordinatesIndex

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

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

delayLoadState: number

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

gammaSpace

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

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

hasAlpha: boolean

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

invertZ

invertZ: boolean

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

is3D

is3D: boolean

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

isBlocking

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

isCube: boolean

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

isRGBD

isRGBD: boolean

Gets whether or not the texture contains RGBD data.

isRenderTarget

isRenderTarget: boolean

Define if the texture is a render target.

level

level: number

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

lodGenerationOffset

lodGenerationOffset: number

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

lodGenerationScale

lodGenerationScale: number

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

name

name: string

Define the name of the texture.

onDispose

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

onDisposeObservable: Observable<BaseTexture>

An event triggered when the texture is disposed.

rotationY

rotationY: number

Gets texture matrix rotation angle around Y axis radians.

sphericalPolynomial

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

textureFormat: number

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

textureType

textureType: number

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

uid

uid: string

Define the unique id of the texture in the scene.

url

url: string

The url of the texture

wrapR

wrapR: number
Value Type Description
0 CLAMP_ADDRESSMODE
1 WRAP_ADDRESSMODE
2 MIRROR_ADDRESSMODE

wrapU

wrapU: number
Value Type Description
0 CLAMP_ADDRESSMODE
1 WRAP_ADDRESSMODE
2 MIRROR_ADDRESSMODE

wrapV

wrapV: number
Value Type Description
0 CLAMP_ADDRESSMODE
1 WRAP_ADDRESSMODE
2 MIRROR_ADDRESSMODE

Static DEFAULT_ANISOTROPIC_FILTERING_LEVEL

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

  • Makes a clone, or deep copy, of the cube texture

    Returns CubeTexture

    a new cube texture

delayLoad

  • delayLoad(): void
  • Delays loading of the cube texture

    Returns void

dispose

  • dispose(): void
  • Dispose the texture and release its associated resources.

    Returns void

getBaseSize

  • 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

  • getClassName(): string
  • Get the class name of the texture.

    Returns string

    "BaseTexture"

getInternalTexture

getReflectionTextureMatrix

  • getReflectionTextureMatrix(): Matrix

getScene

  • Get the scene the texture belongs to.

    Returns Nullable<Scene>

    the scene or null if undefined

getSize

  • Get the size of the texture.

    Returns ISize

    the texture size.

getTextureMatrix

  • Get the texture transform matrix used to offset tile the texture for istance.

    Returns Matrix

    the transformation matrix

isReady

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

    Returns boolean

    true if fully ready

isReadyOrNotBlocking

  • 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

  • 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

  • releaseInternalTexture(): void
  • Release and destroy the underlying lower level texture aka internalTexture.

    Returns void

scale

  • 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

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

    Returns any

    the JSON representation of the texture

setReflectionTextureMatrix

  • setReflectionTextureMatrix(value: Matrix): void
  • Sets the reflection texture matrix

    Parameters

    • value: Matrix

      Reflection texture matrix

    Returns void

toString

  • toString(): string
  • Return a string representation of the texture.

    Returns string

    the texture as a string

Static CreateFromImages

  • 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

  • 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

  • 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

  • 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