Browse Source

Added THREE.SegmentsLine.

Mr.doob 10 years ago
parent
commit
9b63a1d906
39 changed files with 250 additions and 172 deletions
  1. 2 13
      docs/api/objects/Line.html
  2. 53 0
      docs/api/objects/SegmentsLine.html
  3. 1 0
      docs/list.js
  4. 1 1
      examples/canvas_camera_orthographic.html
  5. 1 1
      examples/canvas_camera_orthographic2.html
  6. 1 1
      examples/canvas_interactive_voxelpainter.html
  7. 2 2
      examples/canvas_lines_dashed.html
  8. 1 1
      examples/canvas_materials.html
  9. 1 1
      examples/canvas_performance.html
  10. 1 1
      examples/canvas_sandbox.html
  11. 3 4
      examples/js/renderers/Projector.js
  12. 1 1
      examples/webgl_buffergeometry_drawcalls.html
  13. 1 1
      examples/webgl_buffergeometry_lines_indexed.html
  14. 6 9
      examples/webgl_camera.html
  15. 1 1
      examples/webgl_custom_attributes_lines.html
  16. 26 13
      examples/webgl_helpers.html
  17. 11 2
      examples/webgl_interactive_lines.html
  18. 1 1
      examples/webgl_interactive_voxelpainter.html
  19. 2 2
      examples/webgl_lines_dashed.html
  20. 1 1
      examples/webgl_lines_sphere.html
  21. 1 1
      examples/webgl_loader_collada.html
  22. 1 1
      examples/webgl_loader_collada_keyframe.html
  23. 1 1
      examples/webgl_loader_collada_kinematics.html
  24. 1 1
      examples/webgl_materials.html
  25. 2 2
      src/extras/helpers/AxisHelper.js
  26. 2 2
      src/extras/helpers/BoxHelper.js
  27. 3 3
      src/extras/helpers/CameraHelper.js
  28. 2 2
      src/extras/helpers/EdgesHelper.js
  29. 2 3
      src/extras/helpers/FaceNormalsHelper.js
  30. 2 2
      src/extras/helpers/GridHelper.js
  31. 2 2
      src/extras/helpers/SkeletonHelper.js
  32. 2 2
      src/extras/helpers/VertexNormalsHelper.js
  33. 2 2
      src/extras/helpers/VertexTangentsHelper.js
  34. 2 2
      src/extras/helpers/WireframeHelper.js
  35. 13 9
      src/objects/Line.js
  36. 14 0
      src/objects/SegmentsLine.js
  37. 1 1
      src/renderers/WebGLRenderer.js
  38. 79 80
      test/unit/geometry/EdgesGeometry.js
  39. 1 0
      utils/build/includes/common.json

+ 2 - 13
docs/api/objects/Line.html

@@ -11,12 +11,11 @@
 
 		<h1>[name]</h1>
 
-		<div class="desc">A line or a series of lines.</div>
+		<div class="desc">A continuous line.</div>
 
 
 		<h2>Example</h2>
 
-
 		<code>var material = new THREE.LineBasicMaterial({
 			color: 0x0000ff
 		});
@@ -35,18 +34,15 @@
 
 		<h2>Constructor</h2>
 
-
-		<h3>[name]( [page:Geometry geometry], [page:Material material], [page:Integer type] )</h3>
+		<h3>[name]( [page:Geometry geometry], [page:Material material] )</h3>
 
 		<div>
 		geometry — Vertices representing the line segment(s).<br />
 		material — Material for the line. Default is [page:LineBasicMaterial LineBasicMaterial].<br />
-		type — Connection type between vertices. Default is THREE.LineStrip.
 		</div>
 
 		<div>If no material is supplied, a randomized line material will be created and assigned to the object.</div>
 
-		<div>Also, if no type is supplied, the default (THREE.LineStrip) will be used).</div>
 
 		<h2>Properties</h2>
 
@@ -60,13 +56,6 @@
 		Material for the line.
 		</div>
 
-		<h3>[property:Integer type]</h3>
-		<div>
-		Possible values: THREE.LineStrip or THREE.LinePieces. THREE.LineStrip will draw a series of segments connecting each point (first connected to the second, the second connected to the third, and so on and so forth); and THREE.LinePieces will draw a series of pairs of segments (first connected to the second, the third connected to the fourth, and so on and so forth).</div>
-
-		<div>
-		In OpenGL terms, LineStrip is the classic GL_LINE_STRIP and LinePieces is the equivalent to GL_LINES.
-		</div>
 
 		<h2>Methods</h2>
 

+ 53 - 0
docs/api/objects/SegmentsLine.html

@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html lang="en">
+	<head>
+		<meta charset="utf-8" />
+		<script src="../../list.js"></script>
+		<script src="../../page.js"></script>
+		<link type="text/css" rel="stylesheet" href="../../page.css" />
+	</head>
+	<body>
+		[page:Line] &rarr;
+
+		<h1>[name]</h1>
+
+		<div class="desc">A series of lines.</div>
+
+
+		<h2>Constructor</h2>
+
+		<h3>[name]( [page:Geometry geometry], [page:Material material] )</h3>
+
+		<div>
+		geometry — Vertices representing the line segment(s).<br />
+		material — Material for the line. Default is [page:LineBasicMaterial LineBasicMaterial].
+		</div>
+
+		<div>If no material is supplied, a randomized line material will be created and assigned to the object.</div>
+
+
+		<h2>Properties</h2>
+
+		<h3>[property:Geometry geometry]</h3>
+		<div>
+		Vertices representing the line segment(s).
+		</div>
+
+		<h3>[property:Material material]</h3>
+		<div>
+		Material for the line.
+		</div>
+
+
+		<h2>Methods</h2>
+
+		<h3>[method:Array raycast]([page:Raycaster raycaster], [page:Array intersects])</h3>
+		<div>
+		Get intersections between a casted ray and this Line. [page:Raycaster.intersectObject] will call this method.
+		</div>
+
+		<h2>Source</h2>
+
+		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+	</body>
+</html>

+ 1 - 0
docs/list.js

@@ -110,6 +110,7 @@ var list = {
 			[ "Bone", "api/objects/Bone" ],
 			[ "LensFlare", "api/objects/LensFlare" ],
 			[ "Line", "api/objects/Line" ],
+			[ "SegmentsLine", "api/objects/SegmentsLine" ],
 			[ "LOD", "api/objects/LOD" ],
 			[ "Mesh", "api/objects/Mesh" ],
 			[ "MorphAnimMesh", "api/objects/MorphAnimMesh" ],

+ 1 - 1
examples/canvas_camera_orthographic.html

@@ -68,7 +68,7 @@
 
 				var material = new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.2 } );
 
-				var line = new THREE.Line( geometry, material, THREE.LinePieces );
+				var line = new THREE.SegmentsLine( geometry, material );
 				scene.add( line );
 
 				// Cubes

+ 1 - 1
examples/canvas_camera_orthographic2.html

@@ -137,7 +137,7 @@
 
 				var material = new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.2 } );
 
-				var line = new THREE.Line( geometry, material, THREE.LinePieces );
+				var line = new THREE.SegmentsLine( geometry, material );
 				scene.add( line );
 
 				// Cubes

+ 1 - 1
examples/canvas_interactive_voxelpainter.html

@@ -73,7 +73,7 @@
 
 				var material = new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.2 } );
 
-				var line = new THREE.Line( geometry, material, THREE.LinePieces );
+				var line = new THREE.SegmentsLine( geometry, material );
 				scene.add( line );
 
 				//

+ 2 - 2
examples/canvas_lines_dashed.html

@@ -88,12 +88,12 @@
 				geometryCube.computeLineDistances();
 				geometrySpline.computeLineDistances();
 
-				var object = new THREE.Line( geometrySpline, new THREE.LineDashedMaterial( { color: 0xffffff, dashSize: 1, gapSize: 0.5 } ), THREE.LineStrip );
+				var object = new THREE.Line( geometrySpline, new THREE.LineDashedMaterial( { color: 0xffffff, dashSize: 1, gapSize: 0.5 } ) );
 
 				objects.push( object );
 				scene.add( object );
 
-				var object = new THREE.Line( geometryCube, new THREE.LineDashedMaterial( { color: 0xffaa00, dashSize: 3, gapSize: 1, linewidth: 2 } ), THREE.LinePieces );
+				var object = new THREE.SegmentsLine( geometryCube, new THREE.LineDashedMaterial( { color: 0xffaa00, dashSize: 3, gapSize: 1, linewidth: 2 } ) );
 
 				objects.push( object );
 				scene.add( object );

+ 1 - 1
examples/canvas_materials.html

@@ -60,7 +60,7 @@
 
 				var material = new THREE.LineBasicMaterial( { color: 0xffffff, opacity: 0.2 } );
 
-				var line = new THREE.Line( geometry, material, THREE.LinePieces );
+				var line = new THREE.SegmentsLine( geometry, material );
 				scene.add( line );
 
 				// Spheres

+ 1 - 1
examples/canvas_performance.html

@@ -63,7 +63,7 @@
 
 				var material = new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.5 } );
 
-				var line = new THREE.Line( geometry, material, THREE.LinePieces );
+				var line = new THREE.SegmentsLine( geometry, material );
 				scene.add( line );
 
 				// Spheres

+ 1 - 1
examples/canvas_sandbox.html

@@ -85,7 +85,7 @@
 
 				var material = new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.5 } );
 
-				var line = new THREE.Line( geometry, material, THREE.LinePieces );
+				var line = new THREE.SegmentsLine( geometry, material );
 				scene.add( line );
 
 				// Spheres

+ 3 - 4
examples/js/renderers/Projector.js

@@ -468,7 +468,7 @@ THREE.Projector = function () {
 					_normalMatrix.getNormalMatrix( _modelMatrix );
 
 					var material = object.material;
-					
+
 					var isFaceMaterial = material instanceof THREE.MeshFaceMaterial;
 					var objectMaterials = isFaceMaterial === true ? object.material : null;
 
@@ -616,7 +616,7 @@ THREE.Projector = function () {
 
 						} else {
 
-							var step = object.mode === THREE.LinePieces ? 2 : 1;
+							var step = object instanceof THREE.SegmentsLine ? 2 : 1;
 
 							for ( var i = 0, l = ( positions.length / 3 ) - 1; i < l; i += step ) {
 
@@ -639,8 +639,7 @@ THREE.Projector = function () {
 					v1 = getNextVertexInPool();
 					v1.positionScreen.copy( vertices[ 0 ] ).applyMatrix4( _modelViewProjectionMatrix );
 
-					// Handle LineStrip and LinePieces
-					var step = object.mode === THREE.LinePieces ? 2 : 1;
+					var step = object instanceof THREE.SegmentsLine ? 2 : 1;
 
 					for ( var v = 1, vl = vertices.length; v < vl; v ++ ) {
 

+ 1 - 1
examples/webgl_buffergeometry_drawcalls.html

@@ -177,7 +177,7 @@
 					transparent: true
 				} );
 
-				linesMesh = new THREE.Line( geometry, material, THREE.LinePieces );
+				linesMesh = new THREE.SegmentsLine( geometry, material );
 				group.add( linesMesh );
 
 				//

+ 1 - 1
examples/webgl_buffergeometry_lines_indexed.html

@@ -187,7 +187,7 @@
 				geometry.addAttribute( 'color', new THREE.BufferAttribute( new Float32Array( colors ), 3 ) );
 				geometry.computeBoundingSphere();
 
-				mesh = new THREE.Line( geometry, material, THREE.LinePieces );
+				mesh = new THREE.SegmentsLine( geometry, material );
 				mesh.position.x -= 1200;
 				mesh.position.y -= 1200;
 

+ 6 - 9
examples/webgl_camera.html

@@ -102,25 +102,22 @@
 
 				//
 
-				mesh = new THREE.Line(
+				mesh = new THREE.SegmentsLine(
 					new THREE.WireframeGeometry( new THREE.SphereBufferGeometry( 100, 16, 8 ) ),
-					new THREE.LineBasicMaterial( { color: 0xffffff } ),
-					THREE.LinePieces
+					new THREE.LineBasicMaterial( { color: 0xffffff } )
 				);
 				scene.add( mesh );
 
-				var mesh2 = new THREE.Line(
+				var mesh2 = new THREE.SegmentsLine(
 					new THREE.WireframeGeometry( new THREE.SphereBufferGeometry( 50, 16, 8 ) ),
-					new THREE.LineBasicMaterial( { color: 0x00ff00 } ),
-					THREE.LinePieces
+					new THREE.LineBasicMaterial( { color: 0x00ff00 } )
 				);
 				mesh2.position.y = 150;
 				mesh.add( mesh2 );
 
-				var mesh3 = new THREE.Line(
+				var mesh3 = new THREE.SegmentsLine(
 					new THREE.WireframeGeometry( new THREE.SphereBufferGeometry( 5, 16, 8 ) ),
-					new THREE.LineBasicMaterial( { color: 0x0000ff } ),
-					THREE.LinePieces
+					new THREE.LineBasicMaterial( { color: 0x0000ff } )
 				);
 				mesh3.position.z = 150;
 				cameraRig.add( mesh3 );

+ 1 - 1
examples/webgl_custom_attributes_lines.html

@@ -165,7 +165,7 @@
 
 			geometry.center();
 
-			object = new THREE.Line( geometry, shaderMaterial, THREE.LineStrip );
+			object = new THREE.Line( geometry, shaderMaterial );
 
 			var vertices = object.geometry.vertices;
 

+ 26 - 13
examples/webgl_helpers.html

@@ -53,20 +53,33 @@
 
 					var material = new THREE.MeshLambertMaterial();
 
-					var mesh = new THREE.Mesh( geometry, material );
-					mesh.scale.multiplyScalar( 50 );
-					scene.add( mesh );
-
-					scene.add( new THREE.FaceNormalsHelper( mesh, 10 ) );
-					scene.add( new THREE.VertexNormalsHelper( mesh, 10 ) );
+					var group = new THREE.Group();
+					group.scale.multiplyScalar( 50 );
+					scene.add( group );
 
-					var helper = new THREE.WireframeHelper( mesh );
-					helper.material.depthTest = false;
-					helper.material.opacity = 0.25;
-					helper.material.transparent = true;
-					scene.add( helper );
-
-					scene.add( new THREE.BoxHelper( mesh ) );
+					var mesh = new THREE.Mesh( geometry, material );
+					group.add( mesh );
+
+					group.add( new THREE.FaceNormalsHelper( mesh, 0.1 ) );
+					group.add( new THREE.VertexNormalsHelper( mesh, 0.1 ) );
+
+					group.add( new THREE.BoxHelper( mesh ) );
+
+					var wireframe = new THREE.WireframeGeometry( geometry );
+					var line = new THREE.SegmentsLine( wireframe );
+					line.material.depthTest = false;
+					line.material.opacity = 0.25;
+					line.material.transparent = true;
+					line.position.x = 4;
+					group.add( line );
+
+					var edges = new THREE.EdgesGeometry( geometry );
+					var line = new THREE.SegmentsLine( edges );
+					line.material.depthTest = false;
+					line.material.opacity = 0.25;
+					line.material.transparent = true;
+					line.position.x = -4;
+					group.add( line );
 
 				} );
 

+ 11 - 2
examples/webgl_interactive_lines.html

@@ -89,8 +89,17 @@
 
 				for ( var i = 0; i < 50; i ++ ) {
 
-					var type = Math.random() > 0.5 ? THREE.LineStrip : THREE.LinePieces;
-					var object = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: Math.random() * 0xffffff } ), type );
+					var object;
+
+					if ( Math.random() > 0.5 ) {
+
+						object = new THREE.Line( geometry );
+
+					} else {
+
+						object = new THREE.SegmentsLine( geometry );
+
+					}
 
 					object.position.x = Math.random() * 400 - 200;
 					object.position.y = Math.random() * 400 - 200;

+ 1 - 1
examples/webgl_interactive_voxelpainter.html

@@ -87,7 +87,7 @@
 
 				var material = new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.2, transparent: true } );
 
-				var line = new THREE.Line( geometry, material, THREE.LinePieces );
+				var line = new THREE.SegmentsLine( geometry, material );
 				scene.add( line );
 
 				//

+ 2 - 2
examples/webgl_lines_dashed.html

@@ -85,12 +85,12 @@
 				geometryCube.computeLineDistances();
 				geometrySpline.computeLineDistances();
 
-				var object = new THREE.Line( geometrySpline, new THREE.LineDashedMaterial( { color: 0xffffff, dashSize: 1, gapSize: 0.5 } ), THREE.LineStrip );
+				var object = new THREE.Line( geometrySpline, new THREE.LineDashedMaterial( { color: 0xffffff, dashSize: 1, gapSize: 0.5 } ) );
 
 				objects.push( object );
 				scene.add( object );
 
-				var object = new THREE.Line( geometryCube, new THREE.LineDashedMaterial( { color: 0xffaa00, dashSize: 3, gapSize: 1, linewidth: 2 } ), THREE.LinePieces );
+				var object = new THREE.SegmentsLine( geometryCube, new THREE.LineDashedMaterial( { color: 0xffaa00, dashSize: 3, gapSize: 1, linewidth: 2 } ) );
 
 				objects.push( object );
 				scene.add( object );

+ 1 - 1
examples/webgl_lines_sphere.html

@@ -91,7 +91,7 @@
 
 					material = new THREE.LineBasicMaterial( { color: p[ 1 ], opacity: p[ 2 ], linewidth: p[ 3 ] } );
 
-					line = new THREE.Line( geometry, material, THREE.LinePieces );
+					line = new THREE.SegmentsLine( geometry, material );
 					line.scale.x = line.scale.y = line.scale.z = p[ 0 ];
 					line.originalScale = p[ 0 ];
 					line.rotation.y = Math.random() * Math.PI;

+ 1 - 1
examples/webgl_loader_collada.html

@@ -101,7 +101,7 @@
 
 				}
 
-				var line = new THREE.Line( geometry, material, THREE.LinePieces );
+				var line = new THREE.SegmentsLine( geometry, material );
 				scene.add( line );
 
 				// Add the COLLADA

+ 1 - 1
examples/webgl_loader_collada_keyframe.html

@@ -113,7 +113,7 @@
 
 				}
 
-				var line = new THREE.Line( geometry, material, THREE.LinePieces );
+				var line = new THREE.SegmentsLine( geometry, material );
 				scene.add( line );
 
 				// Add the COLLADA

+ 1 - 1
examples/webgl_loader_collada_kinematics.html

@@ -108,7 +108,7 @@
 
 				}
 
-				var line = new THREE.Line( geometry, material, THREE.LinePieces );
+				var line = new THREE.SegmentsLine( geometry, material );
 				scene.add( line );
 
 				// Add the COLLADA

+ 1 - 1
examples/webgl_materials.html

@@ -60,7 +60,7 @@
 
 				}
 
-				var line = new THREE.Line( geometry, line_material, THREE.LinePieces );
+				var line = new THREE.SegmentsLine( geometry, line_material );
 				scene.add( line );
 
 				// Materials

+ 2 - 2
src/extras/helpers/AxisHelper.js

@@ -25,9 +25,9 @@ THREE.AxisHelper = function ( size ) {
 
 	var material = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors } );
 
-	THREE.Line.call( this, geometry, material, THREE.LinePieces );
+	THREE.SegmentsLine.call( this, geometry, material );
 
 };
 
-THREE.AxisHelper.prototype = Object.create( THREE.Line.prototype );
+THREE.AxisHelper.prototype = Object.create( THREE.SegmentsLine.prototype );
 THREE.AxisHelper.prototype.constructor = THREE.AxisHelper;

+ 2 - 2
src/extras/helpers/BoxHelper.js

@@ -7,7 +7,7 @@ THREE.BoxHelper = function ( object ) {
 	var geometry = new THREE.BufferGeometry();
 	geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( 72 ), 3 ) );
 
-	THREE.Line.call( this, geometry, new THREE.LineBasicMaterial( { color: 0xffff00 } ), THREE.LinePieces );
+	THREE.SegmentsLine.call( this, geometry, new THREE.LineBasicMaterial( { color: 0xffff00 } ) );
 
 	if ( object !== undefined ) {
 
@@ -17,7 +17,7 @@ THREE.BoxHelper = function ( object ) {
 
 };
 
-THREE.BoxHelper.prototype = Object.create( THREE.Line.prototype );
+THREE.BoxHelper.prototype = Object.create( THREE.SegmentsLine.prototype );
 THREE.BoxHelper.prototype.constructor = THREE.BoxHelper;
 
 THREE.BoxHelper.prototype.update = function ( object ) {

+ 3 - 3
src/extras/helpers/CameraHelper.js

@@ -91,7 +91,7 @@ THREE.CameraHelper = function ( camera ) {
 
 	}
 
-	THREE.Line.call( this, geometry, material, THREE.LinePieces );
+	THREE.SegmentsLine.call( this, geometry, material );
 
 	this.camera = camera;
 	this.matrix = camera.matrixWorld;
@@ -103,13 +103,13 @@ THREE.CameraHelper = function ( camera ) {
 
 };
 
-THREE.CameraHelper.prototype = Object.create( THREE.Line.prototype );
+THREE.CameraHelper.prototype = Object.create( THREE.SegmentsLine.prototype );
 THREE.CameraHelper.prototype.constructor = THREE.CameraHelper;
 
 THREE.CameraHelper.prototype.update = function () {
 
 	var geometry, pointMap;
-	
+
 	var vector = new THREE.Vector3();
 	var camera = new THREE.Camera();
 

+ 2 - 2
src/extras/helpers/EdgesHelper.js

@@ -12,12 +12,12 @@ THREE.EdgesHelper = function ( object, hex, thresholdAngle ) {
 
 	var color = ( hex !== undefined ) ? hex : 0xffffff;
 
-	THREE.Line.call( this, new THREE.EdgesGeometry( object.geometry, thresholdAngle ), new THREE.LineBasicMaterial( { color: color } ), THREE.LinePieces );
+	THREE.SegmentsLine.call( this, new THREE.EdgesGeometry( object.geometry, thresholdAngle ), new THREE.LineBasicMaterial( { color: color } ) );
 
 	this.matrix = object.matrixWorld;
 	this.matrixAutoUpdate = false;
 
 };
 
-THREE.EdgesHelper.prototype = Object.create( THREE.Line.prototype );
+THREE.EdgesHelper.prototype = Object.create( THREE.SegmentsLine.prototype );
 THREE.EdgesHelper.prototype.constructor = THREE.EdgesHelper;

+ 2 - 3
src/extras/helpers/FaceNormalsHelper.js

@@ -23,7 +23,7 @@ THREE.FaceNormalsHelper = function ( object, size, hex, linewidth ) {
 
 	}
 
-	THREE.Line.call( this, geometry, new THREE.LineBasicMaterial( { color: color, linewidth: width } ), THREE.LinePieces );
+	THREE.SegmentsLine.call( this, geometry, new THREE.LineBasicMaterial( { color: color, linewidth: width } ) );
 
 	this.matrixAutoUpdate = false;
 
@@ -33,7 +33,7 @@ THREE.FaceNormalsHelper = function ( object, size, hex, linewidth ) {
 
 };
 
-THREE.FaceNormalsHelper.prototype = Object.create( THREE.Line.prototype );
+THREE.FaceNormalsHelper.prototype = Object.create( THREE.SegmentsLine.prototype );
 THREE.FaceNormalsHelper.prototype.constructor = THREE.FaceNormalsHelper;
 
 THREE.FaceNormalsHelper.prototype.update = function () {
@@ -72,4 +72,3 @@ THREE.FaceNormalsHelper.prototype.update = function () {
 	return this;
 
 };
-

+ 2 - 2
src/extras/helpers/GridHelper.js

@@ -23,11 +23,11 @@ THREE.GridHelper = function ( size, step ) {
 
 	}
 
-	THREE.Line.call( this, geometry, material, THREE.LinePieces );
+	THREE.SegmentsLine.call( this, geometry, material );
 
 };
 
-THREE.GridHelper.prototype = Object.create( THREE.Line.prototype );
+THREE.GridHelper.prototype = Object.create( THREE.SegmentsLine.prototype );
 THREE.GridHelper.prototype.constructor = THREE.GridHelper;
 
 THREE.GridHelper.prototype.setColors = function( colorCenterLine, colorGrid ) {

+ 2 - 2
src/extras/helpers/SkeletonHelper.js

@@ -28,7 +28,7 @@ THREE.SkeletonHelper = function ( object ) {
 
 	var material = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors, depthTest: false, depthWrite: false, transparent: true } );
 
-	THREE.Line.call( this, geometry, material, THREE.LinePieces );
+	THREE.SegmentsLine.call( this, geometry, material );
 
 	this.root = object;
 
@@ -40,7 +40,7 @@ THREE.SkeletonHelper = function ( object ) {
 };
 
 
-THREE.SkeletonHelper.prototype = Object.create( THREE.Line.prototype );
+THREE.SkeletonHelper.prototype = Object.create( THREE.SegmentsLine.prototype );
 THREE.SkeletonHelper.prototype.constructor = THREE.SkeletonHelper;
 
 THREE.SkeletonHelper.prototype.getBoneList = function( object ) {

+ 2 - 2
src/extras/helpers/VertexNormalsHelper.js

@@ -29,7 +29,7 @@ THREE.VertexNormalsHelper = function ( object, size, hex, linewidth ) {
 
 	}
 
-	THREE.Line.call( this, geometry, new THREE.LineBasicMaterial( { color: color, linewidth: width } ), THREE.LinePieces );
+	THREE.SegmentsLine.call( this, geometry, new THREE.LineBasicMaterial( { color: color, linewidth: width } ) );
 
 	this.matrixAutoUpdate = false;
 
@@ -39,7 +39,7 @@ THREE.VertexNormalsHelper = function ( object, size, hex, linewidth ) {
 
 };
 
-THREE.VertexNormalsHelper.prototype = Object.create( THREE.Line.prototype );
+THREE.VertexNormalsHelper.prototype = Object.create( THREE.SegmentsLine.prototype );
 THREE.VertexNormalsHelper.prototype.constructor = THREE.VertexNormalsHelper;
 
 THREE.VertexNormalsHelper.prototype.update = ( function ( object ) {

+ 2 - 2
src/extras/helpers/VertexTangentsHelper.js

@@ -30,7 +30,7 @@ THREE.VertexTangentsHelper = function ( object, size, hex, linewidth ) {
 
 	}
 
-	THREE.Line.call( this, geometry, new THREE.LineBasicMaterial( { color: color, linewidth: width } ), THREE.LinePieces );
+	THREE.SegmentsLine.call( this, geometry, new THREE.LineBasicMaterial( { color: color, linewidth: width } ) );
 
 	this.matrixAutoUpdate = false;
 
@@ -38,7 +38,7 @@ THREE.VertexTangentsHelper = function ( object, size, hex, linewidth ) {
 
 };
 
-THREE.VertexTangentsHelper.prototype = Object.create( THREE.Line.prototype );
+THREE.VertexTangentsHelper.prototype = Object.create( THREE.SegmentsLine.prototype );
 THREE.VertexTangentsHelper.prototype.constructor = THREE.VertexTangentsHelper;
 
 THREE.VertexTangentsHelper.prototype.update = ( function ( object ) {

+ 2 - 2
src/extras/helpers/WireframeHelper.js

@@ -6,12 +6,12 @@ THREE.WireframeHelper = function ( object, hex ) {
 
 	var color = ( hex !== undefined ) ? hex : 0xffffff;
 
-	THREE.Line.call( this, new THREE.WireframeGeometry( object.geometry ), new THREE.LineBasicMaterial( { color: color } ), THREE.LinePieces );
+	THREE.SegmentsLine.call( this, new THREE.WireframeGeometry( object.geometry ), new THREE.LineBasicMaterial( { color: color } ) );
 
 	this.matrix = object.matrixWorld;
 	this.matrixAutoUpdate = false;
 
 };
 
-THREE.WireframeHelper.prototype = Object.create( THREE.Line.prototype );
+THREE.WireframeHelper.prototype = Object.create( THREE.SegmentsLine.prototype );
 THREE.WireframeHelper.prototype.constructor = THREE.WireframeHelper;

+ 13 - 9
src/objects/Line.js

@@ -4,6 +4,12 @@
 
 THREE.Line = function ( geometry, material, mode ) {
 
+	if ( mode === 1 ) {
+
+		THREE.error( 'THREE.Line: THREE.LinePieces mode has been removed. Use THREE.SegmentsLine instead.' );
+
+	}
+
 	THREE.Object3D.call( this );
 
 	this.type = 'Line';
@@ -11,13 +17,8 @@ THREE.Line = function ( geometry, material, mode ) {
 	this.geometry = geometry !== undefined ? geometry : new THREE.Geometry();
 	this.material = material !== undefined ? material : new THREE.LineBasicMaterial( { color: Math.random() * 0xffffff } );
 
-	this.mode = mode !== undefined ? mode : THREE.LineStrip;
-
 };
 
-THREE.LineStrip = 0;
-THREE.LinePieces = 1;
-
 THREE.Line.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Line.prototype.constructor = THREE.Line;
 
@@ -54,7 +55,7 @@ THREE.Line.prototype.raycast = ( function () {
 		var vEnd = new THREE.Vector3();
 		var interSegment = new THREE.Vector3();
 		var interRay = new THREE.Vector3();
-		var step = this.mode === THREE.LineStrip ? 1 : 2;
+		var step = this instanceof THREE.SegmentsLine ? 2 : 1;
 
 		if ( geometry instanceof THREE.BufferGeometry ) {
 
@@ -184,7 +185,7 @@ THREE.Line.prototype.raycast = ( function () {
 
 THREE.Line.prototype.clone = function ( object ) {
 
-	if ( object === undefined ) object = new THREE.Line( this.geometry, this.material, this.mode );
+	if ( object === undefined ) object = new THREE[ this.type ]( this.geometry, this.material );
 
 	THREE.Object3D.prototype.clone.call( this, object );
 
@@ -196,8 +197,6 @@ THREE.Line.prototype.toJSON = function ( meta ) {
 
 	var data = THREE.Object3D.prototype.toJSON.call( this, meta );
 
-	data.object.mode = this.mode;
-
 	// only serialize if not in meta geometries cache
 	if ( meta.geometries[ this.geometry.uuid ] === undefined ) {
 		meta.geometries[ this.geometry.uuid ] = this.geometry.toJSON();
@@ -214,3 +213,8 @@ THREE.Line.prototype.toJSON = function ( meta ) {
 	return data;
 
 };
+
+// DEPRECATED
+
+THREE.LineStrip = 0;
+THREE.LinePieces = 1;

+ 14 - 0
src/objects/SegmentsLine.js

@@ -0,0 +1,14 @@
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+THREE.SegmentsLine = function ( geometry, material ) {
+
+	THREE.Line.call( this, geometry, material );
+
+	this.type = 'SegmentsLine';
+
+};
+
+THREE.SegmentsLine.prototype = Object.create( THREE.Line.prototype );
+THREE.SegmentsLine.prototype.constructor = THREE.SegmentsLine;

+ 1 - 1
src/renderers/WebGLRenderer.js

@@ -1190,7 +1190,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	function renderLine( material, geometry, object, program, updateBuffers ) {
 
-		var mode = ( object.mode === THREE.LineStrip ) ? _gl.LINE_STRIP : _gl.LINES;
+		var mode = object instanceof THREE.SegmentsLine ? _gl.LINES : _gl.LINE_STRIP;
 
 		// In case user is not using Line*Material by mistake
 		var lineWidth = material.linewidth !== undefined ? material.linewidth : 1;

+ 79 - 80
test/unit/geometry/EdgesGeometry.js

@@ -3,7 +3,7 @@ module( "EdgesGeometry" );
 var DEBUG = false;
 
 var vertList = [
-	new THREE.Vector3(0, 0, 0), 
+	new THREE.Vector3(0, 0, 0),
 	new THREE.Vector3(1, 0, 0),
 	new THREE.Vector3(1, 1, 0),
 	new THREE.Vector3(0, 1, 0),
@@ -11,72 +11,72 @@ var vertList = [
 ];
 
 test( "singularity", function() {
-	
+
 	testEdges( vertList, [1, 1, 1], 0 );
-	
+
 });
 
 test( "needle", function() {
-	
+
 	testEdges( vertList, [0, 0, 1], 0 );
-	
+
 });
 
 test( "single triangle", function() {
-	
+
 	testEdges( vertList, [0, 1, 2], 3 );
-	
+
 });
 
 test( "two isolated triangles", function() {
-	
+
 	var vertList = [
-		new THREE.Vector3(0, 0, 0), 
+		new THREE.Vector3(0, 0, 0),
 		new THREE.Vector3(1, 0, 0),
 		new THREE.Vector3(1, 1, 0),
-		new THREE.Vector3(0, 0, 1), 
+		new THREE.Vector3(0, 0, 1),
 		new THREE.Vector3(1, 0, 1),
 		new THREE.Vector3(1, 1, 1),
 	];
-	
+
 	testEdges( vertList, [0, 1, 2, 3, 4, 5], 6 );
-	
+
 });
 
 test( "two flat triangles", function() {
-	
+
 	testEdges( vertList, [0, 1, 2, 0, 2, 3], 4 );
-	
+
 });
 
 test( "two flat triangles, inverted", function() {
-	
+
 	testEdges( vertList, [0, 1, 2, 0, 3, 2], 5 );
-	
+
 });
 
 test( "two non-coplanar triangles", function() {
-	
+
 	testEdges( vertList, [0, 1, 2, 0, 4, 2], 5 );
-	
+
 });
 
 test( "three triangles, coplanar first", function() {
-	
+
 	testEdges( vertList, [0, 1, 2, 0, 2, 3, 0, 4, 2], 7 );
-	
+
 });
 
 test( "three triangles, coplanar last", function() {
-	
+
 	testEdges( vertList, [0, 1, 2, 0, 4, 2, 0, 2, 3], 6 ); // Should be 7
-	
+
 });
 
 test( "tetrahedron", function() {
-	
+
 	testEdges( vertList, [0, 1, 2, 0, 1, 4, 0, 4, 2, 1, 2, 4], 6 );
-	
+
 });
 
 
@@ -86,122 +86,122 @@ test( "tetrahedron", function() {
 //
 
 function testEdges ( vertList, idxList, numAfter ) {
-	
+
 	var geoms = createGeometries ( vertList, idxList );
 
 	for ( var i = 0 ; i < geoms.length ; i ++ ) {
-	
+
 		var geom = geoms[i];
 
 		var numBefore = idxList.length;
 		equal( countEdges (geom), numBefore, "Edges before!" );
-	
+
 		var egeom = new THREE.EdgesGeometry ( geom );;
-	
+
 		equal( countEdges (egeom), numAfter, "Edges after!" );
 		output( geom, egeom );
-		
+
 	}
-	
+
 }
 
 function createGeometries ( vertList, idxList ) {
-	
+
 	var geomIB = createIndexedBufferGeometry ( vertList, idxList );
 	var geom = new THREE.Geometry().fromBufferGeometry( geomIB );
 	var geomB = new THREE.BufferGeometry().fromGeometry( geom );
 	var geomDC = addDrawCalls( geomIB.clone() );
 	return [ geom, geomB, geomIB, geomDC ];
-	
+
 }
 
 function createIndexedBufferGeometry ( vertList, idxList ) {
-	
+
 	var geom = new THREE.BufferGeometry();
-	
-	var indexTable = [];	
+
+	var indexTable = [];
 	var numTris = idxList.length / 3;
 	var numVerts = 0;
 
 	var indices = new Uint32Array( numTris * 3 );
 	var vertices = new Float32Array( vertList.length * 3 );
-	
+
 	for ( var i = 0; i < numTris; i ++ ) {
 
 		for ( var j = 0; j < 3; j ++ ) {
-			
+
 			var idx = idxList[ 3 * i + j ];
 			if ( indexTable[ idx ] === undefined ) {
-				
+
 				var v = vertList[ idx ];
 				vertices[ 3 * numVerts ] = v.x;
 				vertices[ 3 * numVerts + 1 ] = v.y;
 				vertices[ 3 * numVerts + 2 ] = v.z;
-				
+
 				indexTable[ idx ] = numVerts;
-				
+
 				numVerts ++;
-				
+
 			}
-			
+
 			indices[ 3 * i + j ] = indexTable[ idx ] ;
-			
+
 		}
-		
+
 	}
-	
+
 	vertices = vertices.subarray( 0, 3 * numVerts );
-	
+
 	geom.addAttribute( 'index', new THREE.BufferAttribute( indices, 1 ) );
 	geom.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
-		
+
 	geom.computeFaceNormals();
-	
+
 	return geom;
-	
+
 }
 
 function addDrawCalls ( geometry ) {
-	
+
 	var numTris = geometry.getAttribute( 'index' ).length / 3;
-	
+
 	var offset = 0;
 	for ( var i = 0 ; i < numTris; i ++ ) {
 
 		var start = i * 3;
 		var count = 3;
-	
+
 		geometry.addDrawCall ( start, count, offset );
-	
+
 	}
-	
+
 	return geometry;
-	
+
 }
 
 function countEdges ( geom ) {
-	
+
 	if ( geom instanceof THREE.EdgesGeometry ) {
-		
+
 		return geom.getAttribute( 'position' ).length / 2;
-		
+
 	}
-	
+
 	if ( geom.faces !== undefined ) {
-		
+
 		return geom.faces.length * 3;
-		
+
 	}
-		
+
 	var indices = geom.getAttribute( 'index' );
 	if ( indices !== undefined ) {
-		
+
 		return indices.length;
-		 
+
 	}
-		
+
 	return geom.getAttribute( 'position' ).length;
-	
+
 }
 
 //
@@ -214,23 +214,23 @@ var scene = new THREE.Scene();
 var xoffset = 0;
 
 function output ( geom, egeom ) {
-	
+
 	if ( DEBUG !== true ) return;
-	
+
 	if ( !renderer ) initDebug();
-	
+
 	var mesh = new THREE.Mesh( geom, undefined );
-	var edges = new THREE.Line( egeom, new THREE.LineBasicMaterial( { color: 'black' }), THREE.LinePieces );
+	var edges = new THREE.SegmentsLine( egeom, new THREE.LineBasicMaterial( { color: 'black' } ) );
 
 	mesh.position.setX( xoffset );
 	edges.position.setX( xoffset ++ );
 	scene.add(mesh);
 	scene.add(edges);
-	
+
 	if (scene.children.length % 8 === 0) {
 		xoffset += 2;
 	}
-	
+
 }
 
 function initDebug () {
@@ -238,12 +238,12 @@ function initDebug () {
 	renderer = new THREE.WebGLRenderer({
 
 		antialias: true
-		
+
 	});
-	
+
 	var width = 600;
 	var height = 480;
-	
+
 	renderer.setSize(width, height);
 	renderer.setClearColor( 0xCCCCCC );
 
@@ -251,12 +251,12 @@ function initDebug () {
 	camera.position.x = 30;
 	camera.position.z = 40;
 	camera.lookAt(new THREE.Vector3(30, 0, 0));
-	
+
 	document.body.appendChild(renderer.domElement);
 
 	var controls = new THREE.OrbitControls( camera, renderer.domElement );
 	controls.target = new THREE.Vector3(30, 0, 0);
-	
+
 	animate();
 
 	function animate() {
@@ -264,10 +264,9 @@ function initDebug () {
 		requestAnimationFrame( animate );
 
 		controls.update();
-		
+
 		renderer.render( scene, camera );
 
 	}
-	
-}
 
+}

+ 1 - 0
utils/build/includes/common.json

@@ -78,6 +78,7 @@
 	"src/objects/Group.js",
 	"src/objects/PointCloud.js",
 	"src/objects/Line.js",
+	"src/objects/SegmentsLine.js",
 	"src/objects/Mesh.js",
 	"src/objects/Bone.js",
 	"src/objects/Skeleton.js",