|
207 | 207 | var geometry = new THREE.BufferGeometry();
|
208 | 208 |
|
209 | 209 | var positions = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
|
| 210 | + positions.dynamic = true; |
210 | 211 | geometry.addAttribute( 'position', positions );
|
211 | 212 |
|
212 | 213 | var normals = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
|
| 214 | + normals.dynamic = true; |
213 | 215 | geometry.addAttribute( 'normal', normals );
|
214 | 216 |
|
215 | 217 | var colors = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
|
| 218 | + colors.dynamic = true; |
216 | 219 | geometry.addAttribute( 'color', colors );
|
217 | 220 |
|
218 | 221 | geometry.drawRange.count = 0;
|
|
349 | 352 | }
|
350 | 353 |
|
351 | 354 | geometry.drawRange.count = count;
|
| 355 | + |
| 356 | + } |
| 357 | + |
| 358 | + function updateGeometry( start, end ) { |
| 359 | + |
| 360 | + if ( start === end ) return; |
| 361 | + |
| 362 | + var offset = start * 3; |
| 363 | + var count = ( end - start ) * 3; |
| 364 | + |
| 365 | + var geometry = line.geometry; |
| 366 | + var attributes = geometry.attributes; |
| 367 | + |
| 368 | + attributes.position.updateRange.offset = offset; |
| 369 | + attributes.position.updateRange.count = count; |
352 | 370 | attributes.position.needsUpdate = true;
|
| 371 | + |
| 372 | + attributes.normal.updateRange.offset = offset; |
| 373 | + attributes.normal.updateRange.count = count; |
353 | 374 | attributes.normal.needsUpdate = true;
|
| 375 | + |
| 376 | + attributes.color.updateRange.offset = offset; |
| 377 | + attributes.color.updateRange.count = count; |
354 | 378 | attributes.color.needsUpdate = true;
|
355 | 379 |
|
356 | 380 | }
|
|
411 | 435 |
|
412 | 436 | controls.update();
|
413 | 437 |
|
| 438 | + var count = line.geometry.drawRange.count; |
| 439 | + |
414 | 440 | handleController( controller1 );
|
415 | 441 | handleController( controller2 );
|
416 | 442 |
|
| 443 | + updateGeometry( count, line.geometry.drawRange.count ); |
| 444 | + |
417 | 445 | effect.render( scene, camera );
|
418 | 446 |
|
419 | 447 | }
|
|
0 commit comments