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: WebGLRendererParametersDefines 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.
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.
Debug configurations.
A 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.
Use .shadowMap.cullFace instead.
Use .shadowMap.enabled instead.
Use .shadowMap.type instead.
Defines whether the renderer should sort objects. Default is true.
Use .xr instead.
Color space used for output to HTMLCanvasElement. Supported values are SRGBColorSpace and LinearSRGBColorSpace.
Use .setAnimationLoop() instead.
Copies the pixels of a texture in the bounds [srcRegion]Box3 in the destination texture starting from the given position. 2D Texture, 3D Textures, or a mix of the two can be used as source and destination texture arguments for copying between layers of 3d textures
The depthTexture
and texture
property of render targets are supported as well.
When using render target textures as srcTexture
and dstTexture
, you must make sure both render targets are
initialized e.g. via .initRenderTarget().
Specifies the source texture.
Specifies the destination texture.
Optional
srcRegion: null | Box3 | Box2Specifies the bounds
Optional
dstPosition: null | Vector2 | Vector3Specifies the pixel offset into the dstTexture where the copy will occur.
Optional
dstLevel: numberSpecifies the destination mipmap level of the texture.
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.
Use "copyTextureToTexture" instead.
Copies the pixels of a texture in the bounds srcRegion
in the destination texture starting from the given
position. The depthTexture
and texture
property of 3D render targets are supported as well.
When using render target textures as srcTexture
and dstTexture
, you must make sure both render targets are
intitialized e.g. via .initRenderTarget().
Use .setScissorTest() instead.
Use .getRenderTarget() instead.
Use .capabilities.getMaxAnisotropy() instead.
Use .capabilities.precision instead.
Returns the current render target. If no render target is set, null is returned.
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.
Optional
activeCubeFaceIndex: numberOptional
activeCubeFaceIndex: numberRender 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.
Use .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.
Sets the clear color, using color for the color and alpha for the opacity.
Optional
alpha: numberSets 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.
Sets the scissor area from (x, y) to (x + width, y + height).
Optional
y: numberOptional
width: numberOptional
height: numberSets 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: numberUse .extensions.get( 'EXT_blend_minmax' ) instead.
Use .extensions.get( 'WEBGL_compressed_texture_pvrtc' ) instead.
Use .extensions.get( 'WEBGL_compressed_texture_s3tc' ) instead.
Use .extensions.get( 'OES_texture_float' ) instead.
Use .extensions.get( 'OES_texture_half_float' ) instead.
Use .extensions.get( 'ANGLE_instanced_arrays' ) instead.
Use .extensions.get( 'OES_standard_derivatives' ) instead.
Use .capabilities.vertexTextures 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