parameters is an optional object with properties defining the renderer's behavior.
The constructor also accepts no parameters at all.
In all cases, it will assume sane defaults when parameters are missing.
Optional
parameters: WebGLRendererParametersA Canvas where the renderer draws its output.
This is automatically created by the renderer in the constructor (if not provided already); you just need to add it to your page.
Defines whether the renderer should automatically clear its output before rendering.
If autoClear is true, defines whether the renderer should clear the color buffer. Default is true.
If autoClear is true, defines whether the renderer should clear the depth buffer. Default is true.
If autoClear is true, defines whether the renderer should clear the stencil buffer. Default is true.
Debug configurations.
Defines whether the renderer should sort objects. Default is true.
Compiles all materials in the scene with the camera. This is useful to precompile shaders before the first
rendering. If you want to add a 3D object to an existing scene, use the third optional parameter for applying the
target scene.
Note that the (target) scene's lighting should be configured before calling this method.
Asynchronous version of compile(). The method returns a Promise that resolves when the given scene can be
rendered without unnecessary stalling due to shader compilation.
This method makes use of the KHR_parallel_shader_compile WebGL extension.
Use .xr instead.
Use .shadowMap.enabled instead.
Use .shadowMap.type instead.
Use .shadowMap.cullFace instead.
Color space used for output to HTMLCanvasElement. Supported values are
SRGBColorSpace and LinearSRGBColorSpace.
Use .capabilities.getMaxAnisotropy() instead.
Use .capabilities.precision instead.
Sets the viewport to render from (x, y) to (x + width, y + height).
(x, y) is the lower-left corner of the region.
Optional
y: numberOptional
width: numberOptional
height: numberSets the scissor area from (x, y) to (x + width, y + height).
Optional
y: numberOptional
width: numberOptional
height: numberSets the clear color, using color for the color and alpha for the opacity.
Optional
alpha: numberUse .state.reset() instead.
A build in function that can be used instead of requestAnimationFrame. For WebXR projects this function must be used.
The function will be called every available frame. If null
is passed it will stop any already ongoing animation.
Use .setAnimationLoop() instead.
Render a scene or an object using a camera.
The render is done to a previously specified WebGLRenderTarget#renderTarget .renderTarget set by calling
.setRenderTarget or to the canvas as usual.
By default render buffers are cleared before rendering but you can prevent this by setting the property
autoClear to false. If you want to prevent only certain buffers being cleared
you can set either the autoClearColor,
autoClearStencil or autoClearDepth
properties to false. To forcibly clear one ore more buffers call .clear.
Returns the current render target. If no render target is set, null is returned.
Use .getRenderTarget() instead.
Sets the active render target.
The renderTarget that needs to be activated. When null
is given, the canvas is set as the active render target instead.
Optional
activeCubeFace: numberSpecifies the active cube side (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) of WebGLCubeRenderTarget.
Optional
activeMipmapLevel: numberSpecifies the active mipmap level.
Optional
activeCubeFaceIndex: numberOptional
activeCubeFaceIndex: numberCopies the pixels of a texture in the bounds srcRegion
in the destination texture starting from the given
position.
Specifies the source texture.
Specifies the destination texture.
Optional
srcRegion: null | Box2Specifies the bounds
Optional
dstPosition: null | Vector2Specifies the pixel offset into the dstTexture where the copy will occur.
Optional
level: numberSpecifies the destination mipmap level of the texture.
Copies the pixels of a texture in the bounds srcRegion
in the destination texture starting from the given
position.
Specifies the source texture.
Specifies the destination texture.
Optional
srcRegion: null | Box3Specifies the bounds
Optional
dstPosition: null | Vector3Specifies the pixel offset into the dstTexture where the copy will occur.
Optional
level: numberSpecifies the destination mipmap level of the texture.
Initializes the given WebGLRenderTarget memory. Useful for initializing a render target so data can be copied
into it using WebGLRenderer.copyTextureToTexture before it has been rendered to.
Initializes the given texture. Can be used to preload a texture rather than waiting until first render (which can cause noticeable lags due to decode and GPU upload overhead).
The texture to Initialize.
Use .extensions.get( 'OES_texture_float' ) instead.
Use .extensions.get( 'OES_texture_half_float' ) instead.
Use .extensions.get( 'OES_standard_derivatives' ) instead.
Use .extensions.get( 'WEBGL_compressed_texture_s3tc' ) instead.
Use .extensions.get( 'WEBGL_compressed_texture_pvrtc' ) instead.
Use .extensions.get( 'EXT_blend_minmax' ) instead.
Use .capabilities.vertexTextures instead.
Use .extensions.get( 'ANGLE_instanced_arrays' ) instead.
Use .setScissorTest() instead.
The WebGL renderer displays your beautifully crafted scenes using WebGL, if your device supports it.
This renderer has way better performance than CanvasRenderer.
see https://github.com/mrdoob/three.js/blob/master/src/renderers/WebGLRenderer.js|src/renderers/WebGLRenderer.js