| 15599 | } |
| 15600 | |
| 15601 | function calculateLight( position, normal, color ) { |
| 15602 | |
| 15603 | for ( var l = 0, ll = _lights.length; l < ll; l ++ ) { |
| 15604 | |
| 15605 | var light = _lights[ l ]; |
| 15606 | |
| 15607 | _lightColor.copy( light.color ); |
| 15608 | |
| 15609 | if ( light instanceof THREE.DirectionalLight ) { |
| 15610 | |
| 15611 | var lightPosition = _vector3.getPositionFromMatrix( light.matrixWorld ).normalize(); |
| 15612 | |
| 15613 | var amount = normal.dot( lightPosition ); |
| 15614 | |
| 15615 | if ( amount <= 0 ) continue; |
| 15616 | |
| 15617 | amount *= light.intensity; |
| 15618 | |
| 15619 | color.add( _lightColor.multiplyScalar( amount ) ); |
| 15620 | |
| 15621 | } else if ( light instanceof THREE.PointLight ) { |
| 15622 | |
| 15623 | var lightPosition = _vector3.getPositionFromMatrix( light.matrixWorld ); |
| 15624 | |
| 15625 | var amount = normal.dot( _vector3.subVectors( lightPosition, position ).normalize() ); |
| 15626 | |
| 15627 | if ( amount <= 0 ) continue; |
| 15628 | |
| 15629 | amount *= light.distance == 0 ? 1 : 1 - Math.min( position.distanceTo( lightPosition ) / light.distance, 1 ); |
| 15630 | |
| 15631 | if ( amount == 0 ) continue; |
| 15632 | |
| 15633 | amount *= light.intensity; |
| 15634 | |
| 15635 | color.add( _lightColor.multiplyScalar( amount ) ); |
| 15636 | |
| 15637 | } |
| 15638 | |
| 15639 | } |
| 15640 | |
| 15641 | } |
| 15642 | |
| 15643 | function renderParticle( v1, element, material ) { |
| 15644 | |