mirror of
git://f0xx.org/android_cast
synced 2026-07-29 05:58:14 +03:00
test landing
This commit is contained in:
@@ -1,16 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* Hub landing globe — orthographic Canvas2D (globe3d=1).
|
* Hub landing globe — orthographic Canvas2D (globe3d=1).
|
||||||
* Layer order matches globe3d=0 SVG stack: ocean → grid → continents.
|
* Matches globe3d=0 stack: globe (ocean+base grid) → grid overlay → continents.
|
||||||
* Land baked to equirectangular (ortho ref + mercator-flat wrap); grid under continents.
|
* Grid/land sampled from hub SVG disks in body-fixed frame (Mercator ortho, not geodesic lines).
|
||||||
*/
|
*/
|
||||||
export const GLOBE_VIEW = { imgW: 1920, imgH: 1080, cx: 720, cy: 560, r: 322, rim: 330 };
|
export const GLOBE_VIEW = { imgW: 1920, imgH: 1080, cx: 720, cy: 560, r: 322, rim: 330 };
|
||||||
|
|
||||||
const AUTO_SPIN_RAD_S = 0.035;
|
const AUTO_SPIN_RAD_S = 0.035;
|
||||||
const DRAG_ROTATION_PER_PX = 0.004;
|
const DRAG_ROTATION_PER_PX = 0.004;
|
||||||
const OCEAN_FALLBACK = { r: 22, g: 38, b: 60 };
|
const OCEAN_FALLBACK = { r: 22, g: 38, b: 60 };
|
||||||
const EQ_W = 1024;
|
const FRONT_Z = 0.02;
|
||||||
const EQ_H = 512;
|
const RASTER_SCALE = 2;
|
||||||
const VIEW_Z_MIN = 0.06;
|
|
||||||
|
|
||||||
function hubAsset(rel, build) {
|
function hubAsset(rel, build) {
|
||||||
const link = document.querySelector('link[href*="hub.css"]');
|
const link = document.querySelector('link[href*="hub.css"]');
|
||||||
@@ -52,141 +51,115 @@ function loadImage(url) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function rasterizeImage(img, w, h) {
|
function rasterizeImage(img, w, h, scale) {
|
||||||
|
const s = scale || 1;
|
||||||
|
const rw = Math.max(1, Math.round(w * s));
|
||||||
|
const rh = Math.max(1, Math.round(h * s));
|
||||||
const c = document.createElement('canvas');
|
const c = document.createElement('canvas');
|
||||||
c.width = w;
|
c.width = rw;
|
||||||
c.height = h;
|
c.height = rh;
|
||||||
const ctx = c.getContext('2d', { willReadFrequently: true });
|
const ctx = c.getContext('2d', { willReadFrequently: true });
|
||||||
ctx.drawImage(img, 0, 0, w, h);
|
ctx.imageSmoothingEnabled = true;
|
||||||
return ctx.getImageData(0, 0, w, h);
|
ctx.imageSmoothingQuality = 'high';
|
||||||
|
ctx.drawImage(img, 0, 0, rw, rh);
|
||||||
|
return { data: ctx.getImageData(0, 0, rw, rh).data, w: rw, h: rh };
|
||||||
}
|
}
|
||||||
|
|
||||||
function sampleImageData(imgData, w, h, x, y) {
|
function sampleImageDataBilinear(imgData, w, h, fx, fy) {
|
||||||
const ix = Math.max(0, Math.min(w - 1, x | 0));
|
const x = Math.max(0, Math.min(w - 1.001, fx));
|
||||||
const iy = Math.max(0, Math.min(h - 1, y | 0));
|
const y = Math.max(0, Math.min(h - 1.001, fy));
|
||||||
const i = (iy * w + ix) * 4;
|
const x0 = x | 0;
|
||||||
return [imgData[i], imgData[i + 1], imgData[i + 2], imgData[i + 3]];
|
const y0 = y | 0;
|
||||||
}
|
const x1 = Math.min(w - 1, x0 + 1);
|
||||||
|
const y1 = Math.min(h - 1, y0 + 1);
|
||||||
function flipSouthNorth(p) {
|
const tx = x - x0;
|
||||||
return { x: p.x, y: -p.y, z: -p.z };
|
const ty = y - y0;
|
||||||
|
const i00 = (y0 * w + x0) * 4;
|
||||||
|
const i10 = (y0 * w + x1) * 4;
|
||||||
|
const i01 = (y1 * w + x0) * 4;
|
||||||
|
const i11 = (y1 * w + x1) * 4;
|
||||||
|
const out = [0, 0, 0, 0];
|
||||||
|
for (let c = 0; c < 4; c++) {
|
||||||
|
out[c] = Math.round(
|
||||||
|
imgData[i00 + c] * (1 - tx) * (1 - ty) +
|
||||||
|
imgData[i10 + c] * tx * (1 - ty) +
|
||||||
|
imgData[i01 + c] * (1 - tx) * ty +
|
||||||
|
imgData[i11 + c] * tx * ty
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
function inverseRotateY(nx, ny, nz, rotY) {
|
function inverseRotateY(nx, ny, nz, rotY) {
|
||||||
const cosR = Math.cos(rotY);
|
const cosR = Math.cos(rotY);
|
||||||
const sinR = Math.sin(rotY);
|
const sinR = Math.sin(rotY);
|
||||||
return flipSouthNorth({
|
return {
|
||||||
x: nx * cosR - nz * sinR,
|
x: nx * cosR - nz * sinR,
|
||||||
y: ny,
|
y: ny,
|
||||||
z: nx * sinR + nz * cosR,
|
z: nx * sinR + nz * cosR,
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function rotateYRaw(x, y, z, rotY) {
|
|
||||||
return {
|
|
||||||
x: x * Math.cos(rotY) + z * Math.sin(rotY),
|
|
||||||
y,
|
|
||||||
z: -x * Math.sin(rotY) + z * Math.cos(rotY),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function sphereLatLon(lon, lat) {
|
/** Hub SVG disk is N-up; negate Y for texture lookup only. */
|
||||||
const cosLat = Math.cos(lat);
|
function toTextureBody(body) {
|
||||||
return flipSouthNorth({
|
return { x: body.x, y: -body.y, z: body.z };
|
||||||
x: cosLat * Math.sin(lon),
|
|
||||||
y: Math.sin(lat),
|
|
||||||
z: cosLat * Math.cos(lon),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function bodyToHubPixel(xb, yb) {
|
function hubPixelF(tex) {
|
||||||
return {
|
return {
|
||||||
x: Math.round(GLOBE_VIEW.cx + xb * GLOBE_VIEW.r),
|
x: GLOBE_VIEW.cx + tex.x * GLOBE_VIEW.r,
|
||||||
y: Math.round(GLOBE_VIEW.cy - yb * GLOBE_VIEW.r),
|
y: GLOBE_VIEW.cy - tex.y * GLOBE_VIEW.r,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function lonLatFromBody(body) {
|
function mercatorFlatUV(lon, lat, w, h) {
|
||||||
return {
|
return {
|
||||||
lon: Math.atan2(body.x, body.z),
|
x: ((lon + Math.PI) / (2 * Math.PI)) * (w - 1),
|
||||||
lat: Math.asin(Math.max(-1, Math.min(1, body.y))),
|
y: (0.5 - lat / Math.PI) * (h - 1),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function sampleMercatorFlat(merc, lon, lat) {
|
function isLandPixel(r, g, b, a) {
|
||||||
const u = (lon + Math.PI) / (2 * Math.PI);
|
|
||||||
const v = 0.5 - lat / Math.PI;
|
|
||||||
const x = Math.round(u * (merc.w - 1));
|
|
||||||
const y = Math.round(v * (merc.h - 1));
|
|
||||||
return sampleImageData(merc.data, merc.w, merc.h, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
function sampleEquatorLand(landEq, lon, lat) {
|
|
||||||
const u = (lon + Math.PI) / (2 * Math.PI);
|
|
||||||
const v = 0.5 - lat / Math.PI;
|
|
||||||
const x = Math.round(u * (EQ_W - 1));
|
|
||||||
const y = Math.round(v * (EQ_H - 1));
|
|
||||||
return sampleImageData(landEq.data, EQ_W, EQ_H, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isLandMask(r, g, b, a) {
|
|
||||||
return a > 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isFlatLand(r, g, b, a) {
|
|
||||||
return a > 12 && r > 100 && g < 140 && b < 140;
|
return a > 12 && r > 100 && g < 140 && b < 140;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Equirect land: ortho globe3d=0 colors on front body + mercator-flat elsewhere. */
|
function sampleOceanRgba(globe, tex) {
|
||||||
function bakeLandEquator(continents, mercFlat) {
|
const hp = hubPixelF(tex);
|
||||||
const out = new Uint8ClampedArray(EQ_W * EQ_H * 4);
|
const sx = (hp.x / GLOBE_VIEW.imgW) * (globe.w - 1);
|
||||||
for (let j = 0; j < EQ_H; j++) {
|
const sy = (hp.y / GLOBE_VIEW.imgH) * (globe.h - 1);
|
||||||
for (let i = 0; i < EQ_W; i++) {
|
const ocean = sampleImageDataBilinear(globe.data, globe.w, globe.h, sx, sy);
|
||||||
const lon = (i / EQ_W) * 2 * Math.PI - Math.PI;
|
if (ocean[3] < 8) {
|
||||||
const lat = Math.PI * 0.5 - (j / EQ_H) * Math.PI;
|
return [OCEAN_FALLBACK.r, OCEAN_FALLBACK.g, OCEAN_FALLBACK.b, 255];
|
||||||
const body = sphereLatLon(lon, lat);
|
|
||||||
const p = (j * EQ_W + i) * 4;
|
|
||||||
let rgba = [0, 0, 0, 0];
|
|
||||||
|
|
||||||
if (body.z > 0) {
|
|
||||||
const hp = bodyToHubPixel(body.x, body.y);
|
|
||||||
const ortho = sampleImageData(continents.data, continents.w, continents.h, hp.x, hp.y);
|
|
||||||
if (ortho[3] > 20) {
|
|
||||||
rgba = [ortho[0], ortho[1], ortho[2], 255];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (rgba[3] < 16) {
|
|
||||||
const flat = sampleMercatorFlat(mercFlat, lon, lat);
|
|
||||||
if (isFlatLand(flat[0], flat[1], flat[2], flat[3])) {
|
|
||||||
rgba = [flat[0], flat[1], flat[2], 220];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
out[p] = rgba[0];
|
|
||||||
out[p + 1] = rgba[1];
|
|
||||||
out[p + 2] = rgba[2];
|
|
||||||
out[p + 3] = rgba[3];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return { data: out, w: EQ_W, h: EQ_H };
|
return ocean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function viewDirBody(rotY) {
|
function sampleOverlayRgba(layer, tex) {
|
||||||
return inverseRotateY(0, 0, 1, rotY);
|
const hp = hubPixelF(tex);
|
||||||
|
const sx = (hp.x / GLOBE_VIEW.imgW) * (layer.w - 1);
|
||||||
|
const sy = (hp.y / GLOBE_VIEW.imgH) * (layer.h - 1);
|
||||||
|
return sampleImageDataBilinear(layer.data, layer.w, layer.h, sx, sy);
|
||||||
}
|
}
|
||||||
|
|
||||||
function facingCamera(body, rotY) {
|
function sampleLandRgba(continents, mercFlat, body) {
|
||||||
const vd = viewDirBody(rotY);
|
const tex = toTextureBody(body);
|
||||||
return body.x * vd.x + body.y * vd.y + body.z * vd.z > 0.002;
|
const hp = hubPixelF(tex);
|
||||||
}
|
const sx = (hp.x / GLOBE_VIEW.imgW) * (continents.w - 1);
|
||||||
|
const sy = (hp.y / GLOBE_VIEW.imgH) * (continents.h - 1);
|
||||||
function sampleOcean(globe, xb, yb) {
|
const ortho = sampleImageDataBilinear(continents.data, continents.w, continents.h, sx, sy);
|
||||||
const hp = bodyToHubPixel(xb, yb);
|
if (ortho[3] > 6) {
|
||||||
const o = sampleImageData(globe.data, globe.w, globe.h, hp.x, hp.y);
|
return ortho;
|
||||||
if (o[3] < 8) {
|
|
||||||
return [OCEAN_FALLBACK.r, OCEAN_FALLBACK.g, OCEAN_FALLBACK.b];
|
|
||||||
}
|
}
|
||||||
return [o[0], o[1], o[2]];
|
|
||||||
|
const lon = Math.atan2(tex.x, tex.z);
|
||||||
|
const lat = Math.asin(Math.max(-1, Math.min(1, tex.y)));
|
||||||
|
const uv = mercatorFlatUV(lon, lat, mercFlat.w, mercFlat.h);
|
||||||
|
const flat = sampleImageDataBilinear(mercFlat.data, mercFlat.w, mercFlat.h, uv.x, uv.y);
|
||||||
|
if (isLandPixel(flat[0], flat[1], flat[2], flat[3])) {
|
||||||
|
return [flat[0], flat[1], flat[2], Math.min(255, flat[3])];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillDiskRegion(ctx, cx, cy, r, rotY, fn) {
|
function fillDiskRegion(ctx, cx, cy, r, rotY, fn) {
|
||||||
@@ -218,11 +191,11 @@ function fillDiskRegion(ctx, cx, cy, r, rotY, fn) {
|
|||||||
const ny = oy / r;
|
const ny = oy / r;
|
||||||
const nz = Math.sqrt(Math.max(0, 1 - nx * nx - ny * ny));
|
const nz = Math.sqrt(Math.max(0, 1 - nx * nx - ny * ny));
|
||||||
const body = inverseRotateY(nx, ny, nz, rotY);
|
const body = inverseRotateY(nx, ny, nz, rotY);
|
||||||
const rgb = fn(body);
|
const rgba = fn(body);
|
||||||
px[p++] = rgb[0];
|
px[p++] = rgba[0];
|
||||||
px[p++] = rgb[1];
|
px[p++] = rgba[1];
|
||||||
px[p++] = rgb[2];
|
px[p++] = rgba[2];
|
||||||
px[p++] = rgb[3] !== undefined ? rgb[3] : 255;
|
px[p++] = rgba[3] !== undefined ? rgba[3] : 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,166 +214,40 @@ function blitLayer(ctx, cx, cy, r, layer) {
|
|||||||
|
|
||||||
function drawOceanLayer(ctx, cx, cy, r, rotY, globe) {
|
function drawOceanLayer(ctx, cx, cy, r, rotY, globe) {
|
||||||
const layer = fillDiskRegion(ctx, cx, cy, r, rotY, function (body) {
|
const layer = fillDiskRegion(ctx, cx, cy, r, rotY, function (body) {
|
||||||
return sampleOcean(globe, body.x, body.y).concat([255]);
|
if (body.z <= FRONT_Z) {
|
||||||
|
return [OCEAN_FALLBACK.r, OCEAN_FALLBACK.g, OCEAN_FALLBACK.b, 255];
|
||||||
|
}
|
||||||
|
return sampleOceanRgba(globe, toTextureBody(body));
|
||||||
});
|
});
|
||||||
blitLayer(ctx, cx, cy, r, layer);
|
blitLayer(ctx, cx, cy, r, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawContinentsLayer(ctx, cx, cy, r, rotY, landEq) {
|
function drawGridLayer(ctx, cx, cy, r, rotY, gridOverlay) {
|
||||||
const layer = fillDiskRegion(ctx, cx, cy, r, rotY, function (body) {
|
const layer = fillDiskRegion(ctx, cx, cy, r, rotY, function (body) {
|
||||||
if (!facingCamera(body, rotY)) {
|
if (body.z <= FRONT_Z) {
|
||||||
return [0, 0, 0, 0];
|
return [0, 0, 0, 0];
|
||||||
}
|
}
|
||||||
const ll = lonLatFromBody(body);
|
const px = sampleOverlayRgba(gridOverlay, toTextureBody(body));
|
||||||
const land = sampleEquatorLand(landEq, ll.lon, ll.lat);
|
if (px[3] < 10) {
|
||||||
if (!isLandMask(land[0], land[1], land[2], land[3])) {
|
|
||||||
return [0, 0, 0, 0];
|
return [0, 0, 0, 0];
|
||||||
}
|
}
|
||||||
return [land[0], land[1], land[2], land[3]];
|
return px;
|
||||||
});
|
});
|
||||||
blitLayer(ctx, cx, cy, r, layer);
|
blitLayer(ctx, cx, cy, r, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** One continuous path per visible arc — parallels stay on the sphere. */
|
function drawLandLayer(ctx, cx, cy, r, rotY, continents, mercFlat) {
|
||||||
function strokeVisibleArcs3D(ctx, cx, cy, r, rotY, pointAt, styleAt, steps) {
|
const layer = fillDiskRegion(ctx, cx, cy, r, rotY, function (body) {
|
||||||
const samples = [];
|
if (body.z <= FRONT_Z) {
|
||||||
for (let i = 0; i <= steps; i++) {
|
return [0, 0, 0, 0];
|
||||||
const raw = pointAt(i / steps);
|
|
||||||
const p = rotateYRaw(raw.x, raw.y, raw.z, rotY);
|
|
||||||
if (p.z <= VIEW_Z_MIN) {
|
|
||||||
samples.push(null);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
samples.push({ sx: cx + p.x * r, sy: cy - p.y * r, z: p.z });
|
const rgba = sampleLandRgba(continents, mercFlat, body);
|
||||||
}
|
if (!rgba) {
|
||||||
|
return [0, 0, 0, 0];
|
||||||
let run = [];
|
|
||||||
function flushRun() {
|
|
||||||
if (run.length < 2) {
|
|
||||||
run = [];
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
let zSum = 0;
|
return rgba;
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(run[0].sx, run[0].sy);
|
|
||||||
for (let i = 1; i < run.length; i++) {
|
|
||||||
ctx.lineTo(run[i].sx, run[i].sy);
|
|
||||||
zSum += run[i].z;
|
|
||||||
}
|
|
||||||
const style = styleAt(zSum / run.length);
|
|
||||||
ctx.strokeStyle = style.color;
|
|
||||||
ctx.lineWidth = style.width;
|
|
||||||
ctx.lineCap = 'round';
|
|
||||||
ctx.lineJoin = 'round';
|
|
||||||
ctx.stroke();
|
|
||||||
run = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < samples.length; i++) {
|
|
||||||
if (!samples[i]) flushRun();
|
|
||||||
else run.push(samples[i]);
|
|
||||||
}
|
|
||||||
flushRun();
|
|
||||||
}
|
|
||||||
|
|
||||||
function meridianStyle(isPrime, scale, z) {
|
|
||||||
const t = Math.max(0, Math.min(1, (z - VIEW_Z_MIN) / (0.92 - VIEW_Z_MIN)));
|
|
||||||
if (t <= 0) return { width: 0, color: 'rgba(0,0,0,0)' };
|
|
||||||
const bw = isPrime ? Math.max(3, scale * 0.0095) : Math.max(2.5, scale * 0.008);
|
|
||||||
const ca = isPrime ? 0.98 : 0.72;
|
|
||||||
const ea = 0.02;
|
|
||||||
return {
|
|
||||||
width: bw * (0.25 + 0.75 * t * t),
|
|
||||||
color: 'rgba(238,245,255,' + (ea + (ca - ea) * t * t).toFixed(3) + ')',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function parallelStyle(scale, z, bright) {
|
|
||||||
const t = Math.max(0, Math.min(1, (z - VIEW_Z_MIN) / (0.92 - VIEW_Z_MIN)));
|
|
||||||
if (t <= 0) return { width: 0, color: 'rgba(0,0,0,0)' };
|
|
||||||
const bw = bright ? Math.max(2, scale * 0.007) : Math.max(1.5, scale * 0.0055);
|
|
||||||
const ca = bright ? 0.88 : 0.55;
|
|
||||||
return {
|
|
||||||
width: bw * (0.3 + 0.7 * t),
|
|
||||||
color: bright
|
|
||||||
? 'rgba(219,231,246,' + (0.35 + 0.53 * t).toFixed(3) + ')'
|
|
||||||
: 'rgba(231,236,243,' + (0.15 + 0.45 * t).toFixed(3) + ')',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawGridOverlay(ctx, rect, rotY) {
|
|
||||||
const cx = rect.cx;
|
|
||||||
const cy = rect.cy;
|
|
||||||
const r = rect.r;
|
|
||||||
const scale = rect.scale;
|
|
||||||
const steps = 160;
|
|
||||||
|
|
||||||
ctx.save();
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(cx, cy, r, 0, Math.PI * 2);
|
|
||||||
ctx.clip();
|
|
||||||
|
|
||||||
strokeVisibleArcs3D(
|
|
||||||
ctx,
|
|
||||||
cx,
|
|
||||||
cy,
|
|
||||||
r,
|
|
||||||
rotY,
|
|
||||||
function (t) {
|
|
||||||
return sphereLatLon(-Math.PI + t * 2 * Math.PI, 0);
|
|
||||||
},
|
|
||||||
function (z) {
|
|
||||||
return parallelStyle(scale, z, true);
|
|
||||||
},
|
|
||||||
steps
|
|
||||||
);
|
|
||||||
|
|
||||||
[-0.25, 0.25].forEach(function (latFrac) {
|
|
||||||
const lat = latFrac * Math.PI;
|
|
||||||
strokeVisibleArcs3D(
|
|
||||||
ctx,
|
|
||||||
cx,
|
|
||||||
cy,
|
|
||||||
r,
|
|
||||||
rotY,
|
|
||||||
function (t) {
|
|
||||||
return sphereLatLon(-Math.PI + t * 2 * Math.PI, lat);
|
|
||||||
},
|
|
||||||
function (z) {
|
|
||||||
return parallelStyle(scale, z, false);
|
|
||||||
},
|
|
||||||
steps
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
blitLayer(ctx, cx, cy, r, layer);
|
||||||
for (let lonDeg = -150; lonDeg <= 150; lonDeg += 30) {
|
|
||||||
const lon = (lonDeg * Math.PI) / 180;
|
|
||||||
const isPrime = lonDeg === 0;
|
|
||||||
strokeVisibleArcs3D(
|
|
||||||
ctx,
|
|
||||||
cx,
|
|
||||||
cy,
|
|
||||||
r,
|
|
||||||
rotY,
|
|
||||||
function (t) {
|
|
||||||
return sphereLatLon(lon, -Math.PI / 2 + t * Math.PI);
|
|
||||||
},
|
|
||||||
function (z) {
|
|
||||||
return meridianStyle(isPrime, scale, z);
|
|
||||||
},
|
|
||||||
96
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(cx, cy, Math.max(3, scale * 0.01), 0, Math.PI * 2);
|
|
||||||
ctx.fillStyle = '#5eead4';
|
|
||||||
ctx.fill();
|
|
||||||
ctx.strokeStyle = '#0a0e14';
|
|
||||||
ctx.lineWidth = 1;
|
|
||||||
ctx.stroke();
|
|
||||||
|
|
||||||
ctx.restore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawRim(ctx, globeImg, cx, cy, r, rim, layoutScale) {
|
function drawRim(ctx, globeImg, cx, cy, r, rim, layoutScale) {
|
||||||
@@ -430,16 +277,19 @@ export async function mountHubGlobe(stage, opts) {
|
|||||||
const urls = {
|
const urls = {
|
||||||
globe: hubAsset('assets/hub-logo-fragment-globe.svg', build),
|
globe: hubAsset('assets/hub-logo-fragment-globe.svg', build),
|
||||||
continents: hubAsset('assets/hub-logo-continents-mercator-globe.svg', build),
|
continents: hubAsset('assets/hub-logo-continents-mercator-globe.svg', build),
|
||||||
|
gridOverlay: hubAsset('assets/hub-logo-fragment-globe-grid-overlay.svg', build),
|
||||||
mercatorFlat: hubAsset('assets/hub-logo-continents-mercator-flat.svg', build),
|
mercatorFlat: hubAsset('assets/hub-logo-continents-mercator-flat.svg', build),
|
||||||
};
|
};
|
||||||
|
|
||||||
let globeImg;
|
let globeImg;
|
||||||
let continentsImg;
|
let continentsImg;
|
||||||
|
let gridOverlayImg;
|
||||||
let mercatorFlatImg;
|
let mercatorFlatImg;
|
||||||
try {
|
try {
|
||||||
[globeImg, continentsImg, mercatorFlatImg] = await Promise.all([
|
[globeImg, continentsImg, gridOverlayImg, mercatorFlatImg] = await Promise.all([
|
||||||
loadImage(urls.globe),
|
loadImage(urls.globe),
|
||||||
loadImage(urls.continents),
|
loadImage(urls.continents),
|
||||||
|
loadImage(urls.gridOverlay),
|
||||||
loadImage(urls.mercatorFlat),
|
loadImage(urls.mercatorFlat),
|
||||||
]);
|
]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -448,26 +298,12 @@ export async function mountHubGlobe(stage, opts) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const globe = {
|
const globe = rasterizeImage(globeImg, GLOBE_VIEW.imgW, GLOBE_VIEW.imgH, RASTER_SCALE);
|
||||||
w: GLOBE_VIEW.imgW,
|
const continents = rasterizeImage(continentsImg, GLOBE_VIEW.imgW, GLOBE_VIEW.imgH, RASTER_SCALE);
|
||||||
h: GLOBE_VIEW.imgH,
|
const gridOverlay = rasterizeImage(gridOverlayImg, GLOBE_VIEW.imgW, GLOBE_VIEW.imgH, RASTER_SCALE);
|
||||||
data: rasterizeImage(globeImg, GLOBE_VIEW.imgW, GLOBE_VIEW.imgH).data,
|
const mercW = (mercatorFlatImg.naturalWidth || 800) * 2;
|
||||||
};
|
const mercH = (mercatorFlatImg.naturalHeight || 519) * 2;
|
||||||
const continents = {
|
const mercFlat = rasterizeImage(mercatorFlatImg, mercW, mercH, 1);
|
||||||
w: GLOBE_VIEW.imgW,
|
|
||||||
h: GLOBE_VIEW.imgH,
|
|
||||||
data: rasterizeImage(continentsImg, GLOBE_VIEW.imgW, GLOBE_VIEW.imgH).data,
|
|
||||||
};
|
|
||||||
const mercFlat = {
|
|
||||||
w: mercatorFlatImg.naturalWidth || 800,
|
|
||||||
h: mercatorFlatImg.naturalHeight || 519,
|
|
||||||
data: rasterizeImage(
|
|
||||||
mercatorFlatImg,
|
|
||||||
mercatorFlatImg.naturalWidth || 800,
|
|
||||||
mercatorFlatImg.naturalHeight || 519
|
|
||||||
).data,
|
|
||||||
};
|
|
||||||
const landEq = bakeLandEquator(continents, mercFlat);
|
|
||||||
|
|
||||||
let rotation = typeof opts.initialRotationY === 'number' ? opts.initialRotationY : 0;
|
let rotation = typeof opts.initialRotationY === 'number' ? opts.initialRotationY : 0;
|
||||||
let angularVelocity = reducedMotion ? 0 : AUTO_SPIN_RAD_S;
|
let angularVelocity = reducedMotion ? 0 : AUTO_SPIN_RAD_S;
|
||||||
@@ -503,12 +339,11 @@ export async function mountHubGlobe(stage, opts) {
|
|||||||
const cy = (rect.cy - rect.top) * dpr;
|
const cy = (rect.cy - rect.top) * dpr;
|
||||||
const r = rect.r * dpr;
|
const r = rect.r * dpr;
|
||||||
const rim = rect.rim * dpr;
|
const rim = rect.rim * dpr;
|
||||||
const drawRect = { cx, cy, r, rim, scale: rect.scale * dpr };
|
|
||||||
|
|
||||||
ctx.clearRect(0, 0, px, px);
|
ctx.clearRect(0, 0, px, px);
|
||||||
drawOceanLayer(ctx, cx, cy, r, rotation, globe);
|
drawOceanLayer(ctx, cx, cy, r, rotation, globe);
|
||||||
drawGridOverlay(ctx, drawRect, rotation);
|
drawGridLayer(ctx, cx, cy, r, rotation, gridOverlay);
|
||||||
drawContinentsLayer(ctx, cx, cy, r, rotation, landEq);
|
drawLandLayer(ctx, cx, cy, r, rotation, continents, mercFlat);
|
||||||
drawRim(ctx, globeImg, cx, cy, r, rim, rect.scale * dpr);
|
drawRim(ctx, globeImg, cx, cy, r, rim, rect.scale * dpr);
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ unset($__platformDir);
|
|||||||
var supportsLayout = !!(window.CSS && CSS.supports && CSS.supports('object-fit', 'cover'));
|
var supportsLayout = !!(window.CSS && CSS.supports && CSS.supports('object-fit', 'cover'));
|
||||||
var logoEnabled = !!(stage && supportsSvg && supportsLayout);
|
var logoEnabled = !!(stage && supportsSvg && supportsLayout);
|
||||||
|
|
||||||
var logoBuild = '20260606globe4';
|
var logoBuild = '20260606globe6';
|
||||||
|
|
||||||
function hubAsset(rel) {
|
function hubAsset(rel) {
|
||||||
var link = document.querySelector('link[href*="hub.css"]');
|
var link = document.querySelector('link[href*="hub.css"]');
|
||||||
|
|||||||
Reference in New Issue
Block a user