浏览代码

Merge branch 'dev' of git://github.com/mrdoob/three.js.git into triangle

Ben Houston 12 年之前
父节点
当前提交
c927db2fe3

文件差异内容过多而无法显示
+ 9417 - 382
build/three.js


文件差异内容过多而无法显示
+ 138 - 132
build/three.min.js


+ 3 - 2
docs/api/renderers/WebGLRenderer.html

@@ -110,9 +110,10 @@
 		<div>Default is true. TODO</div>
 
 
-		<h3>.[page:Boolean shadowMapSoft]</h3>
+		<h3>.[page:Integer shadowMapType]</h3>
 
-		<div>Default is true. TODO</div>
+		<div>Defines shadow map type (unfiltered, percentage close filtering, percentage close filtering with bilinear filtering in shader)</div>
+		<div>Options are THREE.BasicShadowMap, THREE.PCFShadowMap, THREE.PCFSoftShadowMap. Default is THREE.PCFShadowMap.</div>
 
 
 		<h3>.[page:Boolean shadowMapCullFrontFaces]</h3>

+ 1 - 1
examples/canvas_interactive_voxelpainter.html

@@ -82,7 +82,7 @@
 				scene.add( plane );
 
 				mouse2D = new THREE.Vector3( 0, 10000, 0.5 );
-				raycaster = new THREE.Raycaster( camera.position, null );
+				raycaster = new THREE.Raycaster( camera.position );
 
 				// Lights
 

+ 101 - 85
examples/webgl_interactive_cubes_gpu.html

@@ -50,14 +50,14 @@
 			var highlightBox;
 
 			var mouse = new THREE.Vector2();
-			var offset = new THREE.Vector3(10, 10, 10);
+			var offset = new THREE.Vector3( 10, 10, 10 );
 
 			init();
 			animate();
 
 			function init() {
 
-				container = document.getElementById("container");
+				container = document.getElementById( "container" );
 
 				camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 10000 );
 				camera.position.z = 1000;
@@ -72,126 +72,128 @@
 				controls.dynamicDampingFactor = 0.3;
 
 				scene = new THREE.Scene();
+
 				pickingScene = new THREE.Scene();
-				pickingTexture = new THREE.WebGLRenderTarget(window.innerWidth, window.innerHeight);
+				pickingTexture = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight );
 				pickingTexture.generateMipmaps = false;
 
 				scene.add( new THREE.AmbientLight( 0x555555 ) );
 
 				var light = new THREE.SpotLight( 0xffffff, 1.5 );
-
 				light.position.set( 0, 500, 2000 );
-				light.castShadow = true;
+				scene.add( light );
 
-				light.shadowCameraNear = 200;
-				light.shadowCameraFar = camera.far;
-				light.shadowCameraFov = 50;
+				var geometry = new THREE.Geometry(),
+				pickingGeometry = new THREE.Geometry(),
+				pickingMaterial = new THREE.MeshBasicMaterial( { vertexColors: THREE.VertexColors } ),
+				defaultMaterial = new THREE.MeshLambertMaterial({ color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors	} );
 
-				light.shadowBias = -0.00022;
-				light.shadowDarkness = 0.5;
+				function applyVertexColors( g, c ) {
 
-				light.shadowMapWidth = 1024;
-				light.shadowMapHeight = 1024;
+					g.faces.forEach( function( f ) {
 
-				scene.add( light );
+						var n = ( f instanceof THREE.Face3 ) ? 3 : 4;
+
+						for( var j = 0; j < n; j ++ ) {
+
+							f.vertexColors[ j ] = c;
 
-				var geometry = new THREE.Geometry(),
-					pickingGeometry = new THREE.Geometry(),
-					pickingMaterial = new THREE.MeshBasicMaterial({
-						vertexColors: THREE.VertexColors
-					}),
-					defaultMaterial = new THREE.MeshLambertMaterial({
-						color: 0xffffff,
-						shading: THREE.FlatShading,
-						vertexColors: THREE.VertexColors
-					});
-
-				function applyVertexColors(g, c) {
-					g.faces.forEach(function(f){
-						var n = (f instanceof THREE.Face3) ? 3 : 4;
-						for(var j=0; j<n; j++){
-							f.vertexColors[j] = c;
 						}
-					});
+
+					} );
+
 				}
-				
+
 				for ( var i = 0; i < 5000; i ++ ) {
+
 					var position = new THREE.Vector3();
+
 					position.x = Math.random() * 10000 - 5000;
 					position.y = Math.random() * 6000 - 3000;
 					position.z = Math.random() * 8000 - 4000;
 
 					var rotation = new THREE.Vector3();
-					rotation.x = ( Math.random() * 2 * Math.PI);
-					rotation.y = ( Math.random() * 2 * Math.PI);
-					rotation.z = ( Math.random() * 2 * Math.PI);
+
+					rotation.x = ( Math.random() * 2 * Math.PI );
+					rotation.y = ( Math.random() * 2 * Math.PI );
+					rotation.z = ( Math.random() * 2 * Math.PI );
 
 					var scale = new THREE.Vector3();
+
 					scale.x = Math.random() * 200 + 100;
 					scale.y = Math.random() * 200 + 100;
 					scale.z = Math.random() * 200 + 100;
-					
-					//give the geom's vertices a random color, to be displayed
-					var geom = new THREE.CubeGeometry(1, 1, 1);
-					var color = new THREE.Color(Math.random() * 0xffffff);
-					applyVertexColors(geom, color);
-					var cube = new THREE.Mesh(geom);
-					cube.position.copy(position);
-					cube.rotation.copy(rotation);
-					cube.scale.copy(scale);
-					THREE.GeometryUtils.merge(geometry, cube);
+
+					// give the geom's vertices a random color, to be displayed
+
+					var geom = new THREE.CubeGeometry( 1, 1, 1 );
+					var color = new THREE.Color( Math.random() * 0xffffff );
+					applyVertexColors( geom, color );
+
+					var cube = new THREE.Mesh( geom );
+					cube.position.copy( position );
+					cube.rotation.copy( rotation );
+					cube.scale.copy( scale );
+
+					THREE.GeometryUtils.merge( geometry, cube );
 
 					//give the pickingGeom's vertices a color corresponding to the "id"
-					var pickingGeom = new THREE.CubeGeometry(1, 1, 1);
-					var pickingColor = new THREE.Color(i);
-					applyVertexColors(pickingGeom, pickingColor);
-					var pickingCube = new THREE.Mesh(pickingGeom);
-					pickingCube.position.copy(position);
-					pickingCube.rotation.copy(rotation);
-					pickingCube.scale.copy(scale);
-					THREE.GeometryUtils.merge(pickingGeometry, pickingCube);
-
-					pickingData[i] = {
+
+					var pickingGeom = new THREE.CubeGeometry( 1, 1, 1 );
+					var pickingColor = new THREE.Color( i );
+					applyVertexColors( pickingGeom, pickingColor );
+
+					var pickingCube = new THREE.Mesh( pickingGeom );
+					pickingCube.position.copy( position );
+					pickingCube.rotation.copy( rotation );
+					pickingCube.scale.copy( scale );
+
+					THREE.GeometryUtils.merge( pickingGeometry, pickingCube );
+
+					pickingData[ i ] = {
+
 						position: position,
 						rotation: rotation,
 						scale: scale
+
 					};
+
 				}
-				var drawnObject = new THREE.Mesh(geometry, defaultMaterial);
-					//drawnObject.castShadow = true;
-					//drawnObject.receiveShadow = true;
-					scene.add(drawnObject);
-					
-				pickingScene.add(new THREE.Mesh(pickingGeometry, pickingMaterial));
-
-				highlightBox = new THREE.Mesh(new THREE.CubeGeometry(1, 1, 1), new THREE.MeshLambertMaterial({color: 0xffff00}));
-				scene.add(highlightBox);
-				
+
+				var drawnObject = new THREE.Mesh( geometry, defaultMaterial );
+				scene.add( drawnObject );
+
+				pickingScene.add( new THREE.Mesh( pickingGeometry, pickingMaterial ) );
+
+				highlightBox = new THREE.Mesh( new THREE.CubeGeometry( 1, 1, 1 ), new THREE.MeshLambertMaterial( { color: 0xffff00 } ) );
+				scene.add( highlightBox );
+
 				projector = new THREE.Projector();
 
 				renderer = new THREE.WebGLRenderer( { antialias: true, clearColor: 0xffffff } );
 				renderer.sortObjects = false;
 				renderer.setSize( window.innerWidth, window.innerHeight );
 
-				renderer.shadowMapEnabled = true;
-				renderer.shadowMapSoft = true;
-
 				container.appendChild( renderer.domElement );
-				
+
 				stats = new Stats();
 				stats.domElement.style.position = 'absolute';
 				stats.domElement.style.top = '0px';
 				container.appendChild( stats.domElement );
-				
-				renderer.domElement.addEventListener('mousemove', onMouseMove);
+
+				renderer.domElement.addEventListener( 'mousemove', onMouseMove );
+
 			}
+
 			//
 
-			function onMouseMove(e) {
+			function onMouseMove( e ) {
+
 				mouse.x = e.clientX;
 				mouse.y = e.clientY;
+
 			}
-			
+
 			function animate() {
 
 				requestAnimationFrame( animate );
@@ -202,30 +204,44 @@
 			}
 
 			function pick() {
+
 				//render the picking scene off-screen
+
+				renderer.render( pickingScene, camera, pickingTexture );
+
 				var gl = self.renderer.getContext();
-				renderer.render(pickingScene, camera, pickingTexture);
-				var pixelBuffer = new Uint8Array(4);
-				
+
 				//read the pixel under the mouse from the texture
-				gl.readPixels(mouse.x, pickingTexture.height - mouse.y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixelBuffer);
-				
+
+				var pixelBuffer = new Uint8Array( 4 );
+				gl.readPixels( mouse.x, pickingTexture.height - mouse.y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixelBuffer );
+
 				//interpret the pixel as an ID
-				var id = (pixelBuffer[0] << 16) | (pixelBuffer[1] << 8) | (pixelBuffer[2]);
-				var data = pickingData[id];
-				if(data){
+
+				var id = ( pixelBuffer[0] << 16 ) | ( pixelBuffer[1] << 8 ) | ( pixelBuffer[2] );
+				var data = pickingData[ id ];
+
+				if ( data) {
+
 					//move our highlightBox so that it surrounds the picked object
-					if(data.position && data.rotation && data.scale){
-						highlightBox.position.copy(data.position);
-						highlightBox.rotation.copy(data.rotation);
-						highlightBox.scale.copy(data.scale).addSelf(offset);
+
+					if ( data.position && data.rotation && data.scale ){
+
+						highlightBox.position.copy( data.position );
+						highlightBox.rotation.copy( data.rotation );
+						highlightBox.scale.copy( data.scale ).addSelf( offset );
 						highlightBox.visible = true;
+
 					}
+
 				} else {
+
 					highlightBox.visible = false;
+
 				}
+
 			}
-			
+
 			function render() {
 
 				controls.update();

+ 1 - 1
examples/webgl_interactive_draggablecubes.html

@@ -111,7 +111,7 @@
 				renderer.setSize( window.innerWidth, window.innerHeight );
 
 				renderer.shadowMapEnabled = true;
-				renderer.shadowMapSoft = true;
+				renderer.shadowMapType = THREE.PCFShadowMap;
 
 				container.appendChild( renderer.domElement );
 

+ 1 - 0
examples/webgl_loader_utf8.html

@@ -128,6 +128,7 @@
 				renderer.physicallyBasedShading = true;
 
 				renderer.shadowMapEnabled = true;
+				renderer.shadowMapType = THREE.PCFShadowMap;
 
 				// STATS
 

+ 1 - 1
examples/webgl_materials_normalmap.html

@@ -212,7 +212,7 @@
 				//
 
 				renderer.shadowMapEnabled = true;
-				renderer.shadowMapSoft = true;
+				renderer.shadowMapType = THREE.PCFShadowMap;
 
 
 				//

+ 1 - 0
examples/webgl_morphtargets_md2_control.html

@@ -150,6 +150,7 @@
 				renderer.shadowMapEnabled = true;
 
 				renderer.shadowMapCascade = true;
+				renderer.shadowMapType = THREE.PCFSoftShadowMap;
 				//renderer.shadowMapDebug = true;
 
 				// STATS

+ 1 - 0
examples/webgl_shading_physical.html

@@ -359,6 +359,7 @@
 
 				renderer.shadowMapAutoUpdate = false;
 				renderer.shadowMapEnabled = true;
+				renderer.shadowMapType = THREE.PCFSoftShadowMap;
 
 				//
 

+ 1 - 1
examples/webgl_shadowmap.html

@@ -141,7 +141,7 @@
 				//
 
 				renderer.shadowMapEnabled = true;
-				renderer.shadowMapSoft = true;
+				renderer.shadowMapType = THREE.PCFShadowMap;
 
 				// STATS
 

+ 1 - 1
examples/webgl_shadowmap_performance.html

@@ -141,7 +141,7 @@
 				//
 
 				renderer.shadowMapEnabled = true;
-				renderer.shadowMapSoft = true;
+				renderer.shadowMapType = THREE.PCFSoftShadowMap;
 
 				// STATS
 

+ 0 - 6
examples/webgl_test_memory.html

@@ -87,12 +87,6 @@
 
 				//
 
-				texture.deallocate();
-
-				mesh.deallocate();
-				mesh.geometry.deallocate();
-				mesh.material.deallocate();
-
 				renderer.deallocateObject( mesh );
 				renderer.deallocateTexture( texture );
 

+ 6 - 0
src/Three.js

@@ -91,6 +91,12 @@ THREE.CullFaceFrontBack = 3;
 THREE.FrontFaceDirectionCW = 0;
 THREE.FrontFaceDirectionCCW = 1;
 
+// SHADOWING TYPES
+
+THREE.BasicShadowMap = 0;
+THREE.PCFShadowMap = 1;
+THREE.PCFSoftShadowMap = 2;
+
 // MATERIAL CONSTANTS
 
 // side

+ 0 - 8
src/core/BufferGeometry.js

@@ -29,8 +29,6 @@ THREE.BufferGeometry = function () {
 
 	this.morphTargets = [];
 
-	THREE.GeometryLibrary[ this.id ] = this;
-
 };
 
 THREE.BufferGeometry.prototype = {
@@ -542,12 +540,6 @@ THREE.BufferGeometry.prototype = {
 		this.hasTangents = true;
 		this.tangentsNeedUpdate = true;
 
-	},
-
-	deallocate: function () {
-
-		delete THREE.GeometryLibrary[ this.id ];
-
 	}
 
 };

+ 0 - 9
src/core/Geometry.js

@@ -50,8 +50,6 @@ THREE.Geometry = function () {
 
 	this.buffersNeedUpdate = false;
 
-	THREE.GeometryLibrary[ this.id ] = this;
-
 };
 
 THREE.Geometry.prototype = {
@@ -734,15 +732,8 @@ THREE.Geometry.prototype = {
 
 		return geometry;
 
-	},
-
-	deallocate: function () {
-
-		delete THREE.GeometryLibrary[ this.id ];
-
 	}
 
 };
 
 THREE.GeometryIdCount = 0;
-THREE.GeometryLibrary = {};

+ 0 - 9
src/core/Object3D.js

@@ -47,8 +47,6 @@ THREE.Object3D = function () {
 
 	this._vector = new THREE.Vector3();
 
-	THREE.Object3DLibrary[ this.id ] = this;
-
 };
 
 
@@ -358,12 +356,6 @@ THREE.Object3D.prototype = {
 
 		return object;
 
-	},
-
-	deallocate: function () {
-
-		delete THREE.Object3DLibrary[ this.id ];
-
 	}
 
 };
@@ -372,4 +364,3 @@ THREE.Object3D.__m1 = new THREE.Matrix4();
 THREE.Object3D.defaultEulerOrder = 'XYZ',
 
 THREE.Object3DIdCount = 0;
-THREE.Object3DLibrary = {};

+ 9 - 1
src/extras/renderers/plugins/ShadowMapPlugin.js

@@ -139,7 +139,15 @@ THREE.ShadowMapPlugin = function ( ) {
 
 			if ( ! light.shadowMap ) {
 
-				var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat };
+				var shadowFilter = THREE.LinearFilter;
+
+				if ( _renderer.shadowMapType === THREE.PCFSoftShadowMap ) {
+
+					shadowFilter = THREE.NearestFilter;
+
+				}
+
+				var pars = { minFilter: shadowFilter, magFilter: shadowFilter, format: THREE.RGBAFormat };
 
 				light.shadowMap = new THREE.WebGLRenderTarget( light.shadowMapWidth, light.shadowMapHeight, pars );
 				light.shadowMapSize = new THREE.Vector2( light.shadowMapWidth, light.shadowMapHeight );

+ 0 - 9
src/materials/Material.js

@@ -35,8 +35,6 @@ THREE.Material = function () {
 
 	this.needsUpdate = true;
 
-	THREE.MaterialLibrary[ this.id ] = this;
-
 };
 
 THREE.Material.prototype.setValues = function ( values ) {
@@ -116,11 +114,4 @@ THREE.Material.prototype.clone = function ( material ) {
 
 };
 
-THREE.Material.prototype.deallocate = function () {
-
-	delete THREE.MaterialLibrary[ this.id ];
-
-};
-
 THREE.MaterialIdCount = 0;
-THREE.MaterialLibrary = {};

+ 13 - 12
src/math/Box2.js

@@ -32,38 +32,39 @@ THREE.Box2.prototype = {
 		this.max.copy( max );
 
 		return this;
+
 	},
 
 	setFromPoints: function ( points ) {
 
 		if ( points.length > 0 ) {
 
-			var p = points[ 0 ];
+			var point = points[ 0 ];
 
-			this.min.copy( p );
-			this.max.copy( p );
+			this.min.copy( point );
+			this.max.copy( point );
 
 			for ( var i = 1, il = points.length; i < il; i ++ ) {
 
-				p = points[ i ];
+				point = points[ i ];
 
-				if ( p.x < this.min.x ) {
+				if ( point.x < this.min.x ) {
 
-					this.min.x = p.x;
+					this.min.x = point.x;
 
-				} else if ( p.x > this.max.x ) {
+				} else if ( point.x > this.max.x ) {
 
-					this.max.x = p.x;
+					this.max.x = point.x;
 
 				}
 
-				if ( p.y < this.min.y ) {
+				if ( point.y < this.min.y ) {
 
-					this.min.y = p.y;
+					this.min.y = point.y;
 
-				} else if ( p.y > this.max.y ) {
+				} else if ( point.y > this.max.y ) {
 
-					this.max.y = p.y;
+					this.max.y = point.y;
 
 				}
 

文件差异内容过多而无法显示
+ 0 - 0
src/math/Color.js


+ 41 - 40
src/renderers/CanvasRenderer.js

@@ -51,9 +51,9 @@ THREE.CanvasRenderer = function ( parameters ) {
 	_image, _uvs,
 	_uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y,
 
-	_clipRect = new THREE.Rectangle(),
-	_clearRect = new THREE.Rectangle(),
-	_bboxRect = new THREE.Rectangle(),
+	_clipBox2 = new THREE.Box2(),
+	_clearBox2 = new THREE.Box2(),
+	_elemBox2 = new THREE.Box2(),
 
 	_enableLighting = false,
 	_ambientLight = new THREE.Color(),
@@ -112,8 +112,10 @@ THREE.CanvasRenderer = function ( parameters ) {
 		_canvas.width = _canvasWidth;
 		_canvas.height = _canvasHeight;
 
-		_clipRect.set( - _canvasWidthHalf, - _canvasHeightHalf, _canvasWidthHalf, _canvasHeightHalf );
-		_clearRect.set( - _canvasWidthHalf, - _canvasHeightHalf, _canvasWidthHalf, _canvasHeightHalf );
+		_clipBox2.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
+		_clipBox2.max.set( _canvasWidthHalf, _canvasHeightHalf );
+		_clearBox2.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
+		_clearBox2.max.set( _canvasWidthHalf, _canvasHeightHalf );
 
 		_contextGlobalAlpha = 1;
 		_contextGlobalCompositeOperation = 0;
@@ -130,7 +132,8 @@ THREE.CanvasRenderer = function ( parameters ) {
 		_clearColor.copy( color );
 		_clearOpacity = opacity !== undefined ? opacity : 1;
 
-		_clearRect.set( - _canvasWidthHalf, - _canvasHeightHalf, _canvasWidthHalf, _canvasHeightHalf );
+		_clearBox2.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
+		_clearBox2.max.set( _canvasWidthHalf, _canvasHeightHalf );
 
 	};
 
@@ -139,7 +142,8 @@ THREE.CanvasRenderer = function ( parameters ) {
 		_clearColor.setHex( hex );
 		_clearOpacity = opacity !== undefined ? opacity : 1;
 
-		_clearRect.set( - _canvasWidthHalf, - _canvasHeightHalf, _canvasWidthHalf, _canvasHeightHalf );
+		_clearBox2.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
+		_clearBox2.max.set( _canvasWidthHalf, _canvasHeightHalf );
 
 	};
 
@@ -153,14 +157,14 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 		_context.setTransform( 1, 0, 0, - 1, _canvasWidthHalf, _canvasHeightHalf );
 
-		if ( _clearRect.isEmpty() === false ) {
+		if ( _clearBox2.empty() === false ) {
 
-			_clearRect.minSelf( _clipRect );
-			_clearRect.inflate( 2 );
+			_clearBox2.intersect( _clipBox2 );
+			_clearBox2.expandByScalar( 2 );
 
 			if ( _clearOpacity < 1 ) {
 
-				_context.clearRect( Math.floor( _clearRect.getX() ), Math.floor( _clearRect.getY() ), Math.floor( _clearRect.getWidth() ), Math.floor( _clearRect.getHeight() ) );
+				_context.clearRect( _clearBox2.min.x | 0, _clearBox2.min.y | 0, ( _clearBox2.max.x - _clearBox2.min.x ) | 0, ( _clearBox2.max.y - _clearBox2.min.y ) | 0 );
 
 			}
 
@@ -171,11 +175,11 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 				setFillStyle( 'rgba(' + Math.floor( _clearColor.r * 255 ) + ',' + Math.floor( _clearColor.g * 255 ) + ',' + Math.floor( _clearColor.b * 255 ) + ',' + _clearOpacity + ')' );
 
-				_context.fillRect( Math.floor( _clearRect.getX() ), Math.floor( _clearRect.getY() ), Math.floor( _clearRect.getWidth() ), Math.floor( _clearRect.getHeight() ) );
+				_context.fillRect( _clearBox2.min.x | 0, _clearBox2.min.y | 0, ( _clearBox2.max.x - _clearBox2.min.x ) | 0, ( _clearBox2.max.y - _clearBox2.min.y ) | 0 );
 
 			}
 
-			_clearRect.empty();
+			_clearBox2.makeEmpty();
 
 		}
 
@@ -206,7 +210,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 		/* DEBUG
 		_context.fillStyle = 'rgba( 0, 255, 255, 0.5 )';
-		_context.fillRect( _clipRect.getX(), _clipRect.getY(), _clipRect.getWidth(), _clipRect.getHeight() );
+		_context.fillRect( _clipBox2.min.x, _clipBox2.min.y, _clipBox2.max.x - _clipBox2.min.x, _clipBox2.max.y - _clipBox2.min.y );
 		*/
 
 		_enableLighting = _lights.length > 0;
@@ -225,7 +229,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 			if ( material === undefined || material.visible === false ) continue;
 
-			_bboxRect.empty();
+			_elemBox2.makeEmpty();
 
 			if ( element instanceof THREE.RenderableParticle ) {
 
@@ -241,10 +245,9 @@ THREE.CanvasRenderer = function ( parameters ) {
 				_v1.positionScreen.x *= _canvasWidthHalf; _v1.positionScreen.y *= _canvasHeightHalf;
 				_v2.positionScreen.x *= _canvasWidthHalf; _v2.positionScreen.y *= _canvasHeightHalf;
 
-				_bboxRect.addPoint( _v1.positionScreen.x, _v1.positionScreen.y );
-				_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
+				_elemBox2.setFromPoints( [ _v1.positionScreen, _v2.positionScreen ] );
 
-				if ( _clipRect.intersects( _bboxRect ) === true ) {
+				if ( _clipBox2.isIntersectionBox( _elemBox2 ) === true ) {
 
 					renderLine( _v1, _v2, element, material, scene );
 
@@ -267,11 +270,9 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 				}
 
-				_bboxRect.add3Points( _v1.positionScreen.x, _v1.positionScreen.y,
-						      _v2.positionScreen.x, _v2.positionScreen.y,
-						      _v3.positionScreen.x, _v3.positionScreen.y );
+				_elemBox2.setFromPoints( [ _v1.positionScreen, _v2.positionScreen, _v3.positionScreen ] );
 
-				if ( _clipRect.intersects( _bboxRect ) === true ) {
+				if ( _clipBox2.isIntersectionBox( _elemBox2 ) === true ) {
 
 					renderFace3( _v1, _v2, _v3, 0, 1, 2, element, material, scene );
 
@@ -300,12 +301,9 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 				}
 
-				_bboxRect.addPoint( _v1.positionScreen.x, _v1.positionScreen.y );
-				_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
-				_bboxRect.addPoint( _v3.positionScreen.x, _v3.positionScreen.y );
-				_bboxRect.addPoint( _v4.positionScreen.x, _v4.positionScreen.y );
+				_elemBox2.setFromPoints( [ _v1.positionScreen, _v2.positionScreen, _v3.positionScreen, _v4.positionScreen ] );
 
-				if ( _clipRect.intersects( _bboxRect ) === true ) {
+				if ( _clipBox2.isIntersectionBox( _elemBox2 ) === true ) {
 
 					renderFace4( _v1, _v2, _v3, _v4, _v5, _v6, element, material, scene );
 
@@ -313,21 +311,21 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 			}
 
+
 			/* DEBUG
 			_context.lineWidth = 1;
 			_context.strokeStyle = 'rgba( 0, 255, 0, 0.5 )';
-			_context.strokeRect( _bboxRect.getX(), _bboxRect.getY(), _bboxRect.getWidth(), _bboxRect.getHeight() );
+			_context.strokeRect( _elemBox2.min.x, _elemBox2.min.y, _elemBox2.max.x - _elemBox2.min.x, _elemBox2.max.y - _elemBox2.min.y );
 			*/
 
-			_clearRect.addRectangle( _bboxRect );
-
+			_clearBox2.union( _elemBox2 );
 
 		}
 
 		/* DEBUG
 		_context.lineWidth = 1;
 		_context.strokeStyle = 'rgba( 255, 0, 0, 0.5 )';
-		_context.strokeRect( _clearRect.getX(), _clearRect.getY(), _clearRect.getWidth(), _clearRect.getHeight() );
+		_context.strokeRect( _clearBox2.min.x, _clearBox2.min.y, _clearBox2.max.x - _clearBox2.min.x, _clearBox2.max.y - _clearBox2.min.y );
 		*/
 
 		_context.setTransform( 1, 0, 0, 1, 0, 0 );
@@ -438,9 +436,10 @@ THREE.CanvasRenderer = function ( parameters ) {
 					scaleX *= element.scale.x * _canvasWidthHalf;
 					scaleY *= element.scale.y * _canvasHeightHalf;
 
-					_bboxRect.set( v1.x - scaleX, v1.y - scaleY, v1.x  + scaleX, v1.y + scaleY );
+					_elemBox2.min.set( v1.x - scaleX, v1.y - scaleY );
+					_elemBox2.max.set( v1.x + scaleX, v1.y + scaleY );
 
-					if ( _clipRect.intersects( _bboxRect ) === false ) {
+					if ( _clipBox2.isIntersectionBox( _elemBox2 ) === false ) {
 
 						return;
 
@@ -469,9 +468,10 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 					// TODO: Rotations break this...
 
-					_bboxRect.set( v1.x - width, v1.y - height, v1.x  + width, v1.y + height );
+					_elemBox2.min.set( v1.x - width, v1.y - height );
+					_elemBox2.max.set( v1.x + width, v1.y + height );
 
-					if ( _clipRect.intersects( _bboxRect ) === false ) {
+					if ( _clipBox2.isIntersectionBox( _elemBox2 ) === false ) {
 
 						return;
 
@@ -503,9 +503,10 @@ THREE.CanvasRenderer = function ( parameters ) {
 				width = element.scale.x * _canvasWidthHalf;
 				height = element.scale.y * _canvasHeightHalf;
 
-				_bboxRect.set( v1.x - width, v1.y - height, v1.x + width, v1.y + height );
+				_elemBox2.min.set( v1.x - width, v1.y - height );
+				_elemBox2.max.set( v1.x + width, v1.y + height );
 
-				if ( _clipRect.intersects( _bboxRect ) === false ) {
+				if ( _clipBox2.isIntersectionBox( _elemBox2 ) === false ) {
 
 					return;
 
@@ -544,7 +545,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 				setStrokeStyle( material.color.getStyle() );
 
 				_context.stroke();
-				_bboxRect.inflate( material.linewidth * 2 );
+				_elemBox2.expandByScalar( material.linewidth * 2 );
 
 			}
 
@@ -642,7 +643,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 					if ( material.map.mapping instanceof THREE.UVMapping ) {
 
 						_uvs = element.uvs[ 0 ];
-						patternPath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _uvs[ uv1 ].u, _uvs[ uv1 ].v, _uvs[ uv2 ].u, _uvs[ uv2 ].v, _uvs[ uv3 ].u, _uvs[ uv3 ].v, material.map );
+						patternPath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _uvs[ uv1 ].x, _uvs[ uv1 ].y, _uvs[ uv2 ].x, _uvs[ uv2 ].y, _uvs[ uv3 ].x, _uvs[ uv3 ].y, material.map );
 
 					}
 
@@ -921,7 +922,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 			_context.stroke();
 
-			_bboxRect.inflate( linewidth * 2 );
+			_elemBox2.expandByScalar( linewidth * 2 );
 
 		}
 

+ 16 - 4
src/renderers/WebGLRenderer.js

@@ -53,7 +53,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	this.shadowMapEnabled = false;
 	this.shadowMapAutoUpdate = true;
-	this.shadowMapSoft = true;
+	this.shadowMapType = THREE.PCFShadowMap;
 	this.shadowMapCullFace = THREE.CullFaceFront;
 	this.shadowMapDebug = false;
 	this.shadowMapCascade = false;
@@ -4924,7 +4924,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			maxShadows: maxShadows,
 			shadowMapEnabled: this.shadowMapEnabled && object.receiveShadow,
-			shadowMapSoft: this.shadowMapSoft,
+			shadowMapType: this.shadowMapType,
 			shadowMapDebug: this.shadowMapDebug,
 			shadowMapCascade: this.shadowMapCascade,
 
@@ -6227,6 +6227,18 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
+		var shadowMapTypeDefine = "SHADOWMAP_TYPE_BASIC";
+
+		if ( parameters.shadowMapType === THREE.PCFShadowMap ) {
+
+			shadowMapTypeDefine = "SHADOWMAP_TYPE_PCF";
+
+		} else if ( parameters.shadowMapType === THREE.PCFSoftShadowMap ) {
+
+			shadowMapTypeDefine = "SHADOWMAP_TYPE_PCF_SOFT";
+
+		}
+
 		//console.log( "building new program " );
 
 		//
@@ -6279,7 +6291,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			parameters.flipSided ? "#define FLIP_SIDED" : "",
 
 			parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
-			parameters.shadowMapSoft ? "#define SHADOWMAP_SOFT" : "",
+			parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
 			parameters.shadowMapDebug ? "#define SHADOWMAP_DEBUG" : "",
 			parameters.shadowMapCascade ? "#define SHADOWMAP_CASCADE" : "",
 
@@ -6378,7 +6390,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			parameters.flipSided ? "#define FLIP_SIDED" : "",
 
 			parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
-			parameters.shadowMapSoft ? "#define SHADOWMAP_SOFT" : "",
+			parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
 			parameters.shadowMapDebug ? "#define SHADOWMAP_DEBUG" : "",
 			parameters.shadowMapCascade ? "#define SHADOWMAP_CASCADE" : "",
 

+ 71 - 1
src/renderers/WebGLShaders.js

@@ -1547,7 +1547,7 @@ THREE.ShaderChunk = {
 
 					"shadowCoord.z += shadowBias[ i ];",
 
-					"#ifdef SHADOWMAP_SOFT",
+					"#if defined( SHADOWMAP_TYPE_PCF )",
 
 						// Percentage-close filtering
 						// (9 pixel kernel)
@@ -1617,6 +1617,76 @@ THREE.ShaderChunk = {
 
 						"shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );",
 
+					"#elif defined( SHADOWMAP_TYPE_PCF_SOFT )",
+
+						// Percentage-close filtering
+						// (9 pixel kernel)
+						// http://fabiensanglard.net/shadowmappingPCF/
+
+						"float shadow = 0.0;",
+
+						"float xPixelOffset = 1.0 / shadowMapSize[ i ].x;",
+						"float yPixelOffset = 1.0 / shadowMapSize[ i ].y;",
+
+						"float dx0 = -1.0 * xPixelOffset;",
+						"float dy0 = -1.0 * yPixelOffset;",
+						"float dx1 = 1.0 * xPixelOffset;",
+						"float dy1 = 1.0 * yPixelOffset;",
+
+						"mat3 shadowKernel;",
+						"mat3 depthKernel;",
+
+						"depthKernel[0][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );",
+						"if ( depthKernel[0][0] < shadowCoord.z ) shadowKernel[0][0] = 0.25;",
+						"else shadowKernel[0][0] = 0.0;",
+
+						"depthKernel[0][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );",
+						"if ( depthKernel[0][1] < shadowCoord.z ) shadowKernel[0][1] = 0.25;",
+						"else shadowKernel[0][1] = 0.0;",
+
+						"depthKernel[0][2] = unpackDepth( texture2D( shadowMap[ i], shadowCoord.xy + vec2( dx0, dy1 ) ) );",
+						"if ( depthKernel[0][2] < shadowCoord.z ) shadowKernel[0][2] = 0.25;",
+						"else shadowKernel[0][2] = 0.0;",
+
+						"depthKernel[1][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );",
+						"if ( depthKernel[1][0] < shadowCoord.z ) shadowKernel[1][0] = 0.25;",
+						"else shadowKernel[1][0] = 0.0;",
+
+						"depthKernel[1][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );",
+						"if ( depthKernel[1][1] < shadowCoord.z ) shadowKernel[1][1] = 0.25;",
+						"else shadowKernel[1][1] = 0.0;",
+
+						"depthKernel[1][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );",
+						"if ( depthKernel[1][2] < shadowCoord.z ) shadowKernel[1][2] = 0.25;",
+						"else shadowKernel[1][2] = 0.0;",
+
+						"depthKernel[2][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );",
+						"if ( depthKernel[2][0] < shadowCoord.z ) shadowKernel[2][0] = 0.25;",
+						"else shadowKernel[2][0] = 0.0;",
+
+						"depthKernel[2][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );",
+						"if ( depthKernel[2][1] < shadowCoord.z ) shadowKernel[2][1] = 0.25;",
+						"else shadowKernel[2][1] = 0.0;",
+
+						"depthKernel[2][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );",
+						"if ( depthKernel[2][2] < shadowCoord.z ) shadowKernel[2][2] = 0.25;",
+						"else shadowKernel[2][2] = 0.0;",
+
+						"vec2 fractionalCoord = 1.0 - fract( shadowCoord.xy * shadowMapSize[i].xy );",
+
+						"shadowKernel[0] = mix( shadowKernel[1], shadowKernel[0], fractionalCoord.x );",
+						"shadowKernel[1] = mix( shadowKernel[2], shadowKernel[1], fractionalCoord.x );",
+
+						"vec4 shadowValues;",
+						"shadowValues.x = mix( shadowKernel[0][1], shadowKernel[0][0], fractionalCoord.y );",
+						"shadowValues.y = mix( shadowKernel[0][2], shadowKernel[0][1], fractionalCoord.y );",
+						"shadowValues.z = mix( shadowKernel[1][1], shadowKernel[1][0], fractionalCoord.y );",
+						"shadowValues.w = mix( shadowKernel[1][2], shadowKernel[1][1], fractionalCoord.y );",
+
+						"shadow = dot( shadowValues, vec4( 1.0 ) );",
+
+						"shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );",
+
 					"#else",
 
 						"vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );",

+ 0 - 9
src/textures/Texture.js

@@ -37,8 +37,6 @@ THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, f
 	this.needsUpdate = false;
 	this.onUpdate = null;
 
-	THREE.TextureLibrary[ this.id ] = this;
-
 };
 
 THREE.Texture.prototype = {
@@ -75,15 +73,8 @@ THREE.Texture.prototype = {
 
 		return texture;
 
-	},
-
-	deallocate: function () {
-
-		delete THREE.TextureLibrary[ this.id ];
-
 	}
 
 };
 
 THREE.TextureIdCount = 0;
-THREE.TextureLibrary = {};

+ 2 - 2
test/three-math.html

@@ -11,7 +11,7 @@
 
   <!-- add ThreeJS sources to test below -->
 
-  <script src="../build/Three-math.js"></script>
+  <script src="../build/three-math.js"></script>
 
   <!-- add class-based unit tests below -->
 
@@ -27,4 +27,4 @@
   <script src="core/Vector4.js"></script>
   
 </body>
-</html>
+</html>

+ 2 - 2
test/three.html

@@ -11,7 +11,7 @@
 
   <!-- add ThreeJS sources to test below -->
 
-  <script src="../build/Three.js"></script>
+  <script src="../build/three.js"></script>
 
   <!-- add class-based unit tests below -->
 
@@ -27,4 +27,4 @@
   <script src="core/Vector4.js"></script>
   
 </body>
-</html>
+</html>

+ 2 - 2
test/three.min.html

@@ -11,7 +11,7 @@
 
   <!-- add ThreeJS sources to test below -->
 
-  <script src="../build/Three.min.js"></script>
+  <script src="../build/three.min.js"></script>
 
   <!-- add class-based unit tests below -->
 
@@ -27,4 +27,4 @@
   <script src="core/Vector4.js"></script>
   
 </body>
-</html>
+</html>

部分文件因为文件数量过多而无法显示