提交 d39264b0 编写于 作者: M mschuetz

fixed THREE.PointCloud rendering

上级 53884c7e
......@@ -2770,65 +2770,93 @@ THREE.WebGLRenderer = function ( parameters ) {
// render particles
if ( updateBuffers ) {
var mode = _gl.POINTS;
setupVertexAttributes( material, program, geometry, 0 );
var index = geometry.attributes.index;
}
if ( index ) {
var position = geometry.attributes.position;
// indexed points
// render particles
if ( geometry.attributes.index !== undefined ) {
var type, size;
var indices = geometry.attributes.index;
if ( index.array instanceof Uint32Array && extensions.get( 'OES_element_index_uint' ) ) {
var type;
var size;
type = _gl.UNSIGNED_INT;
size = 4;
if ( indices.array instanceof Uint16Array ) {
} else {
type = _gl.UNSIGNED_SHORT;
size = 2;
} else {
}
console.error( "unsupported index data type" );
return;
var offsets = geometry.offsets;
if ( offsets.length === 0 ) {
if ( updateBuffers ) {
setupVertexAttributes( material, program, geometry, 0 );
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, index.buffer );
}
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, indices.buffer );
_gl.drawElements( mode, index.array.length, type, 0);
_this.info.render.calls ++;
_this.info.render.points += index.array.length;
} else {
if ( geometry.offsets.length > 0 ) {
// if there is more than 1 chunk
// must set attribute pointers to use new offsets for each chunk
// even if geometry and materials didn't change
for ( var i = 0; i < geometry.offsets.length; i++ ) {
if ( offsets.length > 1 ) updateBuffers = true;
var offset = geometry.offsets[ i ];
for ( var i = 0, il = offsets.length; i < il; i ++ ) {
_gl.drawElements( _gl.POINTS, offset.count, type, offset.start * size );
var startIndex = offsets[ i ].index;
if ( updateBuffers ) {
setupVertexAttributes( material, program, geometry, startIndex );
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, index.buffer );
}
} else {
// render indexed points
_gl.drawElements( _gl.POINTS, indices.length, type, 0);
_gl.drawElements( mode, offsets[ i ].count, type, offsets[ i ].start * size );
_this.info.render.calls ++;
_this.info.render.points += offsets[ i ].count;
}
}
} else {
_gl.drawArrays( _gl.POINTS, 0, position.array.length / 3 );
// non-indexed points
if ( updateBuffers ) {
setupVertexAttributes( material, program, geometry, 0 );
}
var position = geometry.attributes.position;
_gl.drawArrays( mode, 0, position.array.length / 3 );
_this.info.render.calls ++;
_this.info.render.points += position.array.length / 3;
}
} else if ( object instanceof THREE.Line ) {
var mode = ( object.mode === THREE.LineStrip ) ? _gl.LINE_STRIP : _gl.LINES;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册