Skip to content

Commit 57e4701

Browse files
authored
Merge pull request #14746 from WestLangley/dev-compute_vertex_normals
BufferGeometry: disregard groups in computeVertexNormals()
2 parents 448c32f + 7f12d41 commit 57e4701

File tree

1 file changed

+19
-35
lines changed

1 file changed

+19
-35
lines changed

src/core/BufferGeometry.js

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
675675

676676
var index = this.index;
677677
var attributes = this.attributes;
678-
var groups = this.groups;
679678

680679
if ( attributes.position ) {
681680

@@ -711,46 +710,31 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
711710

712711
var indices = index.array;
713712

714-
if ( groups.length === 0 ) {
715-
716-
this.addGroup( 0, indices.length );
717-
718-
}
719-
720-
for ( var j = 0, jl = groups.length; j < jl; ++ j ) {
721-
722-
var group = groups[ j ];
713+
for ( var i = 0, il = index.count; i < il; i += 3 ) {
723714

724-
var start = group.start;
725-
var count = group.count;
715+
vA = indices[ i + 0 ] * 3;
716+
vB = indices[ i + 1 ] * 3;
717+
vC = indices[ i + 2 ] * 3;
726718

727-
for ( var i = start, il = start + count; i < il; i += 3 ) {
719+
pA.fromArray( positions, vA );
720+
pB.fromArray( positions, vB );
721+
pC.fromArray( positions, vC );
728722

729-
vA = indices[ i + 0 ] * 3;
730-
vB = indices[ i + 1 ] * 3;
731-
vC = indices[ i + 2 ] * 3;
732-
733-
pA.fromArray( positions, vA );
734-
pB.fromArray( positions, vB );
735-
pC.fromArray( positions, vC );
736-
737-
cb.subVectors( pC, pB );
738-
ab.subVectors( pA, pB );
739-
cb.cross( ab );
740-
741-
normals[ vA ] += cb.x;
742-
normals[ vA + 1 ] += cb.y;
743-
normals[ vA + 2 ] += cb.z;
723+
cb.subVectors( pC, pB );
724+
ab.subVectors( pA, pB );
725+
cb.cross( ab );
744726

745-
normals[ vB ] += cb.x;
746-
normals[ vB + 1 ] += cb.y;
747-
normals[ vB + 2 ] += cb.z;
727+
normals[ vA ] += cb.x;
728+
normals[ vA + 1 ] += cb.y;
729+
normals[ vA + 2 ] += cb.z;
748730

749-
normals[ vC ] += cb.x;
750-
normals[ vC + 1 ] += cb.y;
751-
normals[ vC + 2 ] += cb.z;
731+
normals[ vB ] += cb.x;
732+
normals[ vB + 1 ] += cb.y;
733+
normals[ vB + 2 ] += cb.z;
752734

753-
}
735+
normals[ vC ] += cb.x;
736+
normals[ vC + 1 ] += cb.y;
737+
normals[ vC + 2 ] += cb.z;
754738

755739
}
756740

0 commit comments

Comments
 (0)