Engine

The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

Find examples in Playground
  • new Engine(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean): Engine
  • 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 Engine

Properties

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<Viewport>

Gets the current viewport

customAnimationFrameRequester

Find examples in Playground
customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>

If set, will be used to request the next animation frame for the render loop

description

Find examples in Playground
description: string

Returns a string describing the current engine

disableManifestCheck

Find examples in Playground
disableManifestCheck: boolean

Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)

disablePerformanceMonitorInBackground

Find examples in Playground
disablePerformanceMonitorInBackground: boolean

Turn this value on if you want to pause FPS computation when in background

disableTextureBindingOptimization

Find examples in Playground
disableTextureBindingOptimization: boolean

Gets or sets a value indicating if we want to disable texture binding optimization. This could be required on some buggy drivers which wants to have textures bound in a progressive order. By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is

disableUniformBuffers

Find examples in Playground
disableUniformBuffers: boolean

Gets or sets a boolean indicating that uniform buffers 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

emptyTexture3D

Find examples in Playground
emptyTexture3D: InternalTexture

Gets the default empty 3D texture

enableOfflineSupport

Find examples in Playground
enableOfflineSupport: boolean

Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest

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

isInVRExclusivePointerMode

Find examples in Playground
isInVRExclusivePointerMode: boolean

Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers

see

https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input

isPointerLock

Find examples in Playground
isPointerLock: boolean

Gets a boolean indicating if the pointer is currently locked

isStencilEnable

Find examples in Playground
isStencilEnable: boolean

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

loadingScreen

Find examples in Playground
loadingScreen: ILoadingScreen

Sets the current loading screen object

see

http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen

loadingUIBackgroundColor

Find examples in Playground
loadingUIBackgroundColor: string

Sets the current loading screen background color

see

http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen

loadingUIText

Find examples in Playground
loadingUIText: string

Sets the current loading screen text

see

http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen

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

onAfterShaderCompilationObservable

Find examples in Playground
onAfterShaderCompilationObservable: Observable<Engine>

Observable raised when the engine has jsut compiled a shader

onBeforeShaderCompilationObservable

Find examples in Playground
onBeforeShaderCompilationObservable: Observable<Engine>

Observable raised when the engine is about to compile a shader

onBeforeTextureInitObservable

Find examples in Playground
onBeforeTextureInitObservable: Observable<Texture>

Observable event triggered before each texture is initialized

onBeginFrameObservable

Find examples in Playground
onBeginFrameObservable: Observable<Engine>

Observable raised when the engine begins a new frame

onCanvasBlurObservable

Find examples in Playground
onCanvasBlurObservable: Observable<Engine>

Observable event triggered each time the canvas loses focus

onCanvasFocusObservable

Find examples in Playground
onCanvasFocusObservable: Observable<Engine>

Observable event triggered each time the canvas gains focus

onCanvasPointerOutObservable

Find examples in Playground
onCanvasPointerOutObservable: Observable<PointerEvent>

Observable event triggered each time the canvas receives pointerout event

onContextLostObservable

Find examples in Playground
onContextLostObservable: Observable<Engine>

Observable signaled when a context lost event is raised

onContextRestoredObservable

Find examples in Playground
onContextRestoredObservable: Observable<Engine>

Observable signaled when a context restored event is raised

onEndFrameObservable

Find examples in Playground
onEndFrameObservable: Observable<Engine>

Observable raised when the engine ends the current frame

onNewSceneAddedObservable

Find examples in Playground
onNewSceneAddedObservable: Observable<Scene>

Event raised when a new scene is created

onResizeObservable

Find examples in Playground
onResizeObservable: Observable<Engine>

Observable event triggered each time the rendering canvas is resized

onVRDisplayChangedObservable

Find examples in Playground
onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>

Observable signaled when VR display mode changes

onVRRequestPresentComplete

Find examples in Playground
onVRRequestPresentComplete: Observable<boolean>

Observable signaled when VR request present is complete

onVRRequestPresentStart

Find examples in Playground
onVRRequestPresentStart: Observable<Engine>

Observable signaled when VR request present starts

performanceMonitor

Find examples in Playground
performanceMonitor: PerformanceMonitor

Gets the performance monitor attached to this engine

see

http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation

postProcesses

Find examples in Playground
postProcesses: PostProcess[]

Gets the list of created postprocesses

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

scenes

Find examples in Playground
scenes: Scene[]

Gets the list of created scenes

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

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 ALPHA_ADD

Find examples in Playground
ALPHA_ADD: number

Defines that alpha blending to SRC ALPHA * SRC + DEST

Static ALPHA_COMBINE

Find examples in Playground
ALPHA_COMBINE: number

Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST

Static ALPHA_DISABLE

Find examples in Playground
ALPHA_DISABLE: number

Defines that alpha blending is disabled

Static ALPHA_INTERPOLATE

Find examples in Playground
ALPHA_INTERPOLATE: number

Defines that alpha blending to CST * SRC + (1 - CST) * DEST

Static ALPHA_MAXIMIZED

Find examples in Playground
ALPHA_MAXIMIZED: number

Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST

Static ALPHA_MULTIPLY

Find examples in Playground
ALPHA_MULTIPLY: number

Defines that alpha blending to SRC * DEST

Static ALPHA_ONEONE

Find examples in Playground
ALPHA_ONEONE: number

Defines that alpha blending to SRC + DEST

Static ALPHA_PREMULTIPLIED

Find examples in Playground
ALPHA_PREMULTIPLIED: number

Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST

Static ALPHA_PREMULTIPLIED_PORTERDUFF

Find examples in Playground
ALPHA_PREMULTIPLIED_PORTERDUFF: number

Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA

Static ALPHA_SCREENMODE

Find examples in Playground
ALPHA_SCREENMODE: number

Defines that alpha blending to SRC + (1 - SRC) * DEST Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA

Static ALPHA_SUBTRACT

Find examples in Playground
ALPHA_SUBTRACT: number

Defines that alpha blending to DEST - SRC * DEST

Static ALWAYS

Find examples in Playground
ALWAYS: number

Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn

Static AudioEngineFactory

Find examples in Playground
AudioEngineFactory: function

Default AudioEngine factory responsible of creating the Audio Engine. By default, this will create a BabylonJS Audio Engine if the workload has been embedded.

Type declaration

Static CodeRepository

Find examples in Playground
CodeRepository: string

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

Static CollisionsEpsilon

Find examples in Playground
CollisionsEpsilon: number

Gets or sets the epsilon value used by collision engine

Static DECR

Find examples in Playground
DECR: number

Passed to stencilOperation to specify that stencil value must be decremented

Static DECR_WRAP

Find examples in Playground
DECR_WRAP: number

Passed to stencilOperation to specify that stencil value must be decremented with wrapping

Static DELAYLOADSTATE_LOADED

Find examples in Playground
DELAYLOADSTATE_LOADED: number

Defines that the ressource was successfully delay loaded

Static DELAYLOADSTATE_LOADING

Find examples in Playground
DELAYLOADSTATE_LOADING: number

Defines that the ressource is currently delay loading

Static DELAYLOADSTATE_NONE

Find examples in Playground
DELAYLOADSTATE_NONE: number

Defines that the ressource is not delayed

Static DELAYLOADSTATE_NOTLOADED

Find examples in Playground
DELAYLOADSTATE_NOTLOADED: number

Defines that the ressource is delayed and has not started loading

Static EQUAL

Find examples in Playground
EQUAL: number

Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value

Static ExceptionList

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

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

Static GEQUAL

Find examples in Playground
GEQUAL: number

Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value

Static GREATER

Find examples in Playground
GREATER: number

Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value

Static INCR

Find examples in Playground
INCR: number

Passed to stencilOperation to specify that stencil value must be incremented

Static INCR_WRAP

Find examples in Playground
INCR_WRAP: number

Passed to stencilOperation to specify that stencil value must be incremented with wrapping

Static INVERT

Find examples in Playground
INVERT: number

Passed to stencilOperation to specify that stencil value must be inverted

Static Instances

Find examples in Playground
Instances: Engine[]

Gets the list of created engines

Static KEEP

Find examples in Playground
KEEP: number

Passed to stencilOperation to specify that stencil value must be kept

Static LEQUAL

Find examples in Playground
LEQUAL: number

Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value

Static LESS

Find examples in Playground
LESS: number

Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value

Static LastCreatedEngine

Find examples in Playground
LastCreatedEngine: Nullable<Engine>

Gets the latest created engine

Static LastCreatedScene

Find examples in Playground
LastCreatedScene: Nullable<Scene>

Gets the latest created scene

Static NEVER

Find examples in Playground
NEVER: number

Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn

Static NOTEQUAL

Find examples in Playground
NOTEQUAL: number

Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value

Static OfflineProviderFactory

Find examples in Playground
OfflineProviderFactory: function

Default offline support factory responsible of creating a tool used to store data locally. By default, this will create a Database object if the workload has been embedded.

Type declaration

    • (urlToScene: string, callbackManifestChecked: function, disableManifestCheck: boolean): IOfflineProvider
    • Parameters

      • urlToScene: string
      • callbackManifestChecked: function
          • (checked: boolean): any
          • Parameters

            • checked: boolean

            Returns any

      • disableManifestCheck: boolean

      Returns IOfflineProvider

Static REPLACE

Find examples in Playground
REPLACE: number

Passed to stencilOperation to specify that stencil value must be replaced

Static SCALEMODE_CEILING

Find examples in Playground
SCALEMODE_CEILING: number

Defines that texture rescaling will use a ceil to find the closer power of 2 size

Static SCALEMODE_FLOOR

Find examples in Playground
SCALEMODE_FLOOR: number

Defines that texture rescaling will use a floor to find the closer power of 2 size

Static SCALEMODE_NEAREST

Find examples in Playground
SCALEMODE_NEAREST: number

Defines that texture rescaling will look for the nearest power of 2 size

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 TEXTUREFORMAT_ALPHA

Find examples in Playground
TEXTUREFORMAT_ALPHA: number

ALPHA

Static TEXTUREFORMAT_LUMINANCE

Find examples in Playground
TEXTUREFORMAT_LUMINANCE: number

LUMINANCE

Static TEXTUREFORMAT_LUMINANCE_ALPHA

Find examples in Playground
TEXTUREFORMAT_LUMINANCE_ALPHA: number

LUMINANCE_ALPHA

Static TEXTUREFORMAT_R

Find examples in Playground
TEXTUREFORMAT_R: number

RED (2nd reference)

Static TEXTUREFORMAT_RED

Find examples in Playground
TEXTUREFORMAT_RED: number

RED

Static TEXTUREFORMAT_RED_INTEGER

Find examples in Playground
TEXTUREFORMAT_RED_INTEGER: number

RED_INTEGER

Static TEXTUREFORMAT_RG

Find examples in Playground
TEXTUREFORMAT_RG: number

RG

Static TEXTUREFORMAT_RGB

Find examples in Playground
TEXTUREFORMAT_RGB: number

RGB

Static TEXTUREFORMAT_RGBA

Find examples in Playground
TEXTUREFORMAT_RGBA: number

RGBA

Static TEXTUREFORMAT_RGBA_INTEGER

Find examples in Playground
TEXTUREFORMAT_RGBA_INTEGER: number

RGBA_INTEGER

Static TEXTUREFORMAT_RGB_INTEGER

Find examples in Playground
TEXTUREFORMAT_RGB_INTEGER: number

RGB_INTEGER

Static TEXTUREFORMAT_RG_INTEGER

Find examples in Playground
TEXTUREFORMAT_RG_INTEGER: number

RG_INTEGER

Static TEXTUREFORMAT_R_INTEGER

Find examples in Playground
TEXTUREFORMAT_R_INTEGER: number

RED_INTEGER (2nd reference)

Static TEXTURETYPE_BYTE

Find examples in Playground
TEXTURETYPE_BYTE: number

BYTE

Static TEXTURETYPE_FLOAT

Find examples in Playground
TEXTURETYPE_FLOAT: number

FLOAT

Static TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV

Find examples in Playground
TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number

FLOAT_32_UNSIGNED_INT_24_8_REV

Static TEXTURETYPE_HALF_FLOAT

Find examples in Playground
TEXTURETYPE_HALF_FLOAT: number

HALF_FLOAT

Static TEXTURETYPE_INT

Find examples in Playground
TEXTURETYPE_INT: number

INT

Static TEXTURETYPE_SHORT

Find examples in Playground
TEXTURETYPE_SHORT: number

SHORT

Static TEXTURETYPE_UNSIGNED_BYTE

Find examples in Playground
TEXTURETYPE_UNSIGNED_BYTE: number

UNSIGNED_BYTE

Static TEXTURETYPE_UNSIGNED_INT

Find examples in Playground
TEXTURETYPE_UNSIGNED_INT: number

UNSIGNED_BYTE (2nd reference)

Static TEXTURETYPE_UNSIGNED_INTEGER

Find examples in Playground
TEXTURETYPE_UNSIGNED_INTEGER: number

UNSIGNED_INT

Static TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV

Find examples in Playground
TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number

UNSIGNED_INT_10F_11F_11F_REV

Static TEXTURETYPE_UNSIGNED_INT_24_8

Find examples in Playground
TEXTURETYPE_UNSIGNED_INT_24_8: number

UNSIGNED_INT_24_8

Static TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV

Find examples in Playground
TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number

UNSIGNED_INT_2_10_10_10_REV

Static TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV

Find examples in Playground
TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number

UNSIGNED_INT_5_9_9_9_REV

Static TEXTURETYPE_UNSIGNED_SHORT

Find examples in Playground
TEXTURETYPE_UNSIGNED_SHORT: number

UNSIGNED_SHORT

Static TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4

Find examples in Playground
TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number

UNSIGNED_SHORT_4_4_4_4

Static TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1

Find examples in Playground
TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number

UNSIGNED_SHORT_5_5_5_1

Static TEXTURETYPE_UNSIGNED_SHORT_5_6_5

Find examples in Playground
TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number

UNSIGNED_SHORT_5_6_5

Static TEXTURE_BILINEAR_SAMPLINGMODE

Find examples in Playground
TEXTURE_BILINEAR_SAMPLINGMODE: number

Bilinear is mag = linear and min = linear and mip = nearest

Static TEXTURE_CLAMP_ADDRESSMODE

Find examples in Playground
TEXTURE_CLAMP_ADDRESSMODE: number

Texture is not repeating outside of 0..1 UVs

Static TEXTURE_CUBIC_MODE

Find examples in Playground
TEXTURE_CUBIC_MODE: number

Cubic coordinates mode

Static TEXTURE_EQUIRECTANGULAR_MODE

Find examples in Playground
TEXTURE_EQUIRECTANGULAR_MODE: number

Equirectangular coordinates mode

Static TEXTURE_EXPLICIT_MODE

Find examples in Playground
TEXTURE_EXPLICIT_MODE: number

Explicit coordinates mode

Static TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE

Find examples in Playground
TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number

Equirectangular Fixed Mirrored coordinates mode

Static TEXTURE_FIXED_EQUIRECTANGULAR_MODE

Find examples in Playground
TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number

Equirectangular Fixed coordinates mode

Static TEXTURE_INVCUBIC_MODE

Find examples in Playground
TEXTURE_INVCUBIC_MODE: number

Inverse Cubic coordinates mode

Static TEXTURE_LINEAR_LINEAR

Find examples in Playground
TEXTURE_LINEAR_LINEAR: number

mag = linear and min = linear and mip = none

Static TEXTURE_LINEAR_LINEAR_MIPLINEAR

Find examples in Playground
TEXTURE_LINEAR_LINEAR_MIPLINEAR: number

Trilinear is mag = linear and min = linear and mip = linear

Static TEXTURE_LINEAR_LINEAR_MIPNEAREST

Find examples in Playground
TEXTURE_LINEAR_LINEAR_MIPNEAREST: number

Bilinear is mag = linear and min = linear and mip = nearest

Static TEXTURE_LINEAR_NEAREST

Find examples in Playground
TEXTURE_LINEAR_NEAREST: number

mag = linear and min = nearest and mip = none

Static TEXTURE_LINEAR_NEAREST_MIPLINEAR

Find examples in Playground
TEXTURE_LINEAR_NEAREST_MIPLINEAR: number

mag = linear and min = nearest and mip = linear

Static TEXTURE_LINEAR_NEAREST_MIPNEAREST

Find examples in Playground
TEXTURE_LINEAR_NEAREST_MIPNEAREST: number

mag = linear and min = nearest and mip = nearest

Static TEXTURE_MIRROR_ADDRESSMODE

Find examples in Playground
TEXTURE_MIRROR_ADDRESSMODE: number

Texture is repeating and mirrored

Static TEXTURE_NEAREST_LINEAR

Find examples in Playground
TEXTURE_NEAREST_LINEAR: number

mag = nearest and min = linear and mip = none

Static TEXTURE_NEAREST_LINEAR_MIPLINEAR

Find examples in Playground
TEXTURE_NEAREST_LINEAR_MIPLINEAR: number

mag = nearest and min = linear and mip = linear

Static TEXTURE_NEAREST_LINEAR_MIPNEAREST

Find examples in Playground
TEXTURE_NEAREST_LINEAR_MIPNEAREST: number

mag = nearest and min = linear and mip = nearest

Static TEXTURE_NEAREST_NEAREST

Find examples in Playground
TEXTURE_NEAREST_NEAREST: number

mag = nearest and min = nearest and mip = none

Static TEXTURE_NEAREST_NEAREST_MIPLINEAR

Find examples in Playground
TEXTURE_NEAREST_NEAREST_MIPLINEAR: number

nearest is mag = nearest and min = nearest and mip = linear

Static TEXTURE_NEAREST_NEAREST_MIPNEAREST

Find examples in Playground
TEXTURE_NEAREST_NEAREST_MIPNEAREST: number

mag = nearest and min = nearest and mip = nearest

Static TEXTURE_NEAREST_SAMPLINGMODE

Find examples in Playground
TEXTURE_NEAREST_SAMPLINGMODE: number

nearest is mag = nearest and min = nearest and mip = linear

Static TEXTURE_PLANAR_MODE

Find examples in Playground
TEXTURE_PLANAR_MODE: number

Planar coordinates mode

Static TEXTURE_PROJECTION_MODE

Find examples in Playground
TEXTURE_PROJECTION_MODE: number

Projection coordinates mode

Static TEXTURE_SKYBOX_MODE

Find examples in Playground
TEXTURE_SKYBOX_MODE: number

Skybox coordinates mode

Static TEXTURE_SPHERICAL_MODE

Find examples in Playground
TEXTURE_SPHERICAL_MODE: number

Spherical coordinates mode

Static TEXTURE_TRILINEAR_SAMPLINGMODE

Find examples in Playground
TEXTURE_TRILINEAR_SAMPLINGMODE: number

Trilinear is mag = linear and min = linear and mip = linear

Static TEXTURE_WRAP_ADDRESSMODE

Find examples in Playground
TEXTURE_WRAP_ADDRESSMODE: number

Texture is repeating outside of 0..1 UVs

Static Version

Find examples in Playground
Version: string

Returns the current version of the framework

Static audioEngine

Find examples in Playground
audioEngine: IAudioEngine

Gets the audio engine

see

http://doc.babylonjs.com/how_to/playing_sounds_and_music

ignorenaming

Methods

addExternalData

Find examples in Playground
  • addExternalData<T>(key: string, data: T): boolean
  • Add an externaly attached data from its key. This method call will fail and return false, if such key already exists. If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.

    Type parameters

    • T

    Parameters

    • key: string

      the unique key that identifies the data

    • data: T

      the data object to associate to the key for this Engine instance

    Returns boolean

    true if no such key were already present and the data was added successfully, false otherwise

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

beginOcclusionQuery

Find examples in Playground

beginTransformFeedback

Find examples in Playground
  • beginTransformFeedback(usePoints: boolean): void
  • Begins a transform feedback operation

    Parameters

    • usePoints: boolean

      defines if points or triangles must be used

    Returns void

bindArrayBuffer

Find examples in Playground
  • bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void
  • Bind a webGL buffer to the webGL context

    Parameters

    • buffer: Nullable<WebGLBuffer>

      defines the buffer to bind

    Returns void

bindBuffers

Find examples in Playground
  • bindBuffers(vertexBuffers: object, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void
  • Bind a list of vertex buffers to the webGL context

    Parameters

    • vertexBuffers: object

      defines the list of vertex buffers to bind

    • indexBuffer: Nullable<WebGLBuffer>

      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: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void
  • Bind webGl buffers directly to the webGL context

    Parameters

    • vertexBuffer: WebGLBuffer

      defines the vertex buffer to bind

    • indexBuffer: WebGLBuffer

      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

bindTransformFeedback

Find examples in Playground
  • Bind a webGL transform feedback object to the webgl context

    Parameters

    Returns void

bindTransformFeedbackBuffer

Find examples in Playground
  • bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void
  • Bind a webGL buffer for a transform feedback operation

    Parameters

    • value: Nullable<WebGLBuffer>

      defines the webGL buffer to bind

    Returns void

bindUniformBlock

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

    Parameters

    • shaderProgram: WebGLProgram

      defines the shader program

    • blockName: string

      defines the block name

    • index: number

      defines the index where to bind the block

    Returns void

bindUniformBuffer

Find examples in Playground
  • bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void
  • Bind an uniform buffer to the current webGL context

    Parameters

    • buffer: Nullable<WebGLBuffer>

      defines the buffer to bind

    Returns void

bindUniformBufferBase

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

    Parameters

    • buffer: WebGLBuffer

      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<Color4>, 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<Color4>

      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)

    • Optional noMipmap: boolean

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

    • 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

      if a polynomial sphere should be created for the cube texture

    • 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

    • Optional fallback: Nullable<InternalTexture>

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

    • Optional 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

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 (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)

    Returns InternalTexture

    the dynamic texture inside an InternalTexture

createDynamicUniformBuffer

Find examples in Playground
  • createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer

createDynamicVertexBuffer

Find examples in Playground
  • createDynamicVertexBuffer(data: DataArray): WebGLBuffer
  • Creates a dynamic vertex buffer

    Parameters

    • data: DataArray

      the data for the dynamic vertex buffer

    Returns WebGLBuffer

    the new WebGL dynamic buffer

createEffect

Find examples in Playground
  • createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: function, onError?: function, indexParameters?: any): Effect
  • 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[] | EffectCreationOptions

      defines either a list of attribute names or an EffectCreationOptions object

    • uniformsNamesOrEngine: string[] | Engine

      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: EffectFallbacks

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

    • Optional onCompiled: function

      defines a function to call when the effect creation is successful

        • Parameters

          Returns void

    • Optional onError: function

      defines a function to call when the effect creation has failed

        • (effect: Effect, errors: string): void
        • Parameters

          • effect: Effect
          • errors: string

          Returns void

    • 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

createEffectForParticles

Find examples in Playground
  • createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: function, onError?: function): Effect
  • Create an effect to use with particle systems. Please note that some parameters like animation sheets or not being billboard are not supported in this configuration

    Parameters

    • fragmentName: string

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

    • uniformsNames: string[]

      defines a list of attribute names

    • samplers: string[]

      defines an array of string used to represent textures

    • defines: string

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

    • Optional fallbacks: EffectFallbacks

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

    • Optional onCompiled: function

      defines a function to call when the effect creation is successful

        • Parameters

          Returns void

    • Optional onError: function

      defines a function to call when the effect creation has failed

        • (effect: Effect, errors: string): void
        • Parameters

          • effect: Effect
          • errors: string

          Returns void

    Returns Effect

    the new Effect

createIndexBuffer

Find examples in Playground
  • createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer
  • 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 WebGLBuffer

    a new webGL buffer

createInstancesBuffer

Find examples in Playground
  • createInstancesBuffer(capacity: number): WebGLBuffer
  • Creates a webGL buffer to use with instanciation

    Parameters

    • capacity: number

      defines the size of the buffer

    Returns WebGLBuffer

    the webGL buffer

createMultipleRenderTarget

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

createQuery

Find examples in Playground
  • Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)

    Returns WebGLQuery

    the new query

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 BABYLON.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 BABYLON.Texture.NEAREST_SAMPLINGMODE)

    • Optional compression: Nullable<string>

      defines the compression used (null by default)

    Returns InternalTexture

    the cube texture as an InternalTexture

createRawCubeTextureFromUrl

Find examples in Playground
  • createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: function, mipmapGenerator: Nullable<function>, onLoad?: Nullable<function>, onError?: Nullable<function>, samplingMode?: number, invertY?: boolean): InternalTexture
  • Creates a new raw cube texture from a specified url

    Parameters

    • url: string

      defines the url where the data is located

    • scene: Scene

      defines the current scene

    • size: number

      defines the size of the textures

    • format: number

      defines the format of the data

    • type: number

      defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)

    • noMipmap: boolean

      defines if the engine should avoid generating the mip levels

    • callback: function

      defines a callback used to extract texture data from loaded data

        • (ArrayBuffer: ArrayBuffer): Nullable<ArrayBufferView[]>
        • Parameters

          • ArrayBuffer: ArrayBuffer

          Returns Nullable<ArrayBufferView[]>

    • mipmapGenerator: Nullable<function>

      defines to provide an optional tool to generate mip levels

    • Optional onLoad: Nullable<function>

      defines a callback called when texture is loaded

    • Optional onError: Nullable<function>

      defines a callback called if there is an error

    • Optional samplingMode: number

      defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)

    • Optional invertY: boolean

      defines if data must be stored with Y axis inverted

    Returns InternalTexture

    the cube texture as an InternalTexture

createRawShaderProgram

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

    Parameters

    • 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 (BABYLON.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 (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)

    Returns InternalTexture

    the raw texture inside 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 BABYLON.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(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram
  • Creates a webGL program

    Parameters

    • 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 BABYLON.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. Ignored for compressed textures. Must be flipped in the file

    • scene: Nullable<Scene>

      needed for loading to the correct scene

    • Optional samplingMode: number

      mode with should be used sample / access the texture (Default: BABYLON.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 | HTMLImageElement | Blob>

      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)

    Returns InternalTexture

    a InternalTexture for assignment back into BABYLON.Texture

createTransformFeedback

Find examples in Playground
  • Creates a webGL transform feedback object Please makes sure to check webGLVersion property to check if you are running webGL 2+

    Returns WebGLTransformFeedback

    the webGL transform feedback object

createUniformBuffer

Find examples in Playground
  • createUniformBuffer(elements: FloatArray): WebGLBuffer

createVertexBuffer

Find examples in Playground
  • createVertexBuffer(data: DataArray): WebGLBuffer
  • Creates a vertex buffer

    Parameters

    • data: DataArray

      the data for the vertex buffer

    Returns WebGLBuffer

    the new WebGL static buffer

deleteInstancesBuffer

Find examples in Playground
  • deleteInstancesBuffer(buffer: WebGLBuffer): void
  • Delete a webGL buffer used with instanciation

    Parameters

    • buffer: WebGLBuffer

      defines the webGL buffer to delete

    Returns void

deleteQuery

Find examples in Playground
  • Delete and release a webGL query

    Parameters

    Returns Engine

    the current engine

deleteTransformFeedback

Find examples in Playground
  • Delete a webGL transform feedback object

    Parameters

    Returns void

disableVR

Find examples in Playground
  • disableVR(): void

displayLoadingUI

Find examples in Playground
  • displayLoadingUI(): void

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

enableVR

Find examples in Playground
  • enableVR(): void

endFrame

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

    Returns void

endOcclusionQuery

Find examples in Playground
  • endOcclusionQuery(algorithmType: number): Engine

endTimeQuery

Find examples in Playground
  • endTimeQuery(token: _TimeToken): int
  • Ends a time query

    Parameters

    • token: _TimeToken

      defines the token used to measure the time span

    Returns int

    the time spent (in ns)

endTransformFeedback

Find examples in Playground
  • endTransformFeedback(): void
  • Ends a transform feedback operation

    Returns void

flushFramebuffer

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

    Returns void

generateMipMapsForCubemap

Find examples in Playground
  • Force the mipmap generation for the given render target texture

    Parameters

    Returns void

getAlphaMode

Find examples in Playground
  • getAlphaMode(): number

getAspectRatio

Find examples in Playground
  • getAspectRatio(camera: Camera, useScreen?: boolean): number
  • Gets current aspect ratio

    Parameters

    • camera: Camera

      defines the camera to use to get the aspect ratio

    • Optional useScreen: boolean

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

    Returns number

    a number defining the aspect ratio

getAttributes

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

    Parameters

    • shaderProgram: WebGLProgram

      defines the webGL program 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

getColorWrite

Find examples in Playground
  • getColorWrite(): boolean
  • Gets a boolean indicating if color writing is enabled

    Returns boolean

    the current color writing state

getDeltaTime

Find examples in Playground
  • getDeltaTime(): number
  • Gets the time spent between current and previous frame

    Returns number

    a number representing the delta time in ms

getDepthFunction

Find examples in Playground
  • Gets the current depth function

    Returns Nullable<number>

    a number defining the depth function

getDepthWrite

Find examples in Playground
  • getDepthWrite(): boolean
  • Gets a boolean indicating if depth writing is enabled

    Returns boolean

    the current depth writing state

getError

Find examples in Playground
  • getError(): number

getExternalData

Find examples in Playground
  • getExternalData<T>(key: string): T
  • Get an externaly attached data from its key

    Type parameters

    • T

    Parameters

    • key: string

      the unique key that identifies the data

    Returns T

    the associated data, if present (can be null), or undefined if not present

getFps

Find examples in Playground
  • getFps(): number
  • Gets the current framerate

    Returns number

    a number representing the framerate

getFragmentShaderSource

Find examples in Playground
  • getFragmentShaderSource(program: WebGLProgram): Nullable<string>
  • Gets the source code of the fragment shader associated with a specific webGL program

    Parameters

    • program: WebGLProgram

      defines the program to use

    Returns Nullable<string>

    a string containing the source code of the fragment shader associated with the program

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

getLoadedTexturesCache

Find examples in Playground
  • Gets the list of loaded textures

    Returns InternalTexture[]

    an array containing all loaded textures

getLockstepMaxSteps

Find examples in Playground
  • getLockstepMaxSteps(): number

getOrAddExternalDataWithFactory

Find examples in Playground
  • getOrAddExternalDataWithFactory<T>(key: string, factory: function): T
  • Get an externaly attached data from its key, create it using a factory if it's not already present

    Type parameters

    • T

    Parameters

    • key: string

      the unique key that identifies the data

    • factory: function

      the factory that will be called to create the instance if and only if it doesn't exists

        • (k: string): T
        • Parameters

          • k: string

          Returns T

    Returns T

    the associated data, can be null if the factory returned null.

getQueryResult

Find examples in Playground
  • Gets the value of a given query

    Parameters

    Returns number

    the value of the query

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

getRenderingCanvasClientRect

Find examples in Playground
  • getRenderingCanvasClientRect(): Nullable<ClientRect>
  • Gets the client rect of the HTML canvas attached with the current webGL context

    Returns Nullable<ClientRect>

    a client rectanglee

getScreenAspectRatio

Find examples in Playground
  • getScreenAspectRatio(): number
  • Gets current screen aspect ratio

    Returns number

    a number defining the aspect ratio

getStencilBuffer

Find examples in Playground
  • getStencilBuffer(): boolean
  • Gets a boolean indicating if stencil buffer is enabled

    Returns boolean

    the current stencil buffer state

getStencilFunction

Find examples in Playground
  • getStencilFunction(): number
  • Gets the current stencil function

    Returns number

    a number defining the stencil function to use

getStencilFunctionMask

Find examples in Playground
  • getStencilFunctionMask(): number
  • Gets the current stencil mask

    Returns number

    a number defining the stencil mask to use

getStencilFunctionReference

Find examples in Playground
  • getStencilFunctionReference(): number
  • Gets the current stencil reference value

    Returns number

    a number defining the stencil reference value to use

getStencilMask

Find examples in Playground
  • getStencilMask(): number
  • Gets the current stencil mask

    Returns number

    a number defining the new stencil mask to use

getStencilOperationDepthFail

Find examples in Playground
  • getStencilOperationDepthFail(): number
  • Gets the current stencil operation when depth fails

    Returns number

    a number defining stencil operation to use when depth fails

getStencilOperationFail

Find examples in Playground
  • getStencilOperationFail(): number
  • Gets the current stencil operation when stencil fails

    Returns number

    a number defining stencil operation to use when stencil fails

getStencilOperationPass

Find examples in Playground
  • getStencilOperationPass(): number
  • Gets the current stencil operation when stencil passes

    Returns number

    a number defining stencil operation to use when stencil passes

getUniforms

Find examples in Playground
  • getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[]
  • Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names

    Parameters

    • shaderProgram: WebGLProgram

      defines the webGL program to use

    • uniformsNames: string[]

      defines the list of uniform names

    Returns Nullable<WebGLUniformLocation>[]

    an array of webGL uniform locations

getVRDevice

Find examples in Playground
  • getVRDevice(): any
  • Gets the current webVR device

    Returns any

    the current webVR device (or null)

getVertexShaderSource

Find examples in Playground
  • getVertexShaderSource(program: WebGLProgram): Nullable<string>
  • Gets the source code of the vertex shader associated with a specific webGL program

    Parameters

    • program: WebGLProgram

      defines the program to use

    Returns Nullable<string>

    a string containing the source code of the vertex shader associated with the program

getZOffset

Find examples in Playground
  • getZOffset(): number
  • Gets the current value of the zOffset

    Returns number

    the current zOffset state

hideLoadingUI

Find examples in Playground
  • hideLoadingUI(): void

initWebVR

Find examples in Playground
  • Initializes a webVR display and starts listening to display change events The onVRDisplayChangedObservable will be notified upon these changes

    Returns Observable<IDisplayChangedEventArgs>

    The onVRDisplayChangedObservable

initWebVRAsync

Find examples in Playground
  • Initializes a webVR display and starts listening to display change events The onVRDisplayChangedObservable will be notified upon these changes

    Returns Promise<IDisplayChangedEventArgs>

    A promise containing a VRDisplay and if vr is supported

isDeterministicLockStep

Find examples in Playground
  • isDeterministicLockStep(): boolean

isQueryResultAvailable

Find examples in Playground
  • isQueryResultAvailable(query: WebGLQuery): boolean
  • Check if a given query has resolved and got its value

    Parameters

    Returns boolean

    true if the query got its value

isVRDevicePresent

Find examples in Playground
  • isVRDevicePresent(): boolean
  • Gets a boolean indicating if a webVR device was detected

    Returns boolean

    true if a webVR device was detected

readPixels

Find examples in Playground
  • readPixels(x: number, y: number, width: number, height: number): Uint8Array
  • Reads pixels from the current frame buffer. Please note that this function can be slow

    Parameters

    • x: number

      defines the x coordinate of the rectangle where pixels must be read

    • y: number

      defines the y coordinate of the rectangle where pixels must be read

    • width: number

      defines the width of the rectangle where pixels must be read

    • height: number

      defines the height of the rectangle where pixels must be read

    Returns Uint8Array

    a Uint8Array containing RGBA colors

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

removeExternalData

Find examples in Playground
  • removeExternalData(key: string): boolean
  • Remove an externaly attached data from the Engine instance

    Parameters

    • key: string

      the unique key that identifies the data

    Returns boolean

    true if the data was successfully removed, false if it doesn't exist

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

scissorClear

Find examples in Playground
  • scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void
  • Executes a scissor clear (ie. a clear on a specific portion of the screen)

    Parameters

    • x: number

      defines the x-coordinate of the top left corner of the clear rectangle

    • y: number

      defines the y-coordinate of the corner of the clear rectangle

    • width: number

      defines the width of the clear rectangle

    • height: number

      defines the height of the clear rectangle

    • clearColor: Color4

      defines the clear color

    Returns void

setAlphaConstants

Find examples in Playground
  • setAlphaConstants(r: number, g: number, b: number, a: number): void
  • Sets alpha constants used by some alpha blending modes

    Parameters

    • r: number

      defines the red component

    • g: number

      defines the green component

    • b: number

      defines the blue component

    • a: number

      defines the alpha component

    Returns void

setAlphaMode

Find examples in Playground
  • setAlphaMode(mode: number, noDepthWriteChange?: boolean): void

setArray

Find examples in Playground
  • setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): 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[]

      defines the array of number to store

    Returns void

setArray2

Find examples in Playground
  • setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): 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[]

      defines the array of number to store

    Returns void

setArray3

Find examples in Playground
  • setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): 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[]

      defines the array of number to store

    Returns void

setArray4

Find examples in Playground
  • setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): 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[]

      defines the array of number to store

    Returns void

setBool

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

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • bool: number

      defines the boolean to store

    Returns void

setColor3

Find examples in Playground
  • setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void
  • Set the value of an uniform to a Color3

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • color3: Color3

      defines the color to store

    Returns void

setColor4

Find examples in Playground
  • setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void
  • Set the value of an uniform to a Color3 and an alpha value

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • color3: Color3

      defines the color to store

    • alpha: number

      defines the alpha component to store

    Returns void

setColorWrite

Find examples in Playground
  • setColorWrite(enable: boolean): void
  • Enable or disable color writing

    Parameters

    • enable: boolean

      defines the state to set

    Returns void

setDepthBuffer

Find examples in Playground
  • setDepthBuffer(enable: boolean): void
  • Enable or disable depth buffering

    Parameters

    • enable: boolean

      defines the state to set

    Returns void

setDepthFunction

Find examples in Playground
  • setDepthFunction(depthFunc: number): void
  • Sets the current depth function

    Parameters

    • depthFunc: number

      defines the function to use

    Returns void

setDepthFunctionToGreater

Find examples in Playground
  • setDepthFunctionToGreater(): void
  • Sets the current depth function to GREATER

    Returns void

setDepthFunctionToGreaterOrEqual

Find examples in Playground
  • setDepthFunctionToGreaterOrEqual(): void
  • Sets the current depth function to GEQUAL

    Returns void

setDepthFunctionToLess

Find examples in Playground
  • setDepthFunctionToLess(): void
  • Sets the current depth function to LESS

    Returns void

setDepthFunctionToLessOrEqual

Find examples in Playground
  • setDepthFunctionToLessOrEqual(): void
  • Sets the current depth function to LEQUAL

    Returns void

setDepthStencilTexture

Find examples in Playground
  • Sets a depth stencil texture from a render target to the according uniform.

    Parameters

    • channel: number

      The texture channel

    • uniform: Nullable<WebGLUniformLocation>

      The uniform to set

    • texture: Nullable<RenderTargetTexture>

      The render target texture containing the depth stencil texture to apply

    Returns void

setDepthWrite

Find examples in Playground
  • setDepthWrite(enable: boolean): void
  • Enable or disable depth writing

    Parameters

    • enable: boolean

      defines the state to set

    Returns void

setDirectColor4

Find examples in Playground
  • setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void
  • Sets a Color4 on a uniform variable

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the uniform location

    • color4: Color4

      defines the value to be set

    Returns void

setDirectViewport

Find examples in Playground
  • setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>
  • Directly set the WebGL Viewport

    Parameters

    • x: number

      defines the x coordinate of the viewport (in screen space)

    • y: number

      defines the y coordinate of the viewport (in screen space)

    • width: number

      defines the width of the viewport (in screen space)

    • height: number

      defines the height of the viewport (in screen space)

    Returns Nullable<Viewport>

    the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state

setDitheringState

Find examples in Playground
  • setDitheringState(value: boolean): void
  • Sets a boolean indicating if the dithering state is enabled or disabled

    Parameters

    • value: boolean

      defines the dithering state

    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

setFloatArray

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

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Float32Array

      defines the array of float32 to store

    Returns void

setFloatArray2

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

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Float32Array

      defines the array of float32 to store

    Returns void

setFloatArray3

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

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Float32Array

      defines the array of float32 to store

    Returns void

setFloatArray4

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

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Float32Array

      defines the array of float32 to store

    Returns void

setFrameBufferDepthStencilTexture

Find examples in Playground
  • Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.

    Parameters

    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

setMatrix

Find examples in Playground
  • setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void
  • Set the value of an uniform to a matrix

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • matrix: Matrix

      defines the matrix 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

setRasterizerState

Find examples in Playground
  • setRasterizerState(value: boolean): void
  • Sets a boolean indicating if the rasterizer state is enabled or disabled

    Parameters

    • value: boolean

      defines the rasterizer state

    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

setState

Find examples in Playground
  • setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void
  • Set various states to the webGL context

    Parameters

    • culling: boolean

      defines backface culling state

    • Optional zOffset: number

      defines the value to apply to zOffset (0 by default)

    • Optional force: boolean

      defines if states must be applied even if cache is up to date

    • Optional reverseSide: boolean

      defines if culling must be reversed (CCW instead of CW and CW instead of CCW)

    Returns void

setStencilBuffer

Find examples in Playground
  • setStencilBuffer(enable: boolean): void
  • Enable or disable the stencil buffer

    Parameters

    • enable: boolean

      defines if the stencil buffer must be enabled or disabled

    Returns void

setStencilFunction

Find examples in Playground
  • setStencilFunction(stencilFunc: number): void
  • Sets the current stencil function

    Parameters

    • stencilFunc: number

      defines the new stencil function to use

    Returns void

setStencilFunctionMask

Find examples in Playground
  • setStencilFunctionMask(mask: number): void
  • Sets the current stencil mask

    Parameters

    • mask: number

      defines the new stencil mask to use

    Returns void

setStencilFunctionReference

Find examples in Playground
  • setStencilFunctionReference(reference: number): void
  • Sets the current stencil reference

    Parameters

    • reference: number

      defines the new stencil reference to use

    Returns void

setStencilMask

Find examples in Playground
  • setStencilMask(mask: number): void
  • Sets the current stencil mask

    Parameters

    • mask: number

      defines the new stencil mask to use

    Returns void

setStencilOperationDepthFail

Find examples in Playground
  • setStencilOperationDepthFail(operation: number): void
  • Sets the stencil operation to use when depth fails

    Parameters

    • operation: number

      defines the stencil operation to use when depth fails

    Returns void

setStencilOperationFail

Find examples in Playground
  • setStencilOperationFail(operation: number): void
  • Sets the stencil operation to use when stencil fails

    Parameters

    • operation: number

      defines the stencil operation to use when stencil fails

    Returns void

setStencilOperationPass

Find examples in Playground
  • setStencilOperationPass(operation: number): void
  • Sets the stencil operation to use when stencil passes

    Parameters

    • operation: number

      defines the stencil operation to use when stencil passes

    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

setTextureFormatToUse

Find examples in Playground
  • setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>
  • Set the compressed texture format to use, based on the formats you have, and the formats supported by the hardware / browser.

    Khronos Texture Container (.ktx) files are used to support this. This format has the advantage of being specifically designed for OpenGL. Header elements directly correspond to API arguments needed to compressed textures. This puts the burden on the container generator to house the arcane code for determining these for current & future formats.

    for description see https://www.khronos.org/opengles/sdk/tools/KTX/ for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/

    Note: The result of this call is not taken into account when a texture is base64.

    Parameters

    • formatsAvailable: Array<string>

      defines the list of those format families you have created on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)

      Current families are astc, dxt, pvrtc, etc2, & etc1.

    Returns Nullable<string>

    The extension selected.

setTextureFromPostProcess

Find examples in Playground
  • Sets a texture to the webGL context from a postprocess

    Parameters

    • channel: number

      defines the channel to use

    • postProcess: Nullable<PostProcess>

      defines the source postprocess

    Returns void

setTextureFromPostProcessOutput

Find examples in Playground
  • Binds the output of the passed in post process to the texture channel specified

    Parameters

    • channel: number

      The channel the texture should be bound to

    • postProcess: Nullable<PostProcess>

      The post process which's output should be bound

    Returns void

setTranformFeedbackVaryings

Find examples in Playground
  • setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void
  • Specify the varyings to use with transform feedback

    Parameters

    • program: WebGLProgram

      defines the associated webGL program

    • value: string[]

      defines the list of strings representing the varying names

    Returns void

setViewport

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

    Parameters

    • viewport: Viewport

      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

setZOffset

Find examples in Playground
  • setZOffset(value: number): void
  • Set the z offset to apply to current rendering

    Parameters

    • value: number

      defines the offset to apply

    Returns void

startTimeQuery

Find examples in Playground
  • startTimeQuery(): Nullable<_TimeToken>
  • Starts a time query (used to measure time spent by the GPU on a specific frame) Please note that only one query can be issued at a time

    Returns Nullable<_TimeToken>

    a time token used to track the time span

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

switchFullscreen

Find examples in Playground
  • switchFullscreen(requestPointerLock: boolean): void
  • Toggle full screen mode

    Parameters

    • requestPointerLock: boolean

      defines if a pointer lock should be requested from the user

    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

    • 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

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
  • updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void
  • Update the content of a webGL buffer used with instanciation and bind it to the webGL context

    Parameters

    • instancesBuffer: WebGLBuffer

      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

updateDynamicIndexBuffer

Find examples in Playground
  • updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void
  • Update a dynamic index buffer

    Parameters

    • indexBuffer: WebGLBuffer

      defines the target index buffer

    • indices: IndicesArray

      defines the data to update

    • Optional offset: number

      defines the offset in the target index buffer where update should start

    Returns void

updateDynamicTexture

Find examples in Playground
  • updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, 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

      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

updateDynamicVertexBuffer

Find examples in Playground
  • updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void
  • Updates a dynamic vertex buffer.

    Parameters

    • vertexBuffer: WebGLBuffer

      the vertex buffer to update

    • data: DataArray

      the data used to update the vertex buffer

    • Optional byteOffset: number

      the byte offset of the data

    • Optional byteLength: number

      the byte length of the data

    Returns void

updateMultipleRenderTargetTextureSampleCount

Find examples in Playground

updateRawCubeTexture

Find examples in Playground
  • updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void
  • Update a raw cube texture

    Parameters

    • texture: InternalTexture

      defines the texture to udpdate

    • data: ArrayBufferView[]

      defines the data to store

    • format: number

      defines the data format

    • type: number

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

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • Optional compression: Nullable<string>

      defines the compression used (null by default)

    • Optional level: number

      defines which level of the texture to update

    Returns void

updateRawTexture

Find examples in Playground
  • Update a raw texture

    Parameters

    • texture: Nullable<InternalTexture>

      defines the texture to update

    • data: Nullable<ArrayBufferView>

      defines the data to store in the texture

    • format: number

      defines the format of the data

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • Optional compression: Nullable<string>

      defines the compression used (null by default)

    • Optional type: number

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

    Returns void

updateRawTexture3D

Find examples in Playground
  • updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void
  • Update a raw 3D texture

    Parameters

    • texture: InternalTexture

      defines the texture to update

    • data: Nullable<ArrayBufferView>

      defines the data to store

    • format: number

      defines the data format

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • Optional compression: Nullable<string>

      defines the used compression (can be null)

    • Optional textureType: number

      defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)

    Returns void

updateRenderTargetTextureSampleCount

Find examples in Playground

updateTextureComparisonFunction

Find examples in Playground
  • updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void
  • Updates a depth texture Comparison Mode and Function. If the comparison Function is equal to 0, the mode will be set to none. Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.

    Parameters

    • texture: InternalTexture

      The texture to set the comparison function for

    • comparisonFunction: number

      The comparison function to set, 0 if no comparison required

    Returns void

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: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void
  • Parameters

    • uniformBuffer: WebGLBuffer

      defines the target uniform buffer

    • elements: FloatArray

      defines the content to update

    • Optional offset: number

      defines the offset in the uniform buffer where update should start

    • Optional count: number

      defines the size of the data to update

    Returns 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 MarkAllMaterialsAsDirty

Find examples in Playground
  • MarkAllMaterialsAsDirty(flag: number, predicate?: function): void
  • Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation

    Parameters

    • flag: number

      defines which part of the materials must be marked as dirty

    • Optional predicate: function

      defines a predicate used to filter which materials should be affected

    Returns void

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