Skip to content

Commit

Permalink
Added THREE.SegmentsLine.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Apr 30, 2015
1 parent 8574cb4 commit 9b63a1d
Show file tree
Hide file tree
Showing 39 changed files with 250 additions and 172 deletions.
15 changes: 2 additions & 13 deletions docs/api/objects/Line.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand All @@ -35,18 +34,15 @@ <h2>Example</h2>

<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>

Expand All @@ -60,13 +56,6 @@ <h3>[property:Material material]</h3>
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>

Expand Down
53 changes: 53 additions & 0 deletions docs/api/objects/SegmentsLine.html
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions docs/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" ],
Expand Down
2 changes: 1 addition & 1 deletion examples/canvas_camera_orthographic.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/canvas_camera_orthographic2.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/canvas_interactive_voxelpainter.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

//
Expand Down
4 changes: 2 additions & 2 deletions examples/canvas_lines_dashed.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion examples/canvas_materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/canvas_performance.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/canvas_sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions examples/js/renderers/Projector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 ) {

Expand All @@ -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 ++ ) {

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_buffergeometry_drawcalls.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
transparent: true
} );

linesMesh = new THREE.Line( geometry, material, THREE.LinePieces );
linesMesh = new THREE.SegmentsLine( geometry, material );
group.add( linesMesh );

//
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_buffergeometry_lines_indexed.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
15 changes: 6 additions & 9 deletions examples/webgl_camera.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_custom_attributes_lines.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
39 changes: 26 additions & 13 deletions examples/webgl_helpers.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

} );

Expand Down
13 changes: 11 additions & 2 deletions examples/webgl_interactive_lines.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_interactive_voxelpainter.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

//
Expand Down
4 changes: 2 additions & 2 deletions examples/webgl_lines_dashed.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_lines_sphere.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_loader_collada.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_loader_collada_keyframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_loader_collada_kinematics.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 9b63a1d

Please sign in to comment.