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

* Fixed some minor issues handling opacity in hex colors

上级 1849e905
此差异已折叠。
此差异已折叠。
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<script type="text/javascript" src="../src/core/Vector2.js"></script> <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/Vector3.js"></script>
<script type="text/javascript" src="../src/core/Vector4.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/Rectangle.js"></script>
<script type="text/javascript" src="../src/core/Matrix3.js"></script> <script type="text/javascript" src="../src/core/Matrix3.js"></script>
<script type="text/javascript" src="../src/core/Matrix4.js"></script> <script type="text/javascript" src="../src/core/Matrix4.js"></script>
......
...@@ -4,12 +4,6 @@ ...@@ -4,12 +4,6 @@
THREE.Color = function ( hex ) { THREE.Color = function ( hex ) {
/*
this.r; this.g; this.b; this.a;
this.hex;
this.__styleString;
*/
this.autoUpdate = true; this.autoUpdate = true;
this.setHex( hex ); this.setHex( hex );
...@@ -73,7 +67,7 @@ THREE.Color.prototype = { ...@@ -73,7 +67,7 @@ THREE.Color.prototype = {
updateHex: function () { 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 @@ ...@@ -5,8 +5,7 @@
THREE.LineColorMaterial = function ( hex, opacity, lineWidth ) { THREE.LineColorMaterial = function ( hex, opacity, lineWidth ) {
this.lineWidth = lineWidth || 1; this.lineWidth = lineWidth || 1;
this.color = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ hex );
this.color = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | hex );
}; };
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
THREE.MeshBitmapMaterial = function ( bitmap, mode ) { THREE.MeshBitmapMaterial = function ( bitmap, mode ) {
this.id = THREE.MeshBitmapMaterialCounter.value ++;
this.bitmap = bitmap; this.bitmap = bitmap;
this.mode = mode || THREE.MeshBitmapMaterialMode.UVMAPPING; this.mode = mode || THREE.MeshBitmapMaterialMode.UVMAPPING;
this.id = THREE.MeshBitmapMaterialCounter.value++;
this.toString = function () { this.toString = function () {
return 'THREE.MeshBitmapMaterial ( bitmap: ' + this.bitmap + ', mode: ' + this.mode + ', id: ' + this.id + ' )'; return 'THREE.MeshBitmapMaterial ( bitmap: ' + this.bitmap + ', mode: ' + this.mode + ', id: ' + this.id + ' )';
...@@ -17,6 +17,5 @@ THREE.MeshBitmapMaterial = function ( bitmap, mode ) { ...@@ -17,6 +17,5 @@ THREE.MeshBitmapMaterial = function ( bitmap, mode ) {
}; };
THREE.MeshBitmapMaterialCounter = { value:0 }; THREE.MeshBitmapMaterialCounter = { value: 0 };
THREE.MeshBitmapMaterialMode = { UVMAPPING: 0 }; THREE.MeshBitmapMaterialMode = { UVMAPPING: 0 };
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
THREE.MeshColorFillMaterial = function ( hex, opacity ) { 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 () { this.toString = function () {
......
...@@ -6,7 +6,7 @@ THREE.MeshColorStrokeMaterial = function ( hex, opacity, lineWidth ) { ...@@ -6,7 +6,7 @@ THREE.MeshColorStrokeMaterial = function ( hex, opacity, lineWidth ) {
this.lineWidth = lineWidth || 1; 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 () { this.toString = function () {
......
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
THREE.MeshPhongMaterial = function ( ambient, diffuse, specular, shininess, opacity ) { THREE.MeshPhongMaterial = function ( ambient, diffuse, specular, shininess, opacity ) {
this.ambient = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | ambient ); this.ambient = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ ambient );
this.diffuse = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | diffuse ); this.diffuse = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ diffuse );
this.specular = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | specular ); this.specular = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ specular );
this.shininess = shininess;
this.opacity = opacity; this.shininess = shininess;
this.opacity = opacity;
this.toString = function () { this.toString = function () {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
THREE.ParticleCircleMaterial = function ( hex, opacity ) { 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 () { this.toString = function () {
......
...@@ -52,7 +52,7 @@ THREE.Mesh.prototype.sortFacesByMaterial = 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 () { ...@@ -60,40 +60,41 @@ THREE.Mesh.prototype.sortFacesByMaterial = function () {
face = this.geometry.faces[ f ]; face = this.geometry.faces[ f ];
material = face.material; material = face.material;
mhash = materialHash( material ); mhash = materialHash( material );
if ( hash_map[ mhash ] == undefined ) { if ( hash_map[ mhash ] == undefined ) {
hash_map[ mhash ] = { 'hash': mhash, 'counter': 0 }; 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 ) { if ( this.materialFaceGroup[ ghash ] == undefined ) {
this.materialFaceGroup[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 }; this.materialFaceGroup[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 };
} }
vertices = face instanceof THREE.Face3 ? 3 : 4; vertices = face instanceof THREE.Face3 ? 3 : 4;
if ( this.materialFaceGroup[ ghash ].vertices + vertices > 65535 ) { if ( this.materialFaceGroup[ ghash ].vertices + vertices > 65535 ) {
hash_map[ mhash ].counter += 1; 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 ) { if ( this.materialFaceGroup[ ghash ] == undefined ) {
this.materialFaceGroup[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 }; this.materialFaceGroup[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 };
} }
} }
this.materialFaceGroup[ ghash ].faces.push( f ); this.materialFaceGroup[ ghash ].faces.push( f );
this.materialFaceGroup[ ghash ].vertices += vertices; this.materialFaceGroup[ ghash ].vertices += vertices;
} }
......
...@@ -15,14 +15,11 @@ THREE.Scene = function () { ...@@ -15,14 +15,11 @@ THREE.Scene = function () {
this.removeObject = function ( object ) { 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 ); this.objects.splice( i, 1 );
return;
}
} }
...@@ -36,14 +33,11 @@ THREE.Scene = function () { ...@@ -36,14 +33,11 @@ THREE.Scene = function () {
this.removeLight = function ( light ) { this.removeLight = function ( light ) {
for ( var i = 0, l = this.lights.length; i < l; i++ ) { var i = this.lights.indexOf( light );
if ( light == this.lights[ i ] ) {
this.lights.splice( i, 1 ); if ( i !== -1 ) {
return;
} this.lights.splice( i, 1 );
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册