Engine

Engine

Description

class Engine

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

Constructor

new Engine(canvasOrContext, WebGLRenderingContext, antialias, options, adaptToDeviceRatio)

@constructor

Parameters

Name Type Description
canvasOrContext Nullable<HTMLCanvasElement> or WebGLRenderingContext
optional antialias boolean
optional options EngineOptions - further options to be sent to the getContext function

Members

static WebGL2UniformBuffersExceptionList : string[]

static Instances : Engine[]

static LastCreatedEngine : Nullable<Engine>

static LastCreatedScene : Nullable<Scene>

static NEVER : number

static ALWAYS : number

static LESS : number

static EQUAL : number

static LEQUAL : number

static GREATER : number

static GEQUAL : number

static NOTEQUAL : number

static KEEP : number

static REPLACE : number

static INCR : number

static DECR : number

static INVERT : number

static INCR_WRAP : number

static DECR_WRAP : number

static ALPHA_DISABLE : number

static ALPHA_ONEONE : number

static ALPHA_ADD : number

static ALPHA_COMBINE : number

static ALPHA_SUBTRACT : number

static ALPHA_MULTIPLY : number

static ALPHA_MAXIMIZED : number

static ALPHA_PREMULTIPLIED : number

static ALPHA_PREMULTIPLIED_PORTERDUFF : number

static ALPHA_INTERPOLATE : number

static ALPHA_SCREENMODE : number

static DELAYLOADSTATE_NONE : number

static DELAYLOADSTATE_LOADED : number

static DELAYLOADSTATE_LOADING : number

static DELAYLOADSTATE_NOTLOADED : number

static TEXTUREFORMAT_ALPHA : number

static TEXTUREFORMAT_LUMINANCE : number

static TEXTUREFORMAT_LUMINANCE_ALPHA : number

static TEXTUREFORMAT_RGB : number

static TEXTUREFORMAT_RGBA : number

static TEXTURETYPE_UNSIGNED_INT : number

static TEXTURETYPE_FLOAT : number

static TEXTURETYPE_HALF_FLOAT : number

static SCALEMODE_FLOOR : number

static SCALEMODE_NEAREST : number

static SCALEMODE_CEILING : number

static Version : string

static CollisionsEpsilon : number

static CodeRepository : string

static ShadersRepository : string

forcePOTTextures : boolean

isFullscreen : boolean

isPointerLock : boolean

cullBackFaces : boolean

renderEvenInBackground : boolean

preventCacheWipeBetweenFrames : boolean

enableOfflineSupport : boolean

scenes : Scene[]

postProcesses : PostProcess[]

onResizeObservable : Observable<Engine>

Observable event triggered each time the rendering canvas is resized

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

Observable event triggered each time the canvas receives pointerout event

onBeforeTextureInitObservable : Observable<Texture>

Observable event triggered before each texture is initialized

isInVRExclusivePointerMode : boolean

disableUniformBuffers : boolean

supportsUniformBuffers : boolean

onBeginFrameObservable : Observable<Engine>

Observable raised when the engine begins a new frame

onEndFrameObservable : Observable<Engine>

Observable raised when the engine ends the current frame

onBeforeShaderCompilationObservable : Observable<Engine>

Observable raised when the engine is about to compile a shader

onAfterShaderCompilationObservable : Observable<Engine>

Observable raised when the engine has jsut compiled a shader

needPOTTextures : boolean

badOS : boolean

badDesktopOS : boolean

static audioEngine : AudioEngine

onVRDisplayChangedObservable : Observable<IDisplayChangedEventArgs>

onVRRequestPresentComplete : Observable<boolean>

onVRRequestPresentStart : Observable<Engine>

onContextLostObservable : Observable<Engine>

onContextRestoredObservable : Observable<Engine>

disablePerformanceMonitorInBackground : boolean

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

performanceMonitor : PerformanceMonitor

texturesSupported : Array<string>

textureFormatInUse : Nullable<string>

currentViewport : Nullable<Viewport>

emptyTexture : InternalTexture

emptyTexture3D : InternalTexture

emptyCubeTexture : InternalTexture

webGLVersion : number

isStencilEnable : boolean

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

drawCalls : number

drawCallsPerfCounter : Nullable<PerfCounter>

options : boolean

href="/classes/3.1/RenderTargetCreationOptions">RenderTargetCreationOptions : undefined

href="/classes/3.1/InternalTexture">InternalTexture : undefined

onLoad : undefined

loadingScreen : ILoadingScreen

loadingUIText : string

loadingUIBackgroundColor : string

void : () => void

void : () => void

Methods

static MarkAllMaterialsAsDirty(flag, predicate) void

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

Parameters

Name Type Description
flag number
optional predicate mat Material

resetTextureCache() void

isDeterministicLockStep() boolean

getLockstepMaxSteps() number

getGlInfo() { vendor: string, renderer: string, version: string }

getAspectRatio(camera, useScreen) number

Parameters

Name Type Description
camera Camera
optional useScreen boolean

getRenderWidth(useScreen) number

Parameters

Name Type Description
optional useScreen boolean

getRenderHeight(useScreen) number

Parameters

Name Type Description
optional useScreen boolean

getRenderingCanvas() Nullable<HTMLCanvasElement>

getRenderingCanvasClientRect() Nullable<ClientRect>

setHardwareScalingLevel(level) void

Parameters

Name Type Description
level number

getHardwareScalingLevel() number

getLoadedTexturesCache() InternalTexture[]

getCaps() EngineCapabilities

getDepthFunction() Nullable<number>

setDepthFunction(depthFunc) void

Parameters

Name Type Description
depthFunc number

setDepthFunctionToGreater() void

setDepthFunctionToGreaterOrEqual() void

setDepthFunctionToLess() void

setDepthFunctionToLessOrEqual() void

getStencilBuffer() boolean

setStencilBuffer(enable) void

Parameters

Name Type Description
enable boolean

getStencilMask() number

setStencilMask(mask) void

Parameters

Name Type Description
mask number

getStencilFunction() number

getStencilFunctionReference() number

getStencilFunctionMask() number

setStencilFunction(stencilFunc) void

Parameters

Name Type Description
stencilFunc number

setStencilFunctionReference(reference) void

Parameters

Name Type Description
reference number

setStencilFunctionMask(mask) void

Parameters

Name Type Description
mask number

getStencilOperationFail() number

getStencilOperationDepthFail() number

getStencilOperationPass() number

setStencilOperationFail(operation) void

Parameters

Name Type Description
operation number

setStencilOperationDepthFail(operation) void

Parameters

Name Type Description
operation number

setStencilOperationPass(operation) void

Parameters

Name Type Description
operation number

setDitheringState(value) void

Parameters

Name Type Description
value boolean

setRasterizerState(value) void

Parameters

Name Type Description
value boolean

stopRenderLoop(renderFunction) void

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

Parameters

Name Type Description
optional renderFunction

runRenderLoop(renderFunction) void

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

@example

engine.runRenderLoop(function () {

 scene.render()

})

Parameters

Name Type Description
renderFunction

switchFullscreen(requestPointerLock) void

Toggle full screen mode.

Parameters

Name Type Description
requestPointerLock boolean

clear(color, backBuffer, depth, stencil) void

Parameters

Name Type Description
color Nullable<Color4>
backBuffer boolean
depth boolean

scissorClear(x, y, width, height, clearColor) void

Parameters

Name Type Description
x number
y number
width number
height number

setViewport(viewport, requiredWidth, requiredHeight) void

Set the WebGL's viewport

Parameters

Name Type Description
viewport Viewport
optional requiredWidth number
optional requiredHeight number

setDirectViewport(x, y, width, height) Nullable<Viewport>

Directly set the WebGL Viewport

The x, y, width & height are directly passed to the WebGL call

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

Parameters

Name Type Description
x number
y number
width number

beginFrame() void

endFrame() void

resize() void

resize the view according to the canvas' size.

@example

window.addEventListener("resize", function () {

 engine.resize();

});

setSize(width, height) void

force a specific size of the canvas

Parameters

Name Type Description
width number
height number

isVRDevicePresent() boolean

getVRDevice() any

initWebVR() Observable<{ vrDisplay: any, vrSupported: any }>

enableVR() void

disableVR() void

bindFramebuffer(texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) void

Parameters

Name Type Description
texture InternalTexture
optional faceIndex number
optional requiredWidth number
optional requiredHeight number

unBindFramebuffer(texture, disableGenerateMipMaps, onBeforeUnbind) void

Parameters

Name Type Description
texture InternalTexture
optional disableGenerateMipMaps boolean
optional onBeforeUnbind

generateMipMapsForCubemap(texture) void

Parameters

Name Type Description
texture InternalTexture

flushFramebuffer() void

restoreDefaultFramebuffer() void

createUniformBuffer(elements) WebGLBuffer

Parameters

Name Type Description
elements FloatArray

createDynamicUniformBuffer(elements) WebGLBuffer

Parameters

Name Type Description
elements FloatArray

updateUniformBuffer(uniformBuffer, elements, offset, count) void

Parameters

Name Type Description
uniformBuffer WebGLBuffer
elements FloatArray
optional offset number

createVertexBuffer(vertices) WebGLBuffer

Parameters

Name Type Description
vertices FloatArray

createDynamicVertexBuffer(vertices) WebGLBuffer

Parameters

Name Type Description
vertices FloatArray

updateDynamicIndexBuffer(indexBuffer, indices, offset) void

Parameters

Name Type Description
indexBuffer WebGLBuffer
indices IndicesArray
optional offset number

updateDynamicVertexBuffer(vertexBuffer, vertices, offset, count) void

Parameters

Name Type Description
vertexBuffer WebGLBuffer
vertices FloatArray
optional offset number

createIndexBuffer(indices, updatable) WebGLBuffer

Parameters

Name Type Description
indices IndicesArray
optional updatable boolean

bindArrayBuffer(buffer) void

Parameters

Name Type Description
buffer Nullable<WebGLBuffer>

bindUniformBuffer(buffer) void

Parameters

Name Type Description
buffer Nullable<WebGLBuffer>

bindUniformBufferBase(buffer, location) void

Parameters

Name Type Description
buffer WebGLBuffer
location number

bindUniformBlock(shaderProgram, blockName, index) void

Parameters

Name Type Description
shaderProgram WebGLProgram
blockName string
index number

updateArrayBuffer(data) void

Parameters

Name Type Description
data Float32Array

recordVertexArrayObject(vertexBuffers, indexBuffer, effect) WebGLVertexArrayObject

Parameters

Name Type Description
vertexBuffers { [key: string]: VertexBuffer }
indexBuffer Nullable<WebGLBuffer>
effect Effect

bindVertexArrayObject(vertexArrayObject, indexBuffer) void

Parameters

Name Type Description
vertexArrayObject WebGLVertexArrayObject
indexBuffer Nullable<WebGLBuffer>

bindBuffersDirectly(vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) void

Parameters

Name Type Description
vertexBuffer WebGLBuffer
indexBuffer WebGLBuffer
vertexDeclaration number[]
vertexStrideSize number

bindBuffers(vertexBuffers, indexBuffer, effect) void

Parameters

Name Type Description
vertexBuffers { [key: string]: Nullable<VertexBuffer> }
indexBuffer Nullable<WebGLBuffer>
effect Effect

unbindInstanceAttributes() void

releaseVertexArrayObject(vao) void

Parameters

Name Type Description
vao WebGLVertexArrayObject

createInstancesBuffer(capacity) WebGLBuffer

Parameters

Name Type Description
capacity number

deleteInstancesBuffer(buffer) void

Parameters

Name Type Description
buffer WebGLBuffer

updateAndBindInstancesBuffer(instancesBuffer, data, offsetLocations, InstancingAttributeInfo) void

Parameters

Name Type Description
instancesBuffer WebGLBuffer
data Float32Array

applyStates() void

draw(useTriangles, indexStart, indexCount, instancesCount) void

Parameters

Name Type Description
useTriangles boolean
indexStart number
indexCount number

drawPointClouds(verticesStart, verticesCount, instancesCount) void

Parameters

Name Type Description
verticesStart number
verticesCount number
optional instancesCount number

drawUnIndexed(useTriangles, verticesStart, verticesCount, instancesCount) void

Parameters

Name Type Description
useTriangles boolean
verticesStart number
verticesCount number

createEffect(baseName, attributesNamesOrOptions, EffectCreationOptions, uniformsNamesOrEngine, Engine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) Effect

Parameters

Name Type Description
baseName any The base name of the effect (The name of file without .fragment.fx or .vertex.fx)
attributesNamesOrOptions string[] or EffectCreationOptions
uniformsNamesOrEngine string[] or Engine
optional samplers string[] An array of string used to represent textures
optional defines string
optional fallbacks EffectFallbacks
optional onCompiled effect Effect

| optional | onError | | effect | Effect | | errors | string |

createEffectForParticles(fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) Effect

Parameters

Name Type Description
fragmentName string
optional uniformsNames string[]
optional samplers string[]
optional defines string
optional fallbacks EffectFallbacks
optional onCompiled effect Effect

| optional | onError | | effect | Effect |

createRawShaderProgram(vertexCode, fragmentCode, context, transformFeedbackVaryings) WebGLProgram

Parameters

Name Type Description
vertexCode string
fragmentCode string
optional context WebGLRenderingContext

createShaderProgram(vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) WebGLProgram

Parameters

Name Type Description
vertexCode string
fragmentCode string
defines Nullable<string>
optional context WebGLRenderingContext

getUniforms(shaderProgram, uniformsNames) Nullable<WebGLUniformLocation>[]

Parameters

Name Type Description
shaderProgram WebGLProgram
uniformsNames string[]

getAttributes(shaderProgram, attributesNames) number[]

Parameters

Name Type Description
shaderProgram WebGLProgram
attributesNames string[]

enableEffect(effect) void

Parameters

Name Type Description
effect Nullable<Effect>

setIntArray(uniform, array) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
array Int32Array

setIntArray2(uniform, array) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
array Int32Array

setIntArray3(uniform, array) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
array Int32Array

setIntArray4(uniform, array) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
array Int32Array

setFloatArray(uniform, array) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
array Float32Array

setFloatArray2(uniform, array) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
array Float32Array

setFloatArray3(uniform, array) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
array Float32Array

setFloatArray4(uniform, array) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
array Float32Array

setArray(uniform, array) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
array number[]

setArray2(uniform, array) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
array number[]

setArray3(uniform, array) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
array number[]

setArray4(uniform, array) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
array number[]

setMatrices(uniform, matrices) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
matrices Float32Array

setMatrix(uniform, matrix) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
matrix Matrix

setMatrix3x3(uniform, matrix) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
matrix Float32Array

setMatrix2x2(uniform, matrix) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
matrix Float32Array

setFloat(uniform, value) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
value number

setFloat2(uniform, x, y) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
x number
y number

setFloat3(uniform, x, y, z) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
x number
y number

setBool(uniform, bool) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
bool number

setFloat4(uniform, x, y, z, w) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
x number
y number
z number

setColor3(uniform, color3) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
color3 Color3

setColor4(uniform, color3, alpha) void

Parameters

Name Type Description
uniform Nullable<WebGLUniformLocation>
color3 Color3
alpha number

setState(culling, zOffset, force, reverseSide) void

Parameters

Name Type Description
culling boolean
optional zOffset number
optional force boolean

setZOffset(value) void

Parameters

Name Type Description
value number

getZOffset() number

setDepthBuffer(enable) void

Parameters

Name Type Description
enable boolean

getDepthWrite() boolean

setDepthWrite(enable) void

Parameters

Name Type Description
enable boolean

setColorWrite(enable) void

Parameters

Name Type Description
enable boolean

getColorWrite() boolean

setAlphaConstants(r, g, b, a) void

Parameters

Name Type Description
r number
g number
b number

setAlphaMode(mode, noDepthWriteChange) void

Parameters

Name Type Description
mode number
optional noDepthWriteChange boolean

getAlphaMode() number

setAlphaTesting(enable) void

Parameters

Name Type Description
enable boolean

getAlphaTesting() boolean

wipeCaches(bruteForce) void

Parameters

Name Type Description
optional bruteForce boolean

setTextureFormatToUse(formatsAvailable) Nullable<string>

Set the compressed texture format to use, based on the formats you have, and the formats

supported by the hardware / browser.

     * Khronos [Texture](/classes/3.1/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.

     * @param {Array<string>} formatsAvailable- 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 The extension selected.

Parameters

Name Type Description
formatsAvailable Array<string>

createTexture(urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, HTMLImageElement, fallBack, format) InternalTexture

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

                    1. A conventional http URL, e.g. 'http://...' or 'file://...'

                    2. A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'

                    3. An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'

     * @param {boolean} noMipmap- When true, no mipmaps shall be generated.  Ignored for compressed textures.  They must be in the file.

     * @returns {WebGLTexture} for assignment back into BABYLON.[Texture](/classes/3.1/Texture)

Parameters

Name Type Description
urlArg Nullable<string>
noMipmap boolean
invertY boolean
scene Nullable<Scene>
optional samplingMode number
optional onLoad Nullable<() => void>
optional onError Nullable<(message: string, exception: any) => void>
optional buffer Nullable<ArrayBuffer> or HTMLImageElement
optional fallBack Nullable<InternalTexture>

updateRawTexture(texture, data, format, invertY, compression, type) void

Parameters

Name Type Description
texture Nullable<InternalTexture>
data Nullable<ArrayBufferView>
format number
invertY boolean
optional compression Nullable<string>

createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) InternalTexture

Parameters

Name Type Description
data Nullable<ArrayBufferView>
width number
height number
format number
generateMipMaps boolean
invertY boolean
samplingMode number
optional compression Nullable<string>

createDynamicTexture(width, height, generateMipMaps, samplingMode) InternalTexture

Parameters

Name Type Description
width number
height number
generateMipMaps boolean

updateTextureSamplingMode(samplingMode, texture) void

Parameters

Name Type Description
samplingMode number
texture InternalTexture

updateDynamicTexture(texture, canvas, invertY, premulAlpha, format) void

Parameters

Name Type Description
texture Nullable<InternalTexture>
canvas HTMLCanvasElement
invertY boolean
optional premulAlpha boolean

updateVideoTexture(texture, video, invertY) void

Parameters

Name Type Description
texture Nullable<InternalTexture>
video HTMLVideoElement
invertY boolean

createRenderTargetTexture(size) (size)

Parameters

Name Type Description
size number

createMultipleRenderTarget(size, options) InternalTexture[]

Parameters

Name Type Description
size any
options any

updateRenderTargetTextureSampleCount(texture, samples) number

Parameters

Name Type Description
texture Nullable<InternalTexture>
samples number

createRenderTargetCubeTexture(size, options) InternalTexture

Parameters

Name Type Description
size number
optional options RenderTargetCreationOptions

createPrefilteredCubeTexture(rootUrl, scene, scale, offset, onLoad, onError, format, forcedExtension) InternalTexture

Parameters

Name Type Description
rootUrl string
scene Nullable<Scene>
scale number
offset number
optional onLoad Nullable<(internalTexture: Nullable<InternalTexture>) => void>
optional onError Nullable<(message: string, exception: any) => void>
optional format number

createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension) InternalTexture

Parameters

Name Type Description
rootUrl string
scene Nullable<Scene>
files Nullable<string[]>
optional noMipmap boolean
optional onLoad Nullable<(data: any) => void>
optional onError Nullable<(message: string, exception: any) => void>
optional format number

updateRawCubeTexture(texture, data, format, type, invertY, compression, level) void

Parameters

Name Type Description
texture InternalTexture
data ArrayBufferView[]
format number
type number
invertY boolean
optional compression Nullable<string>

createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression) InternalTexture

Parameters

Name Type Description
data Nullable<ArrayBufferView[]>
size number
format number
type number
generateMipMaps boolean
invertY boolean
samplingMode number

createRawCubeTextureFromUrl(url, scene, size, format, type, noMipmap, callback, mipmmapGenerator) (url, scene, size, format, type, noMipmap, callback, mipmmapGenerator)

Parameters

Name Type Description
url string
scene Scene
size number
format number
type number
noMipmap boolean
callback ArrayBuffer ArrayBuffer

|

Nullable() ()

bindSamplers(effect) void

Parameters

Name Type Description
effect Effect

setTextureFromPostProcess(channel, postProcess) void

Parameters

Name Type Description
channel number
postProcess Nullable<PostProcess>

unbindAllTextures() void

setTexture(channel, uniform, texture) void

Parameters

Name Type Description
channel number
uniform Nullable<WebGLUniformLocation>
texture Nullable<BaseTexture>

setTextureArray(channel, uniform, textures) void

Parameters

Name Type Description
channel number
uniform Nullable<WebGLUniformLocation>
textures BaseTexture[]

readPixels(x, y, width, height) Uint8Array

Parameters

Name Type Description
x number
y number
width number

addExternalData(key, data) boolean

Add an externaly attached data from its key.

This method call will fail and return false, if such key already exists.

If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.

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

Parameters

Name Type Description
key string the unique key that identifies the data
data T the data object to associate to the key for this Engine instance

getExternalData(key) T

Get an externaly attached data from its key

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

Parameters

Name Type Description
key string the unique key that identifies the data

getOrAddExternalDataWithFactory(key, factory) T

Get an externaly attached data from its key, create it using a factory if it's not already present

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

Parameters

Name Type Description
key string the unique key that identifies the data
factory k string

removeExternalData(key) boolean

Remove an externaly attached data from the Engine instance

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

Parameters

Name Type Description
key string the unique key that identifies the data

unbindAllAttributes() void

releaseEffects() void

dispose() void

displayLoadingUI() void

hideLoadingUI() void

attachContextLostEvent(callback) (callback)

Parameters

Name Type Description
callback

attachContextRestoredEvent(callback) (callback)

Parameters

Name Type Description
callback

getVertexShaderSource(program) Nullable<string>

Parameters

Name Type Description
program WebGLProgram

getFragmentShaderSource(program) Nullable<string>

Parameters

Name Type Description
program WebGLProgram

getError() number

getFps() number

getDeltaTime() number

createQuery() WebGLQuery

deleteQuery(query) Engine

Parameters

Name Type Description
query WebGLQuery

isQueryResultAvailable(query) boolean

Parameters

Name Type Description
query WebGLQuery

getQueryResult(query) number

Parameters

Name Type Description
query WebGLQuery

beginOcclusionQuery(algorithmType, query) Engine

Parameters

Name Type Description
algorithmType number
query WebGLQuery

endOcclusionQuery(algorithmType) Engine

Parameters

Name Type Description
algorithmType number

startTimeQuery() Nullable<_TimeToken>

endTimeQuery(token) int

Parameters

Name Type Description
token _TimeToken

createTransformFeedback() WebGLTransformFeedback

deleteTransformFeedback(value) void

Parameters

Name Type Description
value WebGLTransformFeedback

bindTransformFeedback(value) void

Parameters

Name Type Description
value Nullable<WebGLTransformFeedback>

beginTransformFeedback(usePoints) void

Parameters

Name Type Description
optional usePoints boolean

endTransformFeedback() void

setTranformFeedbackVaryings(program, value) void

Parameters

Name Type Description
program WebGLProgram
value string[]

bindTransformFeedbackBuffer(value) void

Parameters

Name Type Description
value Nullable<WebGLBuffer>

static isSupported() boolean