|
@@ -1513,7 +1513,19 @@ class BatchedMesh extends Mesh {
|
|
|
// the indexed version of the multi draw function requires specifying the start
|
|
// the indexed version of the multi draw function requires specifying the start
|
|
|
// offset in bytes.
|
|
// offset in bytes.
|
|
|
const index = geometry.getIndex();
|
|
const index = geometry.getIndex();
|
|
|
- const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;
|
|
|
|
|
|
|
+ let bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // the "wireframe" attribute implicitly creates a line attribute in the renderer, which is double
|
|
|
|
|
+ // the vertices to draw (3 lines per triangle) so we multiply the draw counts / starts and make
|
|
|
|
|
+ // assumptions about the index buffer byte size.
|
|
|
|
|
+ let multiDrawMultiplier = 1;
|
|
|
|
|
+ if ( material.wireframe ) {
|
|
|
|
|
+
|
|
|
|
|
+ multiDrawMultiplier = 2;
|
|
|
|
|
+ bytesPerElement = geometry.attributes.position.count > 65535 ? 4 : 2;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
const instanceInfo = this._instanceInfo;
|
|
const instanceInfo = this._instanceInfo;
|
|
|
const multiDrawStarts = this._multiDrawStarts;
|
|
const multiDrawStarts = this._multiDrawStarts;
|
|
@@ -1594,8 +1606,8 @@ class BatchedMesh extends Mesh {
|
|
|
for ( let i = 0, l = list.length; i < l; i ++ ) {
|
|
for ( let i = 0, l = list.length; i < l; i ++ ) {
|
|
|
|
|
|
|
|
const item = list[ i ];
|
|
const item = list[ i ];
|
|
|
- multiDrawStarts[ multiDrawCount ] = item.start * bytesPerElement;
|
|
|
|
|
- multiDrawCounts[ multiDrawCount ] = item.count;
|
|
|
|
|
|
|
+ multiDrawStarts[ multiDrawCount ] = item.start * bytesPerElement * multiDrawMultiplier;
|
|
|
|
|
+ multiDrawCounts[ multiDrawCount ] = item.count * multiDrawMultiplier;
|
|
|
indirectArray[ multiDrawCount ] = item.index;
|
|
indirectArray[ multiDrawCount ] = item.index;
|
|
|
multiDrawCount ++;
|
|
multiDrawCount ++;
|
|
|
|
|
|
|
@@ -1625,8 +1637,8 @@ class BatchedMesh extends Mesh {
|
|
|
if ( ! culled ) {
|
|
if ( ! culled ) {
|
|
|
|
|
|
|
|
const geometryInfo = geometryInfoList[ geometryId ];
|
|
const geometryInfo = geometryInfoList[ geometryId ];
|
|
|
- multiDrawStarts[ multiDrawCount ] = geometryInfo.start * bytesPerElement;
|
|
|
|
|
- multiDrawCounts[ multiDrawCount ] = geometryInfo.count;
|
|
|
|
|
|
|
+ multiDrawStarts[ multiDrawCount ] = geometryInfo.start * bytesPerElement * multiDrawMultiplier;
|
|
|
|
|
+ multiDrawCounts[ multiDrawCount ] = geometryInfo.count * multiDrawMultiplier;
|
|
|
indirectArray[ multiDrawCount ] = i;
|
|
indirectArray[ multiDrawCount ] = i;
|
|
|
multiDrawCount ++;
|
|
multiDrawCount ++;
|
|
|
|
|
|