@@ -171,7 +171,9 @@ var ForwardDiffuseLightPipeline = new Class({
171171 renderer . setFloat1 ( program , lightName + 'intensity' , light . intensity ) ;
172172 renderer . setFloat1 ( program , lightName + 'radius' , light . radius ) ;
173173 }
174-
174+
175+ this . currentNormalMapRotation = null ;
176+
175177 return this ;
176178 } ,
177179
@@ -438,25 +440,35 @@ var ForwardDiffuseLightPipeline = new Class({
438440 */
439441 setNormalMapRotation : function ( rotation )
440442 {
441- var inverseRotationMatrix = this . inverseRotationMatrix ;
442-
443- if ( rotation )
443+ if ( rotation !== this . currentNormalMapRotation || this . batches . length === 0 )
444444 {
445- var rot = - rotation ;
446- var c = Math . cos ( rot ) ;
447- var s = Math . sin ( rot ) ;
445+ if ( this . batches . length > 0 )
446+ {
447+ this . flush ( ) ;
448+ }
448449
449- inverseRotationMatrix [ 1 ] = s ;
450- inverseRotationMatrix [ 3 ] = - s ;
451- inverseRotationMatrix [ 0 ] = inverseRotationMatrix [ 4 ] = c ;
452- }
453- else
454- {
455- inverseRotationMatrix [ 0 ] = inverseRotationMatrix [ 4 ] = 1 ;
456- inverseRotationMatrix [ 1 ] = inverseRotationMatrix [ 3 ] = 0 ;
457- }
450+ var inverseRotationMatrix = this . inverseRotationMatrix ;
458451
459- this . renderer . setMatrix3 ( this . program , 'uInverseRotationMatrix' , false , inverseRotationMatrix ) ;
452+ if ( rotation )
453+ {
454+ var rot = - rotation ;
455+ var c = Math . cos ( rot ) ;
456+ var s = Math . sin ( rot ) ;
457+
458+ inverseRotationMatrix [ 1 ] = s ;
459+ inverseRotationMatrix [ 3 ] = - s ;
460+ inverseRotationMatrix [ 0 ] = inverseRotationMatrix [ 4 ] = c ;
461+ }
462+ else
463+ {
464+ inverseRotationMatrix [ 0 ] = inverseRotationMatrix [ 4 ] = 1 ;
465+ inverseRotationMatrix [ 1 ] = inverseRotationMatrix [ 3 ] = 0 ;
466+ }
467+
468+ this . renderer . setMatrix3 ( this . program , 'uInverseRotationMatrix' , false , inverseRotationMatrix ) ;
469+
470+ this . currentNormalMapRotation = rotation ;
471+ }
460472 } ,
461473
462474 /**
0 commit comments