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

Hierarchy

  • ThinEngine
    • Engine

Constructors

Properties

adaptToDeviceRatio canvasTabIndex cullBackFaces currentRenderPassId customAnimationFrameRequester disableContextMenu disableManifestCheck disablePerformanceMonitorInBackground disableUniformBuffers disableVertexArrayObjects enableOfflineSupport enableUnpackFlipYCached forcePOTTextures hasOriginBottomLeft hostInformation isFullscreen isNDCHalfZRange isPointerLock onAfterShaderCompilationObservable onBeforeShaderCompilationObservable onBeforeTextureInitObservable onBeginFrameObservable onCanvasBlurObservable onCanvasFocusObservable onCanvasPointerOutObservable onContextLostObservable onContextRestoredObservable onDisposeObservable onEndFrameObservable onNewSceneAddedObservable onResizeObservable postProcesses premultipliedAlpha preventCacheWipeBetweenFrames renderEvenInBackground scenes startTime useExactSrgbConversions validateShaderPrograms ALPHA_ADD ALPHA_COMBINE ALPHA_DISABLE ALPHA_INTERPOLATE ALPHA_MAXIMIZED ALPHA_MULTIPLY ALPHA_ONEONE ALPHA_PREMULTIPLIED ALPHA_PREMULTIPLIED_PORTERDUFF ALPHA_SCREENMODE ALPHA_SUBTRACT ALWAYS AudioEngineFactory CollisionsEpsilon DECR DECR_WRAP DELAYLOADSTATE_LOADED DELAYLOADSTATE_LOADING DELAYLOADSTATE_NONE DELAYLOADSTATE_NOTLOADED EQUAL ExceptionList GEQUAL GREATER INCR INCR_WRAP INVERT KEEP LEQUAL LESS NEVER NOTEQUAL OfflineProviderFactory REPLACE SCALEMODE_CEILING SCALEMODE_FLOOR SCALEMODE_NEAREST TEXTUREFORMAT_ALPHA TEXTUREFORMAT_LUMINANCE TEXTUREFORMAT_LUMINANCE_ALPHA TEXTUREFORMAT_R TEXTUREFORMAT_RED TEXTUREFORMAT_RED_INTEGER TEXTUREFORMAT_RG TEXTUREFORMAT_RGB TEXTUREFORMAT_RGBA TEXTUREFORMAT_RGBA_INTEGER TEXTUREFORMAT_RGB_INTEGER TEXTUREFORMAT_RG_INTEGER TEXTUREFORMAT_R_INTEGER TEXTURETYPE_BYTE TEXTURETYPE_FLOAT TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV TEXTURETYPE_HALF_FLOAT TEXTURETYPE_INT TEXTURETYPE_SHORT TEXTURETYPE_UNSIGNED_BYTE TEXTURETYPE_UNSIGNED_INT TEXTURETYPE_UNSIGNED_INTEGER TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV TEXTURETYPE_UNSIGNED_INT_24_8 TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV TEXTURETYPE_UNSIGNED_SHORT TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 TEXTURETYPE_UNSIGNED_SHORT_5_6_5 TEXTURE_BILINEAR_SAMPLINGMODE TEXTURE_CLAMP_ADDRESSMODE TEXTURE_CUBIC_MODE TEXTURE_EQUIRECTANGULAR_MODE TEXTURE_EXPLICIT_MODE TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE TEXTURE_FIXED_EQUIRECTANGULAR_MODE TEXTURE_INVCUBIC_MODE TEXTURE_LINEAR_LINEAR TEXTURE_LINEAR_LINEAR_MIPLINEAR TEXTURE_LINEAR_LINEAR_MIPNEAREST TEXTURE_LINEAR_NEAREST TEXTURE_LINEAR_NEAREST_MIPLINEAR TEXTURE_LINEAR_NEAREST_MIPNEAREST TEXTURE_MIRROR_ADDRESSMODE TEXTURE_NEAREST_LINEAR TEXTURE_NEAREST_LINEAR_MIPLINEAR TEXTURE_NEAREST_LINEAR_MIPNEAREST TEXTURE_NEAREST_NEAREST TEXTURE_NEAREST_NEAREST_MIPLINEAR TEXTURE_NEAREST_NEAREST_MIPNEAREST TEXTURE_NEAREST_SAMPLINGMODE TEXTURE_PLANAR_MODE TEXTURE_PROJECTION_MODE TEXTURE_SKYBOX_MODE TEXTURE_SPHERICAL_MODE TEXTURE_TRILINEAR_SAMPLINGMODE TEXTURE_WRAP_ADDRESSMODE _RescalePostProcessFactory audioEngine

Accessors

Methods

_createDepthStencilCubeTexture _createImageBitmapFromSource _deletePipelineContext _renderLoop _updateRenderBuffer applyStates areAllEffectsReady attachContextLostEvent attachContextRestoredEvent beginFrame bindArrayBuffer bindAttachments bindBuffers bindBuffersDirectly bindFramebuffer bindInstancesBuffer bindSamplers bindUniformBlock bindUniformBuffer bindUniformBufferBase bindVertexArrayObject buildTextureLayout cacheStencilState clear clearInternalTexturesCache createCanvas createCanvasImage createCubeTexture createDepthStencilTexture createDrawContext createDynamicTexture createDynamicUniformBuffer createDynamicVertexBuffer createEffect createImageBitmap createIndexBuffer createInstancesBuffer createMaterialContext createMultipleRenderTarget createPipelineContext createRawCubeTexture createRawCubeTextureFromUrl createRawShaderProgram createRawTexture createRawTexture2DArray createRawTexture3D createRenderPassId createRenderTargetCubeTexture createRenderTargetTexture createShaderProgram createTexture createUniformBuffer createVertexBuffer createVideoElement deleteInstancesBuffer disableAttributeByIndex disableInstanceAttribute disableInstanceAttributeByName disableScissor displayLoadingUI dispose draw drawArraysType drawElementsType drawPointClouds drawUnIndexed enableEffect enableScissor endFrame enterFullscreen enterPointerlock exitFullscreen exitPointerlock flushFramebuffer generateMipMapsForCubemap generateMipmaps getAlphaEquation getAlphaMode getAspectRatio getAttributes getAudioContext getAudioDestination getCaps getClassName getColorWrite getCreationOptions getCurrentRenderPassName getDeltaTime getDepthBuffer getDepthFunction getDepthWrite getError getFontOffset getFps getFragmentShaderSource getGlInfo getHardwareScalingLevel getHostDocument getHostWindow getInfo getInputElement getInputElementClientRect getLoadedTexturesCache getLockstepMaxSteps getRenderHeight getRenderPassNames getRenderWidth getRenderingCanvas getRenderingCanvasClientRect getScreenAspectRatio getStencilBuffer getStencilFunction getStencilFunctionMask getStencilFunctionReference getStencilMask getStencilOperationDepthFail getStencilOperationFail getStencilOperationPass getTimeStep getUniforms getVertexShaderSource getZOffset getZOffsetUnits hideLoadingUI inlineShaderCode isDeterministicLockStep readPixels recordVertexArrayObject releaseEffects releaseRenderPassId releaseVertexArrayObject resetTextureCache resize resizeImageBitmap restoreDefaultFramebuffer restoreSingleAttachment restoreSingleAttachmentForRenderTarget restoreStencilState runRenderLoop scissorClear setAlphaConstants setAlphaEquation setAlphaMode setArray setArray2 setArray3 setArray4 setColorWrite setDepthBuffer setDepthFunction setDepthFunctionToGreater setDepthFunctionToGreaterOrEqual setDepthFunctionToLess setDepthFunctionToLessOrEqual setDepthStencilTexture setDepthWrite setDirectViewport setDitheringState setFloat setFloat2 setFloat3 setFloat4 setHardwareScalingLevel setInt setInt2 setInt3 setInt4 setIntArray setIntArray2 setIntArray3 setIntArray4 setMatrices setMatrix2x2 setMatrix3x3 setRasterizerState setSize setState setStencilBuffer setStencilFunction setStencilFunctionMask setStencilFunctionReference setStencilMask setStencilOperationDepthFail setStencilOperationFail setStencilOperationPass setTexture setTextureArray setTextureFromPostProcess setTextureFromPostProcessOutput setUInt setUInt2 setUInt3 setUInt4 setUIntArray setUIntArray2 setUIntArray3 setUIntArray4 setViewport setZOffset setZOffsetUnits snapshotRenderingReset stopRenderLoop switchFullscreen unBindFramebuffer unBindMultiColorAttachmentFramebuffer unbindAllAttributes unbindAllTextures unbindInstanceAttributes updateAndBindInstancesBuffer updateArrayBuffer updateDynamicIndexBuffer updateDynamicTexture updateDynamicVertexBuffer updateMultipleRenderTargetTextureSampleCount updateRawCubeTexture updateRawTexture updateRawTexture2DArray updateRawTexture3D updateRenderTargetTextureSampleCount updateTextureComparisonFunction updateTextureData updateTextureDimensions updateTextureSamplingMode updateTextureWrappingMode updateUniformBuffer updateVideoTexture wipeCaches wrapWebGLTexture CeilingPOT DefaultLoadingScreenFactory FloorPOT GetExponentOfTwo MarkAllMaterialsAsDirty NearestPOT QueueNewFrame _ExitFullscreen _ExitPointerlock _RequestFullscreen _RequestPointerlock isSupported

Constructors

  • Creates a new engine

    Parameters

    • canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | OffscreenCanvas | WebGL2RenderingContext>

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

adaptToDeviceRatio: boolean

If set to true zooming in and out in the browser will rescale the hardware-scaling correctly.

canvasTabIndex: number

Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events

cullBackFaces: Nullable<boolean>

Gets or sets a boolean indicating if back faces must be culled. If false, front faces are culled instead (true by default) If non null, this takes precedence over the value from the material

currentRenderPassId: number

Gets or sets the current render pass id

customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>

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

disableContextMenu: boolean

Gets or sets a boolean to enable/disable the context menu (right-click) from appearing on the main canvas

disableManifestCheck: boolean

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

disablePerformanceMonitorInBackground: boolean

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

disableUniformBuffers: boolean

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

disableVertexArrayObjects: boolean

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

enableOfflineSupport: boolean

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

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

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

hasOriginBottomLeft: boolean

Indicates that the origin of the texture/framebuffer space is the bottom left corner. If false, the origin is top left

hostInformation: HostInformation

Gets information about the current host

isFullscreen: boolean

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

isNDCHalfZRange: boolean

Indicates if the z range in NDC space is 0..1 (value: true) or -1..1 (value: false)

isPointerLock: boolean

Gets a boolean indicating if the pointer is currently locked

onAfterShaderCompilationObservable: Observable<Engine>

Observable raised when the engine has just compiled a shader

onBeforeShaderCompilationObservable: Observable<Engine>

Observable raised when the engine is about to compile a shader

onBeforeTextureInitObservable: Observable<Texture>

Observable event triggered before each texture is initialized

onBeginFrameObservable: Observable<Engine>

Observable raised when the engine begins a new frame

onCanvasBlurObservable: Observable<Engine>

Observable event triggered each time the canvas loses focus

onCanvasFocusObservable: Observable<Engine>

Observable event triggered each time the canvas gains focus

onCanvasPointerOutObservable: Observable<PointerEvent>

Observable event triggered each time the canvas receives pointerout event

onContextLostObservable: Observable<ThinEngine>

Observable signaled when a context lost event is raised

onContextRestoredObservable: Observable<ThinEngine>

Observable signaled when a context restored event is raised

onDisposeObservable: Observable<ThinEngine>

An event triggered when the engine is disposed.

onEndFrameObservable: Observable<Engine>

Observable raised when the engine ends the current frame

onNewSceneAddedObservable: Observable<Scene>

Event raised when a new scene is created

onResizeObservable: Observable<Engine>

Observable event triggered each time the rendering canvas is resized

postProcesses: PostProcess[]

Gets the list of created postprocesses

premultipliedAlpha: boolean

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

preventCacheWipeBetweenFrames: boolean

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

renderEvenInBackground: boolean

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

scenes: Scene[]

Gets the list of created scenes

startTime: number

The time (in milliseconds elapsed since the current page has been loaded) when the engine was initialized

useExactSrgbConversions: boolean

Gets a boolean indicating if the exact sRGB conversions or faster approximations are used for converting to and from linear space.

validateShaderPrograms: boolean

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

ALPHA_ADD: 1 = 1

Defines that alpha blending to SRC ALPHA * SRC + DEST

ALPHA_COMBINE: 2 = 2

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

ALPHA_DISABLE: 0 = 0

Defines that alpha blending is disabled

ALPHA_INTERPOLATE: 9 = 9

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

ALPHA_MAXIMIZED: 5 = 5

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

ALPHA_MULTIPLY: 4 = 4

Defines that alpha blending to SRC * DEST

ALPHA_ONEONE: 6 = 6

Defines that alpha blending to SRC + DEST

ALPHA_PREMULTIPLIED: 7 = 7

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

ALPHA_PREMULTIPLIED_PORTERDUFF: 8 = 8

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

ALPHA_SCREENMODE: 10 = 10

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

ALPHA_SUBTRACT: 3 = 3

Defines that alpha blending to DEST - SRC * DEST

ALWAYS: 519 = 519

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

AudioEngineFactory: ((hostElement: Nullable<HTMLElement>, audioContext: Nullable<AudioContext>, audioDestination: Nullable<AudioDestinationNode | MediaStreamAudioDestinationNode>) => IAudioEngine)

Type declaration

    • (hostElement: Nullable<HTMLElement>, audioContext: Nullable<AudioContext>, audioDestination: Nullable<AudioDestinationNode | MediaStreamAudioDestinationNode>): IAudioEngine
    • Default AudioEngine factory responsible of creating the Audio Engine. By default, this will create a BabylonJS Audio Engine if the workload has been embedded.

      Parameters

      • hostElement: Nullable<HTMLElement>
      • audioContext: Nullable<AudioContext>
      • audioDestination: Nullable<AudioDestinationNode | MediaStreamAudioDestinationNode>

      Returns IAudioEngine

CollisionsEpsilon: number

Gets or sets the epsilon value used by collision engine

DECR: 7683 = 7683

Passed to stencilOperation to specify that stencil value must be decremented

DECR_WRAP: 34056 = 34056

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

DELAYLOADSTATE_LOADED: 1 = 1

Defines that the resource was successfully delay loaded

DELAYLOADSTATE_LOADING: 2 = 2

Defines that the resource is currently delay loading

DELAYLOADSTATE_NONE: 0 = 0

Defines that the resource is not delayed

DELAYLOADSTATE_NOTLOADED: 4 = 4

Defines that the resource is delayed and has not started loading

EQUAL: 514 = 514

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

ExceptionList: ({ capture: string; captureConstraint: number; key: string; targets: string[] } | { capture: null; captureConstraint: null; key: string; targets: string[] })[]

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

GEQUAL: 518 = 518

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

GREATER: 516 = 516

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

INCR: 7682 = 7682

Passed to stencilOperation to specify that stencil value must be incremented

INCR_WRAP: 34055 = 34055

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

INVERT: 5386 = 5386

Passed to stencilOperation to specify that stencil value must be inverted

KEEP: 7680 = 7680

Passed to stencilOperation to specify that stencil value must be kept

LEQUAL: 515 = 515

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

LESS: 513 = 513

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

NEVER: 512 = 512

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

NOTEQUAL: 517 = 517

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

OfflineProviderFactory: ((urlToScene: string, callbackManifestChecked: ((checked: boolean) => any), disableManifestCheck: boolean) => IOfflineProvider)

Type declaration

    • (urlToScene: string, callbackManifestChecked: ((checked: boolean) => any), disableManifestCheck: boolean): IOfflineProvider
    • 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.

      Parameters

      • urlToScene: string
      • callbackManifestChecked: ((checked: boolean) => any)
          • (checked: boolean): any
          • Parameters

            • checked: boolean

            Returns any

      • disableManifestCheck: boolean

      Returns IOfflineProvider

REPLACE: 7681 = 7681

Passed to stencilOperation to specify that stencil value must be replaced

SCALEMODE_CEILING: 3 = 3

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

SCALEMODE_FLOOR: 1 = 1

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

SCALEMODE_NEAREST: 2 = 2

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

TEXTUREFORMAT_ALPHA: 0 = 0

ALPHA

TEXTUREFORMAT_LUMINANCE: 1 = 1

LUMINANCE

TEXTUREFORMAT_LUMINANCE_ALPHA: 2 = 2

LUMINANCE_ALPHA

TEXTUREFORMAT_R: 6 = 6

RED (2nd reference)

TEXTUREFORMAT_RED: 6 = 6

RED

TEXTUREFORMAT_RED_INTEGER: 8 = 8

RED_INTEGER

TEXTUREFORMAT_RG: 7 = 7

RG

TEXTUREFORMAT_RGB: 4 = 4

RGB

TEXTUREFORMAT_RGBA: 5 = 5

RGBA

TEXTUREFORMAT_RGBA_INTEGER: 11 = 11

RGBA_INTEGER

TEXTUREFORMAT_RGB_INTEGER: 10 = 10

RGB_INTEGER

TEXTUREFORMAT_RG_INTEGER: 9 = 9

RG_INTEGER

TEXTUREFORMAT_R_INTEGER: 8 = 8

RED_INTEGER (2nd reference)

TEXTURETYPE_BYTE: 3 = 3

BYTE

TEXTURETYPE_FLOAT: 1 = 1

FLOAT

TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: 15 = 15

FLOAT_32_UNSIGNED_INT_24_8_REV

TEXTURETYPE_HALF_FLOAT: 2 = 2

HALF_FLOAT

TEXTURETYPE_INT: 6 = 6

INT

TEXTURETYPE_SHORT: 4 = 4

SHORT

TEXTURETYPE_UNSIGNED_BYTE: 0 = 0

UNSIGNED_BYTE

TEXTURETYPE_UNSIGNED_INT: 0 = 0

UNSIGNED_BYTE (2nd reference)

TEXTURETYPE_UNSIGNED_INTEGER: 7 = 7

UNSIGNED_INT

TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: 13 = 13

UNSIGNED_INT_10F_11F_11F_REV

TEXTURETYPE_UNSIGNED_INT_24_8: 12 = 12

UNSIGNED_INT_24_8

TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: 11 = 11

UNSIGNED_INT_2_10_10_10_REV

TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: 14 = 14

UNSIGNED_INT_5_9_9_9_REV

TEXTURETYPE_UNSIGNED_SHORT: 5 = 5

UNSIGNED_SHORT

TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: 8 = 8

UNSIGNED_SHORT_4_4_4_4

TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: 9 = 9

UNSIGNED_SHORT_5_5_5_1

TEXTURETYPE_UNSIGNED_SHORT_5_6_5: 10 = 10

UNSIGNED_SHORT_5_6_5

TEXTURE_BILINEAR_SAMPLINGMODE: 2 = 2

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

TEXTURE_CLAMP_ADDRESSMODE: 0 = 0

Texture is not repeating outside of 0..1 UVs

TEXTURE_CUBIC_MODE: 3 = 3

Cubic coordinates mode

TEXTURE_EQUIRECTANGULAR_MODE: 7 = 7

Equirectangular coordinates mode

TEXTURE_EXPLICIT_MODE: 0 = 0

Explicit coordinates mode

TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: 9 = 9

Equirectangular Fixed Mirrored coordinates mode

TEXTURE_FIXED_EQUIRECTANGULAR_MODE: 8 = 8

Equirectangular Fixed coordinates mode

TEXTURE_INVCUBIC_MODE: 6 = 6

Inverse Cubic coordinates mode

TEXTURE_LINEAR_LINEAR: 2 = 2

mag = linear and min = linear and mip = none

TEXTURE_LINEAR_LINEAR_MIPLINEAR: 3 = 3

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

TEXTURE_LINEAR_LINEAR_MIPNEAREST: 11 = 11

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

TEXTURE_LINEAR_NEAREST: 12 = 12

mag = linear and min = nearest and mip = none

TEXTURE_LINEAR_NEAREST_MIPLINEAR: 10 = 10

mag = linear and min = nearest and mip = linear

TEXTURE_LINEAR_NEAREST_MIPNEAREST: 9 = 9

mag = linear and min = nearest and mip = nearest

TEXTURE_MIRROR_ADDRESSMODE: 2 = 2

Texture is repeating and mirrored

TEXTURE_NEAREST_LINEAR: 7 = 7

mag = nearest and min = linear and mip = none

TEXTURE_NEAREST_LINEAR_MIPLINEAR: 6 = 6

mag = nearest and min = linear and mip = linear

TEXTURE_NEAREST_LINEAR_MIPNEAREST: 5 = 5

mag = nearest and min = linear and mip = nearest

TEXTURE_NEAREST_NEAREST: 1 = 1

mag = nearest and min = nearest and mip = none

TEXTURE_NEAREST_NEAREST_MIPLINEAR: 8 = 8

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

TEXTURE_NEAREST_NEAREST_MIPNEAREST: 4 = 4

mag = nearest and min = nearest and mip = nearest

TEXTURE_NEAREST_SAMPLINGMODE: 1 = 1

nearest is mag = nearest and min = nearest and mip = none

TEXTURE_PLANAR_MODE: 2 = 2

Planar coordinates mode

TEXTURE_PROJECTION_MODE: 4 = 4

Projection coordinates mode

TEXTURE_SKYBOX_MODE: 5 = 5

Skybox coordinates mode

TEXTURE_SPHERICAL_MODE: 1 = 1

Spherical coordinates mode

TEXTURE_TRILINEAR_SAMPLINGMODE: 3 = 3

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

TEXTURE_WRAP_ADDRESSMODE: 1 = 1

Texture is repeating outside of 0..1 UVs

_RescalePostProcessFactory: Nullable<((engine: Engine) => PostProcess)>

Method called to create the default rescale post process on each engine.

audioEngine: Nullable<IAudioEngine>

Accessors

  • get activeRenderLoops(): (() => void)[]
  • Gets the list of current active render loop functions

    Returns

    an array with the current render loop functions

    Returns (() => void)[]

  • get alphaState(): AlphaState
  • Gets the alpha state manager

    Returns AlphaState

  • get compatibilityMode(): boolean
  • (WebGPU only) True (default) to be in compatibility mode, meaning rendering all existing scenes without artifacts (same rendering than WebGL). Setting the property to false will improve performances but may not work in some scenes if some precautions are not taken. See https://doc.babylonjs.com/setup/support/webGPU/webGPUOptimization/webGPUNonCompatibilityMode for more details

    Returns boolean

  • set compatibilityMode(mode: boolean): void
  • Parameters

    • mode: boolean

    Returns void

  • get currentViewport(): Nullable<IViewportLike>
  • Gets the current viewport

    Returns Nullable<IViewportLike>

  • get depthCullingState(): DepthCullingState
  • Gets the depth culling state manager

    Returns DepthCullingState

  • get description(): string
  • Returns a string describing the current engine

    Returns string

  • get doNotHandleContextLost(): boolean
  • Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events

    See

    https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#handling-webgl-context-lost

    Returns boolean

  • set doNotHandleContextLost(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get emptyCubeTexture(): InternalTexture
  • Gets the default empty cube texture

    Returns InternalTexture

  • get emptyTexture(): InternalTexture
  • Gets the default empty texture

    Returns InternalTexture

  • get emptyTexture2DArray(): InternalTexture
  • Gets the default empty 2D array texture

    Returns InternalTexture

  • get emptyTexture3D(): InternalTexture
  • Gets the default empty 3D texture

    Returns InternalTexture

  • get frameId(): number
  • Gets the current frame id

    Returns number

  • set framebufferDimensionsObject(dimensions: Nullable<{ framebufferHeight: number; framebufferWidth: number }>): void
  • sets the object from which width and height will be taken from when getting render width and height Will fallback to the gl object

    Parameters

    • dimensions: Nullable<{ framebufferHeight: number; framebufferWidth: number }>

      the framebuffer width and height that will be used.

    Returns void

  • get isDisposed(): boolean
  • Returns boolean

  • get isStencilEnable(): boolean
  • Returns true if the stencil buffer has been enabled through the creation option of the context.

    Returns boolean

  • get isWebGPU(): boolean
  • Gets a boolean indicating if the engine runs in WebGPU or not.

    Returns boolean

  • get name(): string
  • Gets or sets the name of the engine

    Returns string

  • set name(value: string): void
  • Parameters

    • value: string

    Returns void

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

    Returns boolean

  • get shaderPlatformName(): string
  • Gets the shader platform name used by the effects.

    Returns string

  • get snapshotRendering(): boolean
  • Enables or disables the snapshot rendering mode Note that the WebGL engine does not support snapshot rendering so setting the value won't have any effect for this engine

    Returns boolean

  • set snapshotRendering(activate: boolean): void
  • Parameters

    • activate: boolean

    Returns void

  • get snapshotRenderingMode(): number
  • Gets or sets the snapshot rendering mode

    Returns number

  • set snapshotRenderingMode(mode: number): void
  • Parameters

    • mode: number

    Returns void

  • get stencilState(): StencilState
  • Gets the stencil state manager

    Returns StencilState

  • get stencilStateComposer(): StencilStateComposer
  • Gets the stencil state composer

    Returns StencilStateComposer

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

    Returns boolean

  • set useReverseDepthBuffer(useReverse: boolean): void
  • Parameters

    • useReverse: boolean

    Returns void

  • get version(): number
  • Returns the version of the engine

    Returns number

  • get webGLVersion(): number
  • Gets version of the current webGL context Keep it for back compat - use version instead

    Returns number

  • get HasMajorPerformanceCaveat(): boolean
  • Gets a boolean indicating if the engine can be instantiated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)

    Returns boolean

  • get Instances(): Engine[]
  • Gets the list of created engines

    Returns Engine[]

  • get IsSupported(): boolean
  • Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)

    Returns boolean

  • get IsSupportedAsync(): Promise<boolean>
  • Gets a Promise indicating if the engine can be instantiated (ie. if a webGL context can be found)

    Returns Promise<boolean>

  • get LastCreatedEngine(): Nullable<Engine>
  • Gets the latest created engine

    Returns Nullable<Engine>

  • get LastCreatedScene(): Nullable<Scene>
  • Gets the latest created scene

    Returns Nullable<Scene>

  • get NpmPackage(): string
  • Returns the current npm package of the sdk

    Returns string

  • get ShadersRepository(): string
  • Gets or sets the relative url used to load shaders if using the engine in non-minified mode

    Returns string

  • set ShadersRepository(value: string): void
  • Parameters

    • value: string

    Returns void

  • get Version(): string
  • Returns the current version of the framework

    Returns string

Methods

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

    Returns

    The cube texture

    Parameters

    • size: number

      The size of face edge in the cube texture.

    • options: DepthTextureCreationOptions

      The options defining the cube texture.

    • rtWrapper: RenderTargetWrapper

      The render target wrapper for which the depth/stencil texture must be created

    Returns InternalTexture

  • Engine abstraction for loading and creating an image bitmap from a given source string.

    Returns

    ImageBitmap.

    Parameters

    • imageSource: string

      source to load the image from.

    • Optional options: ImageBitmapOptions

      An object that sets options for the image's extraction.

    Returns Promise<ImageBitmap>

  • Parameters

    • pipelineContext: IPipelineContext

    Returns void

  • Returns void

  • Parameters

    • renderBuffer: Nullable<WebGLRenderbuffer>
    • width: number
    • height: number
    • samples: number
    • internalFormat: number
    • msInternalFormat: number
    • attachment: number
    • Optional unbindBuffer: boolean

    Returns Nullable<WebGLRenderbuffer>

  • Apply all cached states (depth, culling, stencil and alpha)

    Returns void

  • Gets a boolean indicating if all created effects are ready

    Returns

    true if all effects are ready

    Returns boolean

  • Attach a new callback raised when context lost event is fired

    Parameters

    • callback: ((event: WebGLContextEvent) => void)

      defines the callback to call

        • (event: WebGLContextEvent): void
        • Parameters

          • event: WebGLContextEvent

          Returns void

    Returns void

  • Attach a new callback raised when context restored event is fired

    Parameters

    • callback: ((event: WebGLContextEvent) => void)

      defines the callback to call

        • (event: WebGLContextEvent): void
        • Parameters

          • event: WebGLContextEvent

          Returns void

    Returns void

  • Begin a new frame

    Returns void

  • Bind a webGL buffer to the webGL context

    Parameters

    • buffer: Nullable<DataBuffer>

      defines the buffer to bind

    Returns void

  • Select a subsets of attachments to draw to.

    Parameters

    • attachments: number[]

      gl attachments

    Returns void

  • Bind a list of vertex buffers to the webGL context

    Parameters

    • vertexBuffers: { [key: string]: Nullable<VertexBuffer> }

      defines the list of vertex buffers to bind

      • [key: string]: Nullable<VertexBuffer>
    • indexBuffer: Nullable<DataBuffer>

      defines the index buffer to bind

    • effect: Effect

      defines the effect associated with the vertex buffers

    • Optional overrideVertexBuffers: { [kind: string]: Nullable<VertexBuffer> }

      defines optional list of avertex buffers that overrides the entries in vertexBuffers

      • [kind: string]: Nullable<VertexBuffer>

    Returns void

  • Bind webGl buffers directly to the webGL context

    Parameters

    • vertexBuffer: DataBuffer

      defines the vertex buffer to bind

    • indexBuffer: DataBuffer

      defines the index buffer to bind

    • vertexDeclaration: number[]

      defines the vertex declaration to use with the vertex buffer

    • vertexStrideSize: number

      defines the vertex stride of the vertex buffer

    • effect: Effect

      defines the effect associated with the vertex buffer

    Returns void

  • Binds the frame buffer to the specified texture.

    Parameters

    • rtWrapper: RenderTargetWrapper

      The render target wrapper to render to

    • Optional faceIndex: number

      The face of the texture to render to in case of cube texture and if the render target wrapper is not a multi render target

    • 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 lodLevel: number

      Defines the lod level to bind to the frame buffer

    • Optional layer: number

      Defines the 2d array index to bind to the frame buffer if the render target wrapper is not a multi render target

    Returns void

  • Bind the content of a webGL buffer used with instantiation

    Parameters

    • instancesBuffer: DataBuffer

      defines the webGL buffer to bind

    • attributesInfo: InstancingAttributeInfo[]

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

    • Optional computeStride: boolean

      defines Whether to compute the strides from the info or use the default 0

    Returns void

  • Binds an effect to the webGL context

    Parameters

    • effect: Effect

      defines the effect to bind

    Returns void

  • Bind a specific block at a given index in a specific shader program

    Parameters

    • pipelineContext: IPipelineContext

      defines the pipeline context to use

    • blockName: string

      defines the block name

    • index: number

      defines the index where to bind the block

    Returns void

  • Bind an uniform buffer to the current webGL context

    Parameters

    • buffer: Nullable<DataBuffer>

      defines the buffer to bind

    Returns void

  • Bind a buffer to the current webGL context at a given location

    Parameters

    • buffer: DataBuffer

      defines the buffer to bind

    • location: number

      defines the index where to bind the buffer

    • name: string

      Name of the uniform variable to bind

    Returns void

  • Parameters

    • vertexArrayObject: WebGLVertexArrayObject

      defines the vertex array object to bind

    • indexBuffer: Nullable<DataBuffer>

      defines the index buffer to bind

    Returns void

  • Creates a layout object to draw/clear on specific textures in a MRT

    Returns

    A layout to be fed to the engine, calling bindAttachments.

    Parameters

    • textureStatus: boolean[]

      textureStatus[i] indicates if the i-th is active

    Returns number[]

  • Caches the the state of the stencil buffer

    Returns void

  • Clear the current render buffer or the current render target (if any is set up)

    Parameters

    • color: Nullable<IColor4Like>

      defines the color to use

    • backBuffer: boolean

      defines if the back buffer must be cleared

    • depth: boolean

      defines if the depth buffer must be cleared

    • Optional stencil: boolean

      defines if the stencil buffer must be cleared

    Returns void

  • Clears the list of texture accessible through engine. This can help preventing texture load conflict due to name collision.

    Returns void

  • Create a canvas. This method is overridden by other engines

    Returns

    ICanvas interface

    Parameters

    • width: number

      width

    • height: number

      height

    Returns ICanvas

  • Create an image to use with canvas

    Returns

    IImage interface

    Returns IImage

  • Creates a cube texture

    Returns

    the cube texture as an InternalTexture

    Parameters

    • rootUrl: string

      defines the url where the files to load is located

    • scene: Nullable<Scene>

      defines the current scene

    • files: Nullable<string[]>

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

    • noMipmap: undefined | boolean

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

    • onLoad: Nullable<((data?: any) => void)>

      defines an optional callback raised when the texture is loaded

    • onError: Nullable<((message?: string, exception?: any) => void)>

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

    • format: undefined | number

      defines the format of the data

    • forcedExtension: any

      defines the extension to use to pick the right loader

    • createPolynomials: boolean

      if a polynomial sphere should be created for the cube texture

    • lodScale: number

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

    • lodOffset: number

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

    • fallback: Nullable<InternalTexture>

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

    • loaderOptions: any

      options to be passed to the loader

    • useSRGBBuffer: boolean

      defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).

    Returns InternalTexture

  • Creates a cube texture

    Returns

    the cube texture as an InternalTexture

    Parameters

    • rootUrl: string

      defines the url where the files to load is located

    • scene: Nullable<Scene>

      defines the current scene

    • files: Nullable<string[]>

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

    • noMipmap: boolean

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

    • onLoad: Nullable<((data?: any) => void)>

      defines an optional callback raised when the texture is loaded

    • onError: Nullable<((message?: string, exception?: any) => void)>

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

    • format: undefined | number

      defines the format of the data

    • forcedExtension: any

      defines the extension to use to pick the right loader

    Returns InternalTexture

  • Creates a cube texture

    Returns

    the cube texture as an InternalTexture

    Parameters

    • rootUrl: string

      defines the url where the files to load is located

    • scene: Nullable<Scene>

      defines the current scene

    • files: Nullable<string[]>

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

    • noMipmap: boolean

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

    • onLoad: Nullable<((data?: any) => void)>

      defines an optional callback raised when the texture is loaded

    • onError: Nullable<((message?: string, exception?: any) => void)>

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

    • format: undefined | number

      defines the format of the data

    • forcedExtension: any

      defines the extension to use to pick the right loader

    • createPolynomials: boolean

      if a polynomial sphere should be created for the cube texture

    • lodScale: number

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

    • lodOffset: number

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

    Returns InternalTexture

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

    Returns

    The texture

    Parameters

    • size: TextureSize

      The size of face edge in the texture.

    • options: DepthTextureCreationOptions

      The options defining the texture.

    • rtWrapper: RenderTargetWrapper

      The render target wrapper for which the depth/stencil texture must be created

    Returns InternalTexture

  • Creates a new draw context

    Returns

    the new context

    Returns undefined | IDrawContext

  • Creates a dynamic texture

    Returns

    the dynamic texture inside an InternalTexture

    Parameters

    • width: number

      defines the width of the texture

    • height: number

      defines the height of the texture

    • generateMipMaps: boolean

      defines if the engine should generate the mip levels

    • samplingMode: number

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

    Returns InternalTexture

  • Create a dynamic uniform buffer

    See

    https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets

    Returns

    the webGL uniform buffer

    Parameters

    • elements: FloatArray

      defines the content of the uniform buffer

    • Optional label: string

      defines a name for the buffer (for debugging purpose)

    Returns DataBuffer

  • Creates a dynamic vertex buffer

    Returns

    the new WebGL dynamic buffer

    Parameters

    • data: DataArray

      the data for the dynamic vertex buffer

    • Optional _label: string

      defines the label of the buffer (for debug purpose)

    Returns DataBuffer

  • Create a new effect (used to store vertex/fragment shaders)

    Returns

    the new Effect

    Parameters

    • baseName: any

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

    • attributesNamesOrOptions: string[] | IEffectCreationOptions

      defines either a list of attribute names or an IEffectCreationOptions object

    • uniformsNamesOrEngine: string[] | ThinEngine

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

    • Optional samplers: string[]

      defines an array of string used to represent textures

    • Optional defines: string

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

    • Optional fallbacks: IEffectFallbacks

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

    • Optional onCompiled: Nullable<((effect: Effect) => void)>

      defines a function to call when the effect creation is successful

    • Optional onError: Nullable<((effect: Effect, errors: string) => void)>

      defines a function to call when the effect creation has failed

    • Optional indexParameters: any

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

    • Optional shaderLanguage: ShaderLanguage

      the language the shader is written in (default: GLSL)

    Returns Effect

  • Engine abstraction for createImageBitmap

    Returns

    ImageBitmap

    Parameters

    • image: ImageBitmapSource

      source for image

    • Optional options: ImageBitmapOptions

      An object that sets options for the image's extraction.

    Returns Promise<ImageBitmap>

  • Creates a new index buffer

    Returns

    a new webGL buffer

    Parameters

    • indices: IndicesArray

      defines the content of the index buffer

    • Optional updatable: boolean

      defines if the index buffer must be updatable

    • Optional _label: string

      defines the label of the buffer (for debug purpose)

    Returns DataBuffer

  • Creates a webGL buffer to use with instantiation

    Returns

    the webGL buffer

    Parameters

    • capacity: number

      defines the size of the buffer

    Returns DataBuffer

  • Creates a new material context

    Returns

    the new context

    Returns undefined | IMaterialContext

  • Create a multi render target texture

    See

    https://doc.babylonjs.com/setup/support/webGL2#multiple-render-target

    Returns

    a new render target wrapper ready to render textures

    Parameters

    • size: TextureSize

      defines the size of the texture

    • options: IMultiRenderTargetOptions

      defines the creation options

    • Optional initializeBuffers: boolean

      if set to true, the engine will make an initializing call of drawBuffers

    Returns RenderTargetWrapper

  • Creates a new pipeline context

    Returns

    the new pipeline

    Parameters

    • shaderProcessingContext: Nullable<ShaderProcessingContext>

      defines the shader processing context used during the processing if available

    Returns IPipelineContext

  • Creates a new raw cube texture

    Returns

    the cube texture as an InternalTexture

    Parameters

    • data: Nullable<ArrayBufferView[]>

      defines the array of data to use to create each face

    • size: number

      defines the size of the textures

    • format: number

      defines the format of the data

    • type: number

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

    • generateMipMaps: boolean

      defines if the engine should generate the mip levels

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • samplingMode: number

      defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)

    • compression: Nullable<string>

      defines the compression used (null by default)

    Returns InternalTexture

  • Creates a new raw cube texture from a specified url

    Returns

    the cube texture as an InternalTexture

    Parameters

    • url: string

      defines the url where the data is located

    • scene: Nullable<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 Engine.TEXTURETYPE_UNSIGNED_INT)

    • noMipmap: boolean

      defines if the engine should avoid generating the mip levels

    • callback: ((ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>)

      defines a callback used to extract texture data from loaded data

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

          • ArrayBuffer: ArrayBuffer

          Returns Nullable<ArrayBufferView[]>

    • mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>

      defines to provide an optional tool to generate mip levels

    • onLoad: Nullable<(() => void)>

      defines a callback called when texture is loaded

    • onError: Nullable<((message?: string, exception?: any) => void)>

      defines a callback called if there is an error

    Returns InternalTexture

  • Creates a new raw cube texture from a specified url

    Returns

    the cube texture as an InternalTexture

    Parameters

    • url: string

      defines the url where the data is located

    • scene: Nullable<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 Engine.TEXTURETYPE_UNSIGNED_INT)

    • noMipmap: boolean

      defines if the engine should avoid generating the mip levels

    • callback: ((ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>)

      defines a callback used to extract texture data from loaded data

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

          • ArrayBuffer: ArrayBuffer

          Returns Nullable<ArrayBufferView[]>

    • mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>

      defines to provide an optional tool to generate mip levels

    • onLoad: Nullable<(() => void)>

      defines a callback called when texture is loaded

    • onError: Nullable<((message?: string, exception?: any) => void)>

      defines a callback called if there is an error

    • samplingMode: number

      defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    Returns InternalTexture

  • Directly creates a webGL program

    Returns

    the new webGL program

    Parameters

    • pipelineContext: IPipelineContext

      defines the pipeline context to attach to

    • vertexCode: string

      defines the vertex shader code to use

    • fragmentCode: string

      defines the fragment shader code to use

    • Optional context: WebGLRenderingContext

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

    • Optional transformFeedbackVaryings: Nullable<string[]>

      defines the list of transform feedback varyings to use

    Returns WebGLProgram

  • Creates a raw texture

    Returns

    the raw texture inside an InternalTexture

    Parameters

    • data: Nullable<ArrayBufferView>

      defines the data to store in the texture

    • width: number

      defines the width of the texture

    • height: number

      defines the height of the texture

    • format: number

      defines the format of the data

    • generateMipMaps: boolean

      defines if the engine should generate the mip levels

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • samplingMode: number

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

    • compression: Nullable<string>

      defines the compression used (null by default)

    • type: number

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

    • Optional creationFlags: number

      specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)

    • Optional useSRGBBuffer: boolean

      defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).

    Returns InternalTexture

  • Creates a new raw 2D array texture

    Returns

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

    Parameters

    • data: Nullable<ArrayBufferView>

      defines the data used to create the texture

    • width: number

      defines the width of the texture

    • height: number

      defines the height of the texture

    • depth: number

      defines the number of layers of the texture

    • format: number

      defines the format of the texture

    • generateMipMaps: boolean

      defines if the engine must generate mip levels

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • samplingMode: number

      defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)

    • compression: Nullable<string>

      defines the compressed used (can be null)

    • textureType: number

      defines the compressed used (can be null)

    • Optional creationFlags: number

      specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)

    Returns InternalTexture

  • Creates a new raw 3D texture

    Returns

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

    Parameters

    • data: Nullable<ArrayBufferView>

      defines the data used to create the texture

    • width: number

      defines the width of the texture

    • height: number

      defines the height of the texture

    • depth: number

      defines the depth of the texture

    • format: number

      defines the format of the texture

    • generateMipMaps: boolean

      defines if the engine must generate mip levels

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • samplingMode: number

      defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)

    • compression: Nullable<string>

      defines the compressed used (can be null)

    • textureType: number

      defines the compressed used (can be null)

    • Optional creationFlags: number

      specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)

    Returns InternalTexture

  • Creates a render pass id

    Returns

    the id of the new render pass

    Parameters

    • Optional name: string

      Name of the render pass (for debug purpose only)

    Returns number

  • Creates a new render target cube wrapper

    Returns

    a new render target cube wrapper

    Parameters

    • size: number

      defines the size of the texture

    • Optional options: RenderTargetCreationOptions

      defines the options used to create the texture

    Returns RenderTargetWrapper

  • Creates a new render target texture

    Returns

    a new render target wrapper ready to render texture

    Parameters

    • size: TextureSize

      defines the size of the texture

    • options: boolean | RenderTargetCreationOptions

      defines the options used to create the texture

    Returns RenderTargetWrapper

  • Parameters

    • pipelineContext: IPipelineContext
    • vertexCode: string
    • fragmentCode: string
    • defines: Nullable<string>
    • Optional context: WebGLRenderingContext
    • Optional transformFeedbackVaryings: Nullable<string[]>

    Returns WebGLProgram

  • Usually called from Texture.ts. Passed information to create a WebGLTexture

    Returns

    a InternalTexture for assignment back into BABYLON.Texture

    Parameters

    • url: Nullable<string>

      defines a value which contains one of the following:

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

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

    • invertY: boolean

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

    • scene: Nullable<ISceneLike>

      needed for loading to the correct scene

    • Optional samplingMode: number

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

    • Optional onLoad: Nullable<((texture: InternalTexture) => void)>

      optional callback to be called upon successful completion

    • Optional onError: Nullable<((message: string, exception: any) => void)>

      optional callback to be called upon failure

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

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

    • Optional fallback: Nullable<InternalTexture>

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

    • Optional format: Nullable<number>

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

    • Optional forcedExtension: Nullable<string>

      defines the extension to use to pick the right loader

    • Optional mimeType: string

      defines an optional mime type

    • Optional loaderOptions: any

      options to be passed to the loader

    • Optional creationFlags: number

      specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)

    • Optional useSRGBBuffer: boolean

      defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).

    Returns InternalTexture

  • Create an uniform buffer

    See

    https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets

    Returns

    the webGL uniform buffer

    Parameters

    • elements: FloatArray

      defines the content of the uniform buffer

    • Optional label: string

      defines a name for the buffer (for debugging purpose)

    Returns DataBuffer

  • Creates a vertex buffer

    Returns

    the new WebGL static buffer

    Parameters

    • data: DataArray

      the data for the vertex buffer

    • Optional _updatable: boolean

      whether the buffer should be created as updatable

    • Optional _label: string

      defines the label of the buffer (for debug purpose)

    Returns DataBuffer

  • creates and returns a new video element

    Returns

    video element

    Parameters

    • constraints: MediaTrackConstraints

      video constraints

    Returns any

  • Delete a webGL buffer used with instantiation

    Parameters

    • buffer: WebGLBuffer

      defines the webGL buffer to delete

    Returns void

  • Disable the attribute corresponding to the location in parameter

    Parameters

    • attributeLocation: number

      defines the attribute location of the attribute to disable

    Returns void

  • Disable the instance attribute corresponding to the location in parameter

    Parameters

    • attributeLocation: number

      defines the attribute location of the attribute to disable

    Returns void

  • Disable the instance attribute corresponding to the name in parameter

    Parameters

    • name: string

      defines the name of the attribute to disable

    Returns void

  • Disable previously set scissor test rectangle

    Returns void

  • Returns 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 instantiation is enabled)

    Returns 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 instantiation is enabled)

    Returns 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 instantiation is enabled)

    Returns 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 instantiation is enabled)

    Returns 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 instantiation is enabled)

    Returns void

  • Activates an effect, making it the current one (ie. the one used for rendering)

    Parameters

    • effect: Nullable<Effect | DrawWrapper>

      defines the effect to activate

    Returns void

  • Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)

    Parameters

    • x: number

      defines the x-coordinate of the bottom 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

    Returns void

  • End the current frame

    Returns void

  • Enters full screen mode

    Parameters

    • requestPointerLock: boolean

      defines if a pointer lock should be requested from the user

    Returns void

  • Enters Pointerlock mode

    Returns void

  • Exits full screen mode

    Returns void

  • Exits Pointerlock mode

    Returns void

  • Force a webGL flush (ie. a flush of all waiting webGL commands)

    Returns void

  • Force the mipmap generation for the given render target texture

    Parameters

    • texture: InternalTexture

      defines the render target texture to use

    • Optional unbind: boolean

      defines whether or not to unbind the texture after generation. Defaults to true.

    Returns void

  • Generates the mipmaps for a texture

    Parameters

    • texture: InternalTexture

      texture to generate the mipmaps for

    Returns void

  • Gets the current alpha equation.

    Returns

    the current alpha equation

    Returns number

  • Gets current aspect ratio

    Returns

    a number defining the aspect ratio

    Parameters

    • viewportOwner: IViewportOwnerLike

      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

  • Gets the list of active attributes for a given webGL program

    Returns

    an array of indices indicating the offset of each attribute

    Parameters

    • pipelineContext: IPipelineContext

      defines the pipeline context to use

    • attributesNames: string[]

      defines the list of attribute names to get

    Returns number[]

  • Gets the audio context specified in engine initialization options

    Returns

    an Audio Context

    Returns Nullable<AudioContext>

  • Gets the audio destination specified in engine initialization options

    Returns

    an audio destination node

    Returns Nullable<AudioDestinationNode | MediaStreamAudioDestinationNode>

  • Gets the object containing all engine capabilities

    Returns

    the EngineCapabilities object

    Returns EngineCapabilities

  • Gets a string identifying the name of the class

    Returns

    "Engine" string

    Returns string

  • Gets a boolean indicating if color writing is enabled

    Returns

    the current color writing state

    Returns boolean

  • Gets the options used for engine creation

    Returns

    EngineOptions object

    Returns EngineOptions

  • Gets the name of the current render pass

    Returns

    name of the current render pass

    Returns string

  • Gets the time spent between current and previous frame

    Returns

    a number representing the delta time in ms

    Returns number

  • Gets a boolean indicating if depth testing is enabled

    Returns

    the current state

    Returns boolean

  • Gets the current depth function

    Returns

    a number defining the depth function

    Returns Nullable<number>

  • Gets a boolean indicating if depth writing is enabled

    Returns

    the current depth writing state

    Returns boolean

  • Get Font size information

    Returns

    an object containing ascent, height and descent

    Parameters

    • font: string

      font name

    Returns { ascent: number; descent: number; height: number }

    • ascent: number
    • descent: number
    • height: number
  • Gets the current framerate

    Returns

    a number representing the framerate

    Returns number

  • Gets the source code of the fragment shader associated with a specific webGL program

    Returns

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

    Parameters

    • program: WebGLProgram

      defines the program to use

    Returns Nullable<string>

  • Gets an object containing information about the current webGL context

    Returns

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

    Returns { renderer: string; vendor: string; version: string }

    • renderer: string
    • vendor: string
    • version: string
  • 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

    a number indicating the current hardware scaling level

    Returns number

  • Gets host document

    Returns

    the host document object

    Returns Nullable<Document>

  • Gets host window

    Returns

    the host window object

    Returns Nullable<Window>

  • Gets an object containing information about the current engine context

    Returns

    an object containing the vendor, the renderer and the version of the current engine context

    Returns { renderer: string; vendor: string; version: string }

    • renderer: string
    • vendor: string
    • version: string
  • Gets the HTML element used to attach event listeners

    Returns

    a HTML element

    Returns Nullable<HTMLElement>

  • Gets the client rect of the HTML element used for events

    Returns

    a client rectangle

    Returns Nullable<ClientRect>

  • Gets the list of loaded textures

    Returns

    an array containing all loaded textures

    Returns InternalTexture[]

  • Gets the current render height

    Returns

    a number defining the current render height

    Parameters

    • Optional useScreen: boolean

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

    Returns number

  • Gets the names of the render passes that are currently created

    Returns

    list of the render pass names

    Returns string[]

  • Gets the current render width

    Returns

    a number defining the current render width

    Parameters

    • Optional useScreen: boolean

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

    Returns number

  • Gets the HTML canvas attached with the current webGL context

    Returns

    a HTML canvas

    Returns Nullable<HTMLCanvasElement>

  • Gets the client rect of the HTML canvas attached with the current webGL context

    Returns

    a client rectangle

    Returns Nullable<ClientRect>

  • Gets current screen aspect ratio

    Returns

    a number defining the aspect ratio

    Returns number

  • Gets a boolean indicating if stencil buffer is enabled

    Returns

    the current stencil buffer state

    Returns boolean

  • Gets the current stencil function

    Returns

    a number defining the stencil function to use

    Returns number

  • Gets the current stencil mask

    Returns

    a number defining the stencil mask to use

    Returns number

  • Gets the current stencil reference value

    Returns

    a number defining the stencil reference value to use

    Returns number

  • Gets the current stencil mask

    Returns

    a number defining the new stencil mask to use

    Returns number

  • Gets the current stencil operation when depth fails

    Returns

    a number defining stencil operation to use when depth fails

    Returns number

  • Gets the current stencil operation when stencil fails

    Returns

    a number defining stencil operation to use when stencil fails

    Returns number

  • Gets the current stencil operation when stencil passes

    Returns

    a number defining stencil operation to use when stencil passes

    Returns number

  • Returns the time in ms between steps when using deterministic lock step.

    Returns

    time step in (ms)

    Returns number

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

    Returns

    an array of webGL uniform locations

    Parameters

    • pipelineContext: IPipelineContext

      defines the pipeline context to use

    • uniformsNames: string[]

      defines the list of uniform names

    Returns Nullable<WebGLUniformLocation>[]

  • Gets the source code of the vertex shader associated with a specific webGL program

    Returns

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

    Parameters

    • program: WebGLProgram

      defines the program to use

    Returns Nullable<string>

  • Gets the current value of the zOffset Factor

    Returns

    the current zOffset Factor state

    Returns number

  • Gets the current value of the zOffset Units

    Returns

    the current zOffset Units state

    Returns number

  • Inline functions in shader code that are marked to be inlined

    Returns

    inlined code

    Parameters

    • code: string

      code to inline

    Returns string

  • Reads pixels from the current frame buffer. Please note that this function can be slow

    Returns

    a ArrayBufferView promise (Uint8Array) containing RGBA colors

    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

    • Optional hasAlpha: boolean

      defines whether the output should have alpha or not (defaults to true)

    • Optional flushRenderer: boolean

      true to flush the renderer from the pending commands before reading the pixels

    Returns Promise<ArrayBufferView>

  • Records a vertex array object

    See

    https://doc.babylonjs.com/setup/support/webGL2#vertex-array-objects

    Returns

    the new vertex array object

    Parameters

    • vertexBuffers: { [key: string]: VertexBuffer }

      defines the list of vertex buffers to store

      • [key: string]: VertexBuffer
    • indexBuffer: Nullable<DataBuffer>

      defines the index buffer to store

    • effect: Effect

      defines the effect to store

    • Optional overrideVertexBuffers: { [kind: string]: Nullable<VertexBuffer> }

      defines optional list of avertex buffers that overrides the entries in vertexBuffers

      • [kind: string]: Nullable<VertexBuffer>

    Returns WebGLVertexArrayObject

  • 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

  • Releases a render pass id

    Parameters

    • id: number

      id of the render pass to release

    Returns void

  • Release and free the memory of a vertex array object

    Parameters

    • vao: WebGLVertexArrayObject

      defines the vertex array object to delete

    Returns void

  • Reset the texture cache to empty state

    Returns void

  • Resize the view according to the canvas' size

    Parameters

    • Optional forceSetSize: boolean

      true to force setting the sizes of the underlying canvas

    Returns void

  • Resize an image and returns the image data as an uint8array

    Returns

    an uint8array containing RGBA values of bufferWidth * bufferHeight size

    Parameters

    • image: HTMLImageElement | ImageBitmap

      image to resize

    • bufferWidth: number

      destination buffer width

    • bufferHeight: number

      destination buffer height

    Returns Uint8Array

  • Unbind the current render target and bind the default framebuffer

    Returns void

  • Restores the webgl state to only draw on the main color attachment when the frame buffer associated is the canvas frame buffer

    Returns void

  • Restores the webgl state to only draw on the main color attachment when the frame buffer associated is not the canvas frame buffer

    Returns void

  • Restores the state of the stencil buffer

    Returns void

  • Register and execute a render loop. The engine can have more than one render function

    Parameters

    • renderFunction: (() => void)

      defines the function to continuously execute

        • (): void
        • Returns void

    Returns void

  • Executes a scissor clear (ie. a clear on a specific portion of the screen)

    Parameters

    • x: number

      defines the x-coordinate of the bottom 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: IColor4Like

      defines the clear color

    Returns 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

  • Sets the current alpha equation

    Parameters

    • equation: number

      defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)

    Returns void

  • Parameters

    • mode: number

      defines the mode to use (one of the Engine.ALPHA_XXX)

    • Optional noDepthWriteChange: boolean

      defines if depth writing state should remains unchanged (false by default)

    Returns void

  • Set the value of an uniform to an array of number

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: number[] | Float32Array

      defines the array of number to store

    Returns boolean

  • Set the value of an uniform to an array of number (stored as vec2)

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: number[] | Float32Array

      defines the array of number to store

    Returns boolean

  • Set the value of an uniform to an array of number (stored as vec3)

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: number[] | Float32Array

      defines the array of number to store

    Returns boolean

  • Set the value of an uniform to an array of number (stored as vec4)

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: number[] | Float32Array

      defines the array of number to store

    Returns boolean

  • Enable or disable color writing

    Parameters

    • enable: boolean

      defines the state to set

    Returns void

  • Enable or disable depth buffering

    Parameters

    • enable: boolean

      defines the state to set

    Returns void

  • Sets the current depth function

    Parameters

    • depthFunc: number

      defines the function to use

    Returns void

  • Sets the current depth function to GREATER

    Returns void

  • Sets the current depth function to GEQUAL

    Returns void

  • Sets the current depth function to LESS

    Returns void

  • Sets the current depth function to LEQUAL

    Returns void

  • 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

    • Optional name: string

      The texture name

    Returns void

  • Enable or disable depth writing

    Parameters

    • enable: boolean

      defines the state to set

    Returns void

  • Directly set the WebGL Viewport

    Returns

    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

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

  • Sets a boolean indicating if the dithering state is enabled or disabled

    Parameters

    • value: boolean

      defines the dithering state

    Returns void

  • Set the value of an uniform to a number (float)

    Returns

    true if the value was transferred

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • value: number

      defines the float number to store

    Returns boolean

  • Set the value of an uniform to a vec2

    Returns

    true if the value was set

    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 boolean

  • Set the value of an uniform to a vec3

    Returns

    true if the value was set

    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 boolean

  • Set the value of an uniform to a vec4

    Returns

    true if the value was set

    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 boolean

  • 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

  • Set the value of an uniform to a number (int)

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • value: number

      defines the int number to store

    Returns boolean

  • Set the value of an uniform to a int2

    Returns

    true if the value was set

    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 boolean

  • Set the value of an uniform to a int3

    Returns

    true if the value was set

    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 boolean

  • Set the value of an uniform to a int4

    Returns

    true if the value was set

    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 boolean

  • Set the value of an uniform to an array of int32

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Int32Array

      defines the array of int32 to store

    Returns boolean

  • Set the value of an uniform to an array of int32 (stored as vec2)

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Int32Array

      defines the array of int32 to store

    Returns boolean

  • Set the value of an uniform to an array of int32 (stored as vec3)

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Int32Array

      defines the array of int32 to store

    Returns boolean

  • Set the value of an uniform to an array of int32 (stored as vec4)

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Int32Array

      defines the array of int32 to store

    Returns boolean

  • Set the value of an uniform to an array of float32 (stored as matrices)

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • matrices: Float32Array

      defines the array of float32 to store

    Returns boolean

  • Set the value of an uniform to a matrix (2x2)

    Returns

    true if the value was set

    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 boolean

  • Set the value of an uniform to a matrix (3x3)

    Returns

    true if the value was set

    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 boolean

  • Sets a boolean indicating if the rasterizer state is enabled or disabled

    Parameters

    • value: boolean

      defines the rasterizer state

    Returns void

  • Force a specific size of the canvas

    Returns

    true if the size was changed

    Parameters

    • width: number

      defines the new canvas' width

    • height: number

      defines the new canvas' height

    • Optional forceSetSize: boolean

      true to force setting the sizes of the underlying canvas

    Returns boolean

  • Set various states to the webGL context

    Parameters

    • culling: boolean

      defines culling state: true to enable culling, false to disable it

    • 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 if false, CW if true)

    • Optional cullBackFaces: boolean

      true to cull back faces, false to cull front faces (if culling is enabled)

    • Optional stencil: IStencilState

      stencil states to set

    • Optional zOffsetUnits: number

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

    Returns void

  • Enable or disable the stencil buffer

    Parameters

    • enable: boolean

      defines if the stencil buffer must be enabled or disabled

    Returns void

  • Sets the current stencil function

    Parameters

    • stencilFunc: number

      defines the new stencil function to use

    Returns void

  • Sets the current stencil mask

    Parameters

    • mask: number

      defines the new stencil mask to use

    Returns void

  • Sets the current stencil reference

    Parameters

    • reference: number

      defines the new stencil reference to use

    Returns void

  • Sets the current stencil mask

    Parameters

    • mask: number

      defines the new stencil mask to use

    Returns void

  • Sets the stencil operation to use when depth fails

    Parameters

    • operation: number

      defines the stencil operation to use when depth fails

    Returns void

  • Sets the stencil operation to use when stencil fails

    Parameters

    • operation: number

      defines the stencil operation to use when stencil fails

    Returns void

  • Sets the stencil operation to use when stencil passes

    Parameters

    • operation: number

      defines the stencil operation to use when stencil passes

    Returns void

  • Sets a texture to the according uniform.

    Parameters

    • channel: number

      The texture channel

    • uniform: Nullable<WebGLUniformLocation>

      The uniform to set

    • texture: Nullable<ThinTexture>

      The texture to apply

    • name: string

      The name of the uniform in the effect

    Returns 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: ThinTexture[]

      defines the array of textures to bind

    • name: string

      name of the channel

    Returns void

  • 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

    • name: string

      name of the channel

    Returns void

  • 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

    • name: string

      name of the channel

    Returns void

  • Set the value of an uniform to a number (unsigned int)

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • value: number

      defines the unsigned int number to store

    Returns boolean

  • Set the value of an uniform to a unsigned int2

    Returns

    true if the value was set

    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 boolean

  • Set the value of an uniform to a unsigned int3

    Returns

    true if the value was set

    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 boolean

  • Set the value of an uniform to a unsigned int4

    Returns

    true if the value was set

    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 boolean

  • Set the value of an uniform to an array of unsigned int32

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Uint32Array

      defines the array of unsigned int32 to store

    Returns boolean

  • Set the value of an uniform to an array of unsigned int32 (stored as vec2)

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Uint32Array

      defines the array of unsigned int32 to store

    Returns boolean

  • Set the value of an uniform to an array of unsigned int32 (stored as vec3)

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Uint32Array

      defines the array of unsigned int32 to store

    Returns boolean

  • Set the value of an uniform to an array of unsigned int32 (stored as vec4)

    Returns

    true if the value was set

    Parameters

    • uniform: Nullable<WebGLUniformLocation>

      defines the webGL uniform location where to store the value

    • array: Uint32Array

      defines the array of unsigned int32 to store

    Returns boolean

  • Set the WebGL's viewport

    Parameters

    • viewport: IViewportLike

      defines the viewport element to be used

    • Optional requiredWidth: number

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

    • Optional requiredHeight: number

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

    Returns void

  • Set the z offset Factor to apply to current rendering

    Parameters

    • value: number

      defines the offset to apply

    Returns void

  • Set the z offset Units to apply to current rendering

    Parameters

    • value: number

      defines the offset to apply

    Returns void

  • Creates a new snapshot at the next frame using the current snapshotRenderingMode

    Returns void

  • stop executing a render loop function and remove it from the execution array

    Parameters

    • Optional renderFunction: (() => void)

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

        • (): void
        • Returns void

    Returns void

  • Toggle full screen mode

    Parameters

    • requestPointerLock: boolean

      defines if a pointer lock should be requested from the user

    Returns void

  • Unbind the current render target texture from the webGL context

    Parameters

    • texture: RenderTargetWrapper

      defines the render target wrapper to unbind

    • Optional disableGenerateMipMaps: boolean

      defines a boolean indicating that mipmaps must not be generated

    • Optional onBeforeUnbind: (() => void)

      defines a function which will be called before the effective unbind

        • (): void
        • Returns void

    Returns void

  • Unbind a list of render target textures from the webGL context This is used only when drawBuffer extension or webGL2 are active

    Parameters

    • rtWrapper: RenderTargetWrapper

      defines the render target wrapper to unbind

    • disableGenerateMipMaps: boolean

      defines a boolean indicating that mipmaps must not be generated

    • Optional onBeforeUnbind: (() => void)

      defines a function which will be called before the effective unbind

        • (): void
        • Returns void

    Returns void

  • Unbind all vertex attributes from the webGL context

    Returns void

  • Unbind all textures from the webGL context

    Returns void

  • Unbind all instance attributes

    Returns void

  • Update the content of a webGL buffer used with instantiation and bind it to the webGL context

    Parameters

    • instancesBuffer: DataBuffer

      defines the webGL buffer to update and bind

    • data: Float32Array

      defines the data to store in the buffer

    • offsetLocations: number[] | InstancingAttributeInfo[]

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

    Returns void

  • update the bound buffer with the given data

    Parameters

    • data: Float32Array

      defines the data to update

    Returns void

  • Update a dynamic index buffer

    Parameters

    • indexBuffer: DataBuffer

      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

  • Update the content of a dynamic texture

    Parameters

    • texture: Nullable<InternalTexture>

      defines the texture to update

    • source: HTMLCanvasElement | HTMLImageElement | HTMLVideoElement | ImageBitmap | OffscreenCanvas | ImageData | ICanvas

      defines the source containing the data

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

    • Optional allowGPUOptimization: boolean

      true to allow some specific GPU optimizations (subject to engine feature "allowGPUOptimizationsForGUI" being true)

    Returns void

  • Updates a dynamic vertex buffer.

    Parameters

    • vertexBuffer: DataBuffer

      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

  • Update the sample count for a given multiple render target texture

    See

    https://doc.babylonjs.com/setup/support/webGL2#multisample-render-targets

    Returns

    the effective sample count (could be 0 if multisample render targets are not supported)

    Parameters

    • rtWrapper: Nullable<RenderTargetWrapper>

      defines the render target wrapper to update

    • samples: number

      defines the sample count to set

    • Optional initializeBuffers: boolean

      if set to true, the engine will make an initializing call of drawBuffers

    Returns number

  • Update a raw cube texture

    Parameters

    • texture: InternalTexture

      defines the texture to update

    • data: ArrayBufferView[]

      defines the data to store

    • format: number

      defines the data format

    • type: number

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

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    Returns void

  • Update a raw cube texture

    Parameters

    • texture: InternalTexture

      defines the texture to update

    • data: ArrayBufferView[]

      defines the data to store

    • format: number

      defines the data format

    • type: number

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

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • compression: Nullable<string>

      defines the compression used (null by default)

    Returns void

  • Update a raw cube texture

    Parameters

    • texture: InternalTexture

      defines the texture to update

    • data: ArrayBufferView[]

      defines the data to store

    • format: number

      defines the data format

    • type: number

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

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • compression: Nullable<string>

      defines the compression used (null by default)

    • level: number

      defines which level of the texture to update

    Returns void

  • 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

    Returns void

  • 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

    • compression: Nullable<string>

      defines the compression used (null by default)

    • type: number

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

    • useSRGBBuffer: boolean

      defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).

    Returns void

  • Update a raw 2D array 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

    Returns void

  • Update a raw 2D array 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

    • compression: Nullable<string>

      defines the used compression (can be null)

    • textureType: number

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

    Returns 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

    Returns 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

    • compression: Nullable<string>

      defines the used compression (can be null)

    • textureType: number

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

    Returns void

  • Updates the sample count of a render target texture

    See

    https://doc.babylonjs.com/setup/support/webGL2#multisample-render-targets

    Returns

    the effective sample count (could be 0 if multisample render targets are not supported)

    Parameters

    • rtWrapper: Nullable<RenderTargetWrapper>

      defines the render target wrapper to update

    • samples: number

      defines the sample count to set

    Returns number

  • 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

  • Update a portion of an internal texture

    Parameters

    • texture: InternalTexture

      defines the texture to update

    • imageData: ArrayBufferView

      defines the data to store into the texture

    • xOffset: number

      defines the x coordinates of the update rectangle

    • yOffset: number

      defines the y coordinates of the update rectangle

    • width: number

      defines the width of the update rectangle

    • height: number

      defines the height of the update rectangle

    • Optional faceIndex: number

      defines the face index if texture is a cube (0 by default)

    • Optional lod: number

      defines the lod level to update (0 by default)

    • Optional generateMipMaps: boolean

      defines whether to generate mipmaps or not

    Returns void

  • Update the dimensions of a texture

    Parameters

    • texture: InternalTexture

      texture to update

    • width: number

      new width of the texture

    • height: number

      new height of the texture

    • Optional depth: number

      new depth of the texture

    Returns void

  • Update the sampling mode of a given texture

    Parameters

    • samplingMode: number

      defines the required sampling mode

    • texture: InternalTexture

      defines the texture to update

    • Optional generateMipMaps: boolean

      defines whether to generate mipmaps for the texture

    Returns void

  • Update the sampling mode of a given texture

    Parameters

    • texture: InternalTexture

      defines the texture to update

    • wrapU: Nullable<number>

      defines the texture wrap mode of the u coordinates

    • Optional wrapV: Nullable<number>

      defines the texture wrap mode of the v coordinates

    • Optional wrapR: Nullable<number>

      defines the texture wrap mode of the r coordinates

    Returns void

  • Parameters

    • uniformBuffer: DataBuffer

      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

  • Update a video texture

    Parameters

    • texture: Nullable<InternalTexture>

      defines the texture to update

    • video: HTMLVideoElement | Nullable<ExternalTexture>

      defines the video element to use

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    Returns 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

  • Wraps an external web gl texture in a Babylon texture.

    Returns

    the babylon internal texture

    Parameters

    • texture: WebGLTexture

      defines the external texture

    • Optional hasMipMaps: boolean

      defines whether the external texture has mip maps (default: false)

    • Optional samplingMode: number

      defines the sampling mode for the external texture (default: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE)

    • Optional width: number

      defines the width for the external texture (default: 0)

    • Optional height: number

      defines the height for the external texture (default: 0)

    Returns InternalTexture

  • Find the next highest power of two.

    Returns

    Next highest power of two.

    Parameters

    • x: number

      Number to start search from.

    Returns number

  • Method called to create the default loading screen. This can be overridden in your own app.

    Returns

    The loading screen

    Parameters

    • canvas: HTMLCanvasElement

      The rendering canvas element

    Returns ILoadingScreen

  • Find the next lowest power of two.

    Returns

    Next lowest power of two.

    Parameters

    • x: number

      Number to start search from.

    Returns number