| 15686 | } |
| 15687 | |
| 15688 | function calculateLight( position, normal, color ) { |
| 15689 | |
| 15690 | for ( var l = 0, ll = _lights.length; l < ll; l ++ ) { |
| 15691 | |
| 15692 | var light = _lights[ l ]; |
| 15693 | |
| 15694 | _lightColor.copy( light.color ); |
| 15695 | |
| 15696 | if ( light instanceof THREE.DirectionalLight ) { |
| 15697 | |
| 15698 | var lightPosition = _vector3.getPositionFromMatrix( light.matrixWorld ).normalize(); |
| 15699 | |
| 15700 | var amount = normal.dot( lightPosition ); |
| 15701 | |
| 15702 | if ( amount <= 0 ) continue; |
| 15703 | |
| 15704 | amount *= light.intensity; |
| 15705 | |
| 15706 | color.add( _lightColor.multiplyScalar( amount ) ); |
| 15707 | |
| 15708 | } else if ( light instanceof THREE.PointLight ) { |
| 15709 | |
| 15710 | var lightPosition = _vector3.getPositionFromMatrix( light.matrixWorld ); |
| 15711 | |
| 15712 | var amount = normal.dot( _vector3.subVectors( lightPosition, position ).normalize() ); |
| 15713 | |
| 15714 | if ( amount <= 0 ) continue; |
| 15715 | |
| 15716 | amount *= light.distance == 0 ? 1 : 1 - Math.min( position.distanceTo( lightPosition ) / light.distance, 1 ); |
| 15717 | |
| 15718 | if ( amount == 0 ) continue; |
| 15719 | |
| 15720 | amount *= light.intensity; |
| 15721 | |
| 15722 | color.add( _lightColor.multiplyScalar( amount ) ); |
| 15723 | |
| 15724 | } |
| 15725 | |
| 15726 | } |
| 15727 | |
| 15728 | } |
| 15729 | |
| 15730 | function renderSprite( v1, element, material ) { |
| 15731 | |