mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-23 05:57:57 +01:00
162 lines
5.0 KiB
HTML
162 lines
5.0 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="utf-8" />
|
||
|
<script src="../../list.js"></script>
|
||
|
<script src="../../page.js"></script>
|
||
|
<link type="text/css" rel="stylesheet" href="../../page.css" />
|
||
|
</head>
|
||
|
<body>
|
||
|
<h1>[name]</h1>
|
||
|
|
||
|
<div class="desc">
|
||
|
The Canvas renderer displays your beautifully crafted scenes <em>not</em> using WebGL, but draws it using the (slower) <a href="http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas/">Canvas 2D Context</a> API.<br /><br />
|
||
|
This renderer can be a nice fallback from [page:WebGLRenderer] for simple scenes:
|
||
|
|
||
|
<code>
|
||
|
function webglAvailable() {
|
||
|
try {
|
||
|
var canvas = document.createElement( 'canvas' );
|
||
|
return !!( window.WebGLRenderingContext && (
|
||
|
canvas.getContext( 'webgl' ) ||
|
||
|
canvas.getContext( 'experimental-webgl' ) )
|
||
|
);
|
||
|
} catch ( e ) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( webglAvailable() ) {
|
||
|
renderer = new THREE.WebGLRenderer();
|
||
|
} else {
|
||
|
renderer = new THREE.CanvasRenderer();
|
||
|
}
|
||
|
</code>
|
||
|
|
||
|
Note: both WebGLRenderer and CanvasRenderer are embedded in the web page using an HTML5 <canvas> tag.
|
||
|
The "Canvas" in CanvasRenderer means it uses Canvas 2D instead of WebGL.<br /><br />
|
||
|
|
||
|
Don't confuse either CanvasRenderer with the SoftwareRenderer example, which simulates a screen buffer in a Javascript array.
|
||
|
</div>
|
||
|
|
||
|
<h2>Constructor</h2>
|
||
|
|
||
|
|
||
|
<h3>[name]([page:object parameters])</h3>
|
||
|
<div>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.</div>
|
||
|
|
||
|
<div>
|
||
|
canvas — A [page:Canvas] where the renderer draws its output.
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<h2>Properties</h2>
|
||
|
|
||
|
<h3>[property:Object info]</h3>
|
||
|
|
||
|
<div>
|
||
|
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:</div>
|
||
|
<ul>
|
||
|
<li>render:
|
||
|
<ul>
|
||
|
<li>vertices</li>
|
||
|
<li>faces</li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
|
||
|
<h3>[property:DOMElement domElement]</h3>
|
||
|
|
||
|
<div>
|
||
|
A [page:Canvas] where the renderer draws its output.<br />
|
||
|
This is automatically created by the renderer in the constructor (if not provided already); you just need to add it to your page.
|
||
|
</div>
|
||
|
|
||
|
<h3>[property:Boolean autoClear]</h3>
|
||
|
<div>
|
||
|
Defines whether the renderer should automatically clear its output before rendering.
|
||
|
</div>
|
||
|
|
||
|
<h3>[property:Boolean sortObjects]</h3>
|
||
|
<div>
|
||
|
Defines whether the renderer should sort objects. Default is true.<br />
|
||
|
Note: Sorting is used to attempt to properly render objects that have some degree of transparency. By definition, sorting objects may not work in all cases. Depending on the needs of application, it may be neccessary to turn off sorting and use other methods to deal with transparency rendering e.g. manually determining the object rendering order.
|
||
|
</div>
|
||
|
|
||
|
<h3>[property:boolean sortElements]</h3>
|
||
|
<div>
|
||
|
Defines whether the renderer should sort the face of each object. Default is true.
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<h2>Methods</h2>
|
||
|
|
||
|
<h3>[method:null render]([page:Scene scene], [page:Camera camera])</h3>
|
||
|
<div>
|
||
|
scene -- The scene to render. <br />
|
||
|
camera -- the camera to view the scene.
|
||
|
</div>
|
||
|
<div>
|
||
|
Render a scene using a camera.
|
||
|
</div>
|
||
|
|
||
|
<h3>[method:null clear]()</h3>
|
||
|
<div>
|
||
|
Tells the renderer to clear its color drawing buffer with the clearcolor.
|
||
|
</div>
|
||
|
|
||
|
<h3>[method:null setClearColor]([page:Color color], [page:number alpha])</h3>
|
||
|
<div>
|
||
|
color -- The color to clear the canvas with. <br />
|
||
|
alpha -- The alpha channel to clear the canvas with.
|
||
|
</div>
|
||
|
<div>
|
||
|
This set the clearColor and the clearAlpha.
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<h3>[method:null setSize]([page:Number width], [page:Number height])</h3>
|
||
|
<div>
|
||
|
width -- The width of the drawing canvas. <br />
|
||
|
height -- The height of the drawing canvas.
|
||
|
</div>
|
||
|
<div>
|
||
|
This set the size of the drawing canvas and if updateStyle is set, then the css of the canvas is updated too.
|
||
|
</div>
|
||
|
|
||
|
<h3>[method:null setClearColorHex]([page:number hex], [page:number alpha])</h3>
|
||
|
<div>
|
||
|
hex -- The the hexadecimal value of the color to clear the canvas with. <br />
|
||
|
alpha -- The alpha channel to clear the canvas with.
|
||
|
</div>
|
||
|
<div>
|
||
|
This set the clearColor and the clearAlpha.
|
||
|
</div>
|
||
|
|
||
|
<h3>[method:number getClearColorHex]()</h3>
|
||
|
<div>
|
||
|
Returns the [page:number hex] color.
|
||
|
</div>
|
||
|
|
||
|
<h3>[method:number getClearAlpha]()</h3>
|
||
|
<div>
|
||
|
Returns the alpha value.
|
||
|
</div>
|
||
|
|
||
|
<h2>Empty Methods to Maintain Compatibility with [page:WebglRenderer]</h2>
|
||
|
<div>
|
||
|
[method:null clearColor]()<br/>
|
||
|
[method:null clearDepth]()<br/>
|
||
|
[method:null clearStencil]()<br/>
|
||
|
[method:null setFaceCulling]()<br/>
|
||
|
[method:null supportsVertexTextures]()<br/>
|
||
|
[method:number getMaxAnisotropy]() - returns 1 <br/>
|
||
|
</div>
|
||
|
|
||
|
<h2>Source</h2>
|
||
|
|
||
|
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|
||
|
</body>
|
||
|
</html>
|