28 lines
503 B
React
28 lines
503 B
React
|
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}
|
||
|
/>
|
||
|
)
|
||
|
}
|
||
|
|