Browse Source

* CanvasRenderer light per particle and lines

Mr.doob 15 years ago
parent
commit
836f1b878f
4 changed files with 42 additions and 14 deletions
  1. 0 0
      build/Three.js
  2. 0 0
      build/ThreeDebug.js
  3. 37 9
      src/renderers/CanvasRenderer.js
  4. 5 5
      src/renderers/SVGRenderer.js

File diff suppressed because it is too large
+ 0 - 0
build/Three.js


File diff suppressed because it is too large
+ 0 - 0
build/ThreeDebug.js


+ 37 - 9
src/renderers/CanvasRenderer.js

@@ -109,6 +109,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 
 							_light.copyRGB( _ambientLight );
+							calculateLight( scene, element, _light );
 
 							_color.copyRGBA( material.color );
 							_color.multiplySelfRGB( _light );
@@ -223,6 +224,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 
 							_light.copyRGB( _ambientLight );
+							calculateLight( scene, element, _light );
 
 							_color.copyRGBA( material.color );
 							_color.multiplySelfRGB( _light );
@@ -284,7 +286,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 							_color.copyRGBA( material.color );
 							_color.multiplySelfRGB( _light );
@@ -311,7 +313,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 							_color.copyRGBA( material.color );
 							_color.multiplySelfRGB( _light );
@@ -344,7 +346,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 							_color.copyRGBA( element.color );
 							_color.multiplySelfRGB( _light );
@@ -371,7 +373,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 							_color.copyRGBA( element.color );
 							_color.multiplySelfRGB( _light );
@@ -490,7 +492,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 							_color.copyRGBA( material.color );
 							_color.multiplySelfRGB( _light );
@@ -519,7 +521,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 							_color.copyRGBA( material.color );
 							_color.multiplySelfRGB( _light );
@@ -553,7 +555,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 							_color.copyRGBA( element.color );
 							_color.multiplySelfRGB( _light );
@@ -581,7 +583,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 							_color.copyRGBA( element.color );
 							_color.multiplySelfRGB( _light );
@@ -697,7 +699,33 @@ THREE.CanvasRenderer = function () {
 
 	}
 
-	function addLights( scene, element, color ) {
+	function calculateLight( scene, element, color ) {
+
+		var l, ll, light;
+
+		for ( l = 0, ll = scene.lights.length; l < ll; l++ ) {
+
+			light = scene.lights[ l ];
+
+			if ( light instanceof THREE.DirectionalLight ) {
+
+				color.r += light.color.r;
+				color.g += light.color.g;
+				color.b += light.color.b;
+
+			} else if ( light instanceof THREE.PointLight ) {
+
+				color.r += light.color.r;
+				color.g += light.color.g;
+				color.b += light.color.b;
+
+			}
+
+		}
+
+	}
+
+	function calculateFaceLight( scene, element, color ) {
 
 		var l, ll, light, amount;
 

+ 5 - 5
src/renderers/SVGRenderer.js

@@ -159,7 +159,7 @@ THREE.SVGRenderer = function () {
 					if ( _enableLighting ) {
 
 						_light.copyRGB( _ambientLight );
-						addLights( scene, element, _light );
+						calculateFaceLight( scene, element, _light );
 
 						_color.copyRGBA( material.color );
 						_color.multiplySelfRGB( _light );
@@ -178,7 +178,7 @@ THREE.SVGRenderer = function () {
 					if ( _enableLighting ) {
 
 						_light.copyRGB( _ambientLight );
-						addLights( scene, element, _light );
+						calculateFaceLight( scene, element, _light );
 
 						_color.copyRGBA( element.color );
 						_color.multiplySelfRGB( _light );
@@ -197,7 +197,7 @@ THREE.SVGRenderer = function () {
 					if ( _enableLighting ) {
 
 						_light.copyRGB( _ambientLight );
-						addLights( scene, element, _light );
+						calculateFaceLight( scene, element, _light );
 
 						_color.copyRGBA( material.color );
 						_color.multiplySelfRGB( _light );
@@ -216,7 +216,7 @@ THREE.SVGRenderer = function () {
 					if ( _enableLighting ) {
 
 						_light.copyRGB( _ambientLight );
-						addLights( scene, element, _light );
+						calculateFaceLight( scene, element, _light );
 
 						_color.copyRGBA( element.color );
 						_color.multiplySelfRGB( _light );
@@ -262,7 +262,7 @@ THREE.SVGRenderer = function () {
 
 	}
 
-	function addLights( scene, element, color ) {
+	function calculateFaceLight( scene, element, color ) {
 
 		var l, ll, light, amount;
 

Some files were not shown because too many files changed in this diff