silphius/app/react-components/pixi/light.jsx
2024-07-17 05:07:50 -05:00

28 lines
503 B
JavaScript

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}
/>
)
}