import {PixiComponent} from '@pixi/react';

let PointLight;
if ('undefined' !== typeof window) {
  ({PointLight} = await import('@pixi/lights'));
}

const LightInternal = PixiComponent('Light', {
  create({x, y}) {
    const light = new PointLight(0xffffff, 1);
    light.position.set(x, y);
    return light;
  },
  applyProps(light, oldProps, {x, y}) {
    light.position.set(x, y);
  },
});

export default function Light({x, y}) {
  return (
    <LightInternal
      x={x}
      y={y}
    />
  )
}

