Constructor
new WebGLRenderer(context)
Create a WebGL renderer.
Name | Type | Description |
---|---|---|
context | WebGLRenderingContext | The Rendering Context privided by canvas. |
Extends
Members
capabilities :WebGLCapabilities
An object containing details about the capabilities of the current RenderingContext.
- WebGLCapabilities
- Overrides
context :WebGLRenderingContext|WebGPURenderingContext
The Rendering Context privided by canvas.
- WebGLRenderingContext |
WebGPURenderingContext
- Overrides
lightingOptions :object
The lighting options.
- object
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
clustered | object | The clustered lighting options. Properties
|
- Overrides
shaderCompileOptions :object
The shader compiler options.
- object
Name | Type | Description |
---|---|---|
checkErrors | boolean | Whether to use error checking when compiling shaders, defaults to true. |
compileAsynchronously | boolean | Whether to compile shaders asynchronously, defaults to false. |
maxMaterialPrograms | number | The maximum number of programs that one material can cache, defaults to 5. |
- Overrides
Methods
beginQuery(query, target)
Begin a query instance.
Name | Type | Description |
---|---|---|
query | Query | |
target | QUERY_TYPE |
- Overrides
beginRender()
Begin rendering.
- Overrides
blitRenderTarget(read, draw, coloropt, depthopt, stencilopt)
Copy a frame buffer to another. This copy process can be used to perform multi-sampling (MSAA).
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
read | RenderTargetBase | The source renderTarget. | ||
draw | RenderTargetBase | The destination renderTarget. | ||
color | boolean | <optional> | true | Copy color buffer. |
depth | boolean | <optional> | true | Copy depth buffer. |
stencil | boolean | <optional> | true | Copy stencil buffer. |
- Overrides
clear(coloropt, depthopt, stencilopt)
Clear the color, depth and stencil buffers.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
color | boolean | <optional> | false | Clear color buffer. |
depth | boolean | <optional> | false | Clear depth buffer. |
stencil | boolean | <optional> | false | Clear stencil buffer. |
- Overrides
endQuery(query)
End a query instance.
Name | Type | Description |
---|---|---|
query | Query |
- Overrides
endRender()
End rendering.
- Overrides
getClearColor() → {Vector4}
Returns a Vector4 instance with the current clear color and alpha. Note: Do not modify the value of Vector4, it is read-only.
- Overrides
- Type:
- Vector4
getQueryResult(query) → {number}
Get the query result.
Name | Type | Description |
---|---|---|
query | Query |
- Overrides
The query result.
- Type:
- number
getRenderTarget() → {RenderTargetBase|null}
Returns the current RenderTarget if there are; returns null otherwise.
- Overrides
- Type:
- RenderTargetBase |
null
(protected) increaseId() → {number}
Used for context lost and restored.
- Overrides
- Type:
- number
init()
Initialize the renderer. This method will be called automatically by the constructor. In the case of context lost, you can call this function to restart the renderer.
isQueryResultAvailable(query) → {boolean}
Check if the query result is available.
Name | Type | Description |
---|---|---|
query | Query |
- Overrides
If query result is available.
- Type:
- boolean
isTimerQueryDisjoint(query) → {boolean}
Returns true if the timer query was disjoint, indicating that timing results are invalid. This is rare and might occur, for example, if the GPU was throttled while timing.
Name | Type | Description |
---|---|---|
query | Query |
- Overrides
Returns true if the timer query was disjoint.
- Type:
- boolean
queryCounter(query)
Records the current time into the corresponding query object.
Name | Type | Description |
---|---|---|
query | Query |
- Overrides
readTexturePixels(texture, x, y, width, height, buffer, zIndexopt, mipLevelopt) → {Promise.<TypedArray>}
Read pixels from a texture. This is an asynchronous operation. See ThinRenderer#readTexturePixelsSync for the synchronous version.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
texture | TextureBase | The texture to read from. | ||
x | number | The x coordinate of the rectangle to read from. | ||
y | number | The y coordinate of the rectangle to read from. | ||
width | number | The width of the rectangle to read from. | ||
height | number | The height of the rectangle to read from. | ||
buffer | TypedArray | The buffer to store the pixel data. | ||
zIndex | number | <optional> | 0 | For CubeTexture, the face index; for Texture3D/TextureArray, the layer/slice index. |
mipLevel | number | <optional> | 0 | The mip level to read. |
- Overrides
A promise that resolves with the passed in buffer after it has been filled with the pixel data.
- Type:
- Promise.<TypedArray>
readTexturePixelsSync(texture, x, y, width, height, buffer, zIndexopt, mipLevelopt) → {TypedArray}
Read pixels from a texture. This is a synchronous operation. See ThinRenderer#readTexturePixels for the asynchronous version.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
texture | TextureBase | The texture to read from. | ||
x | number | The x coordinate of the rectangle to read from. | ||
y | number | The y coordinate of the rectangle to read from. | ||
width | number | The width of the rectangle to read from. | ||
height | number | The height of the rectangle to read from. | ||
buffer | TypedArray | The buffer to store the pixel data. | ||
zIndex | number | <optional> | 0 | For CubeTexture, the face index; for Texture3D/TextureArray, the layer/slice index. |
mipLevel | number | <optional> | 0 | The mip level to read. |
- Overrides
The passed in buffer after it has been filled with the pixel data.
- Type:
- TypedArray
renderRenderableItem(renderable, renderStates, optionsopt)
Render a single renderable item with render states.
Name | Type | Attributes | Description |
---|---|---|---|
renderable | object | The renderable item. | |
renderStates | RenderStates | The render states. | |
options | RenderOptions | <optional> | The render options for this render task. |
- Overrides
renderRenderableList(renderables, renderStates, optionsopt)
Render a single renderable list with render states.
Name | Type | Attributes | Description |
---|---|---|---|
renderables | Array | Array of renderable. | |
renderStates | RenderStates | Render states. | |
options | RenderOptions | <optional> | The render options for this render task. |
- Overrides
renderScene(scene, camera, optionsopt)
Render a scene with a particular camera. This method will render all layers in scene's RenderQueue by default. If you need a customized rendering process, it is recommended to use renderRenderableList method.
Name | Type | Attributes | Description |
---|---|---|---|
scene | Scene | The scene to render. | |
camera | Camera | The camera used to render the scene. | |
options | RenderOptions | <optional> | The render options for this scene render task. |
- Overrides
resetState()
Reset all render states cached in this renderer. This is useful when you use multiple renderers in one application.
- Overrides
resetVertexArrayBindings(forceopt)
Reset vertex array object bindings.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
force | boolean | <optional> | false | Whether clear the current vertex array object. |
setBufferExternal(buffer, webglBuffer)
Bind webglBuffer to Buffer.
Name | Type | Description |
---|---|---|
buffer | Buffer | |
webglBuffer | WebGLBuffer |
- Overrides
setClearColor(r, g, b, a, premultipliedAlpha)
Set clear color.
Name | Type | Description |
---|---|---|
r | number | Red component in the range 0.0 - 1.0. |
g | number | Green component in the range 0.0 - 1.0. |
b | number | Blue component in the range 0.0 - 1.0. |
a | number | Alpha component in the range 0.0 - 1.0. |
premultipliedAlpha | number | Whether the alpha is premultiplied. |
- Overrides
setRenderBufferExternal(renderBuffer, webglRenderbuffer)
Bind webglRenderbuffer to RenderBuffer.
Name | Type | Description |
---|---|---|
renderBuffer | RenderBuffer | |
webglRenderbuffer | WebGLRenderbuffer |
- Overrides
setRenderTarget(renderTarget)
This method sets the active rendertarget.
Name | Type | Description |
---|---|---|
renderTarget | RenderTargetBase | The renderTarget that needs to be activated. |
- Overrides
setTextureExternal(texture, webglTexture)
Bind webglTexture to Texture.
Name | Type | Description |
---|---|---|
texture | TextureBase | |
webglTexture | WebGLTexture |
- Overrides
updateRenderTargetMipmap(renderTarget)
Generate mipmaps for the renderTarget you pass in.
Name | Type | Description |
---|---|---|
renderTarget | RenderTargetBase | The renderTarget to update. |