Skip to content
alteredq edited this page Aug 22, 2011 · 4 revisions

The WebGLRenderer class provides all of the functionality needed to handle objects and render scenes.

Constructor

new THREE.WebGLRenderer({
	antialias: false,
	canvas: document.createElement( 'canvas' ),
	clearColor: 0x000000,
	clearAlpha: 0,
	maxLights: 4,
	stencil: true,
	preserveDrawingBuffer: false
});
  • antialias specifies whether or not antialiasing is enabled
  • canvas if specified, the renderer will use this HTMLCanvasElement instead of creating a new one
  • clearColor defines the background color the scene will render with
  • clearAlpha defines the opacity of the scene's background color, range 0.0 (invisible) to 1.0 (opaque)
  • maxLights specifies how many total lights are allowed in the scene (divided evenly between point & directional lights)
  • stencil specifies if the WebGL context should enable the stencil buffer
  • preserveDrawingBuffer keep drawing buffer content after return from render function (see WebGL specs)

Properties

  • data holds information on the number of vertices and faces drawn in how many draw calls
  • maxMorphTargets the maximum number of morph targets a material can have
  • autoClear specifies whether each call to render() will clear the canvas before rendering
  • sortObjects if true, objects are sorted by their Z position before drawing

Methods

  • clear() clears the canvas's color, depth, and stencil buffers
  • enableDepthBufferWrite(enable) true/false, enables or disables writing to the depth buffer
  • enableScissorTest(enable) true/false, specifies if scissor test is enabled
  • getContext() returns the canvas's 3D context
  • render(scene, camera, renderTarget, forceClear) renders scene as viewed by camera onto the canvas element. If supplied, renderTarget must be a THREE.WebGLRenderTarget object which will be rendererd onto instead of painting the canvas element. If forceClear is true then the canvas is cleared regardness of the autoClear value.
  • setClearColor(color, alpha) updates the canvas's clearColor RGBA values
  • setClearColorHex(hex, alpha) updates the canvas's clearColor RGBA values
  • setFaceCulling(cullFace, frontFace) if cullFace is not false, the face it specifies will be culled. cullFace values are "front" or "back", if cullFace is not false, "front", or "back" then both faces are culled. frontFace value can be "ccw" or "cw"
  • setScissor(x, y, width, height) sets area of canvas which should be scissored
  • setSize(width, height) sets the canvas element's width and height and updates the context's viewport
  • setViewport(x, y, width, height) changes the 3D context's viewport dimensions
  • setStencilShadowDarkness(value) specifies how dark shadows generated by the stencil buffer will appear, range 0.0 (black) - 1.0 (none)
  • supportsVertexTextures() returns true/false depending on GPU support of using textures in vertex shaders