33 lines
723 B
JavaScript
33 lines
723 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);
|
|
// light.shader.program.fragmentSrc = light.shader.program.fragmentSrc.replace(
|
|
// 'float D = length(lightVector)',
|
|
// 'float D = length(lightVector) / 2.0',
|
|
// );
|
|
// light.falloff = [1, 10, 100]
|
|
return light;
|
|
},
|
|
applyProps(light, oldProps, {x, y}) {
|
|
light.position.set(x, y);
|
|
},
|
|
});
|
|
|
|
export default function Light({x, y}) {
|
|
return (
|
|
<LightInternal
|
|
x={x}
|
|
y={y}
|
|
/>
|
|
)
|
|
}
|
|
|