Skip to content

Commit

Permalink
Improved webgl_interactive_raycasting_points example.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Dec 26, 2018
1 parent 2ad018c commit 76d0e23
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions examples/webgl_interactive_raycasting_points.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@

var threshold = 0.1;
var pointSize = 0.05;
var width = 150;
var length = 150;
var width = 80;
var length = 160;
var rotateY = new THREE.Matrix4().makeRotationY( 0.005 );

init();
Expand All @@ -79,7 +79,7 @@
var u = i / width;
var v = j / length;
var x = u - 0.5;
var y = ( Math.cos( u * Math.PI * 8 ) + Math.sin( v * Math.PI * 8 ) ) / 20;
var y = ( Math.cos( u * Math.PI * 4 ) + Math.sin( v * Math.PI * 8 ) ) / 20;
var z = v - 0.5;

positions[ 3 * k ] = x;
Expand Down Expand Up @@ -108,11 +108,9 @@
function generatePointcloud( color, width, length ) {

var geometry = generatePointCloudGeometry( color, width, length );

var material = new THREE.PointsMaterial( { size: pointSize, vertexColors: THREE.VertexColors } );
var pointcloud = new THREE.Points( geometry, material );

return pointcloud;
return new THREE.Points( geometry, material );

}

Expand All @@ -138,9 +136,8 @@
geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );

var material = new THREE.PointsMaterial( { size: pointSize, vertexColors: THREE.VertexColors } );
var pointcloud = new THREE.Points( geometry, material );

return pointcloud;
return new THREE.Points( geometry, material );

}

Expand All @@ -167,9 +164,8 @@
geometry.addGroup( 0, indices.length );

var material = new THREE.PointsMaterial( { size: pointSize, vertexColors: THREE.VertexColors } );
var pointcloud = new THREE.Points( geometry, material );

return pointcloud;
return new THREE.Points( geometry, material );

}

Expand All @@ -182,25 +178,25 @@
clock = new THREE.Clock();

camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.set( 15, 15, 15 );
camera.position.set( 10, 10, 10 );
camera.lookAt( scene.position );
camera.updateMatrix();

//

var pcBuffer = generatePointcloud( new THREE.Color( 1, 0, 0 ), width, length );
pcBuffer.scale.set( 10, 10, 10 );
pcBuffer.position.set( - 10, 0, 0 );
pcBuffer.scale.set( 5, 10, 10 );
pcBuffer.position.set( - 5, 0, 0 );
scene.add( pcBuffer );

var pcIndexed = generateIndexedPointcloud( new THREE.Color( 0, 1, 0 ), width, length );
pcIndexed.scale.set( 10, 10, 10 );
pcIndexed.scale.set( 5, 10, 10 );
pcIndexed.position.set( 0, 0, 0 );
scene.add( pcIndexed );

var pcIndexedOffset = generateIndexedWithOffsetPointcloud( new THREE.Color( 0, 1, 1 ), width, length );
pcIndexedOffset.scale.set( 10, 10, 10 );
pcIndexedOffset.position.set( 10, 0, 0 );
pcIndexedOffset.scale.set( 5, 10, 10 );
pcIndexedOffset.position.set( 5, 0, 0 );
scene.add( pcIndexedOffset );

pointclouds = [ pcBuffer, pcIndexed, pcIndexedOffset ];
Expand Down

0 comments on commit 76d0e23

Please sign in to comment.