Browse Source

* Fixed some minor issues handling opacity in hex colors

Mr.doob 14 years ago
parent
commit
3cdc007b90

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


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


+ 1 - 0
examples/camera_free.html

@@ -22,6 +22,7 @@
 		<script type="text/javascript" src="../src/core/Vector2.js"></script>
 		<script type="text/javascript" src="../src/core/Vector3.js"></script>
 		<script type="text/javascript" src="../src/core/Vector4.js"></script>
+		<script type="text/javascript" src="../src/core/Ray.js"></script>
 		<script type="text/javascript" src="../src/core/Rectangle.js"></script>
 		<script type="text/javascript" src="../src/core/Matrix3.js"></script>
 		<script type="text/javascript" src="../src/core/Matrix4.js"></script>

+ 1 - 7
src/core/Color.js

@@ -4,12 +4,6 @@
 
 THREE.Color = function ( hex ) {
 
-	/*
-	this.r; this.g; this.b; this.a;
-	this.hex;
-	this.__styleString;
-	*/
-
 	this.autoUpdate = true;
 	this.setHex( hex );
 
@@ -73,7 +67,7 @@ THREE.Color.prototype = {
 
 	updateHex: function () {
 
-		this.hex = Math.floor( this.a * 255 ) << 24 | Math.floor( this.r * 255 ) << 16 | Math.floor( this.g * 255 ) << 8 | Math.floor( this.b * 255 );
+		this.hex = Math.floor( this.a * 255 ) << 24 ^ Math.floor( this.r * 255 ) << 16 ^ Math.floor( this.g * 255 ) << 8 ^ Math.floor( this.b * 255 );
 
 	},
 

+ 1 - 2
src/materials/LineColorMaterial.js

@@ -5,8 +5,7 @@
 THREE.LineColorMaterial = function ( hex, opacity, lineWidth ) {
 
 	this.lineWidth = lineWidth || 1;
-
-	this.color = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | hex );
+	this.color = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ hex );
 
 };
 

+ 4 - 5
src/materials/MeshBitmapMaterial.js

@@ -4,11 +4,11 @@
 
 THREE.MeshBitmapMaterial = function ( bitmap, mode ) {
 
+	this.id = THREE.MeshBitmapMaterialCounter.value ++;
+
 	this.bitmap = bitmap;
 	this.mode = mode || THREE.MeshBitmapMaterialMode.UVMAPPING;
-    
-    this.id = THREE.MeshBitmapMaterialCounter.value++;
-    
+
 	this.toString = function () {
 
 		return 'THREE.MeshBitmapMaterial ( bitmap: ' + this.bitmap + ', mode: ' + this.mode + ', id: ' + this.id + ' )';
@@ -17,6 +17,5 @@ THREE.MeshBitmapMaterial = function ( bitmap, mode ) {
 
 };
 
-THREE.MeshBitmapMaterialCounter = { value:0 };
-
+THREE.MeshBitmapMaterialCounter = { value: 0 };
 THREE.MeshBitmapMaterialMode = { UVMAPPING: 0 };

+ 1 - 1
src/materials/MeshColorFillMaterial.js

@@ -4,7 +4,7 @@
 
 THREE.MeshColorFillMaterial = function ( hex, opacity ) {
 
-	this.color = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | hex );
+	this.color = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ hex );
 
 	this.toString = function () {
 

+ 1 - 1
src/materials/MeshColorStrokeMaterial.js

@@ -6,7 +6,7 @@ THREE.MeshColorStrokeMaterial = function ( hex, opacity, lineWidth ) {
 
 	this.lineWidth = lineWidth || 1;
 
-	this.color = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | hex );
+	this.color = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ hex );
 
 	this.toString = function () {
 

+ 6 - 5
src/materials/MeshPhongMaterial.js

@@ -4,11 +4,12 @@
 
 THREE.MeshPhongMaterial = function ( ambient, diffuse, specular, shininess, opacity ) {
 
-	this.ambient = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | ambient );
-	this.diffuse = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | diffuse );
-	this.specular = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | specular );
-    this.shininess = shininess;
-    this.opacity = opacity;
+	this.ambient = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ ambient );
+	this.diffuse = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ diffuse );
+	this.specular = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ specular );
+
+	this.shininess = shininess;
+	this.opacity = opacity;
 
 	this.toString = function () {
 

+ 1 - 1
src/materials/ParticleCircleMaterial.js

@@ -4,7 +4,7 @@
 
 THREE.ParticleCircleMaterial = function ( hex, opacity ) {
 
-	this.color = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | hex );
+	this.color = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ hex );
 
 	this.toString = function () {
 

+ 12 - 11
src/objects/Mesh.js

@@ -52,7 +52,7 @@ THREE.Mesh.prototype.sortFacesByMaterial = function () {
 
 		}
 
-		return hash_array.join("_");
+		return hash_array.join( '_' );
 
 	}
 
@@ -60,40 +60,41 @@ THREE.Mesh.prototype.sortFacesByMaterial = function () {
 
 		face = this.geometry.faces[ f ];
 		material = face.material;
-		
+
 		mhash = materialHash( material );
 
 		if ( hash_map[ mhash ] == undefined ) {
-			
+
 			hash_map[ mhash ] = { 'hash': mhash, 'counter': 0 };
+
 		}
 
-		ghash = hash_map[ mhash ].hash + "_" + hash_map[ mhash ].counter;
+		ghash = hash_map[ mhash ].hash + '_' + hash_map[ mhash ].counter;
 
 		if ( this.materialFaceGroup[ ghash ] == undefined ) {
 
 			this.materialFaceGroup[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 };
 
 		}
-		
+
 		vertices = face instanceof THREE.Face3 ? 3 : 4;
 
 		if ( this.materialFaceGroup[ ghash ].vertices + vertices > 65535 ) {
-			
+
 			hash_map[ mhash ].counter += 1;
-			ghash = hash_map[ mhash ].hash + "_" + hash_map[ mhash ].counter;
-			
+			ghash = hash_map[ mhash ].hash + '_' + hash_map[ mhash ].counter;
+
 			if ( this.materialFaceGroup[ ghash ] == undefined ) {
 
 				this.materialFaceGroup[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 };
 
 			}
-			
+
 		}
-		
+
 		this.materialFaceGroup[ ghash ].faces.push( f );
 		this.materialFaceGroup[ ghash ].vertices += vertices;
-		
+
 
 	}
 

+ 6 - 12
src/scenes/Scene.js

@@ -15,14 +15,11 @@ THREE.Scene = function () {
 
 	this.removeObject = function ( object ) {
 
-		for ( var i = 0, l = this.objects.length; i < l; i++ ) {
+		var i = this.objects.indexOf( object );
 
-			if ( object == this.objects[ i ] ) {
+		if ( i !== -1 ) {
 
-				this.objects.splice( i, 1 );
-				return;
-
-			}
+			this.objects.splice( i, 1 );
 
 		}
 
@@ -36,14 +33,11 @@ THREE.Scene = function () {
 
 	this.removeLight = function ( light ) {
 
-		for ( var i = 0, l = this.lights.length; i < l; i++ ) {
-
-			if ( light == this.lights[ i ] ) {
+		var i = this.lights.indexOf( light );
 
-				this.lights.splice( i, 1 );
-				return;
+		if ( i !== -1 ) {
 
-			}
+			this.lights.splice( i, 1 );
 
 		}
 

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