Constructor
new WebGLRenderer(contextopt)
Create a WebGLRenderer.
Name | Type | Attributes | Description |
---|---|---|---|
context | WebGLRenderingContext | <optional> | The WebGL Rendering Context privided by canvas. If not provided, you must call WebGLRenderer.init method with a valid context before using this renderer. |
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
(readonly) id :number
The unique id of this renderer. This will be incremented when the context is lost and restored.
- number
- 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
beginOcclusionQuery(index)
Begin an occlusion query.
Name | Type | Description |
---|---|---|
index | number | The query index in the current occlusion query set. |
- Overrides
beginRender(renderTarget)
Begin rendering.
Name | Type | Description |
---|---|---|
renderTarget | RenderTargetBase | The render target to render to. |
- 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
endOcclusionQuery()
End the current occlusion query.
- Overrides
endRender()
End rendering.
- Overrides
generateMipmaps(texture)
Generate mipmaps for the texture you pass in.
Name | Type | Description |
---|---|---|
texture | TextureBase | The texture to update. |
- Overrides
(protected) increaseId() → {number}
Used for context lost and restored.
- Overrides
- Type:
- number
init(context, optionsopt) → {Promise.<ThinRenderer>}
Initialize this renderer with a rendering context. This method is called automatically by WebGLRenderer constructor when a context is provided. For WebGPURenderer, you must call this method manually and wait for the promise to resolve.
Name | Type | Attributes | Description |
---|---|---|---|
context | WebGLRenderingContext | | The rendering context. | |
options | object | <optional> | The options for initializing this renderer. |
- Overrides
A promise that resolves when initialization completes.
- Type:
- Promise.<ThinRenderer>
readQuerySetResults(querySet, dstBuffer, firstQueryopt, queryCountopt) → {Promise.<(Array|TypedArray)>}
Read back the results of a query set. This is an asynchronous operation.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
querySet | QuerySet | The query set to read from. | ||
dstBuffer | Array | | The buffer to store the results. | ||
firstQuery | number | <optional> | 0 | The first query index to read. |
queryCount | number | <optional> | querySet.count | The number of queries to read. |
- Overrides
A promise that resolves with the passed in buffer after it has been filled with the results.
- Type:
- Promise.<(Array|TypedArray)>
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, renderTarget, 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. | |
renderTarget | RenderTargetBase | The render target to render to. | |
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 |
setFramebufferExternal(renderTarget, webglFramebuffer)
Bind webglFramebuffer to RenderTarget.
Name | Type | Description |
---|---|---|
renderTarget | RenderTarget | |
webglFramebuffer | WebGLFramebuffer |
setRenderBufferExternal(renderBuffer, webglRenderbuffer)
Bind webglRenderbuffer to RenderBuffer.
Name | Type | Description |
---|---|---|
renderBuffer | RenderBuffer | |
webglRenderbuffer | WebGLRenderbuffer |
setTextureExternal(texture, webglTexture)
Bind webglTexture to Texture.
Name | Type | Description |
---|---|---|
texture | TextureBase | |
webglTexture | WebGLTexture |