refactor: light prep
This commit is contained in:
parent
5c619b26c0
commit
b37d3513f6
|
@ -2,6 +2,7 @@ import Component from '@/ecs/component.js';
|
||||||
|
|
||||||
export default class Light extends Component {
|
export default class Light extends Component {
|
||||||
static properties = {
|
static properties = {
|
||||||
|
brightness: {defaultValue: 1, type: 'float32'},
|
||||||
radius: {type: 'uint8'},
|
radius: {type: 'uint8'},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {useDebug} from '@/react/context/debug.js';
|
||||||
import {useMainEntity} from '@/react/context/main-entity.js';
|
import {useMainEntity} from '@/react/context/main-entity.js';
|
||||||
|
|
||||||
import Emitter from './emitter.jsx';
|
import Emitter from './emitter.jsx';
|
||||||
// import Light from './light.jsx';
|
import Light from './light.jsx';
|
||||||
import Sprite from './sprite.jsx';
|
import Sprite from './sprite.jsx';
|
||||||
|
|
||||||
function Aabb({color, width = 0.5, x0, y0, x1, y1, ...rest}) {
|
function Aabb({color, width = 0.5, x0, y0, x1, y1, ...rest}) {
|
||||||
|
@ -67,12 +67,13 @@ function Entity({entity, ...rest}) {
|
||||||
entity={entity}
|
entity={entity}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{/* {entity.Light && (
|
{entity.Light && (
|
||||||
<Light
|
<Light
|
||||||
|
brightness={entity.Light.brightness}
|
||||||
x={entity.Position.x}
|
x={entity.Position.x}
|
||||||
y={entity.Position.y}
|
y={entity.Position.y}
|
||||||
/>
|
/>
|
||||||
)} */}
|
)}
|
||||||
{debug && entity.Position && (
|
{debug && entity.Position && (
|
||||||
<Crosshair x={entity.Position.x} y={entity.Position.y} />
|
<Crosshair x={entity.Position.x} y={entity.Position.y} />
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -3,8 +3,12 @@ import {PixiComponent} from '@pixi/react';
|
||||||
import {PointLight} from './lights.js';
|
import {PointLight} from './lights.js';
|
||||||
|
|
||||||
const LightInternal = PixiComponent('Light', {
|
const LightInternal = PixiComponent('Light', {
|
||||||
create({x, y}) {
|
create({brightness, x, y}) {
|
||||||
const light = new PointLight(0xffffff - 0x2244cc, 1);
|
const light = new PointLight(
|
||||||
|
0xffffff - 0x2244cc,
|
||||||
|
0//brightness,
|
||||||
|
);
|
||||||
|
|
||||||
light.position.set(x, y);
|
light.position.set(x, y);
|
||||||
// light.shader.program.fragmentSrc = light.shader.program.fragmentSrc.replace(
|
// light.shader.program.fragmentSrc = light.shader.program.fragmentSrc.replace(
|
||||||
// 'float D = length(lightVector)',
|
// 'float D = length(lightVector)',
|
||||||
|
@ -16,7 +20,7 @@ const LightInternal = PixiComponent('Light', {
|
||||||
// );
|
// );
|
||||||
// light.falloff = [0.5, 5, 50];
|
// light.falloff = [0.5, 5, 50];
|
||||||
// light.falloff = light.falloff.map((n, i) => n / (2 + i));
|
// light.falloff = light.falloff.map((n, i) => n / (2 + i));
|
||||||
// light.parentGroup = entityLighting.lightGroup;
|
// light.parentGroup = deferredLighting.lightGroup;
|
||||||
// delete light.parentGroup;
|
// delete light.parentGroup;
|
||||||
return light;
|
return light;
|
||||||
},
|
},
|
||||||
|
@ -25,9 +29,10 @@ const LightInternal = PixiComponent('Light', {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function Light({x, y}) {
|
export default function Light({brightness, x, y}) {
|
||||||
return (
|
return (
|
||||||
<LightInternal
|
<LightInternal
|
||||||
|
brightness={brightness}
|
||||||
x={x}
|
x={x}
|
||||||
y={y}
|
y={y}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -33,7 +33,7 @@ export default async function createPlayer(id) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Health: {health: 100},
|
Health: {health: 100},
|
||||||
Light: {},
|
Light: {brightness: 4},
|
||||||
Magnet: {strength: 24},
|
Magnet: {strength: 24},
|
||||||
Player: {},
|
Player: {},
|
||||||
Position: {x: 128, y: 448},
|
Position: {x: 128, y: 448},
|
||||||
|
|
|
@ -29,6 +29,7 @@ for (let i = 0; i < N; ++i) {
|
||||||
Controlled: {},
|
Controlled: {},
|
||||||
Direction: {direction: Math.TAU * (i / N)},
|
Direction: {direction: Math.TAU * (i / N)},
|
||||||
Forces: {},
|
Forces: {},
|
||||||
|
Light: {brightness: 0.1},
|
||||||
Owned: {owner: Player ? Player.id : 0},
|
Owned: {owner: Player ? Player.id : 0},
|
||||||
Position: {x: Position.x, y: Position.y},
|
Position: {x: Position.x, y: Position.y},
|
||||||
Speed: {},
|
Speed: {},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user