Options
All
  • Public
  • Public/Protected
  • All
Menu

The web GPU engine class provides support for WebGPU version of babylon.js.

since

5.0.0

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

  • Create a new instance of the gpu engine.

    Parameters

    • canvas: HTMLCanvasElement

      Defines the canvas to use to display the result

    • Optional options: WebGPUEngineOptions

      Defines the options passed to the engine to create the GPU context dependencies

    Returns WebGPUEngine

Properties

_alphaEquation: number
internal
_alphaMode: number
internal
_alphaState: AlphaState
internal
_badDesktopOS: boolean
internal
_badOS: boolean
internal
_boundRenderFunction: any
internal
_bufferManager: WebGPUBufferManager
internal
_bundleList: WebGPUBundleList
internal
_bundleListRenderTarget: WebGPUBundleList
internal
_cacheRenderPipeline: WebGPUCacheRenderPipeline
internal
_cacheSampler: WebGPUCacheSampler
internal
internal
_captureGPUFrameTime: boolean
internal
_clearDepthValue: 1 = 1
internal
_clearReverseDepthValue: 0 = 0
internal
_clearStencilValue: 0 = 0
internal
_compiledComputeEffects: {}
internal

Type declaration

_counters: { numBundleCreationNonCompatMode: number; numBundleReuseNonCompatMode: number; numEnableDrawWrapper: number; numEnableEffects: number }
internal

Type declaration

  • numBundleCreationNonCompatMode: number
  • numBundleReuseNonCompatMode: number
  • numEnableDrawWrapper: number
  • numEnableEffects: number
_currentDrawContext: WebGPUDrawContext
internal
_currentFramebuffer: Nullable<WebGLFramebuffer>
internal
_currentMaterialContext: WebGPUMaterialContext
internal
_currentNonTimestampToken: Nullable<_TimeToken>
internal
_currentRenderPass: Nullable<GPURenderPassEncoder>
internal
_currentRenderTarget: Nullable<RenderTargetWrapper>
internal
_device: GPUDevice
internal
_deviceSourceManager?: InternalDeviceSourceManager
internal
_doNotHandleContextLost: boolean
internal
_drawCalls: PerfCounter
internal
_dummyFramebuffer: Nullable<WebGLFramebuffer>
internal
_excludedCompressedTextures: string[]
internal
_features: EngineFeatures
internal
_frameHandler: number
internal
_gl: WebGL2RenderingContext
internal
_gpuFrameTime: PerfCounter
internal
_gpuFrameTimeToken: Nullable<_TimeToken>
internal
_hardwareScalingLevel: number
internal
_inputElement: Nullable<HTMLElement>
internal
_internalTexturesCache: InternalTexture[]
internal
_mainRenderPassWrapper: WebGPURenderPassWrapper
internal
_mrtAttachments: number[]
internal
_occlusionQuery: WebGPUOcclusionQuery
internal
_oldHardwareScaleFactor: number
internal
_oldSize: Size
internal
_onAfterUnbindFrameBufferObservable: Observable<WebGPUEngine>
internal
_onBeginFrameObserver: Nullable<Observer<Engine>>
internal
_onEndFrameObserver: Nullable<Observer<Engine>>
internal
_onVrDisplayConnect: Nullable<((display: any) => void)>
internal
_onVrDisplayDisconnect: Nullable<(() => void)>
internal
_onVrDisplayPresentChange: Nullable<(() => void)>
internal
internal
_pendingDebugCommands: [string, Nullable<string>][]
internal
_renderEncoder: GPUCommandEncoder
internal
_renderTargetEncoder: GPUCommandEncoder
internal
_renderTargetWrapperCache: RenderTargetWrapper[]
internal
_rttRenderPassWrapper: WebGPURenderPassWrapper
internal
_storageBuffers: StorageBuffer[]
internal
_textureFormatInUse: string
internal
_textureHelper: WebGPUTextureHelper
internal
_timestampQuery: WebGPUTimestampQuery
internal
_transformTextureUrl: Nullable<((url: string) => string)>
internal
_ubDontInvertY: WebGPUDataBuffer
internal
_ubInvertY: WebGPUDataBuffer
internal
_uniformBuffers: UniformBuffer[]
internal
_uploadEncoder: GPUCommandEncoder
internal
_videoTextureSupported: boolean
internal
_virtualScenes: Scene[]
internal
_vrDisplay: any
internal
_vrExclusivePointerMode: boolean
internal
_vrSupported: boolean
internal
_webGLVersion: number
internal
_webVRInitPromise: Promise<IDisplayChangedEventArgs>
internal
_workingCanvas: Nullable<ICanvas>
internal
internal
activeView: Nullable<EngineView>

Gets the current engine view

see

https://doc.babylonjs.com/how_to/multi_canvases

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

countersLastFrame: { numBundleCreationNonCompatMode: number; numBundleReuseNonCompatMode: number; numEnableDrawWrapper: number; numEnableEffects: number }

Counters from last frame

Type declaration

  • numBundleCreationNonCompatMode: number
  • numBundleReuseNonCompatMode: number
  • numEnableDrawWrapper: number
  • numEnableEffects: number
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

dbgLogIfNotDrawWrapper: boolean
internal
dbgSanityChecks: boolean
internal
dbgShowEmptyEnableEffectCalls: boolean
internal
dbgShowShaderCode: boolean
internal
dbgVerboseLogsForFirstFrames: boolean
internal
dbgVerboseLogsNumFrames: number
internal
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: true = true

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

inputElement: Nullable<HTMLElement>

Gets or sets the HTML element to use for attaching events

isFullscreen: boolean

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

isInVRExclusivePointerMode: boolean

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

see

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

isNDCHalfZRange: false = false

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

numMaxUncapturedErrors: number

Max number of uncaptured error messages to log

onAfterShaderCompilationObservable: Observable<Engine>

Observable raised when the engine has just compiled a shader

onAfterViewRenderObservable: Observable<EngineView>

Will be triggered after the view rendered

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

onBeforeViewRenderObservable: Observable<EngineView>

Will be triggered before the view renders

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

onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>

Observable signaled when VR display mode changes

onVRRequestPresentComplete: Observable<boolean>

Observable signaled when VR request present is complete

onVRRequestPresentStart: Observable<Engine>

Observable signaled when VR request present starts

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

textureFormatInUse: Nullable<string>

Gets the texture format in use

texturesSupported: string[]

Gets the list of texture formats supported

validateShaderPrograms: boolean

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

views: EngineView[]

Gets or sets the list of views

vrPresentationAttributes?: IVRPresentationAttributes

Gets or sets the presentation attributes used to configure VR rendering

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

    • 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

UseTWGSL: boolean

true to enable using TintWASM to convert Spir-V to WGSL

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

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

_TextureLoaders: IInternalTextureLoader[]
internal
audioEngine: Nullable<IAudioEngine>

Gets the audio engine

see

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

ignorenaming

Accessors

  • get _shouldUseHighPrecisionShader(): boolean
  • internal

    Returns boolean

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

    Returns (() => void)[]

    an array with the current render loop functions

  • Gets the alpha state manager

    Returns AlphaState

  • get compatibilityMode(): boolean
  • set compatibilityMode(mode: boolean): void
  • get currentSampleCount(): number
  • internal

    Returns number

  • Gets the depth culling state manager

    Returns DepthCullingState

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

    Returns string

  • get disableCacheBindGroups(): boolean
  • set disableCacheBindGroups(disable: boolean): void
  • Sets this to true to disable the cache for the bind groups. You should do it only for testing purpose!

    Returns boolean

  • Sets this to true to disable the cache for the bind groups. You should do it only for testing purpose!

    Parameters

    • disable: boolean

    Returns void

  • get disableCacheRenderPipelines(): boolean
  • set disableCacheRenderPipelines(disable: boolean): void
  • Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!

    Returns boolean

  • Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!

    Parameters

    • disable: boolean

    Returns void

  • get disableCacheSamplers(): boolean
  • set disableCacheSamplers(disable: boolean): void
  • Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!

    Returns boolean

  • Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!

    Parameters

    • disable: boolean

    Returns void

  • get doNotHandleContextLost(): boolean
  • set doNotHandleContextLost(value: boolean): void
  • Gets the default empty cube texture

    Returns InternalTexture

  • Gets the default empty texture

    Returns InternalTexture

  • Gets the default empty 2D array texture

    Returns InternalTexture

  • Gets the default empty 3D texture

    Returns InternalTexture

  • Gets the currently enabled extensions on the WebGPU device

    Returns readonly GPUFeatureName[]

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

  • set loadingUIBackgroundColor(color: string): void
  • set loadingUIText(text: string): void
  • get name(): string
  • set name(value: string): void
  • Gets or sets the name of the engine

    Returns string

  • Gets or sets the name of the engine

    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
  • set snapshotRendering(activate: boolean): void
  • 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

  • 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

    Parameters

    • activate: boolean

    Returns void

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

    Returns number

  • Gets or sets the snapshot rendering mode

    Parameters

    • mode: number

    Returns void

  • Gets the stencil state manager

    Returns StencilState

  • Gets the stencil state composer

    Returns StencilStateComposer

  • Gets the supported extensions by the WebGPU adapter

    Returns readonly GPUFeatureName[]

  • get supportsUniformBuffers(): boolean
  • Gets a boolean indicating that the engine supports uniform buffers

    Returns boolean

  • get useExactSrgbConversions(): boolean
  • Gets a boolean indicating if the exact sRGB conversions or faster approximations are used for converting to and from linear space.

    Returns boolean

  • get useReverseDepthBuffer(): boolean
  • set useReverseDepthBuffer(useReverse: boolean): void
  • 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

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

    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

  • Gets the list of created engines

    Returns Engine[]

  • get IsSupported(): boolean
  • Not supported by WebGPU, you should call IsSupportedAsync instead!

    Returns boolean

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

Returns Promise<boolean>

  • Gets the latest created engine

    Returns Nullable<Engine>

  • Gets the latest created scene

    Returns Nullable<Scene>

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

    Returns string

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

    Returns string

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

    Parameters

    • value: string

    Returns void

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

    Returns string

Methods

  • internal

    Parameters

    Returns void

  • _bindTexture(channel: number, texture: InternalTexture, name: string): void
  • _bindTextureDirectly(): boolean
  • _bindUnboundFramebuffer(): void
  • _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: ((images: ArrayBuffer[]) => void), files: string[], onError: Nullable<((message?: string, exception?: any) => void)>): void
  • internal

    Parameters

    • scene: Nullable<Scene>
    • onfinish: ((images: ArrayBuffer[]) => void)
        • (images: ArrayBuffer[]): void
        • Parameters

          • images: ArrayBuffer[]

          Returns void

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

    Returns void

  • _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void
  • internal

    Parameters

    • Optional canvas: HTMLCanvasElement
    • Optional document: any

    Returns void

  • internal

    Parameters

    • data: number | DataArray
    • creationFlags: number

    Returns DataBuffer

  • internal

    Parameters

    • computeShader: string
    • defines: Nullable<string>
    • entryPoint: string

    Returns GPUProgrammableStage

  • _createImageBitmapFromSource(imageSource: string, options?: ImageBitmapOptions): Promise<ImageBitmap>
  • Engine abstraction for loading and creating an image bitmap from a given source string.

    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>

    ImageBitmap.

  • Creates an internal texture without binding it to a framebuffer

    internal

    Parameters

    • size: TextureSize

      defines the size of the texture

    • options: boolean | InternalTextureCreationOptions

      defines the options used to create the texture

    • Optional delayGPUTextureCreation: boolean

      true to delay the texture creation the first time it is really needed. false to create it right away

    • Optional source: InternalTextureSource

      source type of the texture

    Returns InternalTexture

    a new internal texture

  • _createRenderBuffer(width: number, height: number, samples: number, internalFormat: number, msInternalFormat: number, attachment: number, unbindBuffer?: boolean): Nullable<WebGLRenderbuffer>
  • internal

    Parameters

    • width: number
    • height: number
    • samples: number
    • internalFormat: number
    • msInternalFormat: number
    • attachment: number
    • Optional unbindBuffer: boolean

    Returns Nullable<WebGLRenderbuffer>

  • _createTimeQuery(): WebGLQuery
  • _currentFrameBufferIsDefaultFrameBuffer(): boolean
  • _debugFlushPendingCommands(): void
  • _debugInsertMarker(text: string, targetObject?: number): void
  • internal

    Parameters

    • text: string
    • Optional targetObject: number

    Returns void

  • _debugPopGroup(targetObject?: number): void
  • internal

    Parameters

    • Optional targetObject: number

    Returns void

  • _debugPushGroup(groupName: string, targetObject?: number): void
  • internal

    Parameters

    • groupName: string
    • Optional targetObject: number

    Returns void

  • _deleteTimeQuery(query: WebGLQuery): void
  • internal

    Parameters

    • query: WebGLQuery

    Returns void

  • _endRenderTargetRenderPass(): void
  • internal

    Returns void

  • _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: (() => void)): void
  • _getCurrentRenderPassIndex(): number
  • internal

    Returns number

  • _getGlAlgorithmType(algorithmType: number): number
  • internal

    Parameters

    • algorithmType: number

    Returns number

  • _getGlobalDefines(defines?: {}): undefined | string
  • internal

    Parameters

    • Optional defines: {}
      • [key: string]: string

    Returns undefined | string

  • _getInternalFormat(format: number, useSRGBBuffer?: boolean): number
  • internal

    Parameters

    • format: number
    • Optional useSRGBBuffer: boolean

    Returns number

  • _getRGBABufferInternalSizedFormat(): number
  • _getRGBAMultiSampleBufferFormat(type: number): number
  • _getSamplingParameters(): { mag: number; min: number }
  • internal

    Returns { mag: number; min: number }

    • mag: number
    • min: number
  • _getShaderSource(shader: WebGLShader): Nullable<string>
  • _getTimeQueryAvailability(query: WebGLQuery): any
  • _getTimeQueryResult(query: WebGLQuery): any
  • internal

    Parameters

    • query: WebGLQuery

    Returns any

  • _getUnpackAlignement(): number
  • _getUseSRGBBuffer(useSRGBBuffer: boolean, noMipmap: boolean): boolean
  • internal

    Parameters

    • useSRGBBuffer: boolean
    • noMipmap: boolean

    Returns boolean

  • _getWebGLTextureType(type: number): number
  • internal

    Parameters

    • type: number

    Returns number

  • _isRenderingStateCompiled(): boolean
  • _loadFile(url: string, onSuccess: ((data: string | ArrayBuffer, responseURL?: string) => void), onProgress?: ((data: any) => void), offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: ((request?: IWebRequest, exception?: any) => void)): IFileRequest
  • internal

    Parameters

    • url: string
    • onSuccess: ((data: string | ArrayBuffer, responseURL?: string) => void)
        • (data: string | ArrayBuffer, responseURL?: string): void
        • Parameters

          • data: string | ArrayBuffer
          • Optional responseURL: string

          Returns void

    • Optional onProgress: ((data: any) => void)
        • (data: any): void
        • Parameters

          • data: any

          Returns void

    • Optional offlineProvider: IOfflineProvider
    • Optional useArrayBuffer: boolean
    • Optional onError: ((request?: IWebRequest, exception?: any) => void)
        • Parameters

          Returns void

    Returns IFileRequest

  • _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>
  • internal

    Parameters

    • url: string
    • Optional offlineProvider: IOfflineProvider
    • Optional useArrayBuffer: boolean

    Returns Promise<string | ArrayBuffer>

  • _onEngineViewChanged(): void
  • Observable to handle when a change to inputElement occurs

    internal

    Returns void

  • _onVRDisplayPointerRestricted(): void
  • _onVRDisplayPointerUnrestricted(): void
  • _onVRFullScreenTriggered(): void
  • _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: ((files: ArrayBuffer[]) => void), onErrorCallBack: Nullable<((message?: string, exception?: any) => void)>): void
  • internal

    Parameters

    • url: string
    • index: number
    • loadedFiles: ArrayBuffer[]
    • onfinish: ((files: ArrayBuffer[]) => void)
        • (files: ArrayBuffer[]): void
        • Parameters

          • files: ArrayBuffer[]

          Returns void

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

    Returns void

  • _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<((texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void)>, onErrorCallBack: Nullable<((message?: string, exception?: any) => void)>, mimeType?: string): void
  • internal

    Parameters

    • url: string
    • index: number
    • loadedImages: HTMLImageElement[] | ImageBitmap[]
    • scene: Nullable<Scene>
    • texture: InternalTexture
    • onfinish: Nullable<((texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void)>
    • onErrorCallBack: Nullable<((message?: string, exception?: any) => void)>
    • Optional mimeType: string

    Returns void

  • _prepareComputePipelineContext(pipelineContext: IComputePipelineContext, computeSourceCode: string, rawComputeSourceCode: string, defines: Nullable<string>, entryPoint: string): void
  • _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>): void
  • internal

    Parameters

    • pipelineContext: IPipelineContext
    • vertexSourceCode: string
    • fragmentSourceCode: string
    • createAsRaw: boolean
    • rawVertexSourceCode: string
    • rawFragmentSourceCode: string
    • rebuildRebind: any
    • defines: Nullable<string>

    Returns void

  • _prepareVRComponent(): void
  • _prepareWorkingCanvas(): void
  • _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): null | Promise<ArrayBufferView>
  • internal

    Parameters

    • x: number
    • y: number
    • w: number
    • h: number
    • format: number
    • type: number
    • outputBuffer: ArrayBufferView

    Returns null | Promise<ArrayBufferView>

  • _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean, noDataConversion?: boolean, x?: number, y?: number): Promise<ArrayBufferView>
  • internal

    Parameters

    • texture: InternalTexture
    • width: number
    • height: number
    • Optional faceIndex: number
    • Optional level: number
    • Optional buffer: Nullable<ArrayBufferView>
    • Optional flushRenderer: boolean
    • Optional noDataConversion: boolean
    • Optional x: number
    • Optional y: number

    Returns Promise<ArrayBufferView>

  • _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean, noDataConversion?: boolean, x?: number, y?: number): ArrayBufferView
  • internal

    Parameters

    • texture: InternalTexture
    • width: number
    • height: number
    • Optional faceIndex: number
    • Optional level: number
    • Optional buffer: Nullable<ArrayBufferView>
    • Optional flushRenderer: boolean
    • Optional noDataConversion: boolean
    • Optional x: number
    • Optional y: number

    Returns ArrayBufferView

  • _rebuildComputeEffects(): void
  • _releaseEffect(effect: Effect): void
  • _renderFrame(): void
  • internal

    Returns void

  • _renderLoop(): void
  • Returns void

  • _renderViews(): boolean
  • internal

    Returns boolean

  • _reportDrawCall(numDrawCalls?: number): void
  • internal

    Parameters

    • Optional numDrawCalls: number

    Returns void

  • _requestVRFrame(): void
  • internal

    Rescales a texture

    Parameters

    • source: InternalTexture

      input texture

    • destination: InternalTexture

      destination texture

    • scene: any

      scene to use to render the resize

    • internalFormat: number

      format to use when resizing

    • onComplete: (() => void)

      callback to be called when resize has completed

        • (): void
        • Returns void

    Returns void

  • _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void
  • _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean, maxLevel?: number): void
  • _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | { height: number; layers?: number; width: number }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void
  • internal

    Parameters

    • internalTexture: InternalTexture
    • size: number | { height: number; layers?: number; width: number }
    • generateStencil: boolean
    • bilinearFiltering: boolean
    • comparisonFunction: number
    • Optional samples: number

    Returns void

  • _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>
  • internal

    Parameters

    • generateStencilBuffer: boolean
    • generateDepthBuffer: boolean
    • width: number
    • height: number
    • Optional samples: number

    Returns Nullable<WebGLRenderbuffer>

  • _submitVRFrame(): void
  • internal

    Returns void

  • _unpackFlipY(): void
  • internal

    Returns void

  • _updateRenderBuffer(renderBuffer: Nullable<WebGLRenderbuffer>, width: number, height: number, samples: number, internalFormat: number, msInternalFormat: number, attachment: number, unbindBuffer?: boolean): Nullable<WebGLRenderbuffer>
  • Parameters

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

    Returns Nullable<WebGLRenderbuffer>

  • _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void
  • _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void
  • _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void
  • internal

    Parameters

    • texture: InternalTexture
    • imageData: ArrayBufferView
    • Optional faceIndex: number
    • Optional lod: number
    • Optional babylonInternalFormat: number
    • Optional useTextureWidthAndHeight: boolean

    Returns void

  • _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void
  • internal

    Parameters

    • texture: InternalTexture
    • image: HTMLImageElement | ImageBitmap
    • Optional faceIndex: number
    • Optional lod: number

    Returns void

  • _viewport(x: number, y: number, width: number, height: number): void
  • internal

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number

    Returns void

  • applyStates(): void
  • internal

    Returns void

  • areAllComputeEffectsReady(): boolean
  • Gets a boolean indicating if all created compute effects are ready

    Returns boolean

    true if all effects are ready

  • areAllEffectsReady(): boolean
  • Gets a boolean indicating if all created effects are ready

    Returns boolean

    always true - No parallel shader compilation

  • attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void
  • 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

  • attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): 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

  • beginFrame(): void
  • Begin a new frame

    Returns void

  • beginOcclusionQuery(algorithmType: number, query: OcclusionQuery): boolean
  • beginTransformFeedback(usePoints: boolean): void
  • Begins a transform feedback operation

    Parameters

    • usePoints: boolean

      defines if points or triangles must be used

    Returns void

  • Bind a webGL buffer to the webGL context

    Parameters

    Returns void

  • bindAttachments(attachments: number[]): void
  • Select a subsets of attachments to draw to.

    Parameters

    • attachments: number[]

      gl attachments

    Returns void

  • Bind a list of vertex buffers with the engine

    Parameters

    • vertexBuffers: {}

      defines the list of vertex buffers to bind

    • indexBuffer: Nullable<DataBuffer>

      defines the index buffer to bind

    • effect: Effect

      defines the effect associated with the vertex buffers

    • Optional overrideVertexBuffers: {}

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

    Returns void

  • bindBuffersDirectly(): void
  • bindFramebuffer(texture: RenderTargetWrapper, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void
  • Binds the frame buffer to the specified texture.

    Parameters

    • texture: RenderTargetWrapper

      The render target wrapper to render to

    • Optional faceIndex: number

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

    • Optional requiredWidth: number

      The width of the target to render to

    • Optional requiredHeight: number

      The height of the target to render to

    • Optional forceFullscreenViewport: boolean

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

    • Optional lodLevel: number

      defines the lod level to bind to the frame buffer

    • Optional layer: number

      defines the 2d array index to bind to frame buffer to

    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

  • bindSamplers(): void
  • internal

    Returns void

  • bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void
  • Bind a webGL transform feedback object to the webgl context

    Parameters

    • value: Nullable<WebGLTransformFeedback>

      defines the webGL transform feedback object to bind

    Returns void

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

    Parameters

    • pipelineContext: IPipelineContext

      defines the pipeline context to use

    • blockName: string

      defines the block name

    • index: number

      defines the index where to bind the block

    Returns void

  • Bind an uniform buffer to the current webGL context

    Parameters

    Returns void

  • bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): 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

  • bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void
  • buildTextureLayout(textureStatus: boolean[]): number[]
  • Creates a layout object to draw/clear on specific textures in a MRT

    Parameters

    • textureStatus: boolean[]

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

    Returns number[]

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

  • cacheStencilState(): void
  • Caches the the state of the stencil buffer

    Returns void

  • captureGPUFrameTime(value: boolean): void
  • Enable or disable the GPU frame time capture

    Parameters

    • value: boolean

      True to enable, false to disable

    Returns void

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

    Parameters

    • color: Nullable<IColor4Like>

      defines the color to use

    • backBuffer: boolean

      defines if the back buffer must be cleared

    • depth: boolean

      defines if the depth buffer must be cleared

    • Optional stencil: boolean

      defines if the stencil buffer must be cleared

    Returns void

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

    Returns void

  • Dispatches a compute shader

    Parameters

    • effect: ComputeEffect

      The compute effect

    • context: IComputeContext

      The compute context

    • bindings: ComputeBindingList

      The list of resources to bind to the shader

    • x: number

      The number of workgroups to execute on the X dimension

    • Optional y: number

      The number of workgroups to execute on the Y dimension

    • Optional z: number

      The number of workgroups to execute on the Z dimension

    • Optional bindingsMapping: ComputeBindingMapping

      list of bindings mapping (key is property name, value is binding location)

    Returns void

  • createCanvas(width: number, height: number): ICanvas
  • Create a canvas. This method is overridden by other engines

    Parameters

    • width: number

      width

    • height: number

      height

    Returns ICanvas

    ICanvas interface

  • createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: undefined | boolean, onLoad: Nullable<((data?: any) => void)>, onError: Nullable<((message?: string, exception?: any) => void)>, format: undefined | number, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any, useSRGBBuffer: boolean): InternalTexture
  • createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<((data?: any) => void)>, onError: Nullable<((message?: string, exception?: any) => void)>, format: undefined | number, forcedExtension: any): InternalTexture
  • createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<((data?: any) => void)>, onError: Nullable<((message?: string, exception?: any) => void)>, format: undefined | number, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture
  • Creates a cube texture

    Parameters

    • rootUrl: string

      defines the url where the files to load is located

    • scene: Nullable<Scene>

      defines the current scene

    • files: Nullable<string[]>

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

    • noMipmap: 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

    the cube texture as an InternalTexture

  • Creates a cube texture

    Parameters

    • rootUrl: string

      defines the url where the files to load is located

    • scene: Nullable<Scene>

      defines the current scene

    • files: Nullable<string[]>

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

    • noMipmap: boolean

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

    • onLoad: Nullable<((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

    the cube texture as an InternalTexture

  • Creates a cube texture

    Parameters

    • rootUrl: string

      defines the url where the files to load is located

    • scene: Nullable<Scene>

      defines the current scene

    • files: Nullable<string[]>

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

    • noMipmap: boolean

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

    • onLoad: Nullable<((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

    the cube texture as an InternalTexture

  • createCubeTextureBase(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<((data?: any) => void)>, onError: Nullable<((message?: string, exception?: any) => void)>, format: undefined | number, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, beforeLoadCubeDataCallback: Nullable<((texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void)>, imageHandler: Nullable<((texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void)>, useSRGBBuffer: boolean): InternalTexture
  • createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture
  • Creates a dynamic texture

    Parameters

    • width: number

      defines the width of the texture

    • height: number

      defines the height of the texture

    • generateMipMaps: boolean

      defines if the engine should generate the mip levels

    • samplingMode: number

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

    Returns InternalTexture

    the dynamic texture inside an InternalTexture

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

    Parameters

    • baseName: any

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

    • attributesNamesOrOptions: string[] | IEffectCreationOptions

      defines either a list of attribute names or an IEffectCreationOptions object

    • uniformsNamesOrEngine: string[] | Engine

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

    • Optional samplers: string[]

      defines an array of string used to represent textures

    • Optional defines: string

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

    • Optional fallbacks: EffectFallbacks

      defines the list of potential fallbacks to use if shader 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

    the new Effect

  • createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: ((effect: Effect) => void), onError?: ((effect: Effect, errors: string) => void), particleSystem?: IParticleSystem): Effect
  • Create an effect to use with particle systems. Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass the particle system for which you want to create a custom effect in the last parameter

    Parameters

    • fragmentName: string

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

    • uniformsNames: string[]

      defines a list of attribute names

    • samplers: string[]

      defines an array of string used to represent textures

    • defines: string

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

    • Optional fallbacks: EffectFallbacks

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

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

      defines a function to call when the effect creation is successful

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

      defines a function to call when the effect creation has failed

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

          Returns void

    • Optional particleSystem: IParticleSystem

      the particle system you want to create the effect for

    Returns Effect

    the new Effect

  • Creates an external texture

    Parameters

    • video: HTMLVideoElement

      video element

    Returns Nullable<ExternalTexture>

    the external texture, or null if external textures are not supported by the engine

  • createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>
  • Engine abstraction for createImageBitmap

    Parameters

    • image: ImageBitmapSource

      source for image

    • Optional options: ImageBitmapOptions

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

    Returns Promise<ImageBitmap>

    ImageBitmap

  • createInstancesBuffer(capacity: number): DataBuffer
  • Creates a webGL buffer to use with instantiation

    Parameters

    • capacity: number

      defines the size of the buffer

    Returns DataBuffer

    the webGL buffer

  • Creates a new multiview render target

    Parameters

    • width: number

      defines the width of the texture

    • height: number

      defines the height of the texture

    Returns RenderTargetWrapper

    the created multiview render target wrapper

  • Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)

    Parameters

    • rootUrl: string

      defines the url where the file to load is located

    • scene: Nullable<Scene>

      defines the current scene

    • lodScale: number

      defines scale to apply to the mip map selection

    • lodOffset: number

      defines offset to apply to the mip map selection

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

      defines an optional callback raised when the texture is loaded

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

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

    • Optional format: number

      defines the format of the data

    • Optional forcedExtension: any

      defines the extension to use to pick the right loader

    • Optional createPolynomials: boolean

      defines wheter or not to create polynomails harmonics for the texture

    Returns InternalTexture

    the cube texture as an InternalTexture

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

    Returns OcclusionQuery

    the new query

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

    Parameters

    • data: Nullable<ArrayBufferView[]>

      defines the array of data to use to create each face

    • size: number

      defines the size of the textures

    • format: number

      defines the format of the data

    • type: number

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

    • generateMipMaps: boolean

      defines if the engine should generate the mip levels

    • invertY: boolean

      defines if data must be stored with Y axis inverted

    • samplingMode: number

      defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)

    • compression: Nullable<string>

      defines the compression used (null by default)

    Returns InternalTexture

    the cube texture as an InternalTexture

  • createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: ((ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>), mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<(() => void)>, onError: Nullable<((message?: string, exception?: any) => void)>): InternalTexture
  • createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: ((ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>), mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<(() => void)>, onError: Nullable<((message?: string, exception?: any) => void)>, samplingMode: number, invertY: boolean): InternalTexture
  • Creates a new raw cube texture from a specified url

    Parameters

    • url: string

      defines the url where the data is located

    • scene: 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

    the cube texture as an InternalTexture

  • Creates a new raw cube texture from a specified url

    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

    the cube texture as an InternalTexture

  • createRawShaderProgram(): WebGLProgram