@@ -1620,6 +1620,8 @@ function light(p5, fn){
16201620 angle ,
16211621 concentration
16221622 ) {
1623+ if ( this . states . spotLightDiffuseColors . length / 3 >= 4 ) return ;
1624+
16231625 let color , position , direction ;
16241626 const length = arguments . length ;
16251627
@@ -1777,18 +1779,26 @@ function light(p5, fn){
17771779 return ;
17781780 }
17791781 this . states . setValue ( 'spotLightDiffuseColors' , [
1782+ ...this . states . spotLightDiffuseColors ,
17801783 color . _array [ 0 ] ,
17811784 color . _array [ 1 ] ,
17821785 color . _array [ 2 ]
17831786 ] ) ;
17841787
17851788 this . states . setValue ( 'spotLightSpecularColors' , [
1789+ ...this . states . spotLightSpecularColors ,
17861790 ...this . states . specularColors
17871791 ] ) ;
17881792
1789- this . states . setValue ( 'spotLightPositions' , [ position . x , position . y , position . z ] ) ;
1793+ this . states . setValue ( 'spotLightPositions' , [
1794+ ...this . states . spotLightPositions ,
1795+ position . x ,
1796+ position . y ,
1797+ position . z
1798+ ] ) ;
17901799 direction . normalize ( ) ;
17911800 this . states . setValue ( 'spotLightDirections' , [
1801+ ...this . states . spotLightDirections ,
17921802 direction . x ,
17931803 direction . y ,
17941804 direction . z
@@ -1808,8 +1818,8 @@ function light(p5, fn){
18081818 }
18091819
18101820 angle = this . _pInst . _toRadians ( angle ) ;
1811- this . states . setValue ( 'spotLightAngle' , [ Math . cos ( angle ) ] ) ;
1812- this . states . setValue ( 'spotLightConc' , [ concentration ] ) ;
1821+ this . states . setValue ( 'spotLightAngle' , [ ... this . states . spotLightAngle , Math . cos ( angle ) ] ) ;
1822+ this . states . setValue ( 'spotLightConc' , [ ... this . states . spotLightConc , concentration ] ) ;
18131823
18141824 this . states . setValue ( 'enableLighting' , true ) ;
18151825 }
0 commit comments