Browse Source

Trying to be nicer to V8.

Mr.doob 13 years ago
parent
commit
46294a0f08
6 changed files with 160 additions and 79 deletions
  1. 1 1
      src/cameras/Camera.js
  2. 8 7
      src/core/Frustum.js
  3. 5 7
      src/core/Object3D.js
  4. 87 16
      src/core/Projector.js
  5. 10 5
      src/core/Rectangle.js
  6. 49 43
      src/renderers/CanvasRenderer.js

+ 1 - 1
src/cameras/Camera.js

@@ -22,7 +22,7 @@ THREE.Camera.prototype.lookAt = function ( vector ) {
 
 	this.matrix.lookAt( this.position, vector, this.up );
 
-	if ( this.rotationAutoUpdate ) {
+	if ( this.rotationAutoUpdate === true ) {
 
 		this.rotation.setEulerFromRotationMatrix( this.matrix, this.eulerOrder );
 

+ 8 - 7
src/core/Frustum.js

@@ -20,7 +20,8 @@ THREE.Frustum = function ( ) {
 
 THREE.Frustum.prototype.setFromMatrix = function ( m ) {
 
-	var i, plane, planes = this.planes;
+	var plane;
+	var planes = this.planes;
 
 	var me = m.elements;
 	var me0 = me[0], me1 = me[1], me2 = me[2], me3 = me[3];
@@ -35,7 +36,7 @@ THREE.Frustum.prototype.setFromMatrix = function ( m ) {
 	planes[ 4 ].set( me3 - me2, me7 - me6, me11 - me10, me15 - me14 );
 	planes[ 5 ].set( me3 + me2, me7 + me6, me11 + me10, me15 + me14 );
 
-	for ( i = 0; i < 6; i ++ ) {
+	for ( var i = 0; i < 6; i ++ ) {
 
 		plane = planes[ i ];
 		plane.divideScalar( Math.sqrt( plane.x * plane.x + plane.y * plane.y + plane.z * plane.z ) );
@@ -46,11 +47,11 @@ THREE.Frustum.prototype.setFromMatrix = function ( m ) {
 
 THREE.Frustum.prototype.contains = function ( object ) {
 
-	var distance,
-	planes = this.planes,
-	matrix = object.matrixWorld,
-	me = matrix.elements,
-	radius = - object.geometry.boundingSphere.radius * matrix.getMaxScaleOnAxis();
+	var distance = 0.0;
+	var planes = this.planes;
+	var matrix = object.matrixWorld;
+	var me = matrix.elements;
+	var radius = - object.geometry.boundingSphere.radius * matrix.getMaxScaleOnAxis();
 
 	for ( var i = 0; i < 6; i ++ ) {
 

+ 5 - 7
src/core/Object3D.js

@@ -117,7 +117,7 @@ THREE.Object3D.prototype = {
 
 		}
 
-		if ( object instanceof THREE.Object3D ) { // && this.children.indexOf( object ) === - 1
+		if ( object instanceof THREE.Object3D ) {
 
 			if ( object.parent !== undefined ) {
 
@@ -213,7 +213,7 @@ THREE.Object3D.prototype = {
 
 		this.matrix.setPosition( this.position );
 
-		if ( this.useQuaternion )  {
+		if ( this.useQuaternion === true )  {
 
 			this.matrix.setRotationFromQuaternion( this.quaternion );
 
@@ -236,13 +236,11 @@ THREE.Object3D.prototype = {
 
 	updateMatrixWorld: function ( force ) {
 
-		this.matrixAutoUpdate && this.updateMatrix();
+		if ( this.matrixAutoUpdate === true ) this.updateMatrix();
 
-		// update matrixWorld
+		if ( this.matrixWorldNeedsUpdate === true || force === true ) {
 
-		if ( this.matrixWorldNeedsUpdate || force ) {
-
-			if ( this.parent ) {
+			if ( this.parent !== undefined ) {
 
 				this.matrixWorld.multiply( this.parent.matrixWorld, this.matrix );
 

+ 87 - 16
src/core/Projector.js

@@ -80,7 +80,7 @@ THREE.Projector = function() {
 			if ( object.visible === false ) return;
 
 			if ( ( object instanceof THREE.Mesh || object instanceof THREE.Line ) &&
-			( object.frustumCulled === false || _frustum.contains( object ) ) ) {
+			( object.frustumCulled === false || _frustum.contains( object ) === true ) ) {
 
 				_vector3.copy( object.matrixWorld.getPosition() );
 				_projScreenMatrix.multiplyVector3( _vector3 );
@@ -118,7 +118,7 @@ THREE.Projector = function() {
 
 		projectObject( root );
 
-		sort && _renderData.objects.sort( painterSort );
+		if ( sort === true ) _renderData.objects.sort( painterSort );
 
 		return _renderData;
 
@@ -202,12 +202,12 @@ THREE.Projector = function() {
 						v2 = _vertexPool[ face.b ];
 						v3 = _vertexPool[ face.c ];
 
-						if ( v1.visible && v2.visible && v3.visible ) {
+						if ( v1.visible === true && v2.visible === true && v3.visible === true ) {
 
 							visible = ( ( v3.positionScreen.x - v1.positionScreen.x ) * ( v2.positionScreen.y - v1.positionScreen.y ) -
 								( v3.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) ) < 0;
 
-							if ( object.doubleSided || visible != object.flipSided ) {
+							if ( object.doubleSided === true || visible !== object.flipSided ) {
 
 								_face = getNextFace3InPool();
 
@@ -234,7 +234,7 @@ THREE.Projector = function() {
 						v3 = _vertexPool[ face.c ];
 						v4 = _vertexPool[ face.d ];
 
-						if ( v1.visible && v2.visible && v3.visible && v4.visible ) {
+						if ( v1.visible === true && v2.visible === true && v3.visible === true && v4.visible === true ) {
 
 							visible = ( v4.positionScreen.x - v1.positionScreen.x ) * ( v2.positionScreen.y - v1.positionScreen.y ) -
 								( v4.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) < 0 ||
@@ -242,7 +242,7 @@ THREE.Projector = function() {
 								( v2.positionScreen.y - v3.positionScreen.y ) * ( v4.positionScreen.x - v3.positionScreen.x ) < 0;
 
 
-							if ( object.doubleSided || visible != object.flipSided ) {
+							if ( object.doubleSided === true || visible !== object.flipSided ) {
 
 								_face = getNextFace4InPool();
 
@@ -266,7 +266,7 @@ THREE.Projector = function() {
 					}
 
 					_face.normalWorld.copy( face.normal );
-					if ( !visible && ( object.flipSided || object.doubleSided ) ) _face.normalWorld.negate();
+					if ( visible === false && ( object.flipSided === true || object.doubleSided === true ) ) _face.normalWorld.negate();
 					objectMatrixWorldRotation.multiplyVector3( _face.normalWorld );
 
 					_face.centroidWorld.copy( face.centroid );
@@ -281,7 +281,9 @@ THREE.Projector = function() {
 
 						normal = _face.vertexNormalsWorld[ n ];
 						normal.copy( faceVertexNormals[ n ] );
-						if ( !visible && ( object.flipSided || object.doubleSided ) ) normal.negate();
+
+						if ( visible === false && ( object.flipSided === true || object.doubleSided === true ) ) normal.negate();
+
 						objectMatrixWorldRotation.multiplyVector3( normal );
 
 					}
@@ -290,7 +292,7 @@ THREE.Projector = function() {
 
 						uvs = faceVertexUvs[ c ][ f ];
 
-						if ( !uvs ) continue;
+						if ( uvs === undefined ) continue;
 
 						for ( u = 0, ul = uvs.length; u < ul; u ++ ) {
 
@@ -335,7 +337,7 @@ THREE.Projector = function() {
 					_clippedVertex1PositionScreen.copy( v1.positionScreen );
 					_clippedVertex2PositionScreen.copy( v2.positionScreen );
 
-					if ( clipLine( _clippedVertex1PositionScreen, _clippedVertex2PositionScreen ) ) {
+					if ( clipLine( _clippedVertex1PositionScreen, _clippedVertex2PositionScreen ) === true ) {
 
 						// Perform the perspective divide
 						_clippedVertex1PositionScreen.multiplyScalar( 1 / _clippedVertex1PositionScreen.w );
@@ -404,7 +406,18 @@ THREE.Projector = function() {
 
 	function getNextObjectInPool() {
 
-		var object = _objectPool[ _objectCount ] = _objectPool[ _objectCount ] || new THREE.RenderableObject();
+		var object;
+
+		if ( _objectCount === _objectPool.length ) {
+
+			object = new THREE.RenderableObject();
+			_objectPool.push( object );
+
+		} else {
+
+			object =  _objectPool[ _objectCount ];
+
+		}
 
 		_objectCount ++;
 
@@ -414,7 +427,18 @@ THREE.Projector = function() {
 
 	function getNextVertexInPool() {
 
-		var vertex = _vertexPool[ _vertexCount ] = _vertexPool[ _vertexCount ] || new THREE.RenderableVertex();
+		var vertex;
+
+		if ( _vertexCount === _vertexPool.length ) {
+
+			vertex = new THREE.RenderableVertex();
+			_vertexPool.push( vertex );
+
+		} else {
+
+			vertex =  _vertexPool[ _vertexCount ];
+
+		}
 
 		_vertexCount ++;
 
@@ -424,17 +448,40 @@ THREE.Projector = function() {
 
 	function getNextFace3InPool() {
 
-		var face = _face3Pool[ _face3Count ] = _face3Pool[ _face3Count ] || new THREE.RenderableFace3();
+		var face;
+
+		if ( _face3Count === _face3Pool.length ) {
+
+			face = new THREE.RenderableFace3();
+			_face3Pool.push( face );
+
+		} else {
+
+			face =  _face3Pool[ _face3Count ];
+
+		}
 
 		_face3Count ++;
 
 		return face;
 
+
 	}
 
 	function getNextFace4InPool() {
 
-		var face = _face4Pool[ _face4Count ] = _face4Pool[ _face4Count ] || new THREE.RenderableFace4();
+		var face;
+
+		if ( _face4Count === _face4Pool.length ) {
+
+			face = new THREE.RenderableFace4();
+			_face4Pool.push( face );
+
+		} else {
+
+			face =  _face4Pool[ _face4Count ];
+
+		}
 
 		_face4Count ++;
 
@@ -444,7 +491,18 @@ THREE.Projector = function() {
 
 	function getNextLineInPool() {
 
-		var line = _linePool[ _lineCount ] = _linePool[ _lineCount ] || new THREE.RenderableLine();
+		var line;
+
+		if ( _lineCount === _linePool.length ) {
+
+			line = new THREE.RenderableLine();
+			_linePool.push( line );
+
+		} else {
+
+			line =  _linePool[ _lineCount ];
+
+		}
 
 		_lineCount ++;
 
@@ -454,8 +512,21 @@ THREE.Projector = function() {
 
 	function getNextParticleInPool() {
 
-		var particle = _particlePool[ _particleCount ] = _particlePool[ _particleCount ] || new THREE.RenderableParticle();
+		var particle;
+
+		if ( _particleCount === _particlePool.length ) {
+
+			particle = new THREE.RenderableParticle();
+			_particlePool.push( particle );
+
+		} else {
+
+			particle =  _particlePool[ _particleCount ];
+
+		}
+
 		_particleCount ++;
+
 		return particle;
 
 	}

+ 10 - 5
src/core/Rectangle.js

@@ -4,8 +4,13 @@
 
 THREE.Rectangle = function () {
 
-	var _left, _top, _right, _bottom,
-	_width, _height, _isEmpty = true;
+	var _left = 0;
+	var _top = 0;
+	var _right = 0;
+	var _bottom = 0;
+	var _width = 0;
+	var _height = 0;
+	var _isEmpty = true;
 
 	function resize() {
 
@@ -75,7 +80,7 @@ THREE.Rectangle = function () {
 
 	this.addPoint = function ( x, y ) {
 
-		if ( _isEmpty ) {
+		if ( _isEmpty === true ) {
 
 			_isEmpty = false;
 			_left = x; _top = y;
@@ -97,7 +102,7 @@ THREE.Rectangle = function () {
 
 	this.add3Points = function ( x1, y1, x2, y2, x3, y3 ) {
 
-		if (_isEmpty) {
+		if ( _isEmpty === true ) {
 
 			_isEmpty = false;
 			_left = x1 < x2 ? ( x1 < x3 ? x1 : x3 ) : ( x2 < x3 ? x2 : x3 );
@@ -122,7 +127,7 @@ THREE.Rectangle = function () {
 
 	this.addRectangle = function ( r ) {
 
-		if ( _isEmpty ) {
+		if ( _isEmpty === true ) {
 
 			_isEmpty = false;
 			_left = r.getLeft(); _top = r.getTop();

+ 49 - 43
src/renderers/CanvasRenderer.js

@@ -144,7 +144,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 		_context.setTransform( 1, 0, 0, - 1, _canvasWidthHalf, _canvasHeightHalf );
 
-		if ( !_clearRect.isEmpty() ) {
+		if ( _clearRect.isEmpty() === false ) {
 
 			_clearRect.minSelf( _clipRect );
 			_clearRect.inflate( 2 );
@@ -177,7 +177,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 		var e, el, element, material;
 
-		this.autoClear ? this.clear() : _context.setTransform( 1, 0, 0, - 1, _canvasWidthHalf, _canvasHeightHalf );
+		this.autoClear === true ? this.clear() : _context.setTransform( 1, 0, 0, - 1, _canvasWidthHalf, _canvasHeightHalf );
 
 		_this.info.render.vertices = 0;
 		_this.info.render.faces = 0;
@@ -193,7 +193,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 		_enableLighting = _lights.length > 0;
 
-		if ( _enableLighting ) {
+		if ( _enableLighting === true ) {
 
 			 calculateLights( _lights );
 
@@ -227,7 +227,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 				_bboxRect.addPoint( _v1.positionScreen.x, _v1.positionScreen.y );
 				_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
 
-				if ( _clipRect.intersects( _bboxRect ) ) {
+				if ( _clipRect.intersects( _bboxRect ) === true ) {
 
 					renderLine( _v1, _v2, element, material, scene );
 
@@ -242,7 +242,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 				_v2.positionScreen.x *= _canvasWidthHalf; _v2.positionScreen.y *= _canvasHeightHalf;
 				_v3.positionScreen.x *= _canvasWidthHalf; _v3.positionScreen.y *= _canvasHeightHalf;
 
-				if ( material.overdraw ) {
+				if ( material.overdraw === true ) {
 
 					expand( _v1.positionScreen, _v2.positionScreen );
 					expand( _v2.positionScreen, _v3.positionScreen );
@@ -254,7 +254,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 						      _v2.positionScreen.x, _v2.positionScreen.y,
 						      _v3.positionScreen.x, _v3.positionScreen.y );
 
-				if ( _clipRect.intersects( _bboxRect ) ) {
+				if ( _clipRect.intersects( _bboxRect ) === true ) {
 
 					renderFace3( _v1, _v2, _v3, 0, 1, 2, element, material, scene );
 
@@ -272,7 +272,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 				_v5.positionScreen.copy( _v2.positionScreen );
 				_v6.positionScreen.copy( _v4.positionScreen );
 
-				if ( material.overdraw ) {
+				if ( material.overdraw === true ) {
 
 					expand( _v1.positionScreen, _v2.positionScreen );
 					expand( _v2.positionScreen, _v4.positionScreen );
@@ -288,7 +288,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 				_bboxRect.addPoint( _v3.positionScreen.x, _v3.positionScreen.y );
 				_bboxRect.addPoint( _v4.positionScreen.x, _v4.positionScreen.y );
 
-				if ( _clipRect.intersects( _bboxRect ) ) {
+				if ( _clipRect.intersects( _bboxRect ) === true ) {
 
 					renderFace4( _v1, _v2, _v3, _v4, _v5, _v6, element, material, scene );
 
@@ -415,7 +415,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 			if ( material instanceof THREE.ParticleBasicMaterial ) {
 
-				if ( material.map ) {
+				if ( material.map !== null ) {
 
 					bitmap = material.map.image;
 					bitmapWidth = bitmap.width >> 1;
@@ -431,7 +431,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 					_bboxRect.set( v1.x - width, v1.y - height, v1.x  + width, v1.y + height );
 
-					if ( !_clipRect.intersects( _bboxRect ) ) {
+					if ( _clipRect.intersects( _bboxRect ) === false ) {
 
 						return;
 
@@ -467,7 +467,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 				_bboxRect.set( v1.x - width, v1.y - height, v1.x + width, v1.y + height );
 
-				if ( !_clipRect.intersects( _bboxRect ) ) {
+				if ( _clipRect.intersects( _bboxRect ) === false ) {
 
 					return;
 
@@ -529,7 +529,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 			if ( material instanceof THREE.MeshBasicMaterial ) {
 
-				if ( material.map ) {
+				if ( material.map !== null ) {
 
 					if ( material.map.mapping instanceof THREE.UVMapping ) {
 
@@ -539,7 +539,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 					}
 
 
-				} else if ( material.envMap ) {
+				} else if ( material.envMap !== null ) {
 
 					if ( material.envMap.mapping instanceof THREE.SphericalReflectionMapping ) {
 
@@ -568,15 +568,15 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 				} else {
 
-					material.wireframe ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color );
+					material.wireframe === true ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color );
 
 				}
 
 			} else if ( material instanceof THREE.MeshLambertMaterial ) {
 
-				if ( _enableLighting ) {
+				if ( _enableLighting === true ) {
 
-					if ( !material.wireframe && material.shading == THREE.SmoothShading && element.vertexNormalsWorld.length == 3 ) {
+					if ( material.wireframe === false && material.shading == THREE.SmoothShading && element.vertexNormalsWorld.length == 3 ) {
 
 						_color1.r = _color2.r = _color3.r = _ambientLight.r;
 						_color1.g = _color2.g = _color3.g = _ambientLight.g;
@@ -618,13 +618,13 @@ THREE.CanvasRenderer = function ( parameters ) {
 						_color.g = Math.max( 0, Math.min( material.color.g * _color.g, 1 ) );
 						_color.b = Math.max( 0, Math.min( material.color.b * _color.b, 1 ) );
 
-						material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
+						material.wireframe === true ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
 
 					}
 
 				} else {
 
-					material.wireframe ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color );
+					material.wireframe === true ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color );
 
 				}
 
@@ -651,7 +651,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 				_color.g = normalToComponent( element.normalWorld.y );
 				_color.b = normalToComponent( element.normalWorld.z );
 
-				material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
+				material.wireframe === true ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
 
 			}
 
@@ -665,7 +665,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 			setOpacity( material.opacity );
 			setBlending( material.blending );
 
-			if ( material.map || material.envMap ) {
+			if ( material.map !== null || material.envMap !== null ) {
 
 				// Let renderFace3() handle this
 
@@ -687,11 +687,11 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 				drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y );
 
-				material.wireframe ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color );
+				material.wireframe === true ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color );
 
 			} else if ( material instanceof THREE.MeshLambertMaterial ) {
 
-				if ( _enableLighting ) {
+				if ( _enableLighting === true ) {
 
 					if ( !material.wireframe && material.shading == THREE.SmoothShading && element.vertexNormalsWorld.length == 4 ) {
 
@@ -744,7 +744,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 						drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y );
 
-						material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
+						material.wireframe === true ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
 
 					}
 
@@ -752,7 +752,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 					drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y );
 
-					material.wireframe ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color );
+					material.wireframe === true ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color );
 
 				}
 
@@ -764,7 +764,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 				drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y );
 
-				material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
+				material.wireframe === true ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
 
 			} else if ( material instanceof THREE.MeshDepthMaterial ) {
 
@@ -842,7 +842,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 				var repeatX = texture.wrapS == THREE.RepeatWrapping;
 				var repeatY = texture.wrapT == THREE.RepeatWrapping;
 
-				_patterns[ texture.id ] = _context.createPattern( texture.image, repeatX && repeatY ? 'repeat' : repeatX && !repeatY ? 'repeat-x' : !repeatX && repeatY ? 'repeat-y' : 'no-repeat' );
+				_patterns[ texture.id ] = _context.createPattern( texture.image, repeatX === true && repeatY === true ? 'repeat' : repeatX === true && repeatY === false ? 'repeat-x' : repeatX === false && repeatY === true ? 'repeat-y' : 'no-repeat' );
 
 				texture.needsUpdate = false;
 
@@ -875,7 +875,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 			det = u1 * v2 - u2 * v1;
 
-			if ( det == 0 ) {
+			if ( det === 0 ) {
 
 				if ( _imagedatas[ texture.id ] === undefined ) {
 
@@ -1011,7 +1011,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 			var x = v2.x - v1.x, y =  v2.y - v1.y,
 			det = x * x + y * y, idet;
 
-			if ( det == 0 ) return;
+			if ( det === 0 ) return;
 
 			idet = 1 / Math.sqrt( det );
 
@@ -1027,9 +1027,10 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 	function setOpacity( value ) {
 
-		if ( _contextGlobalAlpha != value ) {
+		if ( _contextGlobalAlpha !== value ) {
 
-			_context.globalAlpha = _contextGlobalAlpha = value;
+			_context.globalAlpha = value;
+			_contextGlobalAlpha = value;
 
 		}
 
@@ -1037,7 +1038,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 	function setBlending( value ) {
 
-		if ( _contextGlobalCompositeOperation != value ) {
+		if ( _contextGlobalCompositeOperation !== value ) {
 
 			switch ( value ) {
 
@@ -1069,9 +1070,10 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 	function setLineWidth( value ) {
 
-		if ( _contextLineWidth != value ) {
+		if ( _contextLineWidth !== value ) {
 
-			_context.lineWidth = _contextLineWidth = value;
+			_context.lineWidth = value;
+			_contextLineWidth = value;
 
 		}
 
@@ -1081,9 +1083,10 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 		// "butt", "round", "square"
 
-		if ( _contextLineCap != value ) {
+		if ( _contextLineCap !== value ) {
 
-			_context.lineCap = _contextLineCap = value;
+			_context.lineCap = value;
+			_contextLineCap = value;
 
 		}
 
@@ -1093,29 +1096,32 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 		// "round", "bevel", "miter"
 
-		if ( _contextLineJoin != value ) {
+		if ( _contextLineJoin !== value ) {
 
-			_context.lineJoin = _contextLineJoin = value;
+			_context.lineJoin = value;
+			_contextLineJoin = value;
 
 		}
 
 	}
 
-	function setStrokeStyle( style ) {
+	function setStrokeStyle( value ) {
 
-		if ( _contextStrokeStyle != style ) {
+		if ( _contextStrokeStyle !== value ) {
 
-			_context.strokeStyle = _contextStrokeStyle = style;
+			_context.strokeStyle = value;
+			_contextStrokeStyle = value;
 
 		}
 
 	}
 
-	function setFillStyle( style ) {
+	function setFillStyle( value ) {
 
-		if ( _contextFillStyle != style ) {
+		if ( _contextFillStyle !== value ) {
 
-			_context.fillStyle = _contextFillStyle = style;
+			_context.fillStyle = value;
+			_contextFillStyle = value;
 
 		}