Refactored WebGLRenderer to be able to handle MeshShaderMaterial also for Lines and ParticleSystems.

It is now object type that determines which type of primitives is going to be used (triangles / lines / line strips / points).
This commit is contained in:
alteredq
2011-02-13 22:08:59 +01:00
parent 082da28c8e
commit fe2e9759b6
4 changed files with 60 additions and 49 deletions
+30 -19
View File
@@ -1242,31 +1242,42 @@ THREE.WebGLRenderer = function ( parameters ) {
}
// render mesh
if ( object instanceof THREE.Mesh ) {
// wireframe
if ( material.wireframe ) {
_gl.lineWidth( material.wireframe_linewidth );
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLLineBuffer );
_gl.drawElements( _gl.LINES, geometryChunk.__webGLLineCount, _gl.UNSIGNED_SHORT, 0 );
// triangles
} else {
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLFaceBuffer );
_gl.drawElements( _gl.TRIANGLES, geometryChunk.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 );
}
// render lines
} else if ( object instanceof THREE.Line ) {
primitives = object.type == THREE.LineStrip ? _gl.LINE_STRIP : _gl.LINES;
if ( material.wireframe || material instanceof THREE.LineBasicMaterial ) {
linewidth = material.wireframe_linewidth !== undefined ? material.wireframe_linewidth :
material.linewidth !== undefined ? material.linewidth : 1;
primitives = material instanceof THREE.LineBasicMaterial && object.type == THREE.LineStrip ? _gl.LINE_STRIP : _gl.LINES;
_gl.lineWidth( linewidth );
_gl.lineWidth( material.linewidth );
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLLineBuffer );
_gl.drawElements( primitives, geometryChunk.__webGLLineCount, _gl.UNSIGNED_SHORT, 0 );
// render particles
} else if ( material instanceof THREE.ParticleBasicMaterial ) {
} else if ( object instanceof THREE.ParticleSystem ) {
_gl.drawArrays( _gl.POINTS, 0, geometryChunk.__webGLParticleCount );
// render triangles
} else {
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLFaceBuffer );
_gl.drawElements( _gl.TRIANGLES, geometryChunk.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 );
_gl.drawArrays( _gl.POINTS, 0, geometryChunk.__webGLParticleCount );
}