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

* Fixed some minor issues handling opacity in hex colors

上级 1849e905
此差异已折叠。
此差异已折叠。
......@@ -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>
......
......@@ -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 );
},
......
......@@ -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,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 };
......@@ -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 () {
......
......@@ -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 () {
......
......@@ -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 () {
......
......@@ -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 () {
......
......@@ -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;
}
......
......@@ -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 );
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册