Browse Source

Synced with mrdoob's branch.

alteredq 15 years ago
parent
commit
4a7082165a

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 ) {
 						if ( _enableLighting ) {
 
 
 							_light.copyRGB( _ambientLight );
 							_light.copyRGB( _ambientLight );
+							calculateLight( scene, element, _light );
 
 
 							_color.copyRGBA( material.color );
 							_color.copyRGBA( material.color );
 							_color.multiplySelfRGB( _light );
 							_color.multiplySelfRGB( _light );
@@ -223,6 +224,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 						if ( _enableLighting ) {
 
 
 							_light.copyRGB( _ambientLight );
 							_light.copyRGB( _ambientLight );
+							calculateLight( scene, element, _light );
 
 
 							_color.copyRGBA( material.color );
 							_color.copyRGBA( material.color );
 							_color.multiplySelfRGB( _light );
 							_color.multiplySelfRGB( _light );
@@ -284,7 +286,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 						if ( _enableLighting ) {
 
 
 							_light.copyRGB( _ambientLight );
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 
 							_color.copyRGBA( material.color );
 							_color.copyRGBA( material.color );
 							_color.multiplySelfRGB( _light );
 							_color.multiplySelfRGB( _light );
@@ -311,7 +313,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 						if ( _enableLighting ) {
 
 
 							_light.copyRGB( _ambientLight );
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 
 							_color.copyRGBA( material.color );
 							_color.copyRGBA( material.color );
 							_color.multiplySelfRGB( _light );
 							_color.multiplySelfRGB( _light );
@@ -344,7 +346,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 						if ( _enableLighting ) {
 
 
 							_light.copyRGB( _ambientLight );
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 
 							_color.copyRGBA( element.color );
 							_color.copyRGBA( element.color );
 							_color.multiplySelfRGB( _light );
 							_color.multiplySelfRGB( _light );
@@ -371,7 +373,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 						if ( _enableLighting ) {
 
 
 							_light.copyRGB( _ambientLight );
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 
 							_color.copyRGBA( element.color );
 							_color.copyRGBA( element.color );
 							_color.multiplySelfRGB( _light );
 							_color.multiplySelfRGB( _light );
@@ -491,7 +493,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 						if ( _enableLighting ) {
 
 
 							_light.copyRGB( _ambientLight );
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 
 							_color.copyRGBA( material.color );
 							_color.copyRGBA( material.color );
 							_color.multiplySelfRGB( _light );
 							_color.multiplySelfRGB( _light );
@@ -520,7 +522,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 						if ( _enableLighting ) {
 
 
 							_light.copyRGB( _ambientLight );
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 
 							_color.copyRGBA( material.color );
 							_color.copyRGBA( material.color );
 							_color.multiplySelfRGB( _light );
 							_color.multiplySelfRGB( _light );
@@ -554,7 +556,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 						if ( _enableLighting ) {
 
 
 							_light.copyRGB( _ambientLight );
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 
 							_color.copyRGBA( element.color );
 							_color.copyRGBA( element.color );
 							_color.multiplySelfRGB( _light );
 							_color.multiplySelfRGB( _light );
@@ -582,7 +584,7 @@ THREE.CanvasRenderer = function () {
 						if ( _enableLighting ) {
 						if ( _enableLighting ) {
 
 
 							_light.copyRGB( _ambientLight );
 							_light.copyRGB( _ambientLight );
-							addLights( scene, element, _light );
+							calculateFaceLight( scene, element, _light );
 
 
 							_color.copyRGBA( element.color );
 							_color.copyRGBA( element.color );
 							_color.multiplySelfRGB( _light );
 							_color.multiplySelfRGB( _light );
@@ -699,7 +701,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;
 		var l, ll, light, amount;
 
 

+ 5 - 5
src/renderers/SVGRenderer.js

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

+ 3 - 0
src/renderers/WebGLRenderer.js

@@ -377,6 +377,9 @@ THREE.WebGLRenderer = function () {
     
     
     this.setupMatrices = function ( object, camera ) {
     this.setupMatrices = function ( object, camera ) {
         
         
+        camera.autoUpdateMatrix && camera.updateMatrix();
+        object.autoUpdateMatrix && object.updateMatrix();
+
         _viewMatrix.multiply( camera.matrix, object.matrix );
         _viewMatrix.multiply( camera.matrix, object.matrix );
 
 
         _program.viewMatrixArray = new Float32Array( _viewMatrix.flatten() );
         _program.viewMatrixArray = new Float32Array( _viewMatrix.flatten() );

+ 4 - 4
utils/exporters/blender/2.54/scripts/op/io_mesh_threejs/export_threejs.py

@@ -17,7 +17,7 @@
 # ##### END GPL LICENSE BLOCK #####
 # ##### END GPL LICENSE BLOCK #####
 
 
 # Based on export_ply.py
 # Based on export_ply.py
-# Contributors: Mr.doob, Kikko
+# Contributors: Mr.doob, Kikko, alteredq
 
 
 """
 """
 This script exports the selected object for the three.js engine.
 This script exports the selected object for the three.js engine.
@@ -28,19 +28,19 @@ import os
 import os.path
 import os.path
 
 
 def save(operator, context, filepath="", use_modifiers=True, use_normals=True, use_uv_coords=True, use_colors=True):
 def save(operator, context, filepath="", use_modifiers=True, use_normals=True, use_uv_coords=True, use_colors=True):
-    
+
     def rvec3d(v):
     def rvec3d(v):
         return round(v[0], 6), round(v[1], 6), round(v[2], 6)
         return round(v[0], 6), round(v[1], 6), round(v[2], 6)
 
 
     def rvec2d(v):
     def rvec2d(v):
         return round(v[0], 6), round(v[1], 6)
         return round(v[0], 6), round(v[1], 6)
-    
+
     scene = context.scene
     scene = context.scene
     obj = context.object
     obj = context.object
 
 
     if not filepath.lower().endswith('.js'):
     if not filepath.lower().endswith('.js'):
         filepath += '.js'
         filepath += '.js'
-    
+
     classname = os.path.basename(filepath).split(".")[0]
     classname = os.path.basename(filepath).split(".")[0]
 
 
     if not obj:
     if not obj:

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