silphius/app/react/components/pixi/light.jsx

37 lines
1017 B
React
Raw Normal View History

2024-07-17 05:07:50 -05:00
import {PixiComponent} from '@pixi/react';
2024-07-19 01:27:47 -05:00
import {PointLight} from './lights.js';
2024-07-17 05:07:50 -05:00
const LightInternal = PixiComponent('Light', {
create({x, y}) {
2024-07-19 01:27:47 -05:00
const light = new PointLight(0xffffff - 0x2244cc, 1);
2024-07-17 05:07:50 -05:00
light.position.set(x, y);
2024-07-18 04:18:06 -05:00
// light.shader.program.fragmentSrc = light.shader.program.fragmentSrc.replace(
// 'float D = length(lightVector)',
2024-07-19 01:27:47 -05:00
// 'float D = length(lightVector) / 1.0',
// );
// light.shader.program.fragmentSrc = light.shader.program.fragmentSrc.replace(
// 'intensity = diffuse * attenuation',
// 'intensity = diffuse * (attenuation * 2.0)',
2024-07-18 04:18:06 -05:00
// );
2024-07-19 01:27:47 -05:00
// light.falloff = [0.5, 5, 50];
// light.falloff = light.falloff.map((n, i) => n / (2 + i));
// light.parentGroup = entityLighting.lightGroup;
// delete light.parentGroup;
2024-07-17 05:07:50 -05:00
return light;
},
applyProps(light, oldProps, {x, y}) {
light.position.set(x, y);
},
});
export default function Light({x, y}) {
return (
<LightInternal
x={x}
y={y}
/>
)
}