提交 cb4084bf 编写于 作者: M Mr.doob

Added material.emissive support to CanvasRenderer.

上级 4aad148d
......@@ -563,6 +563,9 @@ THREE.CanvasRenderer = function ( parameters ) {
if ( _enableLighting === true ) {
var diffuse = material.color;
var emissive = material.emissive;
if ( material.wireframe === false && material.shading == THREE.SmoothShading && element.vertexNormalsLength == 3 ) {
_color1.r = _color2.r = _color3.r = _ambientLight.r;
......@@ -573,17 +576,17 @@ THREE.CanvasRenderer = function ( parameters ) {
calculateLight( element.v2.positionWorld, element.vertexNormalsWorld[ 1 ], _color2 );
calculateLight( element.v3.positionWorld, element.vertexNormalsWorld[ 2 ], _color3 );
_color1.r = Math.max( 0, Math.min( material.color.r * _color1.r, 1 ) );
_color1.g = Math.max( 0, Math.min( material.color.g * _color1.g, 1 ) );
_color1.b = Math.max( 0, Math.min( material.color.b * _color1.b, 1 ) );
_color1.r = Math.max( 0, Math.min( diffuse.r * _color1.r + emissive.r, 1 ) );
_color1.g = Math.max( 0, Math.min( diffuse.g * _color1.g + emissive.g, 1 ) );
_color1.b = Math.max( 0, Math.min( diffuse.b * _color1.b + emissive.b, 1 ) );
_color2.r = Math.max( 0, Math.min( material.color.r * _color2.r, 1 ) );
_color2.g = Math.max( 0, Math.min( material.color.g * _color2.g, 1 ) );
_color2.b = Math.max( 0, Math.min( material.color.b * _color2.b, 1 ) );
_color2.r = Math.max( 0, Math.min( diffuse.r * _color2.r + emissive.r, 1 ) );
_color2.g = Math.max( 0, Math.min( diffuse.g * _color2.g + emissive.g, 1 ) );
_color2.b = Math.max( 0, Math.min( diffuse.b * _color2.b + emissive.b, 1 ) );
_color3.r = Math.max( 0, Math.min( material.color.r * _color3.r, 1 ) );
_color3.g = Math.max( 0, Math.min( material.color.g * _color3.g, 1 ) );
_color3.b = Math.max( 0, Math.min( material.color.b * _color3.b, 1 ) );
_color3.r = Math.max( 0, Math.min( diffuse.r * _color3.r + emissive.r, 1 ) );
_color3.g = Math.max( 0, Math.min( diffuse.g * _color3.g + emissive.g, 1 ) );
_color3.b = Math.max( 0, Math.min( diffuse.b * _color3.b + emissive.b, 1 ) );
_color4.r = ( _color2.r + _color3.r ) * 0.5;
_color4.g = ( _color2.g + _color3.g ) * 0.5;
......@@ -601,9 +604,9 @@ THREE.CanvasRenderer = function ( parameters ) {
calculateLight( element.centroidWorld, element.normalWorld, _color );
_color.r = Math.max( 0, Math.min( material.color.r * _color.r, 1 ) );
_color.g = Math.max( 0, Math.min( material.color.g * _color.g, 1 ) );
_color.b = Math.max( 0, Math.min( material.color.b * _color.b, 1 ) );
_color.r = Math.max( 0, Math.min( diffuse.r * _color.r + emissive.r, 1 ) );
_color.g = Math.max( 0, Math.min( diffuse.g * _color.g + emissive.g, 1 ) );
_color.b = Math.max( 0, Math.min( diffuse.b * _color.b + emissive.b, 1 ) );
material.wireframe === true ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
......@@ -719,6 +722,9 @@ THREE.CanvasRenderer = function ( parameters ) {
if ( _enableLighting === true ) {
var diffuse = material.color;
var emissive = material.emissive;
if ( material.wireframe === false && material.shading == THREE.SmoothShading && element.vertexNormalsLength == 4 ) {
_color1.r = _color2.r = _color3.r = _color4.r = _ambientLight.r;
......@@ -730,21 +736,21 @@ THREE.CanvasRenderer = function ( parameters ) {
calculateLight( element.v4.positionWorld, element.vertexNormalsWorld[ 3 ], _color3 );
calculateLight( element.v3.positionWorld, element.vertexNormalsWorld[ 2 ], _color4 );
_color1.r = Math.max( 0, Math.min( material.color.r * _color1.r, 1 ) );
_color1.g = Math.max( 0, Math.min( material.color.g * _color1.g, 1 ) );
_color1.b = Math.max( 0, Math.min( material.color.b * _color1.b, 1 ) );
_color1.r = Math.max( 0, Math.min( diffuse.r * _color1.r + emissive.r, 1 ) );
_color1.g = Math.max( 0, Math.min( diffuse.g * _color1.g + emissive.g, 1 ) );
_color1.b = Math.max( 0, Math.min( diffuse.b * _color1.b + emissive.b, 1 ) );
_color2.r = Math.max( 0, Math.min( material.color.r * _color2.r, 1 ) );
_color2.g = Math.max( 0, Math.min( material.color.g * _color2.g, 1 ) );
_color2.b = Math.max( 0, Math.min( material.color.b * _color2.b, 1 ) );
_color2.r = Math.max( 0, Math.min( diffuse.r * _color2.r + emissive.r, 1 ) );
_color2.g = Math.max( 0, Math.min( diffuse.g * _color2.g + emissive.g, 1 ) );
_color2.b = Math.max( 0, Math.min( diffuse.b * _color2.b + emissive.b, 1 ) );
_color3.r = Math.max( 0, Math.min( material.color.r * _color3.r, 1 ) );
_color3.g = Math.max( 0, Math.min( material.color.g * _color3.g, 1 ) );
_color3.b = Math.max( 0, Math.min( material.color.b * _color3.b, 1 ) );
_color3.r = Math.max( 0, Math.min( diffuse.r * _color3.r + emissive.r, 1 ) );
_color3.g = Math.max( 0, Math.min( diffuse.g * _color3.g + emissive.g, 1 ) );
_color3.b = Math.max( 0, Math.min( diffuse.b * _color3.b + emissive.b, 1 ) );
_color4.r = Math.max( 0, Math.min( material.color.r * _color4.r, 1 ) );
_color4.g = Math.max( 0, Math.min( material.color.g * _color4.g, 1 ) );
_color4.b = Math.max( 0, Math.min( material.color.b * _color4.b, 1 ) );
_color4.r = Math.max( 0, Math.min( diffuse.r * _color4.r + emissive.r, 1 ) );
_color4.g = Math.max( 0, Math.min( diffuse.g * _color4.g + emissive.g, 1 ) );
_color4.b = Math.max( 0, Math.min( diffuse.b * _color4.b + emissive.b, 1 ) );
_image = getGradientTexture( _color1, _color2, _color3, _color4 );
......@@ -764,9 +770,9 @@ THREE.CanvasRenderer = function ( parameters ) {
calculateLight( element.centroidWorld, element.normalWorld, _color );
_color.r = Math.max( 0, Math.min( material.color.r * _color.r, 1 ) );
_color.g = Math.max( 0, Math.min( material.color.g * _color.g, 1 ) );
_color.b = Math.max( 0, Math.min( material.color.b * _color.b, 1 ) );
_color.r = Math.max( 0, Math.min( diffuse.r * _color.r + emissive.r, 1 ) );
_color.g = Math.max( 0, Math.min( diffuse.g * _color.g + emissive.g, 1 ) );
_color.b = Math.max( 0, Math.min( diffuse.b * _color.b + emissive.b, 1 ) );
drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册