提交 b9ef4dce 编写于 作者: M Mr.doob

webvr_vive_paint: only upload the new strokes.

上级 6160a0f6
......@@ -207,12 +207,15 @@
var geometry = new THREE.BufferGeometry();
var positions = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
positions.dynamic = true;
geometry.addAttribute( 'position', positions );
var normals = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
normals.dynamic = true;
geometry.addAttribute( 'normal', normals );
var colors = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
colors.dynamic = true;
geometry.addAttribute( 'color', colors );
geometry.drawRange.count = 0;
......@@ -349,8 +352,29 @@
}
geometry.drawRange.count = count;
}
function updateGeometry( start, end ) {
if ( start === end ) return;
var offset = start * 3;
var count = ( end - start ) * 3;
var geometry = line.geometry;
var attributes = geometry.attributes;
attributes.position.updateRange.offset = offset;
attributes.position.updateRange.count = count;
attributes.position.needsUpdate = true;
attributes.normal.updateRange.offset = offset;
attributes.normal.updateRange.count = count;
attributes.normal.needsUpdate = true;
attributes.color.updateRange.offset = offset;
attributes.color.updateRange.count = count;
attributes.color.needsUpdate = true;
}
......@@ -411,9 +435,13 @@
controls.update();
var count = line.geometry.drawRange.count;
handleController( controller1 );
handleController( controller2 );
updateGeometry( count, line.geometry.drawRange.count );
effect.render( scene, camera );
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册