ThinEngine

The base engine class (root of all engines)

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

Find examples in Playground
  • new ThinEngine(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean): ThinEngine
  • Creates a new engine

    Parameters

    • canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>

      defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context

    • Optional antialias: boolean

      defines enable antialiasing (default: false)

    • Optional options: EngineOptions

      defines further options to be sent to the getContext() function

    • Optional adaptToDeviceRatio: boolean

      defines whether to adapt to the device's viewport characteristics (default: false)

    Returns ThinEngine

Properties

alphaState

Find examples in Playground
alphaState: AlphaState

Gets the alpha state manager

cullBackFaces

Find examples in Playground
cullBackFaces: boolean

Gets or sets a boolean indicating if back faces must be culled (true by default)

currentViewport

Find examples in Playground
currentViewport: Nullable<IViewportLike>

Gets the current viewport

depthCullingState

Find examples in Playground
depthCullingState: DepthCullingState

Gets the depth culling state manager

description

Find examples in Playground
description: string

Returns a string describing the current engine

disableUniformBuffers

Find examples in Playground
disableUniformBuffers: boolean

Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported

disableVertexArrayObjects

Find examples in Playground
disableVertexArrayObjects: boolean

Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported

doNotHandleContextLost

Find examples in Playground
doNotHandleContextLost: boolean

Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events

see

http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost

emptyCubeTexture

Find examples in Playground
emptyCubeTexture: InternalTexture

Gets the default empty cube texture

emptyTexture

Find examples in Playground
emptyTexture: InternalTexture

Gets the default empty texture

emptyTexture2DArray

Find examples in Playground
emptyTexture2DArray: InternalTexture

Gets the default empty 2D array texture

emptyTexture3D

Find examples in Playground
emptyTexture3D: InternalTexture

Gets the default empty 3D texture

enableUnpackFlipYCached

Find examples in Playground
enableUnpackFlipYCached: boolean

In case you are sharing the context with other applications, it might be interested to not cache the unpack flip y state to ensure a consistent value would be set.

forcePOTTextures

Find examples in Playground
forcePOTTextures: boolean

Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required

isFullscreen

Find examples in Playground
isFullscreen: boolean

Gets a boolean indicating if the engine is currently rendering in fullscreen mode

isStencilEnable

Find examples in Playground
isStencilEnable: boolean

Returns true if the stencil buffer has been enabled through the creation option of the context.

needPOTTextures

Find examples in Playground
needPOTTextures: boolean

Gets a boolean indicating that only power of 2 textures are supported Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them

onBeforeTextureInitObservable

Find examples in Playground
onBeforeTextureInitObservable: Observable<Texture>

Observable event triggered before each texture is initialized

onContextLostObservable

Find examples in Playground
onContextLostObservable: Observable<ThinEngine>

Observable signaled when a context lost event is raised

onContextRestoredObservable

Find examples in Playground
onContextRestoredObservable: Observable<ThinEngine>

Observable signaled when a context restored event is raised

premultipliedAlpha

Find examples in Playground
premultipliedAlpha: boolean

Defines whether the engine has been created with the premultipliedAlpha option on or not.

preventCacheWipeBetweenFrames

Find examples in Playground
preventCacheWipeBetweenFrames: boolean

Gets or sets a boolean indicating that cache can be kept between frames

renderEvenInBackground

Find examples in Playground
renderEvenInBackground: boolean

Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun

stencilState

Find examples in Playground
stencilState: StencilState

Gets the stencil state manager

supportsUniformBuffers

Find examples in Playground
supportsUniformBuffers: boolean

Gets a boolean indicating that the engine supports uniform buffers

see

http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets

textureFormatInUse

Find examples in Playground
textureFormatInUse: Nullable<string>

Gets the list of texture formats in use

texturesSupported

Find examples in Playground
texturesSupported: Array<string>

Gets the list of texture formats supported

useReverseDepthBuffer

Find examples in Playground
useReverseDepthBuffer: boolean

Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near. This can provide greater z depth for distant objects.

validateShaderPrograms

Find examples in Playground
validateShaderPrograms: boolean

Gets or sets a boolean indicating if the engine should validate programs after compilation

webGLVersion

Find examples in Playground
webGLVersion: number

Gets version of the current webGL context

Static CollisionsEpsilon

Find examples in Playground
CollisionsEpsilon: number

Gets or sets the epsilon value used by collision engine

Static ExceptionList

Find examples in Playground
ExceptionList: (object | object)[]

Use this array to turn off some WebGL2 features on known buggy browsers version

Static NpmPackage

Find examples in Playground
NpmPackage: string

Returns the current npm package of the sdk

Static ShadersRepository

Find examples in Playground
ShadersRepository: string

Gets or sets the relative url used to load shaders if using the engine in non-minified mode

Static Version

Find examples in Playground
Version: string

Returns the current version of the framework

Methods

_createDepthStencilCubeTexture

Find examples in Playground
  • Creates a depth stencil cube texture. This is only available in WebGL 2.

    Parameters

    Returns InternalTexture

    The cube texture

applyStates

Find examples in Playground
  • applyStates(): void
  • Apply all cached states (depth, culling, stencil and alpha)

    Returns void

areAllEffectsReady

Find examples in Playground
  • areAllEffectsReady(): boolean
  • Gets a boolean indicating if all created effects are ready

    Returns boolean

    true if all effects are ready

attachContextLostEvent

Find examples in Playground
  • attachContextLostEvent(callback: function): void
  • Attach a new callback raised when context lost event is fired

    Parameters

    • callback: function

      defines the callback to call

        • (event: WebGLContextEvent): void
        • Parameters

          • event: WebGLContextEvent

          Returns void

    Returns void

attachContextRestoredEvent

Find examples in Playground
  • attachContextRestoredEvent(callback: function): void
  • Attach a new callback raised when context restored event is fired

    Parameters

    • callback: function

      defines the callback to call

        • (event: WebGLContextEvent): void
        • Parameters

          • event: WebGLContextEvent

          Returns void

    Returns void

beginFrame

Find examples in Playground
  • beginFrame(): void
  • Begin a new frame

    Returns void

bindArrayBuffer

Find examples in Playground
  • Bind a webGL buffer to the webGL context

    Parameters

    Returns void

bindBuffers

Find examples in Playground
  • Bind a list of vertex buffers to the webGL context

    Parameters

    • vertexBuffers: object

      defines the list of vertex buffers to bind

    • indexBuffer: Nullable<DataBuffer>

      defines the index buffer to bind

    • effect: Effect

      defines the effect associated with the vertex buffers

    Returns void

bindBuffersDirectly

Find examples in Playground
  • bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void
  • Bind webGl buffers directly to the webGL context

    Parameters

    • vertexBuffer: DataBuffer

      defines the vertex buffer to bind

    • indexBuffer: DataBuffer

      defines the index buffer to bind

    • vertexDeclaration: number[]

      defines the vertex declaration to use with the vertex buffer

    • vertexStrideSize: number

      defines the vertex stride of the vertex buffer

    • effect: Effect

      defines the effect associated with the vertex buffer

    Returns void

bindFramebuffer

Find examples in Playground
  • bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void
  • Binds the frame buffer to the specified texture.

    Parameters

    • texture: InternalTexture

      The texture to render to or null for the default canvas

    • Optional faceIndex: number

      The face of the texture to render to in case of cube texture

    • Optional requiredWidth: number

      The width of the target to render to

    • Optional requiredHeight: number

      The height of the target to render to

    • Optional forceFullscreenViewport: boolean

      Forces the viewport to be the entire texture/screen if true

    • Optional depthStencilTexture: InternalTexture

      The depth stencil texture to use to render

    • Optional lodLevel: number

      defines le lod level to bind to the frame buffer

    Returns void

bindSamplers

Find examples in Playground
  • bindSamplers(effect: Effect): void
  • Binds an effect to the webGL context

    Parameters

    • effect: Effect

      defines the effect to bind

    Returns void

bindUniformBlock

Find examples in Playground
  • bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void
  • Bind a specific block at a given index in a specific shader program

    Parameters

    • pipelineContext: IPipelineContext

      defines the pipeline context to use

    • blockName: string

      defines the block name

    • index: number

      defines the index where to bind the block

    Returns void

bindUniformBuffer

Find examples in Playground
  • Bind an uniform buffer to the current webGL context

    Parameters

    Returns void

bindUniformBufferBase

Find examples in Playground
  • bindUniformBufferBase(buffer: DataBuffer, location: number): void
  • Bind a buffer to the current webGL context at a given location

    Parameters

    • buffer: DataBuffer

      defines the buffer to bind

    • location: number

      defines the index where to bind the buffer

    Returns void

bindVertexArrayObject

Find examples in Playground

clear

Find examples in Playground
  • clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void
  • Clear the current render buffer or the current render target (if any is set up)

    Parameters

    • color: Nullable<IColor4Like>

      defines the color to use

    • backBuffer: boolean

      defines if the back buffer must be cleared

    • depth: boolean

      defines if the depth buffer must be cleared

    • Optional stencil: boolean

      defines if the stencil buffer must be cleared

    Returns void

clearInternalTexturesCache

Find examples in Playground
  • clearInternalTexturesCache(): void
  • Clears the list of texture accessible through engine. This can help preventing texture load conflict due to name collision.

    Returns void

createCubeTexture

Find examples in Playground
  • Creates a cube texture

    Parameters

    • rootUrl: string

      defines the url where the files to load is located

    • scene: Nullable<Scene>

      defines the current scene

    • files: Nullable<string[]>

      defines the list of files to load (1 per face)

    • noMipmap: boolean | undefined

      defines a boolean indicating that no mipmaps shall be generated (false by default)

    • onLoad: Nullable<function>

      defines an optional callback raised when the texture is loaded

    • onError: Nullable<function>

      defines an optional callback raised if there is an issue to load the texture

    • format: number | undefined

      defines the format of the data

    • forcedExtension: any

      defines the extension to use to pick the right loader

    • createPolynomials: boolean

      if a polynomial sphere should be created for the cube texture

    • lodScale: number

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

    • lodOffset: number

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

    • fallback: Nullable<InternalTexture>

      defines texture to use while falling back when (compressed) texture file not found.

    • excludeLoaders: Array<IInternalTextureLoader>

      array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)

    Returns InternalTexture

    the cube texture as an InternalTexture

  • Creates a cube texture

    Parameters

    • rootUrl: string

      defines the url where the files to load is located

    • scene: Nullable<Scene>

      defines the current scene

    • files: Nullable<string[]>

      defines the list of files to load (1 per face)

    • noMipmap: boolean

      defines a boolean indicating that no mipmaps shall be generated (false by default)

    • onLoad: Nullable<function>

      defines an optional callback raised when the texture is loaded

    • onError: Nullable<function>

      defines an optional callback raised if there is an issue to load the texture

    • format: number | undefined

      defines the format of the data

    • forcedExtension: any

      defines the extension to use to pick the right loader

    Returns InternalTexture

    the cube texture as an InternalTexture

  • Creates a cube texture

    Parameters

    • rootUrl: string

      defines the url where the files to load is located

    • scene: Nullable<Scene>

      defines the current scene

    • files: Nullable<string[]>

      defines the list of files to load (1 per face)

    • noMipmap: boolean

      defines a boolean indicating that no mipmaps shall be generated (false by default)

    • onLoad: Nullable<function>

      defines an optional callback raised when the texture is loaded

    • onError: Nullable<function>

      defines an optional callback raised if there is an issue to load the texture

    • format: number | undefined

      defines the format of the data

    • forcedExtension: any

      defines the extension to use to pick the right loader

    • createPolynomials: boolean

      if a polynomial sphere should be created for the cube texture

    • lodScale: number

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

    • lodOffset: number

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

    Returns InternalTexture

    the cube texture as an InternalTexture

createDepthStencilTexture

Find examples in Playground
  • Creates a depth stencil texture. This is only available in WebGL 2 or with the depth texture extension available.

    Parameters

    Returns InternalTexture

    The texture

createDynamicTexture

Find examples in Playground
  • createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture
  • Creates a dynamic texture

    Parameters

    • width: number

      defines the width of the texture

    • height: number

      defines the height of the texture

    • generateMipMaps: boolean

      defines if the engine should generate the mip levels

    • samplingMode: number

      defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)

    Returns InternalTexture

    the dynamic texture inside an InternalTexture

createDynamicUniformBuffer

Find examples in Playground

createDynamicVertexBuffer

Find examples in Playground
  • Creates a dynamic vertex buffer

    Parameters

    • data: DataArray

      the data for the dynamic vertex buffer

    Returns DataBuffer

    the new WebGL dynamic buffer

createEffect

Find examples in Playground
  • Create a new effect (used to store vertex/fragment shaders)

    Parameters

    • baseName: any

      defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)

    • attributesNamesOrOptions: string[] | IEffectCreationOptions

      defines either a list of attribute names or an IEffectCreationOptions object

    • uniformsNamesOrEngine: string[] | ThinEngine

      defines either a list of uniform names or the engine to use

    • Optional samplers: string[]

      defines an array of string used to represent textures

    • Optional defines: string

      defines the string containing the defines to use to compile the shaders

    • Optional fallbacks: IEffectFallbacks

      defines the list of potential fallbacks to use if shader conmpilation fails

    • Optional onCompiled: Nullable<function>

      defines a function to call when the effect creation is successful

    • Optional onError: Nullable<function>

      defines a function to call when the effect creation has failed

    • Optional indexParameters: any

      defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)

    Returns Effect

    the new Effect

createIndexBuffer

Find examples in Playground
  • Creates a new index buffer

    Parameters

    • indices: IndicesArray

      defines the content of the index buffer

    • Optional updatable: boolean

      defines if the index buffer must be updatable

    Returns DataBuffer

    a new webGL buffer

createMultipleRenderTarget

Find examples in Playground

createPipelineContext

Find examples in Playground

createPrefilteredCubeTexture

Find examples in Playground
  • createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<function>, onError?: Nullable<function>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture
  • Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)

    Parameters

    • rootUrl: string

      defines the url where the file to load is located

    • scene: Nullable<Scene>

      defines the current scene

    • lodScale: number

      defines scale to apply to the mip map selection

    • lodOffset: number

      defines offset to apply to the mip map selection

    • Optional onLoad: Nullable<function>

      defines an optional callback raised when the texture is loaded

    • Optional onError: Nullable<function>

      defines an optional callback raised if there is an issue to load the texture

    • Optional format: number

      defines the format of the data

    • Optional forcedExtension: any

      defines the extension to use to pick the right loader

    • Optional createPolynomials: boolean

      defines wheter or not to create polynomails harmonics for the texture

    Returns InternalTexture

    the cube texture as an InternalTexture

createRawCubeTexture

Find examples in Playground
  • createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture
  • Creates a new raw cube texture

    Parameters

    • data: Nullable<ArrayBufferView[]>

      defines the array of data to use to create each face

    • size: number

      defines the size of the textures

    • format: number

      defines the format of the data

    • type: number

      defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)

    • generateMipMaps: boolean

      defines if the engine should generate the mip levels

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • samplingMode: number

      defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)

    • Optional compression: Nullable<string>

      defines the compression used (null by default)

    Returns InternalTexture

    the cube texture as an InternalTexture

createRawShaderProgram

Find examples in Playground
  • createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram
  • Directly creates a webGL program

    Parameters

    • pipelineContext: IPipelineContext

      defines the pipeline context to attach to

    • vertexCode: string

      defines the vertex shader code to use

    • fragmentCode: string

      defines the fragment shader code to use

    • Optional context: WebGLRenderingContext

      defines the webGL context to use (if not set, the current one will be used)

    • Optional transformFeedbackVaryings: Nullable<string[]>

      defines the list of transform feedback varyings to use

    Returns WebGLProgram

    the new webGL program

createRawTexture

Find examples in Playground
  • createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture
  • Creates a raw texture

    Parameters

    • data: Nullable<ArrayBufferView>

      defines the data to store in the texture

    • width: number

      defines the width of the texture

    • height: number

      defines the height of the texture

    • format: number

      defines the format of the data

    • generateMipMaps: boolean

      defines if the engine should generate the mip levels

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • samplingMode: number

      defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)

    • Optional compression: Nullable<string>

      defines the compression used (null by default)

    • Optional type: number

      defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)

    Returns InternalTexture

    the raw texture inside an InternalTexture

createRawTexture2DArray

Find examples in Playground
  • createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture
  • Creates a new raw 2D array texture

    Parameters

    • data: Nullable<ArrayBufferView>

      defines the data used to create the texture

    • width: number

      defines the width of the texture

    • height: number

      defines the height of the texture

    • depth: number

      defines the number of layers of the texture

    • format: number

      defines the format of the texture

    • generateMipMaps: boolean

      defines if the engine must generate mip levels

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • samplingMode: number

      defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)

    • Optional compression: Nullable<string>

      defines the compressed used (can be null)

    • Optional textureType: number

      defines the compressed used (can be null)

    Returns InternalTexture

    a new raw 2D array texture (stored in an InternalTexture)

createRawTexture3D

Find examples in Playground
  • createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture
  • Creates a new raw 3D texture

    Parameters

    • data: Nullable<ArrayBufferView>

      defines the data used to create the texture

    • width: number

      defines the width of the texture

    • height: number

      defines the height of the texture

    • depth: number

      defines the depth of the texture

    • format: number

      defines the format of the texture

    • generateMipMaps: boolean

      defines if the engine must generate mip levels

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • samplingMode: number

      defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)

    • Optional compression: Nullable<string>

      defines the compressed used (can be null)

    • Optional textureType: number

      defines the compressed used (can be null)

    Returns InternalTexture

    a new raw 3D texture (stored in an InternalTexture)

createRenderTargetCubeTexture

Find examples in Playground
  • Creates a new render target cube texture

    Parameters

    • size: number

      defines the size of the texture

    • Optional options: Partial<RenderTargetCreationOptions>

      defines the options used to create the texture

    Returns InternalTexture

    a new render target cube texture stored in an InternalTexture

createRenderTargetTexture

Find examples in Playground
  • Creates a new render target texture

    Parameters

    • size: number | object

      defines the size of the texture

    • options: boolean | RenderTargetCreationOptions

      defines the options used to create the texture

    Returns InternalTexture

    a new render target texture stored in an InternalTexture

createShaderProgram

Find examples in Playground
  • createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram
  • Creates a webGL program

    Parameters

    • pipelineContext: IPipelineContext

      defines the pipeline context to attach to

    • vertexCode: string

      defines the vertex shader code to use

    • fragmentCode: string

      defines the fragment shader code to use

    • defines: Nullable<string>

      defines the string containing the defines to use to compile the shaders

    • Optional context: WebGLRenderingContext

      defines the webGL context to use (if not set, the current one will be used)

    • Optional transformFeedbackVaryings: Nullable<string[]>

      defines the list of transform feedback varyings to use

    Returns WebGLProgram

    the new webGL program

createTexture

Find examples in Playground
  • Usually called from Texture.ts. Passed information to create a WebGLTexture

    Parameters

    • urlArg: Nullable<string>

      defines a value which contains one of the following:

      • A conventional http URL, e.g. 'http://...' or 'file://...'
      • A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
      • An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
    • noMipmap: boolean

      defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file

    • invertY: boolean

      when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)

    • scene: Nullable<ISceneLike>

      needed for loading to the correct scene

    • Optional samplingMode: number

      mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)

    • Optional onLoad: Nullable<function>

      optional callback to be called upon successful completion

    • Optional onError: Nullable<function>

      optional callback to be called upon failure

    • Optional buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>

      a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob

    • Optional fallback: Nullable<InternalTexture>

      an internal argument in case the function must be called again, due to etc1 not having alpha capabilities

    • Optional format: Nullable<number>

      internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures

    • Optional forcedExtension: Nullable<string>

      defines the extension to use to pick the right loader

    • Optional excludeLoaders: Array<IInternalTextureLoader>

      array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)

    • Optional mimeType: string

      defines an optional mime type

    Returns InternalTexture

    a InternalTexture for assignment back into BABYLON.Texture

createUniformBuffer

Find examples in Playground

createVertexBuffer

Find examples in Playground
  • Creates a vertex buffer

    Parameters

    • data: DataArray

      the data for the vertex buffer

    Returns DataBuffer

    the new WebGL static buffer

dispose

Find examples in Playground
  • dispose(): void
  • Dispose and release all associated resources

    Returns void

draw

Find examples in Playground
  • draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void
  • Send a draw order

    Parameters

    • useTriangles: boolean

      defines if triangles must be used to draw (else wireframe will be used)

    • indexStart: number

      defines the starting index

    • indexCount: number

      defines the number of index to draw

    • Optional instancesCount: number

      defines the number of instances to draw (if instanciation is enabled)

    Returns void

drawArraysType

Find examples in Playground
  • drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void
  • Draw a list of unindexed primitives

    Parameters

    • fillMode: number

      defines the primitive to use

    • verticesStart: number

      defines the index of first vertex to draw

    • verticesCount: number

      defines the count of vertices to draw

    • Optional instancesCount: number

      defines the number of instances to draw (if instanciation is enabled)

    Returns void

drawElementsType

Find examples in Playground
  • drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void
  • Draw a list of indexed primitives

    Parameters

    • fillMode: number

      defines the primitive to use

    • indexStart: number

      defines the starting index

    • indexCount: number

      defines the number of index to draw

    • Optional instancesCount: number

      defines the number of instances to draw (if instanciation is enabled)

    Returns void

drawPointClouds

Find examples in Playground
  • drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void
  • Draw a list of points

    Parameters

    • verticesStart: number

      defines the index of first vertex to draw

    • verticesCount: number

      defines the count of vertices to draw

    • Optional instancesCount: number

      defines the number of instances to draw (if instanciation is enabled)

    Returns void

drawUnIndexed

Find examples in Playground
  • drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void
  • Draw a list of unindexed primitives

    Parameters

    • useTriangles: boolean

      defines if triangles must be used to draw (else wireframe will be used)

    • verticesStart: number

      defines the index of first vertex to draw

    • verticesCount: number

      defines the count of vertices to draw

    • Optional instancesCount: number

      defines the number of instances to draw (if instanciation is enabled)

    Returns void

enableEffect

Find examples in Playground
  • Activates an effect, mkaing it the current one (ie. the one used for rendering)

    Parameters

    Returns void

endFrame

Find examples in Playground
  • endFrame(): void
  • Enf the current frame

    Returns void

excludedCompressedTextureFormats

Find examples in Playground
  • Filters the compressed texture formats to only include files that are not included in the skippable list

    Parameters

    • url: Nullable<string>

      the current extension

    • textureFormatInUse: Nullable<string>

      the current compressed texture format

    Returns Nullable<string>

    "format" string

flushFramebuffer

Find examples in Playground
  • flushFramebuffer(): void
  • Force a webGL flush (ie. a flush of all waiting webGL commands)

    Returns void

getAttributes

Find examples in Playground
  • getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[]
  • Gets the lsit of active attributes for a given webGL program

    Parameters

    • pipelineContext: IPipelineContext

      defines the pipeline context to use

    • attributesNames: string[]

      defines the list of attribute names to get

    Returns number[]

    an array of indices indicating the offset of each attribute

getCaps

Find examples in Playground
  • Gets the object containing all engine capabilities

    Returns EngineCapabilities

    the EngineCapabilities object

getClassName

Find examples in Playground
  • getClassName(): string
  • Gets a string idenfifying the name of the class

    Returns string

    "Engine" string

getError

Find examples in Playground
  • getError(): number

getGlInfo

Find examples in Playground
  • getGlInfo(): object
  • Gets an object containing information about the current webGL context

    Returns object

    an object containing the vender, the renderer and the version of the current webGL context

    • renderer: string
    • vendor: string
    • version: string

getHardwareScalingLevel

Find examples in Playground
  • getHardwareScalingLevel(): number
  • Gets the current hardware scaling level. By default the hardware scaling level is computed from the window device ratio. if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.

    Returns number

    a number indicating the current hardware scaling level

getHostDocument

Find examples in Playground
  • getHostDocument(): Document
  • Gets host document

    Returns Document

    the host document object

getHostWindow

Find examples in Playground
  • Gets host window

    Returns Nullable<Window>

    the host window object

getLoadedTexturesCache

Find examples in Playground
  • Gets the list of loaded textures

    Returns InternalTexture[]

    an array containing all loaded textures

getRenderHeight

Find examples in Playground
  • getRenderHeight(useScreen?: boolean): number
  • Gets the current render height

    Parameters

    • Optional useScreen: boolean

      defines if screen size must be used (or the current render target if any)

    Returns number

    a number defining the current render height

getRenderWidth

Find examples in Playground
  • getRenderWidth(useScreen?: boolean): number
  • Gets the current render width

    Parameters

    • Optional useScreen: boolean

      defines if screen size must be used (or the current render target if any)

    Returns number

    a number defining the current render width

getRenderingCanvas

Find examples in Playground
  • getRenderingCanvas(): Nullable<HTMLCanvasElement>
  • Gets the HTML canvas attached with the current webGL context

    Returns Nullable<HTMLCanvasElement>

    a HTML canvas

getUniforms

Find examples in Playground
  • Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names

    Parameters

    • pipelineContext: IPipelineContext

      defines the pipeline context to use

    • uniformsNames: string[]

      defines the list of uniform names

    Returns Nullable<WebGLUniformLocation>[]

    an array of webGL uniform locations

recordVertexArrayObject

Find examples in Playground

releaseEffects

Find examples in Playground
  • releaseEffects(): void
  • Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled

    Returns void

releaseVertexArrayObject

Find examples in Playground
  • Release and free the memory of a vertex array object

    Parameters

    Returns void

resetTextureCache

Find examples in Playground
  • resetTextureCache(): void
  • Reset the texture cache to empty state

    Returns void

resize

Find examples in Playground
  • resize(): void
  • Resize the view according to the canvas' size

    Returns void

restoreDefaultFramebuffer

Find examples in Playground
  • restoreDefaultFramebuffer(): void
  • Unbind the current render target and bind the default framebuffer

    Returns void

runRenderLoop

Find examples in Playground
  • runRenderLoop(renderFunction: function): void
  • Register and execute a render loop. The engine can have more than one render function

    Parameters

    • renderFunction: function

      defines the function to continuously execute

        • (): void
        • Returns void

    Returns void

setArray

Find examples in Playground
  • setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void
  • Set the value of an uniform to an array of number

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: number[] | Float32Array

      defines the array of number to store

    Returns void

setArray2

Find examples in Playground
  • setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void
  • Set the value of an uniform to an array of number (stored as vec2)

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: number[] | Float32Array

      defines the array of number to store

    Returns void

setArray3

Find examples in Playground
  • setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void
  • Set the value of an uniform to an array of number (stored as vec3)

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: number[] | Float32Array

      defines the array of number to store

    Returns void

setArray4

Find examples in Playground
  • setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void
  • Set the value of an uniform to an array of number (stored as vec4)

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: number[] | Float32Array

      defines the array of number to store

    Returns void

setFloat

Find examples in Playground
  • setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void
  • Set the value of an uniform to a number (float)

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • value: number

      defines the float number to store

    Returns void

setFloat2

Find examples in Playground
  • setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void
  • Set the value of an uniform to a vec2

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • x: number

      defines the 1st component of the value

    • y: number

      defines the 2nd component of the value

    Returns void

setFloat3

Find examples in Playground
  • setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void
  • Set the value of an uniform to a vec3

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • x: number

      defines the 1st component of the value

    • y: number

      defines the 2nd component of the value

    • z: number

      defines the 3rd component of the value

    Returns void

setFloat4

Find examples in Playground
  • setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void
  • Set the value of an uniform to a vec4

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • x: number

      defines the 1st component of the value

    • y: number

      defines the 2nd component of the value

    • z: number

      defines the 3rd component of the value

    • w: number

      defines the 4th component of the value

    Returns void

setHardwareScalingLevel

Find examples in Playground
  • setHardwareScalingLevel(level: number): void
  • Defines the hardware scaling level. By default the hardware scaling level is computed from the window device ratio. if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.

    Parameters

    • level: number

      defines the level to use

    Returns void

setInt

Find examples in Playground
  • setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void
  • Set the value of an uniform to a number (int)

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • value: number

      defines the int number to store

    Returns void

setIntArray

Find examples in Playground
  • setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void
  • Set the value of an uniform to an array of int32

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Int32Array

      defines the array of int32 to store

    Returns void

setIntArray2

Find examples in Playground
  • setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void
  • Set the value of an uniform to an array of int32 (stored as vec2)

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Int32Array

      defines the array of int32 to store

    Returns void

setIntArray3

Find examples in Playground
  • setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void
  • Set the value of an uniform to an array of int32 (stored as vec3)

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Int32Array

      defines the array of int32 to store

    Returns void

setIntArray4

Find examples in Playground
  • setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void
  • Set the value of an uniform to an array of int32 (stored as vec4)

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Int32Array

      defines the array of int32 to store

    Returns void

setMatrices

Find examples in Playground
  • setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void
  • Set the value of an uniform to an array of float32 (stored as matrices)

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • matrices: Float32Array

      defines the array of float32 to store

    Returns void

setMatrix2x2

Find examples in Playground
  • setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void
  • Set the value of an uniform to a matrix (2x2)

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • matrix: Float32Array

      defines the Float32Array representing the 2x2 matrix to store

    Returns void

setMatrix3x3

Find examples in Playground
  • setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void
  • Set the value of an uniform to a matrix (3x3)

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • matrix: Float32Array

      defines the Float32Array representing the 3x3 matrix to store

    Returns void

setSize

Find examples in Playground
  • setSize(width: number, height: number): void
  • Force a specific size of the canvas

    Parameters

    • width: number

      defines the new canvas' width

    • height: number

      defines the new canvas' height

    Returns void

setTexture

Find examples in Playground
  • Sets a texture to the according uniform.

    Parameters

    • channel: number

      The texture channel

    • uniform: Nullable<WebGLUniformLocation>

      The uniform to set

    • texture: Nullable<BaseTexture>

      The texture to apply

    Returns void

setTextureArray

Find examples in Playground
  • setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void
  • Sets an array of texture to the webGL context

    Parameters

    • channel: number

      defines the channel where the texture array must be set

    • uniform: Nullable<WebGLUniformLocation>

      defines the associated uniform location

    • textures: BaseTexture[]

      defines the array of textures to bind

    Returns void

setViewport

Find examples in Playground
  • setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void
  • Set the WebGL's viewport

    Parameters

    • viewport: IViewportLike

      defines the viewport element to be used

    • Optional requiredWidth: number

      defines the width required for rendering. If not provided the rendering canvas' width is used

    • Optional requiredHeight: number

      defines the height required for rendering. If not provided the rendering canvas' height is used

    Returns void

stopRenderLoop

Find examples in Playground
  • stopRenderLoop(renderFunction?: function): void
  • stop executing a render loop function and remove it from the execution array

    Parameters

    • Optional renderFunction: function

      defines the function to be removed. If not provided all functions will be removed.

        • (): void
        • Returns void

    Returns void

unBindFramebuffer

Find examples in Playground
  • unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: function): void
  • Unbind the current render target texture from the webGL context

    Parameters

    • texture: InternalTexture

      defines the render target texture to unbind

    • Optional disableGenerateMipMaps: boolean

      defines a boolean indicating that mipmaps must not be generated

    • Optional onBeforeUnbind: function

      defines a function which will be called before the effective unbind

        • (): void
        • Returns void

    Returns void

unBindMultiColorAttachmentFramebuffer

Find examples in Playground
  • unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: function): void
  • Unbind a list of render target textures from the webGL context This is used only when drawBuffer extension or webGL2 are active

    Parameters

    • textures: InternalTexture[]

      defines the render target textures to unbind

    • disableGenerateMipMaps: boolean

      defines a boolean indicating that mipmaps must not be generated

    • Optional onBeforeUnbind: function

      defines a function which will be called before the effective unbind

        • (): void
        • Returns void

    Returns void

unbindAllAttributes

Find examples in Playground
  • unbindAllAttributes(): void
  • Unbind all vertex attributes from the webGL context

    Returns void

unbindAllTextures

Find examples in Playground
  • unbindAllTextures(): void
  • Unbind all textures from the webGL context

    Returns void

unbindInstanceAttributes

Find examples in Playground
  • unbindInstanceAttributes(): void
  • Unbind all instance attributes

    Returns void

updateAndBindInstancesBuffer

Find examples in Playground
  • Update the content of a webGL buffer used with instanciation and bind it to the webGL context

    Parameters

    • instancesBuffer: DataBuffer

      defines the webGL buffer to update and bind

    • data: Float32Array

      defines the data to store in the buffer

    • offsetLocations: number[] | InstancingAttributeInfo[]

      defines the offsets or attributes information used to determine where data must be stored in the buffer

    Returns void

updateArrayBuffer

Find examples in Playground
  • updateArrayBuffer(data: Float32Array): void
  • update the bound buffer with the given data

    Parameters

    • data: Float32Array

      defines the data to update

    Returns void

updateDynamicTexture

Find examples in Playground
  • updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void
  • Update the content of a dynamic texture

    Parameters

    • texture: Nullable<InternalTexture>

      defines the texture to update

    • canvas: HTMLCanvasElement | OffscreenCanvas

      defines the canvas containing the source

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • Optional premulAlpha: boolean

      defines if alpha is stored as premultiplied

    • Optional format: number

      defines the format of the data

    • Optional forceBindTexture: boolean

      if the texture should be forced to be bound eg. after a graphics context loss (Default: false)

    Returns void

updateMultipleRenderTargetTextureSampleCount

Find examples in Playground

updateTextureSamplingMode

Find examples in Playground
  • updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void
  • Update the sampling mode of a given texture

    Parameters

    • samplingMode: number

      defines the required sampling mode

    • texture: InternalTexture

      defines the texture to update

    Returns void

updateUniformBuffer

Find examples in Playground
  • updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void

updateVideoTexture

Find examples in Playground
  • Update a video texture

    Parameters

    • texture: Nullable<InternalTexture>

      defines the texture to update

    • video: HTMLVideoElement

      defines the video element to use

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    Returns void

wipeCaches

Find examples in Playground
  • wipeCaches(bruteForce?: boolean): void
  • Force the entire cache to be cleared You should not have to use this function unless your engine needs to share the webGL context with another engine

    Parameters

    • Optional bruteForce: boolean

      defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)

    Returns void

Static CeilingPOT

Find examples in Playground
  • CeilingPOT(x: number): number
  • Find the next highest power of two.

    Parameters

    • x: number

      Number to start search from.

    Returns number

    Next highest power of two.

Static FloorPOT

Find examples in Playground
  • FloorPOT(x: number): number
  • Find the next lowest power of two.

    Parameters

    • x: number

      Number to start search from.

    Returns number

    Next lowest power of two.

Static GetExponentOfTwo

Find examples in Playground
  • GetExponentOfTwo(value: number, max: number, mode?: number): number
  • Get the closest exponent of two

    Parameters

    • value: number

      defines the value to approximate

    • max: number

      defines the maximum value to return

    • Optional mode: number

      defines how to define the closest value

    Returns number

    closest exponent of two of the given value

Static NearestPOT

Find examples in Playground
  • NearestPOT(x: number): number
  • Find the nearest power of two.

    Parameters

    • x: number

      Number to start search from.

    Returns number

    Next nearest power of two.

Static QueueNewFrame

Find examples in Playground
  • QueueNewFrame(func: function, requester?: any): number
  • Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)

    Parameters

    • func: function

      the function to be called

        • (): void
        • Returns void

    • Optional requester: any

      the object that will request the next frame. Falls back to window.

    Returns number

    frame number

Static isSupported

Find examples in Playground
  • isSupported(): boolean
  • Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)

    ignorenaming

    Returns boolean

    true if the engine can be created

Generated using TypeDoc