Constructor
new WebGLRenderer(context)
Create a WebGL renderer.
Parameters:
Name | Type | Description |
---|---|---|
context | WebGLRenderingContext | The Rendering Context privided by canvas. |
Extends
Members
asyncReadPixel :Boolean
Whether to perform readPixel operations asynchronously.
Type:
- Boolean
- Overrides
- Default Value
- false
capabilities :t3d.WebGLCapabilities
An object containing details about the capabilities of the current RenderingContext.
Type:
- t3d.
WebGLCapabilities
- Overrides
context :WebGLRenderingContext|WebGPURenderingContext
The Rendering Context privided by canvas.
Type:
- WebGLRenderingContext |
WebGPURenderingContext
- Overrides
shaderCompileOptions :Object
The shader compiler options.
Type:
Properties- 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. |
Methods
beginQuery(query, target)
Begin a query instance.
Parameters:
Name | Type | Description |
---|---|---|
query | t3d. | |
target | t3d. |
- 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).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
read | t3d. | The source renderTarget. | ||
draw | t3d. | 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.
Parameters:
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.
Parameters:
Name | Type | Description |
---|---|---|
query | t3d. |
- Overrides
endRender()
End rendering.
- Overrides
getClearColor() → {t3d.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
Returns:
- Type:
- t3d.
Vector4
getQueryResult(query) → {Number}
Get the query result.
Parameters:
Name | Type | Description |
---|---|---|
query | t3d. |
- Overrides
Returns:
The query result.
- Type:
- Number
getRenderTarget() → {t3d.RenderTargetBase|Null}
Returns the current RenderTarget if there are; returns null otherwise.
- Overrides
Returns:
- Type:
- t3d.
RenderTargetBase |Null
(protected) increaseId()
Used for context lost and restored.
- Overrides
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.
Parameters:
Name | Type | Description |
---|---|---|
query | t3d. |
Returns:
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.
Parameters:
Name | Type | Description |
---|---|---|
query | t3d. |
Returns:
Returns true if the timer query was disjoint.
- Type:
- Boolean
queryCounter(query)
Records the current time into the corresponding query object.
Parameters:
Name | Type | Description |
---|---|---|
query | t3d. |
- Overrides
readRenderTargetPixels(x, y, width, height, buffer) → {Promise.<TypedArray>}
Reads the pixel data from the current render target into the provided buffer. The Renderer.asyncReadPixel property determines whether this operation is synchronous or asynchronous. To maintain consistency, this method always returns a Promise object.
Parameters:
Name | Type | Description |
---|---|---|
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 | Uint8Array is the only destination type supported in all cases, other types are renderTarget and platform dependent. |
Returns:
A promise that resolves with the passed in buffer after it has been filled with the pixel data.
- Type:
- Promise.<TypedArray>
renderRenderableItem(renderable, renderStates, options=opt)
Render a single renderable item with render states.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
renderable | Object | The renderable item. | |
renderStates | t3d. | The render states. | |
options= | t3d. | <optional> | The render options for this render task. |
renderRenderableList(renderables, renderStates, options=opt)
Render a single renderable list with render states.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
renderables | Array | Array of renderable. | |
renderStates | t3d. | Render states. | |
options= | t3d. | <optional> | The render options for this render task. |
renderScene(scene, camera, options=opt)
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.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
scene | t3d. | The scene to render. | |
camera | t3d. | The camera used to render the scene. | |
options= | t3d. | <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.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
force | Boolean | <optional> | false | Whether clear the current vertex array object. |
setBufferExternal(buffer, webglBuffer)
Bind webglBuffer to t3d's buffer.
Parameters:
Name | Type | Description |
---|---|---|
buffer | t3d. | |
webglBuffer | WebGLBuffer |
- Overrides
setClearColor(r, g, b, a, premultipliedAlpha)
Set clear color.
Parameters:
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 t3d's renderBuffer.
Parameters:
Name | Type | Description |
---|---|---|
renderBuffer | t3d. | |
webglRenderbuffer | WebGLRenderbuffer |
setRenderTarget(renderTarget)
This method sets the active rendertarget.
Parameters:
Name | Type | Description |
---|---|---|
renderTarget | t3d. | The renderTarget that needs to be activated. |
- Overrides
setTextureExternal(texture, webglTexture)
Bind webglTexture to t3d's texture.
Parameters:
Name | Type | Description |
---|---|---|
texture | t3d. | |
webglTexture | WebGLTexture |
- Overrides
updateRenderTargetMipmap(renderTarget)
Generate mipmaps for the renderTarget you pass in.
Parameters:
Name | Type | Description |
---|---|---|
renderTarget | t3d. | The renderTarget to update. |