@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
42 lines (34 loc) • 1.2 kB
JavaScript
import { assert } from "../../../../../../core/assert.js";
import { LightType } from "../../LightType.js";
/**
*
* @param {Light} component
* @param {ThreeLightCache} cache
* @returns {DirectionalLight|SpotLight|PointLight|AmbientLight}
*/
export function threeMakeLight(component, cache) {
assert.defined(cache, 'cache');
const intensity = component.intensity.getValue();
const color = component.color.toUint();
const type = component.type.getValue();
const result = cache.obtain(type);
switch (type) {
case LightType.DIRECTION:
break;
case LightType.SPOT:
result.angle = component.angle.getValue();
result.penumbra = component.penumbra.getValue();
result.distance = component.distance.getValue();
break;
case LightType.POINT:
break;
case LightType.AMBIENT:
break;
default:
throw new Error('Unknown light type: ' + component.type);
}
result.color.setHex(color);
result.intensity = intensity;
result.castShadow = component.castShadow.getValue();
return result;
}