perf: less change

This commit is contained in:
cha0s 2024-07-13 00:34:26 -05:00
parent 5521d28131
commit 1d61c3c14a

View File

@ -265,12 +265,13 @@ export default function Ui({disconnected}) {
}
if (localMainEntity) {
const mainEntityEntity = ecs.get(localMainEntity);
setCamera({
x: Math.round((mainEntityEntity.Camera.x * scale) - RESOLUTION.x / 2),
y: Math.round((mainEntityEntity.Camera.y * scale) - RESOLUTION.y / 2),
});
const x = Math.round((mainEntityEntity.Camera.x * scale) - RESOLUTION.x / 2);
const y = Math.round((mainEntityEntity.Camera.y * scale) - RESOLUTION.y / 2);
if (x !== camera.x || y !== camera.y) {
setCamera({x, y});
}
}, [ecs, mainEntity, scale]);
}
}, [camera, ecs, mainEntity, scale]);
useEffect(() => {
function onContextMenu(event) {
event.preventDefault();