Limit sky transition buffer memory
This commit is contained in:
parent
8c1389557b
commit
c9aca2ed50
1 changed files with 7 additions and 6 deletions
|
|
@ -1590,13 +1590,14 @@ let lastProjMs = -Infinity;
|
||||||
function projectSky() {
|
function projectSky() {
|
||||||
const W = canvas.width, H = canvas.height;
|
const W = canvas.width, H = canvas.height;
|
||||||
if (!W || !H) return;
|
if (!W || !H) return;
|
||||||
if (renderCanvas.width !== W || renderCanvas.height !== H) {
|
const horizonPx = H * HORIZON_F;
|
||||||
|
const bufferH = Math.ceil(Math.min(H, horizonPx * 1.05));
|
||||||
|
if (renderCanvas.width !== W || renderCanvas.height !== bufferH) {
|
||||||
renderCanvas.width = W;
|
renderCanvas.width = W;
|
||||||
renderCanvas.height = H;
|
renderCanvas.height = bufferH;
|
||||||
}
|
}
|
||||||
const bctx = renderCanvas.getContext('2d');
|
const bctx = renderCanvas.getContext('2d');
|
||||||
bctx.clearRect(0, 0, W, H);
|
bctx.clearRect(0, 0, W, bufferH);
|
||||||
const horizonPx = H * HORIZON_F;
|
|
||||||
const lst = localSiderealDeg(Date.now() + window.__skyTimeOffset);
|
const lst = localSiderealDeg(Date.now() + window.__skyTimeOffset);
|
||||||
const glareOn = !document.body.classList.contains('balada') &&
|
const glareOn = !document.body.classList.contains('balada') &&
|
||||||
!document.body.classList.contains('chuva');
|
!document.body.classList.contains('chuva');
|
||||||
|
|
@ -1687,8 +1688,8 @@ function drawStars(ts) {
|
||||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
const transition = Math.max(0, Math.min(1,
|
const transition = Math.max(0, Math.min(1,
|
||||||
(ts - skyTransitionStart) / SKY_TRANSITION_MS));
|
(ts - skyTransitionStart) / SKY_TRANSITION_MS));
|
||||||
if (transition < 1 && previousBaseCanvas.width === canvas.width &&
|
if (transition < 1 && previousBaseCanvas.width === baseCanvas.width &&
|
||||||
previousBaseCanvas.height === canvas.height) {
|
previousBaseCanvas.height === baseCanvas.height) {
|
||||||
const blend = transition * transition * (3 - 2 * transition);
|
const blend = transition * transition * (3 - 2 * transition);
|
||||||
ctx.globalAlpha = 1 - blend;
|
ctx.globalAlpha = 1 - blend;
|
||||||
ctx.drawImage(previousBaseCanvas, 0, 0);
|
ctx.drawImage(previousBaseCanvas, 0, 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue