42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
import {PixiComponent} from '@pixi/react';
|
|
|
|
import {PointLight} from './lights.js';
|
|
|
|
const LightInternal = PixiComponent('Light', {
|
|
create({brightness, x, y}) {
|
|
const light = new PointLight(
|
|
0xffffff - 0x2244cc,
|
|
0//brightness,
|
|
);
|
|
|
|
light.position.set(x, y);
|
|
// light.shader.program.fragmentSrc = light.shader.program.fragmentSrc.replace(
|
|
// 'float D = length(lightVector)',
|
|
// 'float D = length(lightVector) / 1.0',
|
|
// );
|
|
// light.shader.program.fragmentSrc = light.shader.program.fragmentSrc.replace(
|
|
// 'intensity = diffuse * attenuation',
|
|
// 'intensity = diffuse * (attenuation * 2.0)',
|
|
// );
|
|
// light.falloff = [0.5, 5, 50];
|
|
// light.falloff = light.falloff.map((n, i) => n / (2 + i));
|
|
// light.parentGroup = deferredLighting.lightGroup;
|
|
// delete light.parentGroup;
|
|
return light;
|
|
},
|
|
applyProps(light, oldProps, {x, y}) {
|
|
light.position.set(x, y);
|
|
},
|
|
});
|
|
|
|
export default function Light({brightness, x, y}) {
|
|
return (
|
|
<LightInternal
|
|
brightness={brightness}
|
|
x={x}
|
|
y={y}
|
|
/>
|
|
)
|
|
}
|
|
|