|
@@ -342,47 +342,6 @@ THREE.CanvasRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- } else if ( element instanceof THREE.RenderableFace4 ) {
|
|
|
-
|
|
|
- _v1 = element.v1; _v2 = element.v2; _v3 = element.v3; _v4 = element.v4;
|
|
|
-
|
|
|
- if ( _v1.positionScreen.z < -1 || _v1.positionScreen.z > 1 ) continue;
|
|
|
- if ( _v2.positionScreen.z < -1 || _v2.positionScreen.z > 1 ) continue;
|
|
|
- if ( _v3.positionScreen.z < -1 || _v3.positionScreen.z > 1 ) continue;
|
|
|
- if ( _v4.positionScreen.z < -1 || _v4.positionScreen.z > 1 ) continue;
|
|
|
-
|
|
|
- _v1.positionScreen.x *= _canvasWidthHalf; _v1.positionScreen.y *= _canvasHeightHalf;
|
|
|
- _v2.positionScreen.x *= _canvasWidthHalf; _v2.positionScreen.y *= _canvasHeightHalf;
|
|
|
- _v3.positionScreen.x *= _canvasWidthHalf; _v3.positionScreen.y *= _canvasHeightHalf;
|
|
|
- _v4.positionScreen.x *= _canvasWidthHalf; _v4.positionScreen.y *= _canvasHeightHalf;
|
|
|
-
|
|
|
- _v5.positionScreen.copy( _v2.positionScreen );
|
|
|
- _v6.positionScreen.copy( _v4.positionScreen );
|
|
|
-
|
|
|
- if ( material.overdraw > 0 ) {
|
|
|
-
|
|
|
- expand( _v1.positionScreen, _v2.positionScreen, material.overdraw );
|
|
|
- expand( _v2.positionScreen, _v4.positionScreen, material.overdraw );
|
|
|
- expand( _v4.positionScreen, _v1.positionScreen, material.overdraw );
|
|
|
-
|
|
|
- expand( _v3.positionScreen, _v5.positionScreen, material.overdraw );
|
|
|
- expand( _v3.positionScreen, _v6.positionScreen, material.overdraw );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _elemBox.setFromPoints( [
|
|
|
- _v1.positionScreen,
|
|
|
- _v2.positionScreen,
|
|
|
- _v3.positionScreen,
|
|
|
- _v4.positionScreen
|
|
|
- ] );
|
|
|
-
|
|
|
- if ( _clipBox.isIntersectionBox( _elemBox ) === true ) {
|
|
|
-
|
|
|
- renderFace4( _v1, _v2, _v3, _v4, _v5, _v6, element, material );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/* DEBUG
|
|
@@ -833,165 +792,6 @@ THREE.CanvasRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function renderFace4( v1, v2, v3, v4, v5, v6, element, material ) {
|
|
|
-
|
|
|
- _this.info.render.vertices += 4;
|
|
|
- _this.info.render.faces ++;
|
|
|
-
|
|
|
- setOpacity( material.opacity );
|
|
|
- setBlending( material.blending );
|
|
|
-
|
|
|
- if ( ( material.map !== undefined && material.map !== null ) || ( material.envMap !== undefined && material.envMap !== null ) ) {
|
|
|
-
|
|
|
- // Let renderFace3() handle this
|
|
|
-
|
|
|
- renderFace3( v1, v2, v4, 0, 1, 3, element, material );
|
|
|
- renderFace3( v5, v3, v6, 1, 2, 3, element, material );
|
|
|
-
|
|
|
- return;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _v1x = v1.positionScreen.x; _v1y = v1.positionScreen.y;
|
|
|
- _v2x = v2.positionScreen.x; _v2y = v2.positionScreen.y;
|
|
|
- _v3x = v3.positionScreen.x; _v3y = v3.positionScreen.y;
|
|
|
- _v4x = v4.positionScreen.x; _v4y = v4.positionScreen.y;
|
|
|
- _v5x = v5.positionScreen.x; _v5y = v5.positionScreen.y;
|
|
|
- _v6x = v6.positionScreen.x; _v6y = v6.positionScreen.y;
|
|
|
-
|
|
|
- if ( material instanceof THREE.MeshLambertMaterial || material instanceof THREE.MeshPhongMaterial ) {
|
|
|
-
|
|
|
- _diffuseColor.copy( material.color );
|
|
|
- _emissiveColor.copy( material.emissive );
|
|
|
-
|
|
|
- if ( material.vertexColors === THREE.FaceColors ) {
|
|
|
-
|
|
|
- _diffuseColor.multiply( element.color );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( material.wireframe === false && material.shading == THREE.SmoothShading && element.vertexNormalsLength == 4 ) {
|
|
|
-
|
|
|
- _color1.copy( _ambientLight );
|
|
|
- _color2.copy( _ambientLight );
|
|
|
- _color3.copy( _ambientLight );
|
|
|
- _color4.copy( _ambientLight );
|
|
|
-
|
|
|
- calculateLight( element.v1.positionWorld, element.vertexNormalsModel[ 0 ], _color1 );
|
|
|
- calculateLight( element.v2.positionWorld, element.vertexNormalsModel[ 1 ], _color2 );
|
|
|
- calculateLight( element.v4.positionWorld, element.vertexNormalsModel[ 3 ], _color3 );
|
|
|
- calculateLight( element.v3.positionWorld, element.vertexNormalsModel[ 2 ], _color4 );
|
|
|
-
|
|
|
- _color1.multiply( _diffuseColor ).add( _emissiveColor );
|
|
|
- _color2.multiply( _diffuseColor ).add( _emissiveColor );
|
|
|
- _color3.multiply( _diffuseColor ).add( _emissiveColor );
|
|
|
- _color4.multiply( _diffuseColor ).add( _emissiveColor );
|
|
|
-
|
|
|
- _image = getGradientTexture( _color1, _color2, _color3, _color4 );
|
|
|
-
|
|
|
- // TODO: UVs are incorrect, v4->v3?
|
|
|
-
|
|
|
- drawTriangle( _v1x, _v1y, _v2x, _v2y, _v4x, _v4y );
|
|
|
- clipImage( _v1x, _v1y, _v2x, _v2y, _v4x, _v4y, 0, 0, 1, 0, 0, 1, _image );
|
|
|
-
|
|
|
- drawTriangle( _v5x, _v5y, _v3x, _v3y, _v6x, _v6y );
|
|
|
- clipImage( _v5x, _v5y, _v3x, _v3y, _v6x, _v6y, 1, 0, 1, 1, 0, 1, _image );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- _color.copy( _ambientLight );
|
|
|
-
|
|
|
- calculateLight( element.centroidModel, element.normalModel, _color );
|
|
|
-
|
|
|
- _color.multiply( _diffuseColor ).add( _emissiveColor );
|
|
|
-
|
|
|
- drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y );
|
|
|
-
|
|
|
- material.wireframe === true
|
|
|
- ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin )
|
|
|
- : fillPath( _color );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else if ( material instanceof THREE.MeshBasicMaterial ) {
|
|
|
-
|
|
|
- _color.copy( material.color );
|
|
|
-
|
|
|
- if ( material.vertexColors === THREE.FaceColors ) {
|
|
|
-
|
|
|
- _color.multiply( element.color );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y );
|
|
|
-
|
|
|
- material.wireframe === true
|
|
|
- ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin )
|
|
|
- : fillPath( _color );
|
|
|
-
|
|
|
- } else if ( material instanceof THREE.MeshNormalMaterial ) {
|
|
|
-
|
|
|
- var normal;
|
|
|
-
|
|
|
- if ( material.shading == THREE.FlatShading ) {
|
|
|
-
|
|
|
- normal = element.normalModelView;
|
|
|
- _color.setRGB( normal.x, normal.y, normal.z ).multiplyScalar( 0.5 ).addScalar( 0.5 );
|
|
|
-
|
|
|
- drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y );
|
|
|
-
|
|
|
- material.wireframe === true
|
|
|
- ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin )
|
|
|
- : fillPath( _color );
|
|
|
-
|
|
|
- } else if ( material.shading == THREE.SmoothShading ) {
|
|
|
-
|
|
|
- normal = element.vertexNormalsModelView[ 0 ];
|
|
|
- _color1.setRGB( normal.x, normal.y, normal.z ).multiplyScalar( 0.5 ).addScalar( 0.5 );
|
|
|
-
|
|
|
- normal = element.vertexNormalsModelView[ 1 ];
|
|
|
- _color2.setRGB( normal.x, normal.y, normal.z ).multiplyScalar( 0.5 ).addScalar( 0.5 );
|
|
|
-
|
|
|
- normal = element.vertexNormalsModelView[ 3 ];
|
|
|
- _color3.setRGB( normal.x, normal.y, normal.z ).multiplyScalar( 0.5 ).addScalar( 0.5 );
|
|
|
-
|
|
|
- normal = element.vertexNormalsModelView[ 2 ];
|
|
|
- _color4.setRGB( normal.x, normal.y, normal.z ).multiplyScalar( 0.5 ).addScalar( 0.5 );
|
|
|
-
|
|
|
- _image = getGradientTexture( _color1, _color2, _color3, _color4 );
|
|
|
-
|
|
|
- drawTriangle( _v1x, _v1y, _v2x, _v2y, _v4x, _v4y );
|
|
|
- clipImage( _v1x, _v1y, _v2x, _v2y, _v4x, _v4y, 0, 0, 1, 0, 0, 1, _image );
|
|
|
-
|
|
|
- drawTriangle( _v5x, _v5y, _v3x, _v3y, _v6x, _v6y );
|
|
|
- clipImage( _v5x, _v5y, _v3x, _v3y, _v6x, _v6y, 1, 0, 1, 1, 0, 1, _image );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else if ( material instanceof THREE.MeshDepthMaterial ) {
|
|
|
-
|
|
|
- _near = _camera.near;
|
|
|
- _far = _camera.far;
|
|
|
-
|
|
|
- _color1.r = _color1.g = _color1.b = 1 - smoothstep( v1.positionScreen.z * v1.positionScreen.w, _near, _far );
|
|
|
- _color2.r = _color2.g = _color2.b = 1 - smoothstep( v2.positionScreen.z * v2.positionScreen.w, _near, _far );
|
|
|
- _color3.r = _color3.g = _color3.b = 1 - smoothstep( v4.positionScreen.z * v4.positionScreen.w, _near, _far );
|
|
|
- _color4.r = _color4.g = _color4.b = 1 - smoothstep( v3.positionScreen.z * v3.positionScreen.w, _near, _far );
|
|
|
-
|
|
|
- _image = getGradientTexture( _color1, _color2, _color3, _color4 );
|
|
|
-
|
|
|
- // TODO: UVs are incorrect, v4->v3?
|
|
|
-
|
|
|
- drawTriangle( _v1x, _v1y, _v2x, _v2y, _v4x, _v4y );
|
|
|
- clipImage( _v1x, _v1y, _v2x, _v2y, _v4x, _v4y, 0, 0, 1, 0, 0, 1, _image );
|
|
|
-
|
|
|
- drawTriangle( _v5x, _v5y, _v3x, _v3y, _v6x, _v6y );
|
|
|
- clipImage( _v5x, _v5y, _v3x, _v3y, _v6x, _v6y, 1, 0, 1, 1, 0, 1, _image );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
//
|
|
|
|
|
|
function drawTriangle( x0, y0, x1, y1, x2, y2 ) {
|
|
@@ -1004,17 +804,6 @@ THREE.CanvasRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function drawQuad( x0, y0, x1, y1, x2, y2, x3, y3 ) {
|
|
|
-
|
|
|
- _context.beginPath();
|
|
|
- _context.moveTo( x0, y0 );
|
|
|
- _context.lineTo( x1, y1 );
|
|
|
- _context.lineTo( x2, y2 );
|
|
|
- _context.lineTo( x3, y3 );
|
|
|
- _context.closePath();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
function strokePath( color, linewidth, linecap, linejoin ) {
|
|
|
|
|
|
setLineWidth( linewidth );
|