Skip to content

Commit b9ef4dc

Browse files
committed
webvr_vive_paint: only upload the new strokes.
1 parent 6160a0f commit b9ef4dc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

examples/webvr_vive_paint.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,15 @@
207207
var geometry = new THREE.BufferGeometry();
208208

209209
var positions = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
210+
positions.dynamic = true;
210211
geometry.addAttribute( 'position', positions );
211212

212213
var normals = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
214+
normals.dynamic = true;
213215
geometry.addAttribute( 'normal', normals );
214216

215217
var colors = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
218+
colors.dynamic = true;
216219
geometry.addAttribute( 'color', colors );
217220

218221
geometry.drawRange.count = 0;
@@ -349,8 +352,29 @@
349352
}
350353

351354
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;
352370
attributes.position.needsUpdate = true;
371+
372+
attributes.normal.updateRange.offset = offset;
373+
attributes.normal.updateRange.count = count;
353374
attributes.normal.needsUpdate = true;
375+
376+
attributes.color.updateRange.offset = offset;
377+
attributes.color.updateRange.count = count;
354378
attributes.color.needsUpdate = true;
355379

356380
}
@@ -411,9 +435,13 @@
411435

412436
controls.update();
413437

438+
var count = line.geometry.drawRange.count;
439+
414440
handleController( controller1 );
415441
handleController( controller2 );
416442

443+
updateGeometry( count, line.geometry.drawRange.count );
444+
417445
effect.render( scene, camera );
418446

419447
}

0 commit comments

Comments
 (0)