Skip to content

Commit 900094e

Browse files
Ian Kerrmrdoob
Ian Kerr
authored andcommitted
This commit fixes wireframe rendering when groups and drawRange are in use. (mrdoob#9698)
1 parent 4669e6f commit 900094e

File tree

2 files changed

+5
-34
lines changed

2 files changed

+5
-34
lines changed

src/renderers/WebGLRenderer.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,10 +777,12 @@ function WebGLRenderer( parameters ) {
777777

778778
var index = geometry.index;
779779
var position = geometry.attributes.position;
780+
var rangeFactor = 1;
780781

781782
if ( material.wireframe === true ) {
782783

783784
index = objects.getWireframeAttribute( geometry );
785+
rangeFactor = 2;
784786

785787
}
786788

@@ -811,7 +813,6 @@ function WebGLRenderer( parameters ) {
811813

812814
//
813815

814-
var dataStart = 0;
815816
var dataCount = 0;
816817

817818
if ( index !== null ) {
@@ -830,8 +831,8 @@ function WebGLRenderer( parameters ) {
830831
var groupStart = group !== null ? group.start : 0;
831832
var groupCount = group !== null ? group.count : Infinity;
832833

833-
var drawStart = Math.max( dataStart, rangeStart, groupStart );
834-
var drawEnd = Math.min( dataStart + dataCount, rangeStart + rangeCount, groupStart + groupCount ) - 1;
834+
var drawStart = Math.max( rangeStart, groupStart ) * rangeFactor;
835+
var drawEnd = ( Math.min( dataCount, rangeStart + rangeCount, groupStart + groupCount ) - 1 ) * rangeFactor;
835836

836837
var drawCount = Math.max( 0, drawEnd - drawStart + 1 );
837838

src/renderers/webgl/WebGLObjects.js

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ function WebGLObjects( gl, properties, info ) {
157157
var b = array[ i + 1 ];
158158
var c = array[ i + 2 ];
159159

160-
if ( checkEdge( edges, a, b ) ) indices.push( a, b );
161-
if ( checkEdge( edges, b, c ) ) indices.push( b, c );
162-
if ( checkEdge( edges, c, a ) ) indices.push( c, a );
160+
indices.push( a, b, b, c, c, a );
163161

164162
}
165163

@@ -192,34 +190,6 @@ function WebGLObjects( gl, properties, info ) {
192190

193191
}
194192

195-
function checkEdge( edges, a, b ) {
196-
197-
if ( a > b ) {
198-
199-
var tmp = a;
200-
a = b;
201-
b = tmp;
202-
203-
}
204-
205-
var list = edges[ a ];
206-
207-
if ( list === undefined ) {
208-
209-
edges[ a ] = [ b ];
210-
return true;
211-
212-
} else if ( list.indexOf( b ) === -1 ) {
213-
214-
list.push( b );
215-
return true;
216-
217-
}
218-
219-
return false;
220-
221-
}
222-
223193
return {
224194

225195
getAttributeBuffer: getAttributeBuffer,

0 commit comments

Comments
 (0)