Open jonlepage opened 6 years ago
According to https://github.com/pixijs/pixi-lights/blob/master/src/lights/pointLight/point.frag.js#L19 and https://github.com/pixijs/pixi-lights/blob/master/src/lights/pointLight/PointLight.js#L33
PointLight position is adjusted with matrix, and size is not. Divide lightVector
by translationMatrix[0].x
and translationMatrix[1].y
, or adjust the radius somehow.
I can fix it later when ill make another pass on pixi-lights. In a week, or a month, i dont know :)
@ivanpopelyshev ok for now i do it manually in outScope pixiLight.js, the result seem ok. I don't know for performance but it a temp fix.
// storage
if(CAGE.source.type === "light"){ // update session for light because not follow scale scene
CAGE.session.brightness[1] = CAGE.brightness;
CAGE.session.lightHeight[1] = CAGE.lightHeight;
CAGE.radius && (CAGE.session.radius[1] = CAGE.radius);
}
// update light zoom
if(InObjSprite && InObjSprite.source.type === "light"){
const session = InObjSprite.session;
InObjSprite.brightness = session.brightness[1]*Zoom.x;
InObjSprite.lightHeight = session.lightHeight[1]*Zoom.x;
InObjSprite.radius && (InObjSprite.radius = session.radius[1]*Zoom.x);
};
edit: radius are Infinity so need check if is finite
function update_lightZoom() {
const list = TilesMap._objLight;
list.forEach(light => {
const session = light.session;
light.brightness = session.brightness[1]*Zoom.x;
light.lightHeight = session.lightHeight[1]*Zoom.x;
isFinite(light.radius) && (light.radius = session.radius[1]*Zoom.x);
});
if(InObjSprite && InObjSprite.source.type === "light"){
const session = InObjSprite.session;
InObjSprite.brightness = session.brightness[1]*Zoom.x;
InObjSprite.lightHeight = session.lightHeight[1]*Zoom.x;
isFinite(InObjSprite.radius) && (InObjSprite.radius = session.radius[1]*Zoom.x);
};
}
oh, there are other parameters! Thanks, now I have more information what to fix there :)
If we add a light to a scene. And resize the scene with scale. The light does not follow the zoom scale.
What would be the best approach? Do I have to do it manually by multiplying each value by the scale of the scene. Or there is already something native planned and that will consume less resource ? If i need to myself, where the best place to add a update in the module?