浏览代码

Merge remote-tracking branch 'bhouston/ray3' into dev

Mr.doob 12 年之前
父节点
当前提交
abdb139406
共有 46 个文件被更改,包括 722 次插入429 次删除
  1. 2 2
      docs/api/core/Projector.html
  2. 1 1
      docs/list.js
  3. 1 1
      editor/js/ui/Viewport.js
  4. 2 2
      examples/canvas_interactive_cubes.html
  5. 2 2
      examples/canvas_interactive_cubes_tween.html
  6. 2 2
      examples/canvas_interactive_particles.html
  7. 5 5
      examples/canvas_interactive_voxelpainter.html
  8. 1 1
      examples/misc_controls_pointerlock.html
  9. 2 2
      examples/webgl_interactive_cubes.html
  10. 6 6
      examples/webgl_interactive_draggablecubes.html
  11. 4 4
      examples/webgl_interactive_voxelpainter.html
  12. 11 8
      src/core/BufferGeometry.js
  13. 1 1
      src/core/Projector.js
  14. 0 285
      src/core/Ray.js
  15. 255 0
      src/core/Raycaster.js
  16. 1 1
      src/extras/geometries/CircleGeometry.js
  17. 1 1
      src/extras/geometries/PolyhedronGeometry.js
  18. 1 1
      src/extras/geometries/SphereGeometry.js
  19. 0 6
      src/math/Box2.js
  20. 0 6
      src/math/Box3.js
  21. 0 0
      src/math/Clock.js
  22. 0 0
      src/math/Color.js
  23. 0 0
      src/math/Frustum.js
  24. 16 0
      src/math/Math.js
  25. 0 0
      src/math/Matrix3.js
  26. 0 0
      src/math/Matrix4.js
  27. 0 8
      src/math/Plane.js
  28. 0 0
      src/math/Quaternion.js
  29. 161 0
      src/math/Ray.js
  30. 0 0
      src/math/Rectangle.js
  31. 0 6
      src/math/Sphere.js
  32. 0 0
      src/math/Spline.js
  33. 0 0
      src/math/UV.js
  34. 0 0
      src/math/Vector2.js
  35. 0 0
      src/math/Vector3.js
  36. 0 0
      src/math/Vector4.js
  37. 0 0
      src/math/Vertex.js
  38. 1 10
      test/core/Box2.js
  39. 0 5
      test/core/Box3.js
  40. 0 8
      test/core/Plane.js
  41. 177 0
      test/core/Ray.js
  42. 1 0
      test/index.html
  43. 17 13
      utils/includes/canvas.json
  44. 20 19
      utils/includes/common.json
  45. 12 8
      utils/includes/css3d.json
  46. 19 15
      utils/includes/webgl.json

+ 2 - 2
docs/api/core/Projector.html

@@ -23,9 +23,9 @@
 
 		<h3>.unprojectVector( [page:Vector3 vector], [page:Camera camera] ) [page:Vector3]</h3>
 
-		<h3>.pickingRay( [page:Vector3 vector], [page:Camera camera] ) [page:Ray]</h3>
+		<h3>.pickingRay( [page:Vector3 vector], [page:Camera camera] ) [page:Raycaster]</h3>
 		<div>
-		Translates a 2D point from NDC (<em>Normalized Device Coordinates</em>) to a [page:Ray] that can be used for picking. NDC range from [-1..1] in x (left to right) and [1.0 .. -1.0] in y (top to bottom).
+		Translates a 2D point from NDC (<em>Normalized Device Coordinates</em>) to a [page:Raycaster] that can be used for picking. NDC range from [-1..1] in x (left to right) and [1.0 .. -1.0] in y (top to bottom).
 		</div>
 
 		<h3>.projectScene( [page:Scene scene], [page:Camera camera], [page:Boolean sort] ) [page:Object]</h3>

+ 1 - 1
docs/list.js

@@ -26,7 +26,7 @@ var list = {
 			[ "Object3D", "api/core/Object3D" ],
 			[ "Projector", "api/core/Projector" ],
 			[ "Quaternion", "api/core/Quaternion" ],
-			[ "Ray", "api/core/Ray" ],
+			[ "Raycaster", "api/core/Raycaster" ],
 			[ "Rectangle", "api/core/Rectangle" ],
 			[ "Spline", "api/core/Spline" ],
 			[ "UV", "api/core/UV" ],

+ 1 - 1
editor/js/ui/Viewport.js

@@ -66,7 +66,7 @@ var Viewport = function ( signals ) {
 	intersectionPlane.visible = false;
 	sceneHelpers.add( intersectionPlane );
 
-	var ray = new THREE.Ray();
+	var ray = new THREE.Raycaster();
 	var projector = new THREE.Projector();
 	var offset = new THREE.Vector3();
 

+ 2 - 2
examples/canvas_interactive_cubes.html

@@ -122,9 +122,9 @@
 				var vector = new THREE.Vector3( ( event.clientX / window.innerWidth ) * 2 - 1, - ( event.clientY / window.innerHeight ) * 2 + 1, 0.5 );
 				projector.unprojectVector( vector, camera );
 
-				var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
+				var raycaster = new THREE.Raycaster( camera.position, vector.subSelf( camera.position ).normalize() );
 
-				var intersects = ray.intersectObjects( objects );
+				var intersects = raycaster.intersectObjects( objects );
 
 				if ( intersects.length > 0 ) {
 

+ 2 - 2
examples/canvas_interactive_cubes_tween.html

@@ -101,9 +101,9 @@
 				var vector = new THREE.Vector3( ( event.clientX / window.innerWidth ) * 2 - 1, - ( event.clientY / window.innerHeight ) * 2 + 1, 0.5 );
 				projector.unprojectVector( vector, camera );
 
-				var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
+				var raycaster = new THREE.Raycaster( camera.position, vector.subSelf( camera.position ).normalize() );
 
-				var intersects = ray.intersectObjects( scene.children );
+				var intersects = raycaster.intersectObjects( scene.children );
 
 				if ( intersects.length > 0 ) {
 

+ 2 - 2
examples/canvas_interactive_particles.html

@@ -149,9 +149,9 @@
 				var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
 				projector.unprojectVector( vector, camera );
 
-				var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
+				var raycaster = new THREE.Raycaster( camera.position, vector.subSelf( camera.position ).normalize() );
 
-				var intersects = ray.intersectObjects( scene.children );
+				var intersects = raycaster.intersectObjects( scene.children );
 
 				if ( intersects.length > 0 ) {
 

+ 5 - 5
examples/canvas_interactive_voxelpainter.html

@@ -24,7 +24,7 @@
 			var container, stats;
 			var camera, scene, renderer;
 			var projector, plane;
-			var mouse2D, mouse3D, ray, theta = 45,
+			var mouse2D, mouse3D, raycaster, theta = 45,
 			isShiftDown = false, isCtrlDown = false,
 			target = new THREE.Vector3( 0, 200, 0 );
 			var ROLLOVERED;
@@ -82,7 +82,7 @@
 				scene.add( plane );
 
 				mouse2D = new THREE.Vector3( 0, 10000, 0.5 );
-				ray = new THREE.Ray( camera.position, null );
+				raycaster = new THREE.Raycaster( camera.position, null );
 
 				// Lights
 
@@ -141,9 +141,9 @@
 				mouse2D.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
 
 				mouse3D = projector.unprojectVector( mouse2D.clone(), camera );
-				ray.direction = mouse3D.subSelf( camera.position ).normalize();
+				raycaster.direction = mouse3D.subSelf( camera.position ).normalize();
 
-				var intersects = ray.intersectObjects( scene.children );
+				var intersects = raycaster.intersectObjects( scene.children );
 
 				if ( intersects.length > 0 ) {
 
@@ -160,7 +160,7 @@
 
 				event.preventDefault();
 
-				var intersects = ray.intersectObjects( scene.children );
+				var intersects = raycaster.intersectObjects( scene.children );
 
 				if ( intersects.length > 0 ) {
 

+ 1 - 1
examples/misc_controls_pointerlock.html

@@ -192,7 +192,7 @@
 				controls = new THREE.PointerLockControls( camera );
 				scene.add( controls.getObject() );
 
-				ray = new THREE.Ray();
+				ray = new THREE.Raycaster();
 				ray.direction.set( 0, -1, 0 );
 
 				// floor

+ 2 - 2
examples/webgl_interactive_cubes.html

@@ -145,9 +145,9 @@
 				var vector = new THREE.Vector3( mouse.x, mouse.y, 1 );
 				projector.unprojectVector( vector, camera );
 
-				var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
+				var raycaster = new THREE.Raycaster( camera.position, vector.subSelf( camera.position ).normalize() );
 
-				var intersects = ray.intersectObjects( scene.children );
+				var intersects = raycaster.intersectObjects( scene.children );
 
 				if ( intersects.length > 0 ) {
 

+ 6 - 6
examples/webgl_interactive_draggablecubes.html

@@ -159,19 +159,19 @@
 				var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
 				projector.unprojectVector( vector, camera );
 
-				var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
+				var raycaster = new THREE.Raycaster( camera.position, vector.subSelf( camera.position ).normalize() );
 
 
 				if ( SELECTED ) {
 
-					var intersects = ray.intersectObject( plane );
+					var intersects = raycaster.intersectObject( plane );
 					SELECTED.position.copy( intersects[ 0 ].point.subSelf( offset ) );
 					return;
 
 				}
 
 
-				var intersects = ray.intersectObjects( objects );
+				var intersects = raycaster.intersectObjects( objects );
 
 				if ( intersects.length > 0 ) {
 
@@ -208,9 +208,9 @@
 				var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
 				projector.unprojectVector( vector, camera );
 
-				var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
+				var raycaster = new THREE.Raycaster( camera.position, vector.subSelf( camera.position ).normalize() );
 
-				var intersects = ray.intersectObjects( objects );
+				var intersects = raycaster.intersectObjects( objects );
 
 				if ( intersects.length > 0 ) {
 
@@ -218,7 +218,7 @@
 
 					SELECTED = intersects[ 0 ].object;
 
-					var intersects = ray.intersectObject( plane );
+					var intersects = raycaster.intersectObject( plane );
 					offset.copy( intersects[ 0 ].point ).subSelf( plane.position );
 
 					container.style.cursor = 'move';

+ 4 - 4
examples/webgl_interactive_voxelpainter.html

@@ -31,7 +31,7 @@
 			var container, stats;
 			var camera, scene, renderer;
 			var projector, plane, cube;
-			var mouse2D, mouse3D, ray,
+			var mouse2D, mouse3D, raycaster,
 			rollOveredFace, isShiftDown = false,
 			theta = 45, isCtrlDown = false;
 
@@ -196,7 +196,7 @@
 
 				event.preventDefault();
 
-				var intersects = ray.intersectObjects( scene.children );
+				var intersects = raycaster.intersectObjects( scene.children );
 
 				if ( intersects.length > 0 ) {
 
@@ -276,9 +276,9 @@
 
 				}
 
-				ray = projector.pickingRay( mouse2D.clone(), camera );
+				raycaster = projector.pickingRay( mouse2D.clone(), camera );
 
-				var intersects = ray.intersectObjects( scene.children );
+				var intersects = raycaster.intersectObjects( scene.children );
 
 				if ( intersects.length > 0 ) {
 

+ 11 - 8
src/core/BufferGeometry.js

@@ -71,12 +71,7 @@ THREE.BufferGeometry.prototype = {
 
 		if ( ! this.boundingBox ) {
 
-			this.boundingBox = {
-
-				min: new THREE.Vector3( Infinity, Infinity, Infinity ),
-				max: new THREE.Vector3( -Infinity, -Infinity, -Infinity )
-
-			};
+			this.boundingBox = new THREE.Box3();
 
 		}
 
@@ -87,7 +82,13 @@ THREE.BufferGeometry.prototype = {
 			var bb = this.boundingBox;
 			var x, y, z;
 
-			for ( var i = 0, il = positions.length; i < il; i += 3 ) {
+			if( positions.length >= 3 ) {
+				bb.min.x = bb.max.x = positions[ 0 ];
+				bb.min.y = bb.max.y = positions[ 1 ];
+				bb.min.z = bb.max.z = positions[ 2 ];
+			}
+
+			for ( var i = 3, il = positions.length; i < il; i += 3 ) {
 
 				x = positions[ i ];
 				y = positions[ i + 1 ];
@@ -140,7 +141,9 @@ THREE.BufferGeometry.prototype = {
 
 	computeBoundingSphere: function () {
 
-		if ( ! this.boundingSphere ) this.boundingSphere = { radius: 0 };
+		if ( ! this.boundingSphere ) {
+			this.boundingSphere = new THREE.Sphere();
+		}
 
 		var positions = this.attributes[ "position" ].array;
 

+ 1 - 1
src/core/Projector.js

@@ -65,7 +65,7 @@ THREE.Projector = function() {
 		// find direction from vector to end
 		end.subSelf( vector ).normalize();
 
-		return new THREE.Ray( vector, end );
+		return new THREE.Raycaster( vector, end );
 
 	};
 

+ 0 - 285
src/core/Ray.js

@@ -1,285 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-( function ( THREE ) {
-
-	THREE.Ray = function ( origin, direction, near, far ) {
-
-		this.origin = origin || new THREE.Vector3();
-		this.direction = direction || new THREE.Vector3();
-		this.near = near || 0;
-		this.far = far || Infinity;
-
-	};
-
-	var originCopy = new THREE.Vector3();
-
-	var localOriginCopy = new THREE.Vector3();
-	var localDirectionCopy = new THREE.Vector3();
-
-	var vector = new THREE.Vector3();
-	var normal = new THREE.Vector3();
-	var intersectPoint = new THREE.Vector3();
-
-	var inverseMatrix = new THREE.Matrix4();
-
-	var descSort = function ( a, b ) {
-
-		return a.distance - b.distance;
-
-	};
-
-	var v0 = new THREE.Vector3(), v1 = new THREE.Vector3(), v2 = new THREE.Vector3();
-
-	var distanceFromIntersection = function ( origin, direction, position ) {
-
-		v0.sub( position, origin );
-
-		var dot = v0.dot( direction );
-
-		var intersect = v1.add( origin, v2.copy( direction ).multiplyScalar( dot ) );
-		var distance = position.distanceTo( intersect );
-
-		return distance;
-
-	};
-
-	// http://www.blackpawn.com/texts/pointinpoly/default.html
-
-	var pointInFace3 = function ( p, a, b, c ) {
-
-		v0.sub( c, a );
-		v1.sub( b, a );
-		v2.sub( p, a );
-
-		var dot00 = v0.dot( v0 );
-		var dot01 = v0.dot( v1 );
-		var dot02 = v0.dot( v2 );
-		var dot11 = v1.dot( v1 );
-		var dot12 = v1.dot( v2 );
-
-		var invDenom = 1 / ( dot00 * dot11 - dot01 * dot01 );
-		var u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;
-		var v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;
-
-		return ( u >= 0 ) && ( v >= 0 ) && ( u + v < 1 );
-
-	};
-
-	var intersectObject = function ( object, ray, intersects ) {
-
-		if ( object instanceof THREE.Particle ) {
-
-			var distance = distanceFromIntersection( ray.origin, ray.direction, object.matrixWorld.getPosition() );
-
-			if ( distance > object.scale.x ) {
-
-				return intersects;
-
-			}
-
-			intersects.push( {
-
-				distance: distance,
-				point: object.position,
-				face: null,
-				object: object
-
-			} );
-
-		} else if ( object instanceof THREE.Mesh ) {
-
-			// Checking boundingSphere
-
-			var scaledRadius = object.geometry.boundingSphere.radius * object.matrixWorld.getMaxScaleOnAxis();
-
-			// Checking distance to ray
-
-			var distance = distanceFromIntersection( ray.origin, ray.direction, object.matrixWorld.getPosition() );
-
-			if ( distance > scaledRadius) {
-
-				return intersects;
-
-			}
-
-			// Checking faces
-
-			var geometry = object.geometry;
-			var vertices = geometry.vertices;
-
-			var isFaceMaterial = object.material instanceof THREE.MeshFaceMaterial;
-			var objectMaterials = isFaceMaterial === true ? object.material.materials : null;
-
-			var side = object.material.side;
-
-			var a, b, c, d;
-			var precision = ray.precision;
-
-			object.matrixRotationWorld.extractRotation( object.matrixWorld );
-
-			originCopy.copy( ray.origin );
-
-			inverseMatrix.getInverse( object.matrixWorld );
-
-			localOriginCopy.copy( originCopy );
-			inverseMatrix.multiplyVector3( localOriginCopy );
-
-			localDirectionCopy.copy( ray.direction );
-			inverseMatrix.rotateAxis( localDirectionCopy ).normalize();
-
-			for ( var f = 0, fl = geometry.faces.length; f < fl; f ++ ) {
-
-				var face = geometry.faces[ f ];
-
-				var material = isFaceMaterial === true ? objectMaterials[ face.materialIndex ] : object.material;
-
-				if ( material === undefined ) continue;
-
-				side = material.side;
-
-				vector.sub( face.centroid, localOriginCopy );
-
-				var normal = face.normal;
-				var dot = localDirectionCopy.dot( normal );
-
-				// bail if ray and plane are parallel
-
-				if ( Math.abs( dot ) < precision ) continue;
-
-				// calc distance to plane
-
-				var scalar = normal.dot( vector ) / dot;
-
-				// if negative distance, then plane is behind ray
-
-				if ( scalar < 0 ) continue;
-
-				if ( side === THREE.DoubleSide || ( side === THREE.FrontSide ? dot < 0 : dot > 0 ) ) {
-
-					intersectPoint.add( localOriginCopy, localDirectionCopy.multiplyScalar( scalar ) );
-
-					if ( face instanceof THREE.Face3 ) {
-
-						a = vertices[ face.a ];
-						b = vertices[ face.b ];
-						c = vertices[ face.c ];
-
-						if ( pointInFace3( intersectPoint, a, b, c ) ) {
-
-							var point = object.matrixWorld.multiplyVector3( intersectPoint.clone() );
-							distance = originCopy.distanceTo( point );
-
-							if ( distance < ray.near || distance > ray.far ) continue;
-
-							intersects.push( {
-
-								distance: distance,
-								point: point,
-								face: face,
-								faceIndex: f,
-								object: object
-
-							} );
-
-						}
-
-					} else if ( face instanceof THREE.Face4 ) {
-
-						a = vertices[ face.a ];
-						b = vertices[ face.b ];
-						c = vertices[ face.c ];
-						d = vertices[ face.d ];
-
-						if ( pointInFace3( intersectPoint, a, b, d ) || pointInFace3( intersectPoint, b, c, d ) ) {
-
-							var point = object.matrixWorld.multiplyVector3( intersectPoint.clone() );
-							distance = originCopy.distanceTo( point );
-
-							if ( distance < ray.near || distance > ray.far ) continue;
-
-							intersects.push( {
-
-								distance: distance,
-								point: point,
-								face: face,
-								faceIndex: f,
-								object: object
-
-							} );
-
-						}
-
-					}
-
-				}
-
-			}
-
-		}
-
-	};
-
-	var intersectDescendants = function ( object, ray, intersects ) {
-
-		var descendants = object.getDescendants();
-
-		for ( var i = 0, l = descendants.length; i < l; i ++ ) {
-
-			intersectObject( descendants[ i ], ray, intersects );
-
-		}
-	};
-
-	//
-
-	THREE.Ray.prototype.precision = 0.0001;
-
-	THREE.Ray.prototype.set = function ( origin, direction ) {
-
-		this.origin = origin;
-		this.direction = direction;
-
-	};
-
-	THREE.Ray.prototype.intersectObject = function ( object, recursive ) {
-
-		var intersects = [];
-
-		if ( recursive === true ) {
-
-			intersectDescendants( object, this, intersects );
-
-		}
-
-		intersectObject( object, this, intersects );
-
-		intersects.sort( descSort );
-
-		return intersects;
-
-	};
-
-	THREE.Ray.prototype.intersectObjects = function ( objects, recursive ) {
-
-		var intersects = [];
-
-		for ( var i = 0, l = objects.length; i < l; i ++ ) {
-
-			intersectObject( objects[ i ], this, intersects );
-
-			if ( recursive === true ) {
-
-				intersectDescendants( objects[ i ], this, intersects );
-
-			}
-		}
-
-		intersects.sort( descSort );
-
-		return intersects;
-
-	};
-
-}( THREE ) );

+ 255 - 0
src/core/Raycaster.js

@@ -0,0 +1,255 @@
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+( function ( THREE ) {
+
+	THREE.Raycaster = function ( origin, direction, near, far ) {
+
+		this.ray = new THREE.Ray( origin, direction );
+		
+		// normalized ray.direction required for accurate distance calculations
+		if( this.ray.direction.length() > 0 ) {
+
+			this.ray.direction.normalize();
+
+		}
+
+		this.near = near || 0;
+		this.far = far || Infinity;
+
+	};
+
+	var sphere = new THREE.Sphere();
+	var localRay = new THREE.Ray();
+	var facePlane = new THREE.Plane();
+	var intersectPoint = new THREE.Vector3();
+
+	var inverseMatrix = new THREE.Matrix4();
+
+	var descSort = function ( a, b ) {
+
+		return a.distance - b.distance;
+
+	};
+
+	var v0 = new THREE.Vector3(), v1 = new THREE.Vector3(), v2 = new THREE.Vector3();
+
+	// http://www.blackpawn.com/texts/pointinpoly/default.html
+
+	var pointInFace3 = function ( p, a, b, c ) {
+
+		v0.sub( c, a );
+		v1.sub( b, a );
+		v2.sub( p, a );
+
+		var dot00 = v0.dot( v0 );
+		var dot01 = v0.dot( v1 );
+		var dot02 = v0.dot( v2 );
+		var dot11 = v1.dot( v1 );
+		var dot12 = v1.dot( v2 );
+
+		var invDenom = 1 / ( dot00 * dot11 - dot01 * dot01 );
+		var u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;
+		var v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;
+
+		return ( u >= 0 ) && ( v >= 0 ) && ( u + v < 1 );
+
+	};
+
+	var intersectObject = function ( object, raycaster, intersects ) {
+
+		if ( object instanceof THREE.Particle ) {
+
+			var distance = raycaster.ray.distanceToPoint( object.matrixWorld.getPosition() );
+
+			if ( distance > object.scale.x ) {
+
+				return intersects;
+
+			}
+
+			intersects.push( {
+
+				distance: distance,
+				point: object.position,
+				face: null,
+				object: object
+
+			} );
+
+		} else if ( object instanceof THREE.Mesh ) {
+
+			// Checking boundingSphere distance to ray
+			sphere.set(
+				object.matrixWorld.getPosition(),
+				object.geometry.boundingSphere.radius* object.matrixWorld.getMaxScaleOnAxis() );
+
+			if ( ! raycaster.ray.isIntersectionSphere( sphere ) ) {
+
+				return intersects;
+
+			}
+
+			// Checking faces
+
+			var geometry = object.geometry;
+			var vertices = geometry.vertices;
+
+			var isFaceMaterial = object.material instanceof THREE.MeshFaceMaterial;
+			var objectMaterials = isFaceMaterial === true ? object.material.materials : null;
+
+			var side = object.material.side;
+
+			var a, b, c, d;
+			var precision = raycaster.precision;
+
+			object.matrixRotationWorld.extractRotation( object.matrixWorld );
+
+			inverseMatrix.getInverse( object.matrixWorld );
+
+			localRay.copy( raycaster.ray ).transformSelf( inverseMatrix );
+	
+			for ( var f = 0, fl = geometry.faces.length; f < fl; f ++ ) {
+
+				var face = geometry.faces[ f ];
+
+				var material = isFaceMaterial === true ? objectMaterials[ face.materialIndex ] : object.material;
+
+				if ( material === undefined ) continue;
+				
+				facePlane.setFromNormalAndCoplanarPoint( face.normal, face.centroid );
+
+				var planeDistance = localRay.distanceToPlane( facePlane );
+	
+				// bail if raycaster and plane are parallel
+				if ( Math.abs( planeDistance ) < precision ) continue;
+	
+				// if negative distance, then plane is behind raycaster
+				if ( planeDistance < 0 ) continue;
+
+				// check if we hit the wrong side of a single sided face
+				side = material.side;
+				if( side !== THREE.DoubleSide ) {
+
+					var planeSign = localRay.direction.dot( facePlane.normal );
+
+					if( ! ( side === THREE.FrontSide ? planeSign < 0 : planeSign > 0 ) ) continue;
+
+				}
+
+				// this can be done using the planeDistance from localRay because localRay wasn't normalized, but ray was
+				if ( planeDistance < raycaster.near || planeDistance > raycaster.far ) continue;
+				
+				intersectPoint = localRay.at( planeDistance, intersectPoint ); // passing in intersectPoint avoids a copy
+
+				if ( face instanceof THREE.Face3 ) {
+
+					a = vertices[ face.a ];
+					b = vertices[ face.b ];
+					c = vertices[ face.c ];
+
+					if ( ! pointInFace3( intersectPoint, a, b, c ) ) continue;
+
+				} else if ( face instanceof THREE.Face4 ) {
+
+					a = vertices[ face.a ];
+					b = vertices[ face.b ];
+					c = vertices[ face.c ];
+					d = vertices[ face.d ];
+
+					if ( ( ! pointInFace3( intersectPoint, a, b, d ) ) &&
+						 ( ! pointInFace3( intersectPoint, b, c, d ) ) ) continue;
+
+				} else {
+
+					// This is added because if we call out of this if/else group when none of the cases
+					//    match it will add a point to the intersection list erroneously.
+					throw Error( "face type not supported" );
+
+				}
+
+				intersects.push( {
+
+					distance: planeDistance,	// this works because the original ray was normalized, and the transformed localRay wasn't
+					point: raycaster.ray.at( planeDistance ),
+					face: face,
+					faceIndex: f,
+					object: object
+
+				} );
+
+			}
+
+		}
+
+	};
+
+	var intersectDescendants = function ( object, raycaster, intersects ) {
+
+		var descendants = object.getDescendants();
+
+		for ( var i = 0, l = descendants.length; i < l; i ++ ) {
+
+			intersectObject( descendants[ i ], raycaster, intersects );
+
+		}
+	};
+
+	//
+
+	THREE.Raycaster.prototype.precision = 0.0001;
+
+	THREE.Raycaster.prototype.set = function ( origin, direction ) {
+
+		this.ray.set( origin, direction );
+
+		// normalized ray.direction required for accurate distance calculations
+		if( this.ray.direction.length() > 0 ) {
+
+			this.ray.direction.normalize();
+
+		}
+
+	};
+
+	THREE.Raycaster.prototype.intersectObject = function ( object, recursive ) {
+
+		var intersects = [];
+
+		if ( recursive === true ) {
+
+			intersectDescendants( object, this, intersects );
+
+		}
+
+		intersectObject( object, this, intersects );
+
+		intersects.sort( descSort );
+
+		return intersects;
+
+	};
+
+	THREE.Raycaster.prototype.intersectObjects = function ( objects, recursive ) {
+
+		var intersects = [];
+
+		for ( var i = 0, l = objects.length; i < l; i ++ ) {
+
+			intersectObject( objects[ i ], this, intersects );
+
+			if ( recursive === true ) {
+
+				intersectDescendants( objects[ i ], this, intersects );
+
+			}
+		}
+
+		intersects.sort( descSort );
+
+		return intersects;
+
+	};
+
+}( THREE ) );

+ 1 - 1
src/extras/geometries/CircleGeometry.js

@@ -46,7 +46,7 @@ THREE.CircleGeometry = function ( radius, segments, thetaStart, thetaLength ) {
     this.computeCentroids();
     this.computeFaceNormals();
 
-    this.boundingSphere = { radius: radius };
+    this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
 
 };
 

+ 1 - 1
src/extras/geometries/PolyhedronGeometry.js

@@ -139,7 +139,7 @@ THREE.PolyhedronGeometry = function ( vertices, faces, radius, detail ) {
 
 	this.computeCentroids();
 
-	this.boundingSphere = { radius: radius };
+    this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
 
 };
 

+ 1 - 1
src/extras/geometries/SphereGeometry.js

@@ -89,7 +89,7 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar
 	this.computeCentroids();
 	this.computeFaceNormals();
 
-	this.boundingSphere = { radius: this.radius };
+    this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
 
 };
 

+ 0 - 6
src/core/Box2.js → src/math/Box2.js

@@ -115,12 +115,6 @@ THREE.Box2.prototype = {
 
 	},
 
-	volume: function () {
-
-		return ( this.max.x - this.min.x ) * ( this.max.y - this.min.y );
-
-	},
-
 	center: function () {
 
 		return new THREE.Vector2().add( this.min, this.max ).multiplyScalar( 0.5 );

+ 0 - 6
src/core/Box3.js → src/math/Box3.js

@@ -133,12 +133,6 @@ THREE.Box3.prototype = {
 
 	},
 
-	volume: function () {
-
-		return ( this.max.x - this.min.x ) * ( this.max.y - this.min.y ) * ( this.max.z - this.min.z );
-
-	},
-
 	center: function () {
 
 		return new THREE.Vector3().add( this.min, this.max ).multiplyScalar( 0.5 );

+ 0 - 0
src/core/Clock.js → src/math/Clock.js


+ 0 - 0
src/core/Color.js → src/math/Color.js


+ 0 - 0
src/core/Frustum.js → src/math/Frustum.js


+ 16 - 0
src/core/Math.js → src/math/Math.js

@@ -67,4 +67,20 @@ THREE.Math = {
 
 	}
 
+	degreesToRadians: function( degrees ) {
+
+	  return degrees * THREE.Math.__d2r;
+
+	};
+
+	radiansToDegrees: function( radians ) {
+
+	  return radians * THREE.Math.__r2d;
+
+	};
+
+
 };
+
+THREE.Math.__d2r =  Math.PI / 180;
+THREE.Math.__r2d =  180 / Math.PI;

+ 0 - 0
src/core/Matrix3.js → src/math/Matrix3.js


+ 0 - 0
src/core/Matrix4.js → src/math/Matrix4.js


+ 0 - 8
src/core/Plane.js → src/math/Plane.js

@@ -71,14 +71,6 @@ THREE.Plane.prototype = {
 
 	},
 
-	flip: function () {
-
-		this.normal.negate();
-
-		return this;
-
-	},
-
 	normalize: function () {
 
 		// Note: will lead to a divide by zero if the plane is invalid.

+ 0 - 0
src/core/Quaternion.js → src/math/Quaternion.js


+ 161 - 0
src/math/Ray.js

@@ -0,0 +1,161 @@
+/**
+ * @author bhouston / http://exocortex.com
+ */
+
+THREE.Ray = function ( origin, direction ) {
+
+
+	this.origin = origin !== undefined ? origin.clone() : new THREE.Vector3();
+	this.direction = direction !== undefined ? direction.clone() : new THREE.Vector3();
+
+};
+
+THREE.Ray.prototype = {
+
+	constructor: THREE.Ray,
+
+	set: function ( origin, direction ) {
+
+		this.origin.copy( origin );
+		this.direction.copy( direction );
+
+		return this;
+
+	},
+
+	copy: function ( ray ) {
+
+		this.origin.copy( ray.origin );
+		this.direction.copy( ray.direction );
+
+		return this;
+
+	},
+
+	at: function( t, optionalTarget ) {
+
+		if( optionalTarget === undefined ) {
+			optionalTarget = this.direction.clone();
+		}
+		else {
+			optionalTarget.copy( this.direction );
+		}
+		return optionalTarget.multiplyScalar( t ).addSelf( this.origin );
+
+	},
+
+	recastSelf: function ( t ) {
+
+		this.origin = this.at( t );
+
+		return this;
+
+	},
+
+	closestPointToPoint: function ( point ) {
+
+		var result = point.clone().subSelf( this.origin );
+		var directionDistance = result.dot( this.direction );
+
+		return result.copy( this.direction ).multiplyScalar( directionDistance ).addSelf( this.origin );
+
+	},
+
+	distanceToPoint: function ( point ) {
+
+		var directionDistance = THREE.Ray.__v1.sub( point, this.origin ).dot( this.direction );		
+		THREE.Ray.__v1.copy( this.direction ).multiplyScalar( directionDistance ).addSelf( this.origin );
+
+		return THREE.Ray.__v1.distanceTo( point );
+
+	},
+
+	isIntersectionSphere: function( sphere ) {
+
+		return ( this.distanceToPoint( sphere.center ) <= sphere.radius );
+
+	},
+
+	isIntersectionPlane: function ( plane ) {
+
+		// check if the line and plane are non-perpendicular, if they
+		// eventually they will intersect.
+		var denominator = plane.normal.dot( this.direction );
+		if ( denominator != 0 ) {
+
+			return true;
+
+		}
+
+		// line is coplanar, return origin
+		if( plane.distanceToPoint( this.origin ) == 0 ) {
+
+			return true;
+
+		}
+
+		return false;
+
+	},
+
+	distanceToPlane: function ( plane ) {
+
+		var denominator = plane.normal.dot( this.direction );
+		if ( denominator == 0 ) {
+
+			// line is coplanar, return origin
+			if( plane.distanceToPoint( this.origin ) == 0 ) {
+
+				return 0;
+
+			}
+
+			// Unsure if this is the correct method to handle this case.
+			return undefined;
+
+		}
+
+		var t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator;
+
+		return t;
+
+	},
+
+	intersectPlane: function ( plane ) {
+
+		var t = this.distanceToPlane( plane );
+
+		if( t === undefined ) {
+
+			return undefined;
+		}
+
+		return this.at( t );
+
+	},
+
+	transformSelf: function ( matrix4 ) {
+
+		this.direction = matrix4.multiplyVector3( this.direction.addSelf( this.origin ) );
+		this.origin = matrix4.multiplyVector3( this.origin );
+		this.direction.subSelf( this.origin );
+
+		return this;
+	},
+
+	equals: function ( ray ) {
+
+		return ray.origin.equals( this.origin ) && ray.direction.equals( this.direction );
+
+	},
+
+	clone: function () {
+
+		return new THREE.Ray().copy( this );
+
+	}
+
+};
+
+THREE.Ray.__v1 = new THREE.Vector3();
+THREE.Ray.__v2 = new THREE.Vector3();

+ 0 - 0
src/core/Rectangle.js → src/math/Rectangle.js


+ 0 - 6
src/core/Sphere.js → src/math/Sphere.js

@@ -65,12 +65,6 @@ THREE.Sphere.prototype = {
 
 	},
 
-	volume: function () {
-
-		return Math.PI * 4 / 3 * ( this.radius * this.radius * this.radius );
-
-	},
-
 	containsPoint: function ( point ) {
 
 		return ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );

+ 0 - 0
src/core/Spline.js → src/math/Spline.js


+ 0 - 0
src/core/UV.js → src/math/UV.js


+ 0 - 0
src/core/Vector2.js → src/math/Vector2.js


+ 0 - 0
src/core/Vector3.js → src/math/Vector3.js


+ 0 - 0
src/core/Vector4.js → src/math/Vector4.js


+ 0 - 0
src/core/Vertex.js → src/math/Vertex.js


+ 1 - 10
test/core/Box2.js

@@ -1,4 +1,4 @@
-	/**
+/**
  * @author bhouston / http://exocortex.com
  */
 
@@ -18,7 +18,6 @@ test( "constructor", function() {
 	ok( a.max.equals( one2 ), "Passed!" );
 });
 
-
 test( "copy", function() {
 	var a = new THREE.Box2( zero2, one2 );
 	var b = new THREE.Box2().copy( a );
@@ -52,14 +51,6 @@ test( "empty/makeEmpty", function() {
 	ok( a.empty(), "Passed!" );
 });
 
-test( "volume", function() {
-	var a = new THREE.Box2( zero2, one2 );
-	ok( a.volume() == 1, "Passed!" );
-
-	a = new THREE.Box2( one2.clone().negate(), zero2 );
-	ok( a.volume() == 1, "Passed!" );
-});
-
 test( "center", function() {
 	var a = new THREE.Box2( zero2 );
 

+ 0 - 5
test/core/Box3.js

@@ -51,11 +51,6 @@ test( "empty/makeEmpty", function() {
 	ok( a.empty(), "Passed!" );
 });
 
-test( "volume", function() {
-	var a = new THREE.Box3( zero3, one3 );
-	ok( a.volume() == 1, "Passed!" );
-});
-
 test( "center", function() {
 	var a = new THREE.Box3( zero3 );
 

+ 0 - 8
test/core/Plane.js

@@ -78,14 +78,6 @@ test( "setFromNormalAndCoplanarPoint", function() {
 	ok( a.constant == 0, "Passed!" );
 });
 
-test( "flip", function() {
-	var a = new THREE.Plane( one3, 0 );
-	
-	ok( a.normal.equals( one3 ), "Passed!" );
-	a.flip();
-	ok( a.normal.negate().equals( one3 ), "Passed!" );
-});
-
 test( "normalize", function() {
 	var a = new THREE.Plane( new THREE.Vector3( 2, 0, 0 ), 2 );
 	

+ 177 - 0
test/core/Ray.js

@@ -0,0 +1,177 @@
+/**
+ * @author bhouston / http://exocortex.com
+ */
+
+module( "Ray" );
+
+test( "constructor/equals", function() {
+	var a = new THREE.Ray();
+	ok( a.origin.equals( zero3 ), "Passed!" );
+	ok( a.direction.equals( zero3 ), "Passed!" );
+
+	a = new THREE.Ray( two3, one3 );
+	ok( a.origin.equals( two3 ), "Passed!" );
+	ok( a.direction.equals( one3 ), "Passed!" );
+});
+
+test( "copy/equals", function() {
+	var a = new THREE.Ray( zero3, one3 );
+	var b = new THREE.Ray().copy( a );
+	ok( b.origin.equals( zero3 ), "Passed!" );
+	ok( b.direction.equals( one3 ), "Passed!" );
+
+	// ensure that it is a true copy
+	a.origin = zero3;
+	a.direction = one3;
+	ok( b.origin.equals( zero3 ), "Passed!" );
+	ok( b.direction.equals( one3 ), "Passed!" );
+});
+
+test( "set", function() {
+	var a = new THREE.Ray();
+
+	a.set( one3, one3 )
+	ok( a.origin.equals( one3 ), "Passed!" );
+	ok( a.direction.equals( one3 ), "Passed!" );
+});
+
+test( "at", function() {
+	var a = new THREE.Ray( one3, new THREE.Vector3( 0, 0, 1 ) );
+
+	ok( a.at( 0 ).equals( one3 ), "Passed!" );
+	ok( a.at( -1 ).equals( new THREE.Vector3( 1, 1, 0 ) ), "Passed!" );
+	ok( a.at( 1 ).equals( new THREE.Vector3( 1, 1, 2 ) ), "Passed!" );
+});
+
+test( "recastSelf/clone", function() {
+	var a = new THREE.Ray( one3, new THREE.Vector3( 0, 0, 1 ) );
+
+	ok( a.recastSelf( 0 ).equals( a ), "Passed!" );
+
+	var b = a.clone();
+	ok( b.recastSelf( -1 ).equals( new THREE.Ray( new THREE.Vector3( 1, 1, 0 ), new THREE.Vector3( 0, 0, 1 ) ) ), "Passed!" );
+
+	var c = a.clone();
+	ok( c.recastSelf( 1 ).equals( new THREE.Ray( new THREE.Vector3( 1, 1, 2 ), new THREE.Vector3( 0, 0, 1 ) ) ), "Passed!" );
+
+	var d = a.clone();
+	var e = d.clone().recastSelf( 1 );
+	ok( d.equals( a ), "Passed!" );
+	ok( ! e.equals( d ), "Passed!" );
+	ok( e.equals( c ), "Passed!" );
+});
+
+test( "closestPointToPoint", function() {
+	var a = new THREE.Ray( one3, new THREE.Vector3( 0, 0, 1 ) );
+
+	// nearby the ray
+	var b = a.closestPointToPoint( zero3 );
+	ok( b.equals( new THREE.Vector3( 1, 1, 0 ) ), "Passed!" );
+
+	// exactly on the ray
+	var c = a.closestPointToPoint( one3 );
+	ok( c.equals( one3 ), "Passed!" );
+});
+
+test( "distanceToPoint", function() {
+	var a = new THREE.Ray( one3, new THREE.Vector3( 0, 0, 1 ) );
+
+	// nearby the ray
+	var b = a.distanceToPoint( zero3 );
+	ok( b == Math.sqrt( 2 ), "Passed!" );
+
+	// exactly on the ray
+	var c = a.distanceToPoint( one3 );
+	ok( c == 0, "Passed!" );
+});
+
+test( "isIntersectionSphere", function() {
+	var a = new THREE.Ray( one3, new THREE.Vector3( 0, 0, 1 ) );
+	var b = new THREE.Sphere( zero3, 0.5 );
+	var c = new THREE.Sphere( zero3, 1.5 );
+	var d = new THREE.Sphere( one3, 0.1 );
+	var e = new THREE.Sphere( two3, 0.1 );
+	var f = new THREE.Sphere( two3, 1 );
+
+	ok( ! a.isIntersectionSphere( b ), "Passed!" );
+	ok( a.isIntersectionSphere( c ), "Passed!" );
+	ok( a.isIntersectionSphere( d ), "Passed!" );
+	ok( ! a.isIntersectionSphere( e ), "Passed!" );
+	ok( ! a.isIntersectionSphere( f ), "Passed!" );
+});
+
+test( "isIntersectionPlane", function() {
+	var a = new THREE.Ray( one3, new THREE.Vector3( 0, 0, 1 ) );
+	
+	// parallel plane behind
+	var b = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 0, 0, 1 ), one3.clone().subSelf( new THREE.Vector3( 0, 0, -1 ) ) );
+	ok( a.isIntersectionPlane( b ), "Passed!" );
+
+	// parallel plane coincident with origin
+	var c = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 0, 0, 1 ), one3.clone().subSelf( new THREE.Vector3( 0, 0, 0 ) ) );
+	ok( a.isIntersectionPlane( c ), "Passed!" );
+
+	// parallel plane infront
+	var d = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 0, 0, 1 ), one3.clone().subSelf( new THREE.Vector3( 0, 0, 1 ) ) );
+	ok( a.isIntersectionPlane( d ), "Passed!" );
+
+	// perpendical ray that overlaps exactly
+	var e = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 1, 0, 0 ), one3 );
+	ok( a.isIntersectionPlane( e ), "Passed!" );
+
+	// perpendical ray that doesn't overlap
+	var f = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 1, 0, 0 ), zero3 );
+	ok( ! a.isIntersectionPlane( f ), "Passed!" );
+});
+
+test( "intersectPlane", function() {
+	var a = new THREE.Ray( one3, new THREE.Vector3( 0, 0, 1 ) );
+
+	// parallel plane behind
+	var b = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 0, 0, 1 ), new THREE.Vector3( 1, 1, -1 ) );
+	ok( a.intersectPlane( b ).equals( new THREE.Vector3( 1, 1, -1 ) ), "Passed!" );
+
+	// parallel plane coincident with origin
+	var c = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 0, 0, 1 ), new THREE.Vector3( 1, 1, 0 ) );
+	ok( a.intersectPlane( c ).equals( new THREE.Vector3( 1, 1, 0 ) ), "Passed!" );
+
+	// parallel plane infront
+	var d = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 0, 0, 1 ), new THREE.Vector3( 1, 1, 1 ) );
+	ok( a.intersectPlane( d ).equals( new THREE.Vector3( 1, 1, 1 ) ), "Passed!" );
+
+	// perpendical ray that overlaps exactly
+	var e = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 1, 0, 0 ), one3 );
+	ok( a.intersectPlane( e ).equals( a.origin ), "Passed!" );
+
+	// perpendical ray that doesn't overlap
+	var f = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 1, 0, 0 ), zero3 );
+	ok( a.intersectPlane( f ) === undefined, "Passed!" );
+});
+
+
+test( "transformSelf", function() {
+	var a = new THREE.Ray( one3, new THREE.Vector3( 0, 0, 1 ) );
+	var m = new THREE.Matrix4().identity();
+
+	ok( a.clone().transformSelf( m ).equals( a ), "Passed!" );
+
+	a = new THREE.Ray( zero3, new THREE.Vector3( 0, 0, 1 ) );
+	m.rotateByAxis( new THREE.Vector3( 0, 0, 1 ), Math.PI );
+	ok( a.clone().transformSelf( m ).equals( a ), "Passed!" );
+
+	m.identity().rotateX( Math.PI );
+	var b = a.clone();
+	b.direction.negate();
+	var a2 = a.clone().transformSelf( m );
+	ok( a2.origin.distanceTo( b.origin ) < 0.0001, "Passed!" );
+	ok( a2.direction.distanceTo( b.direction ) < 0.0001, "Passed!" );
+
+	a.origin = new THREE.Vector3( 0, 0, 1 );
+	b.origin = new THREE.Vector3( 0, 0, -1 );
+	var a2 = a.clone().transformSelf( m );
+	ok( a2.origin.distanceTo( b.origin ) < 0.0001, "Passed!" );
+	ok( a2.direction.distanceTo( b.direction ) < 0.0001, "Passed!" );
+});
+
+
+

+ 1 - 0
test/index.html

@@ -20,6 +20,7 @@
   <script src="core/Vector2.js"></script>
   <script src="core/Vector3.js"></script>
   <script src="core/Vector4.js"></script>
+  <script src="core/Ray.js"></script>
   
 </body>
 </html>

+ 17 - 13
utils/includes/canvas.json

@@ -1,23 +1,27 @@
 [
 	"../src/Three.js",
-	"../src/core/Color.js",
-	"../src/core/Vector2.js",
-	"../src/core/Vector3.js",
-	"../src/core/Vector4.js",
-	"../src/core/Matrix3.js",
-	"../src/core/Matrix4.js",
+	"../src/math/Color.js",
+	"../src/math/Vector2.js",
+	"../src/math/Vector3.js",
+	"../src/math/Vector4.js",
+	"../src/math/Matrix3.js",
+	"../src/math/Matrix4.js",
+	"../src/math/Box2.js",
+	"../src/math/Box3.js",
+	"../src/math/Sphere.js",
+	"../src/math/Plane.js",
+	"../src/math/Frustum.js",
+	"../src/math/Rectangle.js",
+	"../src/math/Math.js",
+	"../src/math/Quaternion.js",
+	"../src/math/Vertex.js",
+	"../src/math/UV.js",
 	"../src/core/EventTarget.js",
-	"../src/core/Frustum.js",
-	"../src/core/Ray.js",
-	"../src/core/Rectangle.js",
-	"../src/core/Math.js",
+	"../src/core/Raycaster.js",
 	"../src/core/Object3D.js",
 	"../src/core/Projector.js",
-	"../src/core/Quaternion.js",
-	"../src/core/Vertex.js",
 	"../src/core/Face3.js",
 	"../src/core/Face4.js",
-	"../src/core/UV.js",
 	"../src/core/Geometry.js",
 	"../src/cameras/Camera.js",
 	"../src/cameras/OrthographicCamera.js",

+ 20 - 19
utils/includes/common.json

@@ -1,31 +1,32 @@
 [
 	"../src/Three.js",
-	"../src/core/Clock.js",
-	"../src/core/Color.js",
-	"../src/core/Vector2.js",
-	"../src/core/Vector3.js",
-	"../src/core/Vector4.js",
-	"../src/core/Box2.js",
-	"../src/core/Box3.js",
-	"../src/core/Matrix3.js",
-	"../src/core/Matrix4.js",
+	"../src/math/Clock.js",
+	"../src/math/Color.js",
+	"../src/math/Vector2.js",
+	"../src/math/Vector3.js",
+	"../src/math/Vector4.js",
+	"../src/math/Box2.js",
+	"../src/math/Box3.js",
+	"../src/math/Matrix3.js",
+	"../src/math/Matrix4.js",
+	"../src/math/Ray.js",
+	"../src/math/Frustum.js",
+	"../src/math/Plane.js",
+	"../src/math/Rectangle.js",
+	"../src/math/Sphere.js",
+	"../src/math/Math.js",
+	"../src/math/Quaternion.js",
+	"../src/math/Spline.js",
+	"../src/math/Vertex.js",
+	"../src/math/UV.js",
 	"../src/core/EventTarget.js",
-	"../src/core/Frustum.js",
-	"../src/core/Plane.js",
-	"../src/core/Ray.js",
-	"../src/core/Rectangle.js",
-	"../src/core/Sphere.js",
-	"../src/core/Math.js",
+	"../src/core/Raycaster.js",
 	"../src/core/Object3D.js",
 	"../src/core/Projector.js",
-	"../src/core/Quaternion.js",
-	"../src/core/Vertex.js",
 	"../src/core/Face3.js",
 	"../src/core/Face4.js",
-	"../src/core/UV.js",
 	"../src/core/Geometry.js",
 	"../src/core/BufferGeometry.js",
-	"../src/core/Spline.js",
 	"../src/cameras/Camera.js",
 	"../src/cameras/OrthographicCamera.js",
 	"../src/cameras/PerspectiveCamera.js",

+ 12 - 8
utils/includes/css3d.json

@@ -1,16 +1,20 @@
 [
 	"../src/Three.js",
-	"../src/core/Vector2.js",
-	"../src/core/Vector3.js",
-	"../src/core/Vector4.js",
-	"../src/core/Matrix3.js",
-	"../src/core/Matrix4.js",
+	"../src/math/Vector2.js",
+	"../src/math/Vector3.js",
+	"../src/math/Vector4.js",
+	"../src/math/Matrix3.js",
+	"../src/math/Matrix4.js",
+	"../src/math/Quaternion.js",
+	"../src/math/Frustum.js",
+	"../src/math/Box2.js",
+	"../src/math/Box3.js",
+	"../src/math/Sphere.js",
+	"../src/math/Plane.js",
 	"../src/core/EventTarget.js",
-	"../src/core/Frustum.js",
-	"../src/core/Ray.js",
+	"../src/core/Raycaster.js",
 	"../src/core/Object3D.js",
 	"../src/core/Projector.js",
-	"../src/core/Quaternion.js",
 	"../src/cameras/Camera.js",
 	"../src/cameras/PerspectiveCamera.js",
 	"../src/lights/Light.js",

+ 19 - 15
utils/includes/webgl.json

@@ -1,27 +1,31 @@
 [
 	"../src/Three.js",
-	"../src/core/Clock.js",
-	"../src/core/Color.js",
-	"../src/core/Vector2.js",
-	"../src/core/Vector3.js",
-	"../src/core/Vector4.js",
-	"../src/core/Matrix3.js",
-	"../src/core/Matrix4.js",
+	"../src/math/Clock.js",
+	"../src/math/Color.js",
+	"../src/math/Vector2.js",
+	"../src/math/Vector3.js",
+	"../src/math/Vector4.js",
+	"../src/math/Matrix3.js",
+	"../src/math/Matrix4.js",
+	"../src/math/Frustum.js",
+	"../src/math/Rectangle.js",
+	"../src/math/Math.js",
+	"../src/math/Quaternion.js",
+	"../src/math/Vertex.js",
+	"../src/math/UV.js",
+	"../src/math/Spline.js",
+	"../src/math/Box2.js",
+	"../src/math/Box3.js",
+	"../src/math/Sphere.js",
+	"../src/math/Plane.js",
 	"../src/core/EventTarget.js",
-	"../src/core/Frustum.js",
-	"../src/core/Ray.js",
-	"../src/core/Rectangle.js",
-	"../src/core/Math.js",
+	"../src/core/Raycaster.js",
 	"../src/core/Object3D.js",
 	"../src/core/Projector.js",
-	"../src/core/Quaternion.js",
-	"../src/core/Vertex.js",
 	"../src/core/Face3.js",
 	"../src/core/Face4.js",
-	"../src/core/UV.js",
 	"../src/core/Geometry.js",
 	"../src/core/BufferGeometry.js",
-	"../src/core/Spline.js",
 	"../src/cameras/Camera.js",
 	"../src/cameras/OrthographicCamera.js",
 	"../src/cameras/PerspectiveCamera.js",