neon-activity-graph 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1266,7 +1266,7 @@ function mountScene(el, opts, st) {
|
|
|
1266
1266
|
const rgb = opts.rodColor({ layer: src, index: cell, date: layout.top.cells[cell].date, t });
|
|
1267
1267
|
return rgb ? new THREE.Color(rgb[0], rgb[1], rgb[2]) : null;
|
|
1268
1268
|
};
|
|
1269
|
-
const groundLayers = (stack2, tones, dark) => {
|
|
1269
|
+
const groundLayers = (stack2, tones, dark, page) => {
|
|
1270
1270
|
const cw = Math.ceil((width + GLOW_PAD * 2) * PX);
|
|
1271
1271
|
const ch = Math.ceil((total + GLOW_PAD * 2) * PX);
|
|
1272
1272
|
const lw = Math.ceil((width + GLOW_PAD * 2) * LPX);
|
|
@@ -1537,7 +1537,7 @@ void main() {
|
|
|
1537
1537
|
const prevClear = renderer.getClearColor(new THREE.Color());
|
|
1538
1538
|
const prevAlpha = renderer.getClearAlpha();
|
|
1539
1539
|
renderer.setRenderTarget(bake);
|
|
1540
|
-
renderer.setClearColor(
|
|
1540
|
+
renderer.setClearColor(page, 1);
|
|
1541
1541
|
renderer.clear();
|
|
1542
1542
|
renderer.render(bakeScene, cam);
|
|
1543
1543
|
renderer.setRenderTarget(prevTarget);
|
|
@@ -1566,7 +1566,6 @@ void main() {
|
|
|
1566
1566
|
}
|
|
1567
1567
|
if (dark && DARK_BACKDROP) {
|
|
1568
1568
|
const uBackdrop = { value: 0 };
|
|
1569
|
-
const page = pageColour();
|
|
1570
1569
|
const proxyMat = new THREE.MeshBasicMaterial({ map: ground2.texture, toneMapped: false });
|
|
1571
1570
|
proxyMat.onBeforeCompile = (shader) => {
|
|
1572
1571
|
shader.uniforms.uBackdrop = uBackdrop;
|
|
@@ -1610,10 +1609,15 @@ void main() {
|
|
|
1610
1609
|
})();
|
|
1611
1610
|
let tallest = 1;
|
|
1612
1611
|
const boxes = /* @__PURE__ */ new Map();
|
|
1612
|
+
const repeat = (count, ...v) => {
|
|
1613
|
+
const a = new Float32Array(count * v.length);
|
|
1614
|
+
for (let i = 0; i < a.length; i += v.length) for (let k = 0; k < v.length; k++) a[i + k] = v[k];
|
|
1615
|
+
return a;
|
|
1616
|
+
};
|
|
1613
1617
|
const roundedBox = (w2, h2, d, seg, r) => {
|
|
1614
1618
|
const key = `${w2.toFixed(4)}|${h2.toFixed(4)}|${d.toFixed(4)}|${seg}|${r.toFixed(4)}`;
|
|
1615
1619
|
let g = boxes.get(key);
|
|
1616
|
-
if (!g) boxes.set(key, g = new RoundedBoxGeometry(w2, h2, d, seg, r));
|
|
1620
|
+
if (!g) boxes.set(key, g = new THREE.BufferGeometry().copy(new RoundedBoxGeometry(w2, h2, d, seg, r)));
|
|
1617
1621
|
return g.clone();
|
|
1618
1622
|
};
|
|
1619
1623
|
const stock = { top: true, bottom: true };
|
|
@@ -1630,7 +1634,7 @@ void main() {
|
|
|
1630
1634
|
api.bounds = () => bounds;
|
|
1631
1635
|
let picks = [];
|
|
1632
1636
|
const LIFT = 0.04;
|
|
1633
|
-
const build = (stack2, tones, dark)
|
|
1637
|
+
const build = function* (stack2, tones, dark) {
|
|
1634
1638
|
const tb0 = performance.now();
|
|
1635
1639
|
picks = [];
|
|
1636
1640
|
let tileShape = null;
|
|
@@ -1653,7 +1657,9 @@ void main() {
|
|
|
1653
1657
|
tallest = Math.max(tallest, y0 + h2);
|
|
1654
1658
|
return y0 + h2;
|
|
1655
1659
|
};
|
|
1656
|
-
stack2.top.cells.
|
|
1660
|
+
for (let i = 0; i < stack2.top.cells.length; i++) {
|
|
1661
|
+
const g = stack2.top.cells[i];
|
|
1662
|
+
if (i % 48 === 47) yield;
|
|
1657
1663
|
const w2 = stack2.bottom.cells[i];
|
|
1658
1664
|
const { x, z } = at(g.week, g.day);
|
|
1659
1665
|
if (w2.value <= 0 && g.value <= 0) {
|
|
@@ -1675,7 +1681,8 @@ void main() {
|
|
|
1675
1681
|
c3.toArray(col, q * 3);
|
|
1676
1682
|
}
|
|
1677
1683
|
g2.setAttribute("color", new THREE.BufferAttribute(col, 3));
|
|
1678
|
-
tileShape = g2;
|
|
1684
|
+
tileShape = new THREE.BufferGeometry().copy(g2);
|
|
1685
|
+
g2.dispose();
|
|
1679
1686
|
const outer = roundedSquare.getPoints(lite ? 3 : 6);
|
|
1680
1687
|
const ringShape = new THREE.Shape(outer.map((v) => v.clone().multiplyScalar(1.05)));
|
|
1681
1688
|
ringShape.holes.push(new THREE.Path(outer.map((v) => v.clone().multiplyScalar(0.955)).reverse()));
|
|
@@ -1695,7 +1702,8 @@ void main() {
|
|
|
1695
1702
|
c3.toArray(rc, q * 3);
|
|
1696
1703
|
}
|
|
1697
1704
|
ring.setAttribute("color", new THREE.BufferAttribute(rc, 3));
|
|
1698
|
-
ringShape0 = ring;
|
|
1705
|
+
ringShape0 = new THREE.BufferGeometry().copy(ring);
|
|
1706
|
+
ring.dispose();
|
|
1699
1707
|
}
|
|
1700
1708
|
const tile = tileShape.clone();
|
|
1701
1709
|
tile.translate(x, 0, z);
|
|
@@ -1705,12 +1713,12 @@ void main() {
|
|
|
1705
1713
|
rims.push(rim);
|
|
1706
1714
|
pitRims.push({ geom: rim, x, z });
|
|
1707
1715
|
picks.push({ cell: i, x, z, y0: 0, y1: 0.04, pit: true });
|
|
1708
|
-
|
|
1716
|
+
continue;
|
|
1709
1717
|
}
|
|
1710
1718
|
let y = 0;
|
|
1711
1719
|
if (w2.value > 0) y = layer(i, "bottom", x, z, 0, w2.t, tones.bottom) + LIFT;
|
|
1712
1720
|
if (g.value > 0) layer(i, "top", x, z, y, g.t, tones.top);
|
|
1713
|
-
}
|
|
1721
|
+
}
|
|
1714
1722
|
let blockIndex = 0;
|
|
1715
1723
|
neonNeighbours = [];
|
|
1716
1724
|
const shades = dark ? glassShades(specs.map((q) => ({ x: q.x, z: q.z, y0: q.y0, h: q.h })), GLASS_ABSORB, GLASS_FLOOR) : [];
|
|
@@ -1740,7 +1748,9 @@ void main() {
|
|
|
1740
1748
|
behindTint.set(q, new THREE.Color(1, 1, 1).lerp(mean, Math.min(1, cv) * LIGHT_BEHIND_TINT));
|
|
1741
1749
|
});
|
|
1742
1750
|
}
|
|
1751
|
+
let made = 0;
|
|
1743
1752
|
for (const sp of specs) {
|
|
1753
|
+
if (++made % 24 === 0) yield;
|
|
1744
1754
|
const { src, x, z, y0, h: h2, t, hue: hue0 } = sp;
|
|
1745
1755
|
let hue = hue0;
|
|
1746
1756
|
const inc = new THREE.Color(0, 0, 0);
|
|
@@ -1779,8 +1789,8 @@ void main() {
|
|
|
1779
1789
|
return new THREE.Color(1, 1, 1).lerp(new THREE.Color(hue0.r / m, hue0.g / m, hue0.b / m), GLOW_TINT);
|
|
1780
1790
|
})();
|
|
1781
1791
|
const vcount = shell.getAttribute("position").count;
|
|
1782
|
-
shell.setAttribute("aInc", new THREE.BufferAttribute(
|
|
1783
|
-
shell.setAttribute("aTint", new THREE.BufferAttribute(
|
|
1792
|
+
shell.setAttribute("aInc", new THREE.BufferAttribute(repeat(vcount, inc.r * nbShare, inc.g * nbShare, inc.b * nbShare), 3));
|
|
1793
|
+
shell.setAttribute("aTint", new THREE.BufferAttribute(repeat(vcount, glowTint.r, glowTint.g, glowTint.b), 3));
|
|
1784
1794
|
const tier = tEff < 0.34 ? 0 : tEff < 0.67 ? 1 : 2;
|
|
1785
1795
|
const key = `${src}${tier}`;
|
|
1786
1796
|
(shellsBy.get(key) ?? shellsBy.set(key, []).get(key)).push(shell);
|
|
@@ -1801,18 +1811,20 @@ void main() {
|
|
|
1801
1811
|
core.setAttribute("aInc", new THREE.BufferAttribute(incs, 3));
|
|
1802
1812
|
}
|
|
1803
1813
|
core.setAttribute("aBlock", new THREE.BufferAttribute(new Float32Array(core.getAttribute("position").count).fill(blockIndex++), 1));
|
|
1804
|
-
core.setAttribute("aCtr", new THREE.BufferAttribute(
|
|
1814
|
+
core.setAttribute("aCtr", new THREE.BufferAttribute(repeat(core.getAttribute("position").count, x, z), 2));
|
|
1805
1815
|
cores.push(core);
|
|
1806
1816
|
}
|
|
1807
1817
|
if (dark) {
|
|
1808
1818
|
pitRims.forEach((pr, pi) => {
|
|
1809
1819
|
pr.geom.setAttribute("aPit", new THREE.BufferAttribute(new Float32Array(pr.geom.getAttribute("position").count).fill(pi), 1));
|
|
1810
|
-
const
|
|
1820
|
+
const near = [];
|
|
1811
1821
|
specs.forEach((sp, si) => {
|
|
1812
|
-
const
|
|
1813
|
-
|
|
1822
|
+
const dx = sp.x - pr.x;
|
|
1823
|
+
const dz = sp.z - pr.z;
|
|
1824
|
+
const dist = Math.hypot(dx, dz);
|
|
1825
|
+
if (dist >= 0.5 && dist <= 4) near.push({ si, dx, dz, dist, w: emit(sp.t) * Math.exp(-(dist * dist) / (2 * 1.6 * 1.6)) });
|
|
1814
1826
|
});
|
|
1815
|
-
pitLamps.push(
|
|
1827
|
+
pitLamps.push(near.map(({ si, w: w2 }) => ({ si, w: w2 })));
|
|
1816
1828
|
const rp = pr.geom.getAttribute("position");
|
|
1817
1829
|
const rc = pr.geom.getAttribute("color");
|
|
1818
1830
|
for (let q = 0; q < rp.count; q++) {
|
|
@@ -1822,29 +1834,28 @@ void main() {
|
|
|
1822
1834
|
let r = 0;
|
|
1823
1835
|
let gg = 0;
|
|
1824
1836
|
let bb = 0;
|
|
1825
|
-
for (const
|
|
1826
|
-
const dx = sp.x - pr.x;
|
|
1827
|
-
const dz = sp.z - pr.z;
|
|
1828
|
-
const dist = Math.hypot(dx, dz);
|
|
1829
|
-
if (dist < 0.5 || dist > 4) continue;
|
|
1837
|
+
for (const { si, dx, dz, dist, w: w2 } of near) {
|
|
1830
1838
|
const facing = Math.max(0, (-(rx / rl) * dx - rz / rl * dz) / dist);
|
|
1831
1839
|
if (facing <= 0) continue;
|
|
1832
|
-
const k =
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1840
|
+
const k = w2 * facing * facing * 0.018;
|
|
1841
|
+
const hue = specs[si].hue;
|
|
1842
|
+
r += hue.r * k;
|
|
1843
|
+
gg += hue.g * k;
|
|
1844
|
+
bb += hue.b * k;
|
|
1836
1845
|
}
|
|
1837
1846
|
rc.setXYZ(q, page.r + Math.min(r, 0.1), page.g + Math.min(gg, 0.1), page.b + Math.min(bb, 0.1));
|
|
1838
1847
|
}
|
|
1839
1848
|
rc.needsUpdate = true;
|
|
1840
1849
|
});
|
|
1841
1850
|
}
|
|
1851
|
+
yield;
|
|
1842
1852
|
const tb1 = performance.now();
|
|
1843
1853
|
const group = new THREE.Group();
|
|
1844
|
-
const groundGroup = groundLayers(stack2, tones, dark);
|
|
1854
|
+
const groundGroup = groundLayers(stack2, tones, dark, page);
|
|
1845
1855
|
pitLight = groundGroup.userData.setLevels ?? null;
|
|
1846
1856
|
group.add(groundGroup);
|
|
1847
1857
|
const tb2 = performance.now();
|
|
1858
|
+
yield;
|
|
1848
1859
|
rimLight = null;
|
|
1849
1860
|
if (tiles.length) {
|
|
1850
1861
|
const tile = new THREE.Mesh(mergeGeometries(tiles), tileUnlit);
|
|
@@ -1876,6 +1887,7 @@ void main() {
|
|
|
1876
1887
|
}
|
|
1877
1888
|
const materials = [];
|
|
1878
1889
|
for (const [key, list] of shellsBy) {
|
|
1890
|
+
yield;
|
|
1879
1891
|
const [src, tier] = shellTier.get(key);
|
|
1880
1892
|
const mat = blockMaterial.clone();
|
|
1881
1893
|
if (dbg.wireframe) {
|
|
@@ -1940,17 +1952,18 @@ void main() {
|
|
|
1940
1952
|
const blocks = new THREE.Group();
|
|
1941
1953
|
scene.add(blocks);
|
|
1942
1954
|
const ground0 = () => ground.material.opacity = isDark() ? 0 : 0.05;
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1955
|
+
let buildToken = 0;
|
|
1956
|
+
let building = false;
|
|
1957
|
+
let fitted = false;
|
|
1958
|
+
const BUILD_SLICE = 12;
|
|
1959
|
+
const buildBlocks = (done) => {
|
|
1960
|
+
const token = ++buildToken;
|
|
1961
|
+
building = true;
|
|
1962
|
+
stopNeon();
|
|
1963
|
+
window.clearTimeout(focusTimer);
|
|
1964
|
+
window.clearTimeout(focusRaf);
|
|
1965
|
+
cancelAnimationFrame(raf);
|
|
1966
|
+
raf = 0;
|
|
1954
1967
|
const dark = isDark();
|
|
1955
1968
|
const pair = (layer) => {
|
|
1956
1969
|
const [low, high] = colorOf(layer, dark);
|
|
@@ -1962,7 +1975,39 @@ void main() {
|
|
|
1962
1975
|
}
|
|
1963
1976
|
return [new THREE.Color(low), new THREE.Color(high)];
|
|
1964
1977
|
};
|
|
1965
|
-
|
|
1978
|
+
const steps = cm(() => build({ bottom: layout.bottom, top: layout.top }, { bottom: pair("bottom"), top: pair("top") }, dark));
|
|
1979
|
+
const step = () => {
|
|
1980
|
+
if (cancelled || token !== buildToken) return;
|
|
1981
|
+
const t = performance.now();
|
|
1982
|
+
let result;
|
|
1983
|
+
try {
|
|
1984
|
+
result = cm(() => {
|
|
1985
|
+
let r = steps.next();
|
|
1986
|
+
while (!r.done && performance.now() - t < BUILD_SLICE) r = steps.next();
|
|
1987
|
+
return r;
|
|
1988
|
+
});
|
|
1989
|
+
} catch (e) {
|
|
1990
|
+
building = false;
|
|
1991
|
+
throw e;
|
|
1992
|
+
}
|
|
1993
|
+
if (!result.done) return void window.setTimeout(step, 0);
|
|
1994
|
+
cm(() => {
|
|
1995
|
+
showMat.uniforms.bloom.value = dark ? customOn() ? 0.4 : 1 : 0;
|
|
1996
|
+
showMat.uniforms.veil.value = customOn() ? 0.75 : 0;
|
|
1997
|
+
scene.environmentIntensity = dark ? 0 : 0.9;
|
|
1998
|
+
sun.intensity = dark ? 0 : 2.2;
|
|
1999
|
+
ground0();
|
|
2000
|
+
blocks.traverse((o) => {
|
|
2001
|
+
o.geometry?.dispose();
|
|
2002
|
+
o.userData.dispose?.();
|
|
2003
|
+
});
|
|
2004
|
+
blocks.clear();
|
|
2005
|
+
blocks.add(result.value);
|
|
2006
|
+
building = false;
|
|
2007
|
+
done();
|
|
2008
|
+
});
|
|
2009
|
+
};
|
|
2010
|
+
step();
|
|
1966
2011
|
};
|
|
1967
2012
|
const floor = new THREE.Mesh(new THREE.PlaneGeometry(1200, 1200), new THREE.MeshBasicMaterial({ color: pageColour() }));
|
|
1968
2013
|
floor.rotation.x = -Math.PI / 2;
|
|
@@ -2117,6 +2162,7 @@ void main(){
|
|
|
2117
2162
|
return r;
|
|
2118
2163
|
};
|
|
2119
2164
|
const fit = () => {
|
|
2165
|
+
fitted = true;
|
|
2120
2166
|
const size = renderSize({ cssWidth: el.clientWidth, cssHeight: el.clientHeight, devicePixelRatio: window.devicePixelRatio, lite, maxPixelRatio: opts.maxPixelRatio, maxPixels: opts.maxPixels, maxSize: renderer.capabilities.maxTextureSize });
|
|
2121
2167
|
w = size.width;
|
|
2122
2168
|
h = size.height;
|
|
@@ -2192,6 +2238,7 @@ void main(){
|
|
|
2192
2238
|
let blendFloor = 0;
|
|
2193
2239
|
let jitter = 0;
|
|
2194
2240
|
const frameBody = (count = 1) => {
|
|
2241
|
+
if (building) return void (raf = 0);
|
|
2195
2242
|
raf = 0;
|
|
2196
2243
|
const f0 = performance.now();
|
|
2197
2244
|
for (let c = 0; c < count; c++) {
|
|
@@ -2292,6 +2339,7 @@ void main(){
|
|
|
2292
2339
|
let focusRaf = 0;
|
|
2293
2340
|
let focusTimer = 0;
|
|
2294
2341
|
const applyLevels = (levels) => {
|
|
2342
|
+
if (building) return;
|
|
2295
2343
|
lastLevels = levels;
|
|
2296
2344
|
const n2 = neonBlocks.length;
|
|
2297
2345
|
if (effective.length !== n2) effective = new Float32Array(n2).fill(1);
|
|
@@ -2339,7 +2387,7 @@ void main(){
|
|
|
2339
2387
|
const GHOST = 0.12;
|
|
2340
2388
|
const focusOn = (cell, ghosts = []) => {
|
|
2341
2389
|
window.clearTimeout(focusTimer);
|
|
2342
|
-
if (!focusCtl) return;
|
|
2390
|
+
if (!focusCtl || building) return;
|
|
2343
2391
|
focusTimer = window.setTimeout(() => {
|
|
2344
2392
|
for (let i = 0; i < focusTo.length; i++) focusTo[i] = cell < 0 ? 1 : neonBlocks[i].cell === cell ? Math.min(FOCUS_MAX_GAIN, Math.max(FOCUS_ON, FOCUS_MIN_PEAK / Math.max(neonBlocks[i].peak, 1e-3))) : ghosts.includes(neonBlocks[i].cell) ? GHOST : FOCUS_OFF;
|
|
2345
2393
|
window.clearTimeout(focusRaf);
|
|
@@ -2419,8 +2467,10 @@ void main(){
|
|
|
2419
2467
|
ctl.update(half);
|
|
2420
2468
|
}
|
|
2421
2469
|
};
|
|
2422
|
-
buildBlocks()
|
|
2423
|
-
|
|
2470
|
+
buildBlocks(() => {
|
|
2471
|
+
prepareNeon();
|
|
2472
|
+
if (fitted) restart();
|
|
2473
|
+
});
|
|
2424
2474
|
const dom = renderer.domElement;
|
|
2425
2475
|
const ray = new THREE.Raycaster();
|
|
2426
2476
|
const ndc = new THREE.Vector2();
|
|
@@ -2621,9 +2671,10 @@ void main(){
|
|
|
2621
2671
|
void wantTemplates().then(() => !cancelled && rethink(recolour));
|
|
2622
2672
|
return;
|
|
2623
2673
|
}
|
|
2624
|
-
buildBlocks()
|
|
2625
|
-
|
|
2626
|
-
|
|
2674
|
+
buildBlocks(() => {
|
|
2675
|
+
prepareNeon(recolour);
|
|
2676
|
+
restart();
|
|
2677
|
+
});
|
|
2627
2678
|
};
|
|
2628
2679
|
const onScheme = () => st.theme === "auto" && rethink(false);
|
|
2629
2680
|
mq.addEventListener("change", onScheme);
|
|
@@ -2909,4 +2960,4 @@ export {
|
|
|
2909
2960
|
createHoverOverlay,
|
|
2910
2961
|
createActivityGraph
|
|
2911
2962
|
};
|
|
2912
|
-
//# sourceMappingURL=chunk-
|
|
2963
|
+
//# sourceMappingURL=chunk-UTH7N6HE.js.map
|