UNPKG

three.fbo-helper

Version:

FrameBuffer Object inspector for three.js

92 lines (66 loc) 1.47 kB
/** * @author mrdoob / http://mrdoob.com/ */ import { Color } from '../../math/Color'; import { Vector3 } from '../../math/Vector3'; import { Vector2 } from '../../math/Vector2'; function WebGLLights() { var lights = {}; return { get: function ( light ) { if ( lights[ light.id ] !== undefined ) { return lights[ light.id ]; } var uniforms; switch ( light.type ) { case 'DirectionalLight': uniforms = { direction: new Vector3(), color: new Color(), shadow: false, shadowBias: 0, shadowRadius: 1, shadowMapSize: new Vector2() }; break; case 'SpotLight': uniforms = { position: new Vector3(), direction: new Vector3(), color: new Color(), distance: 0, coneCos: 0, penumbraCos: 0, decay: 0, shadow: false, shadowBias: 0, shadowRadius: 1, shadowMapSize: new Vector2() }; break; case 'PointLight': uniforms = { position: new Vector3(), color: new Color(), distance: 0, decay: 0, shadow: false, shadowBias: 0, shadowRadius: 1, shadowMapSize: new Vector2() }; break; case 'HemisphereLight': uniforms = { direction: new Vector3(), skyColor: new Color(), groundColor: new Color() }; break; } lights[ light.id ] = uniforms; return uniforms; } }; } export { WebGLLights };