The WebGL renderer displays your beautifully crafted scenes using WebGL, if your device supports it.
This renderer has way better performance than CanvasRenderer.
parameters is an optional object with properties defining the renderer's behaviour. The constructor also accepts no parameters at all. In all cases, it will assume sane defaults when parameters are missing.
Defines whether the renderer should automatically clear its output before rendering.
public autoClearColor:boolean
If autoClear is true, defines whether the renderer should clear the color buffer. Default is true.
public autoClearDepth:boolean
If autoClear is true, defines whether the renderer should clear the depth buffer. Default is true.
public autoClearStencil:boolean
If autoClear is true, defines whether the renderer should clear the stencil buffer. Default is true.
public autoScaleCubemaps:boolean
Default is true.
public autoUpdateObjects:boolean
Defines whether the renderer should auto update objects. Default is true.
public context:any
The HTML5 Canvas's 'webgl' context obtained from the canvas where the renderer will draw.
public devicePixelRatio:number
public domElement:HTMLCanvasElement
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.
An object with a series of statistical information about the graphics board memory and the rendering process. Useful for debugging or just for the sake of curiosity. The object contains the following fields:
public info.memory:{ programs: number; geometries: number; textures: number; }
Defines shadow map type (unfiltered, percentage close filtering, percentage close filtering with bilinear filtering in shader)
Options are THREE.BasicShadowMap, THREE.PCFShadowMap, THREE.PCFSoftShadowMap. Default is THREE.PCFShadowMap.
public sortObjects:boolean
Defines whether the renderer should sort objects. Default is true.
public render(scene: Scene, camera: Camera, renderTarget?: RenderTarget, forceClear?: boolean)
Render a scene using a camera.
The render is done to the renderTarget (if specified) or to the canvas as usual.
If forceClear is true, the canvas will be cleared before rendering, even if the renderer's autoClear property is false.
public setClearColor(color: string, alpha?: number)
Parameters
color: string
alpha?: numberoptional
public setClearColor(color: number, alpha?: number)
Parameters
color: number
alpha?: numberoptional
public setClearColorHex(hex: number, alpha: number)
Sets the clear color, using hex for the color and alpha for the opacity.
example
// Creates a renderer with black background
var renderer = new THREE.WebGLRenderer();
renderer.setSize(200, 100);
renderer.setClearColorHex(0x000000, 1);
Used for setting the gl frontFace, cullFace states in the GPU, thus enabling/disabling face culling when rendering.
If cullFace is false, culling will be disabled.