|
@@ -18567,15 +18567,15 @@ THREE.ShaderChunk[ 'lights_phong_fragment'] = "#ifndef FLAT_SHADED\n\n vec3 norm
|
|
|
|
|
|
// File:src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl
|
|
|
|
|
|
-THREE.ShaderChunk[ 'lights_phong_pars_fragment'] = "uniform vec3 ambientLightColor;\n\n#if MAX_DIR_LIGHTS > 0\n\n uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\n uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\n uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\n uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n\n uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n uniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n uniform float pointLightDecay[ MAX_POINT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\n uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\n uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\n uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\n uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\n varying vec3 vWorldPosition;\n\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n varying vec3 vNormal;\n\n#endif\n";
|
|
|
+THREE.ShaderChunk[ 'lights_phong_pars_fragment'] = "uniform vec3 ambientLightColor;\n\n#if MAX_DIR_LIGHTS > 0\n\n uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\n uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\n uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\n uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n\n uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n uniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n uniform float pointLightDecay[ MAX_POINT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\n uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\n uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\n uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\n uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_ENVMAP )\n\n varying vec3 vWorldPosition;\n\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n varying vec3 vNormal;\n\n#endif\n";
|
|
|
|
|
|
// File:src/renderers/shaders/ShaderChunk/lights_phong_pars_vertex.glsl
|
|
|
|
|
|
-THREE.ShaderChunk[ 'lights_phong_pars_vertex'] = "#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\n varying vec3 vWorldPosition;\n\n#endif\n";
|
|
|
+THREE.ShaderChunk[ 'lights_phong_pars_vertex'] = "#if MAX_SPOT_LIGHTS > 0 || defined( USE_ENVMAP )\n\n varying vec3 vWorldPosition;\n\n#endif\n";
|
|
|
|
|
|
// File:src/renderers/shaders/ShaderChunk/lights_phong_vertex.glsl
|
|
|
|
|
|
-THREE.ShaderChunk[ 'lights_phong_vertex'] = "#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\n vWorldPosition = worldPosition.xyz;\n\n#endif";
|
|
|
+THREE.ShaderChunk[ 'lights_phong_vertex'] = "#if MAX_SPOT_LIGHTS > 0 || defined( USE_ENVMAP )\n\n vWorldPosition = worldPosition.xyz;\n\n#endif\n";
|
|
|
|
|
|
// File:src/renderers/shaders/ShaderChunk/linear_to_gamma_fragment.glsl
|
|
|
|
|
@@ -20570,17 +20570,53 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( object instanceof THREE.Mesh ) {
|
|
|
+ var index = geometry.attributes.index;
|
|
|
+
|
|
|
+ if ( index !== undefined ) {
|
|
|
+
|
|
|
+ var type, size;
|
|
|
+
|
|
|
+ if ( index.array instanceof Uint32Array && extensions.get( 'OES_element_index_uint' ) ) {
|
|
|
+
|
|
|
+ type = _gl.UNSIGNED_INT;
|
|
|
+ size = 4;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ type = _gl.UNSIGNED_SHORT;
|
|
|
+ size = 2;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( object instanceof THREE.Mesh ) {
|
|
|
+
|
|
|
+ renderIndexedMesh( type, size, material, geometry, program, updateBuffers );
|
|
|
+
|
|
|
+ } else if ( object instanceof THREE.Line ) {
|
|
|
+
|
|
|
+ renderIndexedLine( type, size, material, geometry, object, program, updateBuffers );
|
|
|
+
|
|
|
+ } else if ( object instanceof THREE.PointCloud ) {
|
|
|
+
|
|
|
+ renderIndexedPointCloud( type, size, material, geometry, program, updateBuffers );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
|
|
|
- renderMesh( material, geometry, program, updateBuffers );
|
|
|
+ if ( object instanceof THREE.Mesh ) {
|
|
|
|
|
|
- } else if ( object instanceof THREE.Line ) {
|
|
|
+ renderMesh( material, geometry, program, updateBuffers );
|
|
|
|
|
|
- renderLine( material, geometry, object, program, updateBuffers );
|
|
|
+ } else if ( object instanceof THREE.Line ) {
|
|
|
|
|
|
- } else if ( object instanceof THREE.PointCloud ) {
|
|
|
+ renderLine( material, geometry, object, program, updateBuffers );
|
|
|
|
|
|
- renderPointCloud( material, geometry, program, updateBuffers );
|
|
|
+ } else if ( object instanceof THREE.PointCloud ) {
|
|
|
+
|
|
|
+ renderPointCloud( material, geometry, program, updateBuffers );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -20717,7 +20753,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function renderMesh( material, geometry, program, updateBuffers ) {
|
|
|
+ function renderIndexedMesh( type, size, material, geometry, program, updateBuffers ) {
|
|
|
|
|
|
var mode = _gl.TRIANGLES;
|
|
|
|
|
@@ -20726,53 +20762,66 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
mode = _gl.LINES;
|
|
|
state.setLineWidth( material.wireframeLinewidth * pixelRatio );
|
|
|
|
|
|
- /*
|
|
|
- if ( geometry._wireframe === undefined ) {
|
|
|
+ }
|
|
|
|
|
|
- geometry._wireframe = new THREE.WireframeGeometry( geometry );
|
|
|
- objects.updateAttribute( geometry._wireframe.attributes.position );
|
|
|
+ var index = geometry.attributes.index;
|
|
|
+ var indexBuffer = objects.getAttributeBuffer( index );
|
|
|
|
|
|
- }
|
|
|
+ var drawcall = geometry.drawcalls;
|
|
|
|
|
|
- geometry = geometry._wireframe;
|
|
|
- */
|
|
|
+ if ( drawcall.length === 0 ) {
|
|
|
|
|
|
- }
|
|
|
+ if ( updateBuffers ) {
|
|
|
|
|
|
- var index = geometry.attributes.index;
|
|
|
+ setupVertexAttributes( material, program, geometry, 0 );
|
|
|
+ _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, indexBuffer );
|
|
|
|
|
|
- if ( index ) {
|
|
|
+ }
|
|
|
|
|
|
- // indexed triangles
|
|
|
+ if ( geometry instanceof THREE.InstancedBufferGeometry && geometry.maxInstancedCount > 0 ) {
|
|
|
|
|
|
- var type, size;
|
|
|
+ var extension = extensions.get( 'ANGLE_instanced_arrays' );
|
|
|
|
|
|
- var indexBuffer = objects.getAttributeBuffer( index );
|
|
|
+ if ( extension === null ) {
|
|
|
|
|
|
- if ( index.array instanceof Uint32Array && extensions.get( 'OES_element_index_uint' ) ) {
|
|
|
+ console.error( 'THREE.WebGLRenderer.renderMesh: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
|
|
|
+ return;
|
|
|
|
|
|
- type = _gl.UNSIGNED_INT;
|
|
|
- size = 4;
|
|
|
+ }
|
|
|
+
|
|
|
+ extension.drawElementsInstancedANGLE( mode, index.array.length, type, 0, geometry.maxInstancedCount ); // Draw the instanced meshes
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- type = _gl.UNSIGNED_SHORT;
|
|
|
- size = 2;
|
|
|
+ _gl.drawElements( mode, index.array.length, type, 0 );
|
|
|
|
|
|
}
|
|
|
+ _infoRender.calls ++;
|
|
|
+ _infoRender.vertices += index.array.length; // not really true, here vertices can be shared
|
|
|
+ _infoRender.faces += index.array.length / 3;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ // if there is more than 1 chunk
|
|
|
+ // must set attribute pointers to use new drawcall for each chunk
|
|
|
+ // even if geometry and materials didn't change
|
|
|
|
|
|
- var drawcall = geometry.drawcalls;
|
|
|
+ updateBuffers = true;
|
|
|
|
|
|
- if ( drawcall.length === 0 ) {
|
|
|
+ for ( var i = 0, il = drawcall.length; i < il; i ++ ) {
|
|
|
+
|
|
|
+ var startIndex = drawcall[ i ].index;
|
|
|
|
|
|
if ( updateBuffers ) {
|
|
|
|
|
|
- setupVertexAttributes( material, program, geometry, 0 );
|
|
|
+ setupVertexAttributes( material, program, geometry, startIndex );
|
|
|
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, indexBuffer );
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( geometry instanceof THREE.InstancedBufferGeometry && geometry.maxInstancedCount > 0 ) {
|
|
|
+ // render indexed triangles
|
|
|
+
|
|
|
+ if ( geometry instanceof THREE.InstancedBufferGeometry && drawcall[ i ].instances > 0 ) {
|
|
|
|
|
|
var extension = extensions.get( 'ANGLE_instanced_arrays' );
|
|
|
|
|
@@ -20783,144 +20832,110 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- extension.drawElementsInstancedANGLE( mode, index.array.length, type, 0, geometry.maxInstancedCount ); // Draw the instanced meshes
|
|
|
+ extension.drawElementsInstancedANGLE( mode, drawcall[ i ].count, type, drawcall[ i ].start * size, drawcall[ i ].count, type, drawcall[ i ].instances ); // Draw the instanced meshes
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- _gl.drawElements( mode, index.array.length, type, 0 );
|
|
|
+ _gl.drawElements( mode, drawcall[ i ].count, type, drawcall[ i ].start * size );
|
|
|
|
|
|
}
|
|
|
+
|
|
|
_infoRender.calls ++;
|
|
|
- _infoRender.vertices += index.array.length; // not really true, here vertices can be shared
|
|
|
- _infoRender.faces += index.array.length / 3;
|
|
|
+ _infoRender.vertices += drawcall[ i ].count; // not really true, here vertices can be shared
|
|
|
+ _infoRender.faces += drawcall[ i ].count / 3;
|
|
|
|
|
|
- } else {
|
|
|
+ }
|
|
|
|
|
|
- // if there is more than 1 chunk
|
|
|
- // must set attribute pointers to use new drawcall for each chunk
|
|
|
- // even if geometry and materials didn't change
|
|
|
+ }
|
|
|
|
|
|
- updateBuffers = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderMesh( material, geometry, program, updateBuffers ) {
|
|
|
|
|
|
- for ( var i = 0, il = drawcall.length; i < il; i ++ ) {
|
|
|
+ var mode = _gl.TRIANGLES;
|
|
|
|
|
|
- var startIndex = drawcall[ i ].index;
|
|
|
+ if ( material.wireframe === true ) {
|
|
|
|
|
|
- if ( updateBuffers ) {
|
|
|
+ mode = _gl.LINES;
|
|
|
+ state.setLineWidth( material.wireframeLinewidth * pixelRatio );
|
|
|
|
|
|
- setupVertexAttributes( material, program, geometry, startIndex );
|
|
|
- _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, indexBuffer );
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ if ( updateBuffers ) {
|
|
|
|
|
|
- // render indexed triangles
|
|
|
+ setupVertexAttributes( material, program, geometry, 0 );
|
|
|
|
|
|
- if ( geometry instanceof THREE.InstancedBufferGeometry && drawcall[ i ].instances > 0 ) {
|
|
|
+ }
|
|
|
|
|
|
- var extension = extensions.get( 'ANGLE_instanced_arrays' );
|
|
|
+ // non-indexed triangles
|
|
|
|
|
|
- if ( extension === null ) {
|
|
|
+ var drawcall = geometry.drawcalls;
|
|
|
|
|
|
- console.error( 'THREE.WebGLRenderer.renderMesh: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
|
|
|
- return;
|
|
|
+ if ( drawcall.length === 0 ) {
|
|
|
|
|
|
- }
|
|
|
+ var position = geometry.attributes.position;
|
|
|
|
|
|
- extension.drawElementsInstancedANGLE( mode, drawcall[ i ].count, type, drawcall[ i ].start * size, drawcall[ i ].count, type, drawcall[ i ].instances ); // Draw the instanced meshes
|
|
|
+ // render non-indexed triangles
|
|
|
|
|
|
- } else {
|
|
|
+ if ( geometry instanceof THREE.InstancedBufferGeometry && geometry.maxInstancedCount > 0 ) {
|
|
|
|
|
|
- _gl.drawElements( mode, drawcall[ i ].count, type, drawcall[ i ].start * size );
|
|
|
+ var extension = extensions.get( 'ANGLE_instanced_arrays' );
|
|
|
|
|
|
- }
|
|
|
+ if ( extension === null ) {
|
|
|
|
|
|
- _infoRender.calls ++;
|
|
|
- _infoRender.vertices += drawcall[ i ].count; // not really true, here vertices can be shared
|
|
|
- _infoRender.faces += drawcall[ i ].count / 3;
|
|
|
+ console.error( 'THREE.WebGLRenderer.renderMesh: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
|
|
|
+ return;
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
+ if ( position instanceof THREE.InterleavedBufferAttribute ) {
|
|
|
|
|
|
- if ( updateBuffers ) {
|
|
|
+ extension.drawArraysInstancedANGLE( mode, 0, position.data.count, geometry.maxInstancedCount ); // Draw the instanced meshes
|
|
|
|
|
|
- setupVertexAttributes( material, program, geometry, 0 );
|
|
|
-
|
|
|
- }
|
|
|
+ } else {
|
|
|
|
|
|
- // non-indexed triangles
|
|
|
+ extension.drawArraysInstancedANGLE( mode, 0, position.count, geometry.maxInstancedCount ); // Draw the instanced meshes
|
|
|
|
|
|
- var drawcall = geometry.drawcalls;
|
|
|
+ }
|
|
|
|
|
|
- if ( drawcall.length === 0 ) {
|
|
|
+ } else {
|
|
|
|
|
|
- var position = geometry.attributes.position;
|
|
|
+ if ( position instanceof THREE.InterleavedBufferAttribute ) {
|
|
|
|
|
|
- // render non-indexed triangles
|
|
|
+ _gl.drawArrays( mode, 0, position.data.count );
|
|
|
|
|
|
- if ( geometry instanceof THREE.InstancedBufferGeometry && geometry.maxInstancedCount > 0 ) {
|
|
|
+ } else {
|
|
|
|
|
|
- var extension = extensions.get( 'ANGLE_instanced_arrays' );
|
|
|
+ _gl.drawArrays( mode, 0, position.count );
|
|
|
|
|
|
- if ( extension === null ) {
|
|
|
+ }
|
|
|
|
|
|
- console.error( 'THREE.WebGLRenderer.renderMesh: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
|
|
|
- return;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ _infoRender.calls ++;
|
|
|
+ _infoRender.vertices += position.count;
|
|
|
+ _infoRender.faces += position.array.length / 3;
|
|
|
|
|
|
- if ( position instanceof THREE.InterleavedBufferAttribute ) {
|
|
|
+ } else {
|
|
|
|
|
|
- extension.drawArraysInstancedANGLE( mode, 0, position.data.count, geometry.maxInstancedCount ); // Draw the instanced meshes
|
|
|
+ for ( var i = 0, il = drawcall.length; i < il; i ++ ) {
|
|
|
|
|
|
- } else {
|
|
|
+ // render non-indexed triangles
|
|
|
|
|
|
- extension.drawArraysInstancedANGLE( mode, 0, position.count, geometry.maxInstancedCount ); // Draw the instanced meshes
|
|
|
+ if ( geometry instanceof THREE.InstancedBufferGeometry ) {
|
|
|
|
|
|
- }
|
|
|
+ console.error( 'THREE.WebGLRenderer.renderMesh: cannot use drawCalls with THREE.InstancedBufferGeometry.' );
|
|
|
+ return;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- if ( position instanceof THREE.InterleavedBufferAttribute ) {
|
|
|
-
|
|
|
- _gl.drawArrays( mode, 0, position.data.count );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- _gl.drawArrays( mode, 0, position.count );
|
|
|
-
|
|
|
- }
|
|
|
+ _gl.drawArrays( mode, drawcall[ i ].start, drawcall[ i ].count );
|
|
|
|
|
|
}
|
|
|
|
|
|
_infoRender.calls ++;
|
|
|
- _infoRender.vertices += position.count;
|
|
|
- _infoRender.faces += position.array.length / 3;
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- for ( var i = 0, il = drawcall.length; i < il; i ++ ) {
|
|
|
-
|
|
|
- // render non-indexed triangles
|
|
|
-
|
|
|
- if ( geometry instanceof THREE.InstancedBufferGeometry ) {
|
|
|
-
|
|
|
- console.error( 'THREE.WebGLRenderer.renderMesh: cannot use drawCalls with THREE.InstancedBufferGeometry.' );
|
|
|
- return;
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- _gl.drawArrays( mode, drawcall[ i ].start, drawcall[ i ].count );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _infoRender.calls ++;
|
|
|
- _infoRender.vertices += drawcall[ i ].count;
|
|
|
- _infoRender.faces += ( drawcall[ i ].count ) / 3;
|
|
|
-
|
|
|
- }
|
|
|
+ _infoRender.vertices += drawcall[ i ].count;
|
|
|
+ _infoRender.faces += ( drawcall[ i ].count ) / 3;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -20928,7 +20943,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function renderLine( material, geometry, object, program, updateBuffers ) {
|
|
|
+ function renderIndexedLine( type, size, material, geometry, object, program, updateBuffers ) {
|
|
|
|
|
|
var mode = object instanceof THREE.LineSegments ? _gl.LINES : _gl.LINE_STRIP;
|
|
|
|
|
@@ -20938,103 +20953,87 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
state.setLineWidth( lineWidth * pixelRatio );
|
|
|
|
|
|
var index = geometry.attributes.index;
|
|
|
+ var indexBuffer = objects.getAttributeBuffer( index );
|
|
|
|
|
|
- if ( index ) {
|
|
|
+ var drawcall = geometry.drawcalls;
|
|
|
|
|
|
- // indexed lines
|
|
|
+ if ( drawcall.length === 0 ) {
|
|
|
|
|
|
- var type, size;
|
|
|
+ if ( updateBuffers ) {
|
|
|
|
|
|
- var indexBuffer = objects.getAttributeBuffer( index );
|
|
|
+ setupVertexAttributes( material, program, geometry, 0 );
|
|
|
+ _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, indexBuffer );
|
|
|
|
|
|
- if ( index.array instanceof Uint32Array && extensions.get( 'OES_element_index_uint' ) ) {
|
|
|
+ }
|
|
|
|
|
|
- type = _gl.UNSIGNED_INT;
|
|
|
- size = 4;
|
|
|
+ _gl.drawElements( mode, index.array.length, type, 0 ); // 2 bytes per Uint16Array
|
|
|
|
|
|
- } else {
|
|
|
+ _infoRender.calls ++;
|
|
|
+ _infoRender.vertices += index.array.length; // not really true, here vertices can be shared
|
|
|
|
|
|
- type = _gl.UNSIGNED_SHORT;
|
|
|
- size = 2;
|
|
|
+ } else {
|
|
|
|
|
|
- }
|
|
|
+ // if there is more than 1 chunk
|
|
|
+ // must set attribute pointers to use new drawcall for each chunk
|
|
|
+ // even if geometry and materials didn't change
|
|
|
+
|
|
|
+ if ( drawcall.length > 1 ) updateBuffers = true;
|
|
|
|
|
|
- var drawcall = geometry.drawcalls;
|
|
|
+ for ( var i = 0, il = drawcall.length; i < il; i ++ ) {
|
|
|
|
|
|
- if ( drawcall.length === 0 ) {
|
|
|
+ var startIndex = drawcall[ i ].index;
|
|
|
|
|
|
if ( updateBuffers ) {
|
|
|
|
|
|
- setupVertexAttributes( material, program, geometry, 0 );
|
|
|
+ setupVertexAttributes( material, program, geometry, startIndex );
|
|
|
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, indexBuffer );
|
|
|
|
|
|
}
|
|
|
|
|
|
- _gl.drawElements( mode, index.array.length, type, 0 ); // 2 bytes per Uint16Array
|
|
|
+ _gl.drawElements( mode, drawcall[ i ].count, type, drawcall[ i ].start * size ); // 2 bytes per Uint16Array
|
|
|
|
|
|
_infoRender.calls ++;
|
|
|
- _infoRender.vertices += index.array.length; // not really true, here vertices can be shared
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- // if there is more than 1 chunk
|
|
|
- // must set attribute pointers to use new drawcall for each chunk
|
|
|
- // even if geometry and materials didn't change
|
|
|
+ _infoRender.vertices += drawcall[ i ].count; // not really true, here vertices can be shared
|
|
|
|
|
|
- if ( drawcall.length > 1 ) updateBuffers = true;
|
|
|
-
|
|
|
- for ( var i = 0, il = drawcall.length; i < il; i ++ ) {
|
|
|
-
|
|
|
- var startIndex = drawcall[ i ].index;
|
|
|
+ }
|
|
|
|
|
|
- if ( updateBuffers ) {
|
|
|
+ }
|
|
|
|
|
|
- setupVertexAttributes( material, program, geometry, startIndex );
|
|
|
- _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, indexBuffer );
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ function renderLine( material, geometry, object, program, updateBuffers ) {
|
|
|
|
|
|
- // render indexed lines
|
|
|
+ var mode = object instanceof THREE.LineSegments ? _gl.LINES : _gl.LINE_STRIP;
|
|
|
|
|
|
- _gl.drawElements( mode, drawcall[ i ].count, type, drawcall[ i ].start * size ); // 2 bytes per Uint16Array
|
|
|
+ // In case user is not using Line*Material by mistake
|
|
|
+ var lineWidth = material.linewidth !== undefined ? material.linewidth : 1;
|
|
|
|
|
|
- _infoRender.calls ++;
|
|
|
- _infoRender.vertices += drawcall[ i ].count; // not really true, here vertices can be shared
|
|
|
+ state.setLineWidth( lineWidth * pixelRatio );
|
|
|
|
|
|
- }
|
|
|
+ if ( updateBuffers ) {
|
|
|
|
|
|
- }
|
|
|
+ setupVertexAttributes( material, program, geometry, 0 );
|
|
|
|
|
|
- } else {
|
|
|
+ }
|
|
|
|
|
|
- // non-indexed lines
|
|
|
+ var position = geometry.attributes.position;
|
|
|
+ var drawcall = geometry.drawcalls;
|
|
|
|
|
|
- if ( updateBuffers ) {
|
|
|
+ if ( drawcall.length === 0 ) {
|
|
|
|
|
|
- setupVertexAttributes( material, program, geometry, 0 );
|
|
|
+ _gl.drawArrays( mode, 0, position.array.length / 3 );
|
|
|
|
|
|
- }
|
|
|
+ _infoRender.calls ++;
|
|
|
+ _infoRender.vertices += position.array.length / 3;
|
|
|
|
|
|
- var position = geometry.attributes.position;
|
|
|
- var drawcall = geometry.drawcalls;
|
|
|
+ } else {
|
|
|
|
|
|
- if ( drawcall.length === 0 ) {
|
|
|
+ for ( var i = 0, il = drawcall.length; i < il; i ++ ) {
|
|
|
|
|
|
- _gl.drawArrays( mode, 0, position.array.length / 3 );
|
|
|
+ _gl.drawArrays( mode, drawcall[ i ].index, drawcall[ i ].count );
|
|
|
|
|
|
_infoRender.calls ++;
|
|
|
- _infoRender.vertices += position.array.length / 3;
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- for ( var i = 0, il = drawcall.length; i < il; i ++ ) {
|
|
|
-
|
|
|
- _gl.drawArrays( mode, drawcall[ i ].index, drawcall[ i ].count );
|
|
|
-
|
|
|
- _infoRender.calls ++;
|
|
|
- _infoRender.vertices += drawcall[ i ].count;
|
|
|
-
|
|
|
- }
|
|
|
+ _infoRender.vertices += drawcall[ i ].count;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -21042,108 +21041,87 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function renderPointCloud( material, geometry, program, updateBuffers ) {
|
|
|
+ function renderIndexedPointCloud( type, size, material, geometry, program, updateBuffers ) {
|
|
|
|
|
|
var mode = _gl.POINTS;
|
|
|
|
|
|
var index = geometry.attributes.index;
|
|
|
+ var indexBuffer = objects.getAttributeBuffer( index );
|
|
|
|
|
|
- if ( index ) {
|
|
|
+ var drawcall = geometry.drawcalls;
|
|
|
|
|
|
- // indexed points
|
|
|
+ if ( drawcall.length === 0 ) {
|
|
|
|
|
|
- var type, size;
|
|
|
+ if ( updateBuffers ) {
|
|
|
|
|
|
- var indexBuffer = objects.getAttributeBuffer( index );
|
|
|
+ setupVertexAttributes( material, program, geometry, 0 );
|
|
|
+ _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, indexBuffer );
|
|
|
|
|
|
- if ( index.array instanceof Uint32Array && extensions.get( 'OES_element_index_uint' ) ) {
|
|
|
+ }
|
|
|
|
|
|
- type = _gl.UNSIGNED_INT;
|
|
|
- size = 4;
|
|
|
+ _gl.drawElements( mode, index.array.length, type, 0 );
|
|
|
|
|
|
- } else {
|
|
|
+ _infoRender.calls ++;
|
|
|
+ _infoRender.points += index.array.length;
|
|
|
|
|
|
- type = _gl.UNSIGNED_SHORT;
|
|
|
- size = 2;
|
|
|
+ } else {
|
|
|
|
|
|
- }
|
|
|
+ // if there is more than 1 chunk
|
|
|
+ // must set attribute pointers to use new drawcall for each chunk
|
|
|
+ // even if geometry and materials didn't change
|
|
|
+
|
|
|
+ if ( drawcall.length > 1 ) updateBuffers = true;
|
|
|
|
|
|
- var drawcall = geometry.drawcalls;
|
|
|
+ for ( var i = 0, il = drawcall.length; i < il; i ++ ) {
|
|
|
|
|
|
- if ( drawcall.length === 0 ) {
|
|
|
+ var startIndex = drawcall[ i ].index;
|
|
|
|
|
|
if ( updateBuffers ) {
|
|
|
|
|
|
- setupVertexAttributes( material, program, geometry, 0 );
|
|
|
+ setupVertexAttributes( material, program, geometry, startIndex );
|
|
|
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, indexBuffer );
|
|
|
|
|
|
}
|
|
|
|
|
|
- _gl.drawElements( mode, index.array.length, type, 0 );
|
|
|
+ _gl.drawElements( mode, drawcall[ i ].count, type, drawcall[ i ].start * size );
|
|
|
|
|
|
_infoRender.calls ++;
|
|
|
- _infoRender.points += index.array.length;
|
|
|
+ _infoRender.points += drawcall[ i ].count;
|
|
|
|
|
|
- } else {
|
|
|
-
|
|
|
- // if there is more than 1 chunk
|
|
|
- // must set attribute pointers to use new drawcall for each chunk
|
|
|
- // even if geometry and materials didn't change
|
|
|
+ }
|
|
|
|
|
|
- if ( drawcall.length > 1 ) updateBuffers = true;
|
|
|
+ }
|
|
|
|
|
|
- for ( var i = 0, il = drawcall.length; i < il; i ++ ) {
|
|
|
+ }
|
|
|
|
|
|
- var startIndex = drawcall[ i ].index;
|
|
|
+ function renderPointCloud( material, geometry, program, updateBuffers ) {
|
|
|
|
|
|
- if ( updateBuffers ) {
|
|
|
+ var mode = _gl.POINTS;
|
|
|
|
|
|
- setupVertexAttributes( material, program, geometry, startIndex );
|
|
|
- _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, indexBuffer );
|
|
|
+ if ( updateBuffers ) {
|
|
|
|
|
|
- }
|
|
|
+ setupVertexAttributes( material, program, geometry, 0 );
|
|
|
|
|
|
- // render indexed points
|
|
|
+ }
|
|
|
|
|
|
- _gl.drawElements( mode, drawcall[ i ].count, type, drawcall[ i ].start * size );
|
|
|
+ var position = geometry.attributes.position;
|
|
|
+ var drawcall = geometry.drawcalls;
|
|
|
|
|
|
- _infoRender.calls ++;
|
|
|
- _infoRender.points += drawcall[ i ].count;
|
|
|
+ if ( drawcall.length === 0 ) {
|
|
|
|
|
|
- }
|
|
|
+ _gl.drawArrays( mode, 0, position.array.length / 3 );
|
|
|
|
|
|
- }
|
|
|
+ _infoRender.calls ++;
|
|
|
+ _infoRender.points += position.array.length / 3;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- // non-indexed points
|
|
|
-
|
|
|
- if ( updateBuffers ) {
|
|
|
+ for ( var i = 0, il = drawcall.length; i < il; i ++ ) {
|
|
|
|
|
|
- setupVertexAttributes( material, program, geometry, 0 );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- var position = geometry.attributes.position;
|
|
|
- var drawcall = geometry.drawcalls;
|
|
|
-
|
|
|
- if ( drawcall.length === 0 ) {
|
|
|
-
|
|
|
- _gl.drawArrays( mode, 0, position.array.length / 3 );
|
|
|
+ _gl.drawArrays( mode, drawcall[ i ].index, drawcall[ i ].count );
|
|
|
|
|
|
_infoRender.calls ++;
|
|
|
- _infoRender.points += position.array.length / 3;
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- for ( var i = 0, il = drawcall.length; i < il; i ++ ) {
|
|
|
-
|
|
|
- _gl.drawArrays( mode, drawcall[ i ].index, drawcall[ i ].count );
|
|
|
-
|
|
|
- _infoRender.calls ++;
|
|
|
- _infoRender.points += drawcall[ i ].count;
|
|
|
-
|
|
|
- }
|
|
|
+ _infoRender.points += drawcall[ i ].count;
|
|
|
|
|
|
}
|
|
|
|