WebGPUEngine | Babylon.js API documentation

API
Babylon.js API documentation
    Preparing search index...

    Class WebGPUEngineSince

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

    Hierarchy

    • ThinWebGPUEngine
      • WebGPUEngine
    Index
    _createDepthStencilCubeTexture _createImageBitmapFromSource _loadFileAsync areAllComputeEffectsReady areAllEffectsReady beginFrame beginOcclusionQuery bindAttachments bindBuffers bindFramebuffer bindUniformBlock bindUniformBufferBase buildTextureLayout cacheStencilState captureGPUFrameTime clear clearInternalTexturesCache clearStorageBuffer computeDispatch computeDispatchIndirect createCanvas createCanvasImage createCanvasPath2D createComputeContext createComputeEffect createComputePipelineContext createCubeTexture createDepthStencilTexture createDrawContext createDynamicTexture createDynamicUniformBuffer createDynamicVertexBuffer createEffect createEffectForParticles createExternalTexture createImageBitmap createIndexBuffer createMaterialContext createMultipleRenderTarget createPipelineContext createPrefilteredCubeTexture createQuery createRawCubeTexture createRawCubeTextureFromUrl createRawTexture createRawTexture2DArray createRawTexture3D createRenderPassId createRenderPipelineAsync createRenderTargetCubeTexture createRenderTargetTexture createStorageBuffer createTexture createUniformBuffer createVertexBuffer createVideoElement deleteQuery disableScissor displayLoadingUI dispose drawArraysType drawElementsType enableEffect enableScissor endFrame endOcclusionQuery enterFullscreen enterPointerlock exitFullscreen exitPointerlock extractDriverInfo generateMipmaps generateMipMapsForCubemap generateMipMapsFramebuffer generateMipMapsMultiFramebuffer getAlphaEquation getAlphaMode getAlphaToCoverage getAspectRatio getAttributes getAudioContext getAudioDestination getCaps getClassName getColorWrite getCreationOptions getCurrentRenderPassName getDeltaTime getDepthBuffer getDepthFunction getDepthWrite getError getFontOffset getFps getGPUFrameTimeCounter getHardwareScalingLevel getHostDocument getHostWindow getInfo getInputElement getInputElementClientRect getLoadedTexturesCache getLockstepMaxSteps getQueryResult getRenderHeight getRenderingCanvas getRenderingCanvasClientRect getRenderPassNames getRenderWidth getScreenAspectRatio getStencilBackFunction getStencilBackOperationDepthFail getStencilBackOperationFail getStencilBackOperationPass getStencilBuffer getStencilFunction getStencilFunctionMask getStencilFunctionReference getStencilMask getStencilOperationDepthFail getStencilOperationFail getStencilOperationPass getTimeStep getZOffset getZOffsetUnits hideLoadingUI initAsync inlineShaderCode isDeterministicLockStep isOcclusionQueryVisible isQueryResultAvailable prepareGlslangAndTintAsync readFromMultipleStorageBuffers readFromStorageBuffer readPixels registerView releaseComputeEffects releaseEffects releaseRenderPassId resetTextureCache resize resizeImageBitmap resolveFramebuffer resolveMultiFramebuffer restoreDefaultFramebuffer restoreSingleAttachment restoreSingleAttachmentForRenderTarget restoreStencilState runRenderLoop setAlphaConstants setAlphaEquation setAlphaMode setAlphaToCoverage setColorWrite setCompressedTextureExclusions setDepthBuffer setDepthFunction setDepthFunctionToGreater setDepthFunctionToGreaterOrEqual setDepthFunctionToLess setDepthFunctionToLessOrEqual setDepthStencilTexture setDepthWrite setDitheringState setExternalTexture setHardwareScalingLevel setRasterizerState setSize setState setStateCullFaceType setStencilBackFunction setStencilBackOperationDepthFail setStencilBackOperationFail setStencilBackOperationPass setStencilBuffer setStencilFunction setStencilFunctionMask setStencilFunctionReference setStencilMask setStencilOperationDepthFail setStencilOperationFail setStencilOperationPass setStorageBuffer setTexture setTextureArray setTextureFormatToUse setTextureFromPostProcess setTextureFromPostProcessOutput setTextureSampler setViewport setZOffset setZOffsetUnits snapshotRenderingReset stopRenderLoop switchFullscreen unBindFramebuffer unbindInstanceAttributes unBindMultiColorAttachmentFramebuffer unRegisterView updateDynamicIndexBuffer updateDynamicTexture updateDynamicVertexBuffer updateMultipleRenderTargetTextureSampleCount updateRawCubeTexture updateRawTexture updateRawTexture2DArray updateRawTexture3D updateRenderTargetTextureSampleCount updateStorageBuffer updateTextureArrayLayerFromImageSource updateTextureComparisonFunction updateTextureData updateTextureDimensions updateTextureSamplingMode updateTextureWrappingMode updateUniformBuffer updateVideoTexture updateWrappedWebGLTexture updateWrappedWebGPUTexture wipeCaches wrapWebGLTexture wrapWebGPUTexture CreateAsync DefaultLoadingScreenFactory MarkAllMaterialsAsDirty
    activeView: Nullable<EngineView>

    Gets the current engine view

    adaptToDeviceRatio: boolean = false

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

    canvasTabIndex: number = 1

    Gets or sets the tab index to set to the rendering canvas. Any value >= 0 makes the canvas focusable to capture keyboard events and adds it to the tab order; use -1 to keep it focusable programmatically but out of the tab order

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

    Counters from last frame

    cullBackFaces: Nullable<boolean> = null

    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 = Constants.RENDERPASS_MAIN

    Gets or sets the current render pass id

    customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester> = null

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

    disableContextMenu: boolean = true

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

    disableManifestCheck: boolean = false

    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 = false

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

    disableVertexArrayObjects: boolean = false

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

    enableOfflineSupport: boolean = false

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

    gpuTimeInFrameForMainPass?: WebGPUPerfCounter

    Gets the GPU time spent in the main render pass for the last frame rendered (in nanoseconds). You have to enable the "timestamp-query" extension in the engine constructor options and set engine.enableGPUTimingMeasurements = true. It will only return time spent in the main pass, not additional render target / compute passes (if any)!

    hasOriginBottomLeft: boolean = false

    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 = false

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

    isNDCHalfZRange: boolean = true

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

    isPointerLock: boolean = false

    Gets a boolean indicating if the pointer is currently locked

    loadingScreen: ILoadingScreen

    Gets or sets the current loading screen object

    loadingUIBackgroundColor: string

    Sets the current loading screen background color

    loadingUIText: string

    Sets the current loading screen text

    numMaxUncapturedErrors: number = 20

    Max number of uncaptured error messages to log

    onAfterShaderCompilationObservable: Observable<AbstractEngine> = ...

    Observable raised when the engine has just compiled a shader

    onAfterViewRenderObservable: Observable<EngineView>

    Will be triggered after the view rendered

    onBeforeShaderCompilationObservable: Observable<AbstractEngine> = ...

    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<AbstractEngine> = ...

    Observable raised when the engine begins a new frame

    onCanvasBlurObservable: Observable<AbstractEngine> = ...

    Observable event triggered each time the canvas loses focus

    onCanvasFocusObservable: Observable<AbstractEngine> = ...

    Observable event triggered each time the canvas gains focus

    onCanvasPointerOutObservable: Observable<PointerEvent> = ...

    Observable event triggered each time the canvas receives pointerout event

    onContextLostObservable: Observable<AbstractEngine> = ...

    Observable signaled when a context lost event is raised

    onContextRestoredObservable: Observable<AbstractEngine> = ...

    Observable signaled when a context restored event is raised

    onDisposeObservable: Observable<AbstractEngine> = ...

    An event triggered when the engine is disposed.

    onEffectErrorObservable: Observable<{ effect: Effect; errors: string }> = ...

    Observable event triggered each time an effect compilation fails

    onEndFrameObservable: Observable<AbstractEngine> = ...

    Observable raised when the engine ends the current frame (requires a render loop, e.g. 'engine.runRenderLoop(...)')

    onNewSceneAddedObservable: Observable<Scene> = ...

    Event raised when a new scene is created

    onReleaseEffectsObservable: Observable<AbstractEngine> = ...

    An event triggered when a global cleanup of all effects is required

    onResizeObservable: Observable<AbstractEngine> = ...

    Observable event triggered each time the rendering canvas is resized

    postProcesses: PostProcess[] = []

    Gets the list of created postprocesses

    premultipliedAlpha: boolean = true

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

    preventCacheWipeBetweenFrames: boolean = false

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

    renderEvenInBackground: boolean = true

    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

    skipFrameRender: boolean = false

    Skip frame rendering but keep the frame heartbeat (begin/end frame). This is useful if you need all the plumbing but not the rendering work. (for instance when capturing a screenshot where you do not want to mix rendering to the screen and to the screenshot)

    startTime: number

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

    textureFormatInUse: Nullable<string>

    Gets the texture format in use

    texturesSupported: string[]

    Gets the list of texture formats supported

    uniqueId: -1

    A unique id to identify this instance

    useExactSrgbConversions: boolean

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

    views: EngineView[]

    Gets or sets the list of views

    _RescalePostProcessFactory: Nullable<(engine: AbstractEngine) => PostProcess> = null

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

    audioEngine: Nullable<IAudioEngine>

    Gets the audio engine

    AudioEngineFactory: (
        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.

    please use AudioEngineV2 instead

    CollisionsEpsilon: number = 0.001

    Gets or sets the epsilon value used by collision engine

    OfflineProviderFactory: (
        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.

    QueueNewFrame: (func: () => void, requester?: any) => number = QueueNewFrame

    Queue a new function into the requested animation frame pool (ie. this function will be executed by the browser (or the javascript engine) for the next frame)

    Type Declaration

      • (func: () => void, requester?: any): number
      • Parameters

        • func: () => void

          the function to be called

        • Optionalrequester: any

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

        Returns number

        frame number

    • get activeRenderLoops(): readonly (() => void)[]

      Gets the list of current active render loop functions

      Returns readonly (() => void)[]

      a read only array with the current render loop functions

    • get enableGPUTimingMeasurements(): boolean

      Enables or disables GPU timing measurements. Note that this is only supported if the "timestamp-query" extension is enabled in the options.

      Returns boolean

    • set enableGPUTimingMeasurements(enable: boolean): void

      Parameters

      • enable: boolean

      Returns void

    • 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

      Parameters

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

        the framebuffer width and height that will be used.

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

      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 IsSupportedAsync(): Promise<boolean>
    Gets a Promise indicating if the engine can be instantiated (ie. if a WebGPU context can be found)

    Returns Promise<boolean>

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

      Parameters

      • imageSource: string

        source to load the image from.

      • Optionaloptions: ImageBitmapOptions

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

      Returns Promise<ImageBitmap>

      ImageBitmap

    • Binds the frame buffer to the specified texture.

      Parameters

      • texture: RenderTargetWrapper

        The render target wrapper to render to

      • faceIndex: number = 0

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

      • OptionalrequiredWidth: number

        The width of the target to render to

      • OptionalrequiredHeight: number

        The height of the target to render to

      • OptionalforceFullscreenViewport: boolean

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

      • lodLevel: number = 0

        defines the lod level to bind to the frame buffer

      • layer: number = 0

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

      Returns void

    • Bind a buffer to the current draw context

      Parameters

      • buffer: DataBuffer

        defines the buffer to bind

      • _location: number

        not used in WebGPU

      • name: string

        Name of the uniform variable to bind

      Returns void

    • 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

      • OptionalbackBufferLayout: boolean

        if true, the layout will be built to account for the back buffer only, and textureStatus won't be used

      Returns number[]

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

    • 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

      • OptionalbackBufferLayout: boolean

        if true, the layout will be built to account for the back buffer only, and textureStatus won't be used

      Returns number[]

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

    • 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

      • stencil: boolean = false

        defines if the stencil buffer must be cleared

      • stencilClearValue: number = 0

        defines the value to use to clear the stencil buffer (default is 0)

      Returns void

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

      Returns void

    • Clears a storage buffer to zeroes

      Parameters

      • storageBuffer: DataBuffer

        the storage buffer to clear

      • OptionalbyteOffset: number

        the byte offset to start clearing (optional)

      • OptionalbyteLength: number

        the byte length to clear (optional)

      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

      • Optionaly: number

        The number of workgroups to execute on the Y dimension

      • Optionalz: number

        The number of workgroups to execute on the Z dimension

      • OptionalbindingsMapping: ComputeBindingMapping

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

      • OptionalgpuPerfCounter: WebGPUPerfCounter

        GPU time computed for the compute shader will be assigned to this object

      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

      • buffer: DataBuffer

        The buffer containing the dispatch parameters

      • Optionaloffset: number

        The offset in the buffer where the dispatch parameters start

      • OptionalbindingsMapping: ComputeBindingMapping

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

      • OptionalgpuPerfCounter: WebGPUPerfCounter

        GPU time computed for the compute shader will be assigned to this object

      Returns void

    • Creates a cube texture

      Parameters

      • rootUrl: string

        defines the url where the files to load is located

      • scene: Nullable<Scene>

        defines the current scene

      • files: Nullable<string[]>

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

      • noMipmap: boolean | undefined

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

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

        defines the format of the data

      • forcedExtension: any

        defines the extension to use to pick the right loader

      • createPolynomials: boolean

        if a polynomial sphere should be created for the cube texture

      • lodScale: number

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

      • lodOffset: number

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

      • fallback: Nullable<InternalTexture>

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

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

      • buffer: Nullable<ArrayBufferView<ArrayBufferLike>>

        defines the data buffer to load instead of loading the rootUrl

      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: number | undefined

        defines the format of the data

      • forcedExtension: any

        defines the extension to use to pick the right loader

      Returns InternalTexture

      the cube texture as an InternalTexture

    • Creates a cube texture

      Parameters

      • rootUrl: string

        defines the url where the files to load is located

      • scene: Nullable<Scene>

        defines the current scene

      • files: Nullable<string[]>

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

      • noMipmap: boolean

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

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

        defines the format of the data

      • forcedExtension: any

        defines the extension to use to pick the right loader

      • createPolynomials: boolean

        if a polynomial sphere should be created for the cube texture

      • lodScale: number

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

      • lodOffset: number

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

      Returns InternalTexture

      the cube texture as an InternalTexture

    • Creates a cube texture

      Parameters

      • rootUrl: string

        defines the url where the files to load is located

      • scene: Nullable<Scene>

        defines the current scene

      • files: Nullable<string[]>

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

      • noMipmap: boolean | undefined

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

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

        defines the format of the data

      • forcedExtension: any

        defines the extension to use to pick the right loader

      • createPolynomials: boolean

        if a polynomial sphere should be created for the cube texture

      • lodScale: number

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

      • lodOffset: number

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

      • fallback: Nullable<InternalTexture>

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

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

      • buffer: Nullable<ArrayBufferView<ArrayBufferLike>>

        defines the data buffer to load instead of loading the rootUrl

      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: number | undefined

        defines the format of the data

      • forcedExtension: any

        defines the extension to use to pick the right loader

      Returns InternalTexture

      the cube texture as an InternalTexture

    • Creates a cube texture

      Parameters

      • rootUrl: string

        defines the url where the files to load is located

      • scene: Nullable<Scene>

        defines the current scene

      • files: Nullable<string[]>

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

      • noMipmap: boolean

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

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

        defines the format of the data

      • forcedExtension: any

        defines the extension to use to pick the right loader

      • createPolynomials: boolean

        if a polynomial sphere should be created for the cube texture

      • lodScale: number

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

      • lodOffset: number

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

      Returns InternalTexture

      the cube texture as an InternalTexture

    • 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

    • 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: string | IShaderPath & { fragmentToken?: string; vertexToken?: string }

        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[] | AbstractEngine

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

      • Optionalsamplers: string[]

        defines an array of string used to represent textures

      • Optionaldefines: string

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

      • Optionalfallbacks: EffectFallbacks

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

      • OptionalonCompiled: Nullable<(effect: Effect) => void>

        defines a function to call when the effect creation is successful

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

        defines a function to call when the effect creation has failed

      • OptionalindexParameters: any

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

      • shaderLanguage: ShaderLanguage = ShaderLanguage.GLSL

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

      • OptionalextraInitializationsAsync: () => Promise<void>

        additional async code to run before preparing the effect

      Returns Effect

      the new 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

      • Optionalfallbacks: EffectFallbacks

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

      • OptionalonCompiled: (effect: Effect) => void

        defines a function to call when the effect creation is successful

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

        defines a function to call when the effect creation has failed

      • OptionalparticleSystem: IParticleSystem

        the particle system you want to create the effect for

      • OptionalshaderLanguage: any

        defines the shader language to use

      • OptionalvertexName: string

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

      Returns Effect

      the new Effect

    • Engine abstraction for createImageBitmap

      Parameters

      • image: ImageBitmapSource

        source for image

      • Optionaloptions: ImageBitmapOptions

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

      Returns Promise<ImageBitmap>

      ImageBitmap

    • Creates a new index buffer

      Parameters

      • indices: IndicesArray

        defines the content of the index buffer

      • Optional_updatable: boolean

        defines if the index buffer must be updatable

      • Optionallabel: string

        defines the label of the buffer (for debug purpose)

      Returns DataBuffer

      a new buffer

    • 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

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

        defines an optional callback raised when the texture is loaded

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

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

      • Optionalformat: number

        defines the format of the data

      • forcedExtension: any = null

        defines the extension to use to pick the right loader

      • createPolynomials: boolean = true

        defines wheter or not to create polynomails harmonics for the texture

      • buffer: Nullable<ArrayBufferView<ArrayBufferLike>> = null

        defines the data buffer to load instead of loading the rootUrl

      Returns InternalTexture

      the cube texture as an InternalTexture

    • Creates a new raw cube texture

      Parameters

      • data: Nullable<ArrayBufferView<ArrayBufferLike>[]>

        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_BYTE)

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

      • Optionalcompression: Nullable<string>

        defines the compression used (null by default)

      Returns InternalTexture

      the cube texture as an InternalTexture

    • Creates a new raw cube texture

      Parameters

      • data: Nullable<ArrayBufferView<ArrayBufferLike>[]>

        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_BYTE)

      • 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

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

      • noMipmap: boolean

        defines if the engine should avoid generating the mip levels

      • callback: (
            ArrayBuffer: ArrayBuffer,
        ) => Nullable<
            | ArrayBufferView<ArrayBufferLike>[]
            | Promise<ArrayBufferView<ArrayBufferLike>[]>,
        >

        defines a callback used to extract texture data from loaded data

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

        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_BYTE)

      • noMipmap: boolean

        defines if the engine should avoid generating the mip levels

      • callback: (
            ArrayBuffer: ArrayBuffer,
        ) => Nullable<
            | ArrayBufferView<ArrayBufferLike>[]
            | Promise<ArrayBufferView<ArrayBufferLike>[]>,
        >

        defines a callback used to extract texture data from loaded data

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

        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

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

      • noMipmap: boolean

        defines if the engine should avoid generating the mip levels

      • callback: (
            ArrayBuffer: ArrayBuffer,
        ) => Nullable<
            | ArrayBufferView<ArrayBufferLike>[]
            | Promise<ArrayBufferView<ArrayBufferLike>[]>,
        >

        defines a callback used to extract texture data from loaded data

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

        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_BYTE)

      • noMipmap: boolean

        defines if the engine should avoid generating the mip levels

      • callback: (
            ArrayBuffer: ArrayBuffer,
        ) => Nullable<
            | ArrayBufferView<ArrayBufferLike>[]
            | Promise<ArrayBufferView<ArrayBufferLike>[]>,
        >

        defines a callback used to extract texture data from loaded data

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

        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

    • Creates a raw texture

      Parameters

      • data: Nullable<ArrayBufferView<ArrayBufferLike>>

        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)

      • Optionalcompression: Nullable<string>

        defines the compression used (null by default)

      • Optionaltype: number

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

      • OptionalcreationFlags: number

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

      • OptionaluseSRGBBuffer: boolean

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

      • OptionalmipLevelCount: number

        defines the number of mip levels to allocate for the texture

      Returns InternalTexture

      the raw texture inside an InternalTexture

    • Creates a new raw 2D array texture

      Parameters

      • data: Nullable<ArrayBufferView<ArrayBufferLike>>

        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)

      • Optionalcompression: Nullable<string>

        defines the compressed used (can be null)

      • OptionaltextureType: number

        defines the compressed used (can be null)

      • OptionalcreationFlags: number

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

      • OptionalmipLevelCount: number

        defines the number of mip levels to allocate for the texture

      Returns InternalTexture

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

    • Creates a new raw 3D texture

      Parameters

      • data: Nullable<ArrayBufferView<ArrayBufferLike>>

        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)

      • Optionalcompression: Nullable<string>

        defines the compressed used (can be null)

      • OptionaltextureType: number

        defines the compressed used (can be null)

      • OptionalcreationFlags: number

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

      Returns InternalTexture

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

    • Asynchronously pre-creates one or more render pipelines so they are cached and ready to use without any compilation hitch when first rendered.

      Call this for effects and meshes that are not yet rendering but will be soon (e.g. streaming content, predicted material changes, pre-loading the next level).

      When passing an array, cache state is set once per entry and restored only at the end, making batch pre-warming efficient.

      Parameters

      Returns Promise<GPURenderPipeline>[]

      an array of Promises for the pipelines that had cache misses (empty if all were cached). When a raw GPURenderPipelineDescriptor is provided, always returns a single-element array.

    • Creates a storage buffer

      Parameters

      • data: number | DataArray

        the data for the storage buffer or the size of the buffer

      • creationFlags: number

        flags to use when creating the buffer (see Constants.BUFFER_CREATIONFLAG_XXX). The BUFFER_CREATIONFLAG_STORAGE flag will be automatically added

      • Optionallabel: string

        defines the label of the buffer (for debug purpose)

      Returns DataBuffer

      the new buffer

    • Usually called from Texture.ts. Passed information to create a hardware 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

      • samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE

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

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

        optional callback to be called upon successful completion

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

        optional callback to be called upon failure

      • buffer: Nullable<
            | string
            | ArrayBuffer
            | ArrayBufferView<ArrayBufferLike>
            | HTMLImageElement
            | ImageBitmap
            | Blob,
        > = null

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

      • fallback: Nullable<InternalTexture> = null

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

      • format: Nullable<number> = null

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

      • forcedExtension: Nullable<string> = null

        defines the extension to use to pick the right loader

      • OptionalmimeType: string

        defines an optional mime type

      • OptionalloaderOptions: any

        options to be passed to the loader

      • OptionalcreationFlags: number

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

      • OptionaluseSRGBBuffer: boolean

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

      Returns InternalTexture

      a InternalTexture for assignment back into BABYLON.Texture

    • Creates a vertex buffer

      Parameters

      • data: number | DataArray

        the data or the size for the vertex buffer

      • Optional_updatable: boolean

        whether the buffer should be created as updatable

      • Optionallabel: string

        defines the label of the buffer (for debug purpose)

      Returns DataBuffer

      the new buffer

    • creates and returns a new video element

      Parameters

      • constraints: MediaTrackConstraints

        video constraints

      Returns any

      video element

    • 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

      • instancesCount: number = 1

        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

      • instancesCount: number = 1

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

      Returns void

    • Enable scissor test on a specific rectangle

      Parameters

      • x: number

        defines left coordinate of the rectangle

      • y: number

        defines top coordinate of the rectangle

      • width: number

        defines width of the rectangle

      • height: number

        defines height of the rectangle

      Returns void

    • Enters full screen mode

      Parameters

      • requestPointerLock: boolean

        defines if a pointer lock should be requested from the user

      Returns void

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

      Parameters

      • pipelineContext: IPipelineContext

        defines the pipeline context to use

      • attributesNames: string[]

        defines the list of attribute names to get

      Returns number[]

      an array of indices indicating the offset of each attribute

    • Gets the audio destination specified in engine initialization options

      Returns Nullable<AudioDestinationNode | MediaStreamAudioDestinationNode>

      an audio destination node

      please use AudioEngineV2 instead

    • Get Font size information

      Parameters

      • font: string

        font name

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

      an object containing ascent, height and descent

    • Gets the current hardware scaling level. By default the hardware scaling level is computed from the window device ratio. if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.

      Returns number

      a number indicating the current hardware scaling level

    • Gets an object containing information about the current engine context

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

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

    • Gets the backend-specific value of a query. For an available occlusion query, only zero (no samples passed) versus a positive value (samples passed) is portable across backends. The magnitude of a positive value is backend-dependent and should not be relied upon. Use isOcclusionQueryVisible when only visibility is needed.

      Parameters

      • query: OcclusionQuery

        defines the query to check

      Returns number

      the raw backend query value

    • Gets the current render height

      Parameters

      • useScreen: boolean = false

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

      Returns number

      a number defining the current render height

    • Gets the current render width

      Parameters

      • useScreen: boolean = false

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

      Returns number

      a number defining the current render width

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

      Parameters

      • code: string

        code to inline

      Returns string

      inlined code

    • Checks whether an available occlusion query indicates that any samples passed. This normalizes backend-specific query values without changing the raw value returned by getQueryResult.

      Parameters

      • query: OcclusionQuery

        defines the occlusion query to check

      Returns boolean

      true when the query result is greater than zero, otherwise false

    • Load the glslang and tintWASM libraries and prepare them for use.

      Returns Promise<void>

      a promise that resolves when the engine is ready to use the glslang and tintWASM

    • Read data from multiple storage buffers

      Parameters

      • storageBuffers: DataBuffer[]

        The list of storage buffers to read from

      • Optionaloffset: number

        The offset in the storage buffer to start reading from (default: 0). This is the same offset for all storage buffers!

      • Optionalsize: number

        The number of bytes to read from each storage buffer (default: capacity of the first buffer)

      • Optionalbuffer: ArrayBufferView<ArrayBufferLike>

        The buffer to write the data we have read from the storage buffers to (optional). If provided, the buffer should be large enough to hold the data from all storage buffers!

      • OptionalnoDelay: boolean

        If true, a call to flushFramebuffer will be issued so that the data can be read back immediately and not in engine.onEndFrameObservable. This can speed up data retrieval, at the cost of a small perf penalty (default: false).

      Returns Promise<ArrayBufferView<ArrayBufferLike>>

      If not undefined, returns the (promise) buffer (as provided by the 4th parameter) filled with the data, else it returns a (promise) Uint8Array with the data read from the storage buffer

    • Read data from a storage buffer

      Parameters

      • storageBuffer: DataBuffer

        The storage buffer to read from

      • Optionaloffset: number

        The offset in the storage buffer to start reading from (default: 0)

      • Optionalsize: number

        The number of bytes to read from the storage buffer (default: capacity of the buffer)

      • Optionalbuffer: ArrayBufferView<ArrayBufferLike>

        The buffer to write the data we have read from the storage buffer to (optional)

      • OptionalnoDelay: boolean

        If true, a call to flushFramebuffer will be issued so that the data can be read back immediately and not in engine.onEndFrameObservable. This can speed up data retrieval, at the cost of a small perf penalty (default: false).

      Returns Promise<ArrayBufferView<ArrayBufferLike>>

      If not undefined, returns the (promise) buffer (as provided by the 4th parameter) filled with the data, else it returns a (promise) Uint8Array with the data read from the storage buffer

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

      Parameters

      • x: number

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

      • y: number

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

      • width: number

        defines the width of the rectangle where pixels must be read

      • height: number

        defines the height of the rectangle where pixels must be read

      • _hasAlpha: boolean = true

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

      • flushRenderer: boolean = true

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

      • data: Nullable<Uint8Array<ArrayBufferLike>> = null

        defines the data to fill with the read pixels (if not provided, a new one will be created)

      Returns Promise<ArrayBufferView<ArrayBufferLike>>

      a ArrayBufferView promise (Uint8Array) containing RGBA colors

    • Since

      Register a new child canvas

      Parameters

      • canvas: HTMLCanvasElement

        defines the canvas to register

      • Optionalcamera: Camera | Camera[]

        defines an optional camera or array of cameras to use with this canvas (it will overwrite the scene.activeCamera / scene.activeCameras for this view). Support for array of cameras

      • OptionalclearBeforeCopy: boolean

        Indicates if the destination view canvas should be cleared before copying the parent canvas. Can help if the scene clear color has alpha < 1

      Returns EngineView

      the associated view

    • 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

    • Resize the view according to the canvas' size

      Parameters

      • forceSetSize: boolean = false

        true to force setting the sizes of the underlying canvas

      Returns void

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

      Parameters

      • image: HTMLImageElement | ImageBitmap

        image to resize

      • bufferWidth: number

        destination buffer width

      • bufferHeight: number

        destination buffer height

      Returns Uint8Array

      an uint8array containing RGBA values of bufferWidth * bufferHeight size

    • Resolves the MSAA texture of the render target into its non-MSAA version. Note that if "texture" is not a MSAA render target, no resolve is performed.

      Parameters

      • texture: RenderTargetWrapper

        The render target texture containing the MSAA texture to resolve

      • resolveColors: boolean = true

        If true, resolve the color textures (default: true) - still subject to texture.resolveMSAAColors

      Returns void

    • Resolves the MSAA textures of the (multi) render target into their non-MSAA version. Note that if "texture" is not a MSAA render target, no resolve is performed.

      Parameters

      • texture: RenderTargetWrapper

        The render target texture containing the MSAA textures to resolve

      Returns void

    • Resolves the MSAA textures of the (multi) render target into their non-MSAA version. Note that if "texture" is not a MSAA render target, no resolve is performed.

      Parameters

      • texture: RenderTargetWrapper

        The render target texture containing the MSAA textures to resolve

      • OptionalresolveColors: boolean

        If true, resolve the color textures (default: true) - still subject to texture.resolveMSAAColors

      Returns void

    • Unbind the current render target and bind the default framebuffer

      Parameters

      • OptionalunbindOnly: boolean

        defines a boolean indicating that the function should only unbind the current render target without binding the default framebuffer

      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

      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)

      • OptionaltargetIndex: number

        defines the index of the target to set the equation for (default is 0)

      Returns void

    • Defines the hardware scaling level. By default the hardware scaling level is computed from the window device ratio. if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.

      Parameters

      • level: number

        defines the level to use

      Returns void

    • Force a specific size of the canvas

      Parameters

      • width: number

        defines the new canvas' width

      • height: number

        defines the new canvas' height

      • forceSetSize: boolean = false

        true to force setting the sizes of the underlying canvas

      Returns boolean

      true if the size was changed

    • Set various states to the webGL context

      Parameters

      • culling: boolean

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

      • zOffset: number = 0

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

      • Optionalforce: boolean

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

      • reverseSide: boolean = false

        defines if culling must be reversed (CCW if false, CW if true)

      • OptionalcullBackFaces: boolean

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

      • Optionalstencil: IStencilState

        stencil states to set

      • zOffsetUnits: number = 0

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

      Returns void

    • Sets the type of faces to cull

      Parameters

      • OptionalcullBackFaces: boolean

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

      • force: boolean = false

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

      Returns void

    • Sets an array of texture to the WebGPU context

      Parameters

      • channel: number

        defines the channel where the texture array must be set

      • unused: Nullable<WebGLUniformLocation>

        unused parameter

      • textures: BaseTexture[]

        defines the array of textures to bind

      • name: string

        name of the channel

      Returns void

    • Set the compressed texture format to use, based on the formats you have, and the formats supported by the hardware / browser.

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

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

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

      Parameters

      • formatsAvailable: string[]

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

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

      Returns Nullable<string>

      The extension selected.

    • 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 WebGL's viewport

      Parameters

      • viewport: IViewportLike

        defines the viewport element to be used

      • OptionalrequiredWidth: number

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

      • OptionalrequiredHeight: number

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

      Returns void

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

      Parameters

      • OptionalrenderFunction: () => void

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

      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 WebGPU context

      Parameters

      • texture: RenderTargetWrapper

        defines the render target wrapper to unbind

      • disableGenerateMipMaps: boolean = false

        defines a boolean indicating that mipmaps must not be generated

      • OptionalonBeforeUnbind: () => void

        defines a function which will be called before the effective unbind

      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

      • OptionalonBeforeUnbind: () => void

        defines a function which will be called before the effective unbind

      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

      • OptionalonBeforeUnbind: () => void

        defines a function which will be called before the effective unbind

      Returns void

    • Update the content of a dynamic texture

      Parameters

      • texture: Nullable<InternalTexture>

        defines the texture to update

      • source: ICanvas | ImageSource

        defines the source containing the data

      • OptionalinvertY: boolean

        defines if data must be stored with Y axis inverted

      • OptionalpremulAlpha: boolean

        defines if alpha is stored as premultiplied

      • Optionalformat: number

        defines the format of the data

      • OptionalforceBindTexture: boolean

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

      • OptionalallowGPUOptimization: boolean

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

      Returns void

    • Update the content of a dynamic texture

      Parameters

      • texture: Nullable<InternalTexture>

        defines the texture to update

      • source: ICanvas | ImageSource

        defines the source containing the data

      • OptionalinvertY: boolean

        defines if data must be stored with Y axis inverted

      • OptionalpremulAlpha: boolean

        defines if alpha is stored as premultiplied

      • Optionalformat: number

        defines the format of the data

      • OptionalforceBindTexture: boolean

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

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

      • OptionalbyteOffset: number

        the byte offset of the data

      • OptionalbyteLength: number

        the byte length of the data

      Returns void

    • Update a raw cube texture

      Parameters

      • texture: InternalTexture

        defines the texture to update

      • data: ArrayBufferView<ArrayBufferLike>[]

        defines the data to store

      • format: number

        defines the data format

      • type: number

        defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE 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<ArrayBufferLike>[]

        defines the data to store

      • format: number

        defines the data format

      • type: number

        defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE 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<ArrayBufferLike>[]

        defines the data to store

      • format: number

        defines the data format

      • type: number

        defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE 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 cube texture

      Parameters

      • texture: InternalTexture

        defines the texture to update

      • data: ArrayBufferView<ArrayBufferLike>[]

        defines the data to store

      • format: number

        defines the data format

      • type: number

        defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE 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<ArrayBufferLike>[]

        defines the data to store

      • format: number

        defines the data format

      • type: number

        defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE 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<ArrayBufferLike>[]

        defines the data to store

      • format: number

        defines the data format

      • type: number

        defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE 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<ArrayBufferLike>>

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

        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_BYTE 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 texture

      Parameters

      • texture: Nullable<InternalTexture>

        defines the texture to update

      • data: Nullable<ArrayBufferView<ArrayBufferLike>>

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

        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_BYTE by default)

      • useSRGBBuffer: boolean

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

      • OptionalmipLevel: number

        defines which mipLevel of the texture is going to be updated

      Returns void

    • Update a raw 2D array texture

      Parameters

      • texture: InternalTexture

        defines the texture to update

      • data: Nullable<ArrayBufferView<ArrayBufferLike>>

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

        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_BYTE, Engine.TEXTURETYPE_FLOAT...)

      Returns void

    • Update a raw 2D array texture

      Parameters

      • texture: InternalTexture

        defines the texture to update

      • data: Nullable<ArrayBufferView<ArrayBufferLike>>

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

        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_BYTE, Engine.TEXTURETYPE_FLOAT...)

      Returns void

    • Update a raw 2D array texture

      Parameters

      • texture: InternalTexture

        defines the texture to update

      • data: Nullable<ArrayBufferView<ArrayBufferLike>>

        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_BYTE, Engine.TEXTURETYPE_FLOAT...)

      • OptionalmipLevel: number

        defines which mipLevel of the texture is going to be updated

      Returns void

    • Update a raw 3D texture

      Parameters

      • texture: InternalTexture

        defines the texture to update

      • data: Nullable<ArrayBufferView<ArrayBufferLike>>

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

        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_BYTE, Engine.TEXTURETYPE_FLOAT...)

      Returns void

    • Update a raw 3D texture

      Parameters

      • texture: InternalTexture

        defines the texture to update

      • data: Nullable<ArrayBufferView<ArrayBufferLike>>

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

        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_BYTE, Engine.TEXTURETYPE_FLOAT...)

      Returns void

    • Updates a storage buffer

      Parameters

      • buffer: DataBuffer

        the storage buffer to update

      • data: DataArray

        the data used to update the storage buffer

      • OptionalbyteOffset: number

        the byte offset of the data

      • OptionalbyteLength: number

        the byte length of the data

      Returns void

    • Uploads an image source (ImageBitmap, canvas, video, image element...) into a single layer of a 2D array texture. Unlike updateRawTexture2DArray, which uploads raw bytes, this uploads a decoded image source directly. This is a side-effect engine extension: import "core/Engines/Extensions/engine.texture2DArrayImageSource" (or the WebGPU counterpart) to make it available on the tree-shakeable engine path.

      Parameters

      • texture: InternalTexture

        defines the 2D array texture to update

      • source: ImageSource

        defines the image source to upload

      • layer: number

        defines the array layer (z index) to upload into

      • OptionalinvertY: boolean

        defines if the source must be stored with the Y axis inverted (false by default)

      • OptionalpremultiplyAlpha: boolean

        defines if the source alpha must be premultiplied (false by default)

      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

      • faceIndex: number = 0

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

      • lod: number = 0

        defines the lod level to update (0 by default)

      • generateMipMaps: boolean = false

        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

      • depth: number = 1

        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

      • generateMipMaps: boolean = false

        defines whether to generate mipmaps for the texture

      Returns void

    • Replaces the underlying GPUTexture of a texture previously created via wrapWebGPUTexture, preserving the InternalTexture identity.

      Intended for the device-loss / device-restored flow: when the host recreates its external resource on the new GPU device, it calls this method to repoint Babylon's wrapper at the new handle without losing references held by materials, render-target wrappers, particle systems, etc.

      The new GPUTexture must have the same dimensions as the original. To change dimensions, dispose the wrapped texture and call wrapWebGPUTexture again.

      Throws if the target was not produced by wrapWebGPUTexture, or if the new GPUTexture's dimensions don't match.

      Parameters

      • internalTexture: InternalTexture

        defines the wrapped InternalTexture to repoint

      • texture: GPUTexture

        defines the new GPUTexture to wrap

      Returns void

    • Force the entire cache to be cleared You should not have to use this function unless your engine needs to share the WebGPU context with another engine

      Parameters

      • OptionalbruteForce: boolean

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

      Returns void

    • Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation

      Parameters

      • flag: number

        defines which part of the materials must be marked as dirty

      • Optionalpredicate: (mat: Material) => boolean

        defines a predicate used to filter which materials should be affected

      Returns void