Skip to content

Commit 76d0e23

Browse files
committed
Improved webgl_interactive_raycasting_points example.
1 parent 2ad018c commit 76d0e23

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

examples/webgl_interactive_raycasting_points.html

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555

5656
var threshold = 0.1;
5757
var pointSize = 0.05;
58-
var width = 150;
59-
var length = 150;
58+
var width = 80;
59+
var length = 160;
6060
var rotateY = new THREE.Matrix4().makeRotationY( 0.005 );
6161

6262
init();
@@ -79,7 +79,7 @@
7979
var u = i / width;
8080
var v = j / length;
8181
var x = u - 0.5;
82-
var y = ( Math.cos( u * Math.PI * 8 ) + Math.sin( v * Math.PI * 8 ) ) / 20;
82+
var y = ( Math.cos( u * Math.PI * 4 ) + Math.sin( v * Math.PI * 8 ) ) / 20;
8383
var z = v - 0.5;
8484

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

110110
var geometry = generatePointCloudGeometry( color, width, length );
111-
112111
var material = new THREE.PointsMaterial( { size: pointSize, vertexColors: THREE.VertexColors } );
113-
var pointcloud = new THREE.Points( geometry, material );
114112

115-
return pointcloud;
113+
return new THREE.Points( geometry, material );
116114

117115
}
118116

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

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

143-
return pointcloud;
140+
return new THREE.Points( geometry, material );
144141

145142
}
146143

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

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

172-
return pointcloud;
168+
return new THREE.Points( geometry, material );
173169

174170
}
175171

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

184180
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
185-
camera.position.set( 15, 15, 15 );
181+
camera.position.set( 10, 10, 10 );
186182
camera.lookAt( scene.position );
187183
camera.updateMatrix();
188184

189185
//
190186

191187
var pcBuffer = generatePointcloud( new THREE.Color( 1, 0, 0 ), width, length );
192-
pcBuffer.scale.set( 10, 10, 10 );
193-
pcBuffer.position.set( - 10, 0, 0 );
188+
pcBuffer.scale.set( 5, 10, 10 );
189+
pcBuffer.position.set( - 5, 0, 0 );
194190
scene.add( pcBuffer );
195191

196192
var pcIndexed = generateIndexedPointcloud( new THREE.Color( 0, 1, 0 ), width, length );
197-
pcIndexed.scale.set( 10, 10, 10 );
193+
pcIndexed.scale.set( 5, 10, 10 );
198194
pcIndexed.position.set( 0, 0, 0 );
199195
scene.add( pcIndexed );
200196

201197
var pcIndexedOffset = generateIndexedWithOffsetPointcloud( new THREE.Color( 0, 1, 1 ), width, length );
202-
pcIndexedOffset.scale.set( 10, 10, 10 );
203-
pcIndexedOffset.position.set( 10, 0, 0 );
198+
pcIndexedOffset.scale.set( 5, 10, 10 );
199+
pcIndexedOffset.position.set( 5, 0, 0 );
204200
scene.add( pcIndexedOffset );
205201

206202
pointclouds = [ pcBuffer, pcIndexed, pcIndexedOffset ];

0 commit comments

Comments
 (0)