Skip to content

Commit

Permalink
Fix closed curves and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
WestLangley committed Nov 24, 2015
1 parent eb9527f commit 7aa6271
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions examples/webgl_geometry_shapes.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
info.style.top = '10px';
info.style.width = '100%';
info.style.textAlign = 'center';
info.innerHTML = 'Simple procedurally generated 3D shapes<br/>Drag to spin';
info.innerHTML = 'Simple procedurally-generated shapes<br/>Drag to spin';
container.appendChild( info );

scene = new THREE.Scene();
Expand All @@ -64,15 +64,13 @@
group.position.y = 50;
scene.add( group );

var texture = THREE.ImageUtils.loadTexture( "textures/UV_Grid_Sm.jpg" );
var loader = new THREE.TextureLoader();
var texture = loader.load( "textures/UV_Grid_Sm.jpg" );
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set( 0.008, 0.008 );

function addShape( shape, extrudeSettings, color, x, y, z, rx, ry, rz, s ) {

var points = shape.createPointsGeometry();
var spacedPoints = shape.createSpacedPointsGeometry( 50 );

// flat shape with texture
// note: default UVs generated by ShapeGemoetry are simply the x- and y-coordinates of the vertices

Expand All @@ -94,7 +92,7 @@
mesh.scale.set( s, s, s );
group.add( mesh );

// 3d shape
// extruded shape

var geometry = new THREE.ExtrudeGeometry( shape, extrudeSettings );

Expand All @@ -104,6 +102,12 @@
mesh.scale.set( s, s, s );
group.add( mesh );

// lines

shape.autoClose = true;
var points = shape.createPointsGeometry();
var spacedPoints = shape.createSpacedPointsGeometry( 50 );

// solid line

var line = new THREE.Line( points, new THREE.LineBasicMaterial( { color: color, linewidth: 3 } ) );
Expand All @@ -112,31 +116,29 @@
line.scale.set( s, s, s );
group.add( line );

// vertices from real points

var pgeo = points.clone();
var particles = new THREE.Points( pgeo, new THREE.PointsMaterial( { color: color, size: 4 } ) );
particles.position.set( x, y, z + 25 );
particles.rotation.set( rx, ry, rz );
particles.scale.set( s, s, s );
group.add( particles );

// line from equidistance sampled points

var line = new THREE.Line( spacedPoints, new THREE.LineBasicMaterial( { color: color, linewidth: 3 } ) );
line.position.set( x, y, z + 75 );
line.position.set( x, y, z + 25 );
line.rotation.set( rx, ry, rz );
line.scale.set( s, s, s );
group.add( line );

// vertices from real points

var particles = new THREE.Points( points, new THREE.PointsMaterial( { color: color, size: 4 } ) );
particles.position.set( x, y, z + 75 );
particles.rotation.set( rx, ry, rz );
particles.scale.set( s, s, s );
group.add( particles );

// equidistance sampled points

var pgeo = spacedPoints.clone();
var particles2 = new THREE.Points( pgeo, new THREE.PointsMaterial( { color: color, size: 4 } ) );
particles2.position.set( x, y, z + 125 );
particles2.rotation.set( rx, ry, rz );
particles2.scale.set( s, s, s );
group.add( particles2 );
var particles = new THREE.Points( spacedPoints, new THREE.PointsMaterial( { color: color, size: 4 } ) );
particles.position.set( x, y, z + 125 );
particles.rotation.set( rx, ry, rz );
particles.scale.set( s, s, s );
group.add( particles );

}

Expand Down

0 comments on commit 7aa6271

Please sign in to comment.