Browse Source

Minor changes.
Trying to catch a bug with SmoothShading material objects with no vertexNormals.

Mr.doob 14 years ago
parent
commit
dde35ca06e

+ 0 - 2
examples/materials_multimaterials.html

@@ -32,8 +32,6 @@
 
 			<p>Model by <a href="http://sketchup.google.com/3dwarehouse/details?mid=2c6fd128fca34052adc5f5b98d513da1">Reallusion iClone</a>
 
-			<p>Using a modified version of <a href="http://github.com/alteredq/three.js">Three.js</a> by mrdoob.
-
 			<br/>
 			<p>Best viewed in Chrome 8/9 or Firefox 4 using WebGL renderer.
 			<p>Canvas renderer is very slow on anything other than Chrome.

+ 1 - 1
src/materials/textures/Texture.js

@@ -33,6 +33,6 @@ THREE.RefractionMapping = 2;
 THREE.Multiply = 0;
 THREE.Mix = 1;
 
-THREE.Repeat = 0;
+THREE.Repeat = 0; // TODO: Rename to *Wrapping
 THREE.ClampToEdge = 1;
 THREE.MirroredRepeat = 2;

+ 3 - 2
src/renderers/CanvasRenderer.js

@@ -503,7 +503,7 @@ THREE.CanvasRenderer = function () {
 
 			if ( _enableLighting ) {
 
-				if ( material.shading == THREE.SmoothShading && !material.wireframe ) {
+				if ( !material.wireframe && material.shading == THREE.SmoothShading && element.vertexNormalsWorld.length == 3 ) {
 
 					_color1.r = _color2.r = _color3.r = _ambientLight.r;
 					_color1.g = _color2.g = _color3.g = _ambientLight.g;
@@ -611,7 +611,8 @@ THREE.CanvasRenderer = function () {
 		setLineWidth( linewidth );
 
 		_context.stroke();
-		// _bboxRect.inflate( linewidth * 2 );
+
+		_bboxRect.inflate( linewidth * 2 );
 
 	}
 

+ 6 - 1
src/renderers/Projector.js

@@ -114,7 +114,8 @@ THREE.Projector = function() {
 
 								for ( n = 0, nl = faceVertexNormals.length; n < nl; n ++ ) {
 
-									normal = _face3VertexNormals[ n ].copy( faceVertexNormals[ n ] );
+									normal = _face3VertexNormals[ n ] = _face3VertexNormals[ n ] || new THREE.Vector3();
+									normal.copy( faceVertexNormals[ n ] );
 									objectRotationMatrix.transform( normal );
 
 								}
@@ -172,6 +173,8 @@ THREE.Projector = function() {
 								_face3.centroidScreen.copy( _face3.centroidWorld );
 								_projScreenMatrix.transform( _face3.centroidScreen );
 
+								// TODO: Handle vertex normals
+
 								_face3.z = _face3.centroidScreen.z;
 
 								_face3.meshMaterial = objectMaterial;
@@ -206,6 +209,8 @@ THREE.Projector = function() {
 								_face32.centroidWorld.copy( _face3.centroidWorld );
 								_face32.centroidScreen.copy( _face3.centroidScreen );
 
+								// TODO: Handle vertex normals
+
 								_face32.z = _face32.centroidScreen.z;
 
 								_face32.meshMaterial = objectMaterial;

+ 1 - 1
src/renderers/renderables/RenderableFace3.js

@@ -14,7 +14,7 @@ THREE.RenderableFace3 = function () {
 	this.centroidScreen = new THREE.Vector3();
 
 	this.normalWorld = new THREE.Vector3();
-	this.vertexNormalsWorld = [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ];
+	this.vertexNormalsWorld = [];
 
 	this.meshMaterial = null;
 	this.faceMaterial = null;