diff --git a/docs/field.md b/docs/field.md index f40c0e3..0a6c433 100644 --- a/docs/field.md +++ b/docs/field.md @@ -812,3 +812,14 @@ Four of smoke part 1's checks had been failing since the Nov 28 changes, on `mai 9-ball, 495 of 495 boards under 50 px not asked again in 3 s (checkers' boards meet the far field before they are 50 px across). Neither the freeze nor the pixel rule applies to an app with `afterItems`, which gathers every board asked into one batch: Levels lays all its bodies as one mesh from those asks, and frozen boards fell out of it (part 1's levels check: 265 boards climbed against 1,398). + +- **One board, alone, full screen** (1 Dec 2026: "Double click a labs board to show it alone wth full screen."; ONE BOARD, ALONE, FULL SCREEN, + `soloOpen`, `soloClose`, `window.fieldSolo`). An app with `soloOnDouble` (Gas lab, Gravity lab, Charge lab) has a double click open the board + by itself over the whole page: on the board you are on (before `onDoubleTap`, the margin excepted), or on a board a quick pair of clicks + brought in (the bring-in path, `_isDbl`). It is its own view (a second WebGL renderer in `#soloView`), drawn each frame from the board's + `cellItems` at the screen's size (so a lab's far-board merging never applies) with the app's `itemGeometries`, placed as `_emitInto` places + them, the title over it a few times a second; the browser's full screen is asked for too (refused quietly where it is not allowed). It + keeps playing as the framed board, which it is on the field behind. A drag turns the view about the board, the wheel or two fingers bring it + nearer or farther; a double click, Escape (or leaving the browser's full screen) or its × (the menu button's ring) shuts it. While it is + open the field is not built or drawn under it (the frame loop skips as when resting) and its movement keys go nowhere. Part 5 checks each lab + with real double clicks: opened over the whole page with its pieces and title, turned by a drag, shut by a double click. diff --git a/docs/tables.md b/docs/tables.md index 3c54f51..98e848a 100644 --- a/docs/tables.md +++ b/docs/tables.md @@ -2109,3 +2109,8 @@ out; cooled only back to its starting stir, the light disc clumped); without it is what star-only discs do (Sellwood, 2011), hence the restart. Its cost: 200 to 600 ms of work a simulated second (1,000 to 2,000 stars at 80 steps a second). Part 5 checks the start smooth, the heavy disc's two arms and bar and the light disc's many arms and no bar at 6 s on three boards, and the title. + +### A lab's board alone, full screen (1 Dec 2026) +"Double click a labs board to show it alone wth full screen." The three labs set `soloOnDouble`, the field's ONE BOARD, ALONE, FULL SCREEN +(`docs/field.md`): a double click shows the board by itself over the whole page, turned by a drag, nearer by the wheel or two fingers, shut by a +double click, Escape or ×. Its pieces are asked at the screen's size, so a thousand-body board shows every body (A PIXEL'S WORTH does not apply). diff --git a/games.html b/games.html index a821aec..762d2db 100644 --- a/games.html +++ b/games.html @@ -1002,6 +1002,13 @@ body #menuBtn.chip:hover, #playPad.low button:hover { background: rgba(18, 21, 28, .55); border-color: rgba(232, 200, 106, .95); } body #menuBtn.chip[aria-pressed="true"], body #menuBtn.chip[aria-expanded="true"] { background: rgba(18, 21, 28, .55); color: #fff !important; border-color: rgba(232, 200, 106, .95); box-shadow: 0 1px 4px rgba(0, 0, 0, .6); } #playPad.low button { font-size: 1.125rem; } + /* (ONE BOARD, ALONE, FULL SCREEN, Dec 1: its close button the menu's ring, its title in the field's own words) */ + #soloView { position: fixed; inset: 0; z-index: 4000; background: #0e1420; touch-action: none; } + #soloView canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; } + #soloView .solo-title { position: absolute; left: 16px; right: 72px; top: 14px; color: #e6e4ee; font: 500 0.875rem/1.35 var(--ui-sans, system-ui, sans-serif); text-shadow: 0 1px 3px rgba(0, 0, 0, .8); pointer-events: none; } + #soloView .solo-close { position: absolute; top: 10px; right: 12px; width: 44px; height: 44px; border-radius: 50%; box-sizing: border-box; background: rgba(18, 21, 28, .55); + border: 1.5px solid rgba(255, 255, 255, .7); box-shadow: 0 1px 4px rgba(0, 0, 0, .6); color: #fff; font-size: 1.25rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; } + #soloView .solo-close:hover { border-color: rgba(232, 200, 106, .95); } /* (Nov 23: "The button in the lower left should toggle like the button in the upper right and have a toggle color.": one glyph whichever way it stands, and while the whole table is up the disc is draw's gold, as a pressed chip is) */ /* (Nov 23, later: "Lowe's right button should be the same style as the upper right button. The fill color is different": the gold disc was a @@ -16930,6 +16937,9 @@ // something for it to mean, and a double anywhere else is still the // "make this board the right size" it has always been. if (hintDoubleTapPlays(hit)) return; + // (an app with `soloOnDouble` opens the board alone, full screen: ONE BOARD, ALONE, FULL SCREEN, Dec 1) + { const _sa = window.getFieldApp && window.getFieldApp(); if (_sa && _sa.soloOnDouble && !tapOnFramedMargin(hit)){ const _G = Math.max(1, Math.round(Math.sqrt(st.N))), _ww = v => ((v % _G) + _G) % _G; + soloOpen(_sa, _ww(Math.round(hit.x / gridSpacingX())), _ww(Math.round(hit.z / gridSpacingZ()))); return; } } /* Where on the framed board did this double land? Handed to the app below so IT can decide by position. NO APP READS IT TODAY — chess was the one that did, turning toward the tapped half, and that went @@ -17303,6 +17313,8 @@ try { const _sa = window.getFieldApp && window.getFieldApp(); if (_sa && _sa.startOnDouble){ const _G = Math.max(1, Math.round(Math.sqrt(st.N))), _ww = v => ((v % _G) + _G) % _G; _sa.startOnDouble(_ww(gx), _ww(gz)); } + // (brought in by a quick pair of clicks, a double click: an app with `soloOnDouble` shows it alone, full screen, as on the board you are on) + if (_sa && _sa.soloOnDouble && _isDbl){ const _G = Math.max(1, Math.round(Math.sqrt(st.N))), _ww = v => ((v % _G) + _G) % _G; soloOpen(_sa, _ww(gx), _ww(gz)); } } catch (e){ _reportError('app start as its board is brought in', e); } return; } @@ -18098,7 +18110,8 @@ the view standing still and nothing on the boards moving, and a phone's battery paid for it). See _restDecide: a frame that has nothing new to show is not built or drawn; the light watchers run, and the next frame is asked for as ever. */ _frameStamp++; - if (_restDecide(now)){ + // (a board shown alone, full screen, covers the field: the field is not built or drawn under it, ONE BOARD, ALONE, FULL SCREEN, Dec 1) + if (SOLO.open || _restDecide(now)){ watchFramedCell(); watchStripSource(); watchIconTurn(); updateStripMarkers(dt); requestAnimationFrame(frame); return; @@ -31346,6 +31359,7 @@ }, cellGrid(){ return { n: 1, colors: [BASE] }; }, cellItems(c, r, bp){ return LABW.items('gas', c, r, bp); }, + soloOnDouble: true, // (a double click shows the board alone, full screen: ONE BOARD, ALONE, FULL SCREEN, Dec 1) menu: [{ head: 'Gas lab', items: [{ label: GDL.item.label, title: GDL.item.title, on(){ GDL.item.on(); GLS.clear(); try { fieldItemsChanged(); } catch {} } }, GPICK.item, GSND.item] }], cellTitle(c, r){ return LABW.title('gas', c, r); }, onReset(c, r){ GLS.delete(gkey(c, r)); LABW.reset('gas', gkey(c, r)); GLIVE = { c, r }; try { fieldItemsChanged(); } catch {} return true; }, @@ -32251,6 +32265,7 @@ }, cellGrid(){ return { n: 1, colors: [BASE] }; }, cellItems(c, r, bp){ return LABW.items('gravity', c, r, bp); }, + soloOnDouble: true, // (a double click shows the board alone, full screen: ONE BOARD, ALONE, FULL SCREEN, Dec 1) // (more room for the small dots than the field's 48,000 a kind: a field of boards of a thousand bodies each, A PIXEL'S WORTH, Dec 1) itemCaps: kind => kind === 'gvDot' ? 240000 : 0, menu: [{ head: 'Gravity lab', items: [{ label: GVL.item.label, title: GVL.item.title, on(){ GVL.item.on(); GVS.clear(); try { fieldItemsChanged(); } catch {} } }, GVPICK.item] }], @@ -32567,6 +32582,7 @@ }, cellGrid(){ return { n: 1, colors: [BASE] }; }, cellItems(c, r, bp){ return LABW.items('charge', c, r, bp); }, + soloOnDouble: true, // (a double click shows the board alone, full screen: ONE BOARD, ALONE, FULL SCREEN, Dec 1) menu: [{ head: 'Charge lab', items: [{ label: CHL.item.label, title: CHL.item.title, on(){ CHL.item.on(); CHS.clear(); try { fieldItemsChanged(); } catch {} } }, CHPICK.item] }], cellTitle(c, r){ return LABW.title('charge', c, r); }, onReset(c, r){ CHS.delete(gkey(c, r)); LABW.reset('charge', gkey(c, r)); CHLIVE = { c, r }; try { fieldItemsChanged(); } catch {} return true; }, @@ -69318,6 +69334,97 @@ rec.n++; } +/* ONE BOARD, ALONE, FULL SCREEN (Dec 1: "Double click a labs board to show it alone wth full screen."). An app with `soloOnDouble` (Gas lab, + Gravity lab, Charge lab) has a double click on a board (the board you are on, or a board brought in by the double) open it by itself over + the whole screen (the browser's full screen too, where it is allowed): its own view, drawn from the same pieces the field draws it with + (`cellItems` at the screen's size, so nothing on it is merged; `itemGeometries`, lit as the field lights them), the board's title over it. + It keeps playing as the board brought in, since that is what it is on the field behind. A drag turns the view about the board, the wheel or + two fingers bring it nearer or farther, and a double click, Escape (which also leaves the browser's full screen) or the × shuts it, the field + as it was. */ +const SOLO = { open: null }; +function soloOpen(app, c, r){ + if (SOLO.open) return; + const root = document.createElement('div'); root.id = 'soloView'; + const title = document.createElement('div'); title.className = 'solo-title'; + const close = document.createElement('button'); close.className = 'solo-close'; close.type = 'button'; close.title = 'Back to the field'; close.textContent = '×'; + let R2; + try { R2 = new THREE.WebGLRenderer({ antialias: true }); } catch (e){ _reportError('one board alone', e); return; } + R2.setPixelRatio(Math.min(2, window.devicePixelRatio || 1)); + root.append(R2.domElement, title, close); document.body.appendChild(root); + const scene2 = new THREE.Scene(); scene2.background = new THREE.Color(0x0e1420); + scene2.add(new THREE.HemisphereLight(0xf4f2ff, 0x30343e, 0.95)); const sun = new THREE.DirectionalLight(0xffffff, 0.55); sun.position.set(0.4, 1, 0.3); scene2.add(sun); + const cam = new THREE.PerspectiveCamera(38, 1, 0.01, 100), meshes = new Map(), view = { yaw: 0.6, pitch: 0.55, dist: 0, cy: 0, fitted: false }; + const S = SOLO.open = { app, c, r, root, R2, scene2, cam, meshes, view, raf: 0, titleAt: 0 }; + const recOf = kind => { + let rec = meshes.get(kind); if (rec) return rec; + const build = app.itemGeometries && app.itemGeometries[kind]; let geo = null; + try { geo = build ? build(THREE) : null; } catch {} if (!geo) return null; + const U = geo.userData || {}, mo = U.opacity ? { transparent: true, opacity: U.opacity, depthWrite: false } : {}; + if (U.glyph){ mo.transparent = true; mo.depthWrite = false; } if (U.vertexColors) mo.vertexColors = true; if (U.wireframe) mo.wireframe = true; if (U.map) mo.map = U.map; + const mat = U.unlit ? new THREE.MeshBasicMaterial(mo) : new THREE.MeshLambertMaterial(mo); + if (U.onTop){ mat.depthTest = false; mat.depthWrite = false; mat.transparent = true; } + const mesh = new THREE.InstancedMesh(geo, mat, 256); mesh.frustumCulled = false; mesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage); mesh.setColorAt(0, new THREE.Color(1, 1, 1)); mesh.count = 0; + if (U.onTop) mesh.renderOrder = 1000 + U.onTop; + scene2.add(mesh); rec = { mesh, cap: 256, n: 0 }; meshes.set(kind, rec); return rec; + }; + const P = new THREE.Vector3(), Q = new THREE.Quaternion(), Sc = new THREE.Vector3(), M = new THREE.Matrix4(), UP = new THREE.Vector3(0, 1, 0); + const frame = () => { + S.raf = requestAnimationFrame(frame); + const w = root.clientWidth || window.innerWidth, h = root.clientHeight || window.innerHeight; + if (R2.domElement.width !== Math.round(w * R2.getPixelRatio()) || R2.domElement.height !== Math.round(h * R2.getPixelRatio())){ R2.setSize(w, h, false); cam.aspect = w / h; cam.updateProjectionMatrix(); } + let L = null; try { L = app.cellItems(c, r, Math.max(w, h)); } catch (e){ _reportError('one board alone', e); } + for (const rec of meshes.values()) rec.n = 0; + let lo = Infinity, hi = -Infinity; + for (const it of L || []){ + const rec = recOf(it.kind || 'default'); if (!rec) continue; + if (rec.n >= rec.cap){ rec.cap *= 2; rec.mesh = growInstanced(rec.mesh, rec.cap); } // (it takes the old one's place in the scene) + const u = it.u == null ? 0.5 : it.u, v = it.v == null ? 0.5 : it.v, s = it.scale || 0.25, y = 0.02 + (it.lift || 0); + P.set(0.5 - u, y, 0.5 - v); Sc.set(s * (it.sx || 1), s * (it.sy || 1), s * (it.sz || 1)); + if (it.rot) Q.set(it.rot[2], it.rot[3], -it.rot[0], -it.rot[1]); else if (it.yaw) Q.setFromAxisAngle(UP, Math.PI - it.yaw); else Q.identity(); + M.compose(P, Q, Sc); rec.mesh.setMatrixAt(rec.n, M); rec.mesh.setColorAt(rec.n, _appColor(it.color == null ? 0xf0e6d2 : it.color)); rec.n++; + if (y < lo) lo = y; if (y > hi) hi = y; + } + for (const rec of meshes.values()){ rec.mesh.count = rec.n; rec.mesh.instanceMatrix.needsUpdate = true; if (rec.mesh.instanceColor) rec.mesh.instanceColor.needsUpdate = true; } + // (the view fitted once, to the board and what stands on it: its middle height, and far enough back that a board's width and its height both show) + if (!view.fitted && lo < hi){ view.cy = (lo + hi) / 2; const span = Math.max(1, hi - lo); view.dist = 0.72 * span / Math.tan(cam.fov * Math.PI / 360) / Math.min(1, cam.aspect); view.fitted = true; } + if (!view.fitted){ view.cy = 0.3; view.dist = 2.4; } + const d = view.dist, cp = Math.cos(view.pitch); + cam.position.set(d * cp * Math.sin(view.yaw), view.cy + d * Math.sin(view.pitch), d * cp * Math.cos(view.yaw)); cam.lookAt(0, view.cy, 0); + const now = performance.now(); if (now - S.titleAt > 250){ S.titleAt = now; try { title.textContent = (app.cellTitle && app.cellTitle(c, r)) || ''; } catch {} } + R2.render(scene2, cam); + }; + // turning and nearer: one pointer turns the view about the board, two (or the wheel) bring it nearer or farther + const ptrs = new Map(); let pinch = 0, lastTap = 0; + root.addEventListener('pointerdown', e => { if (e.target === close) return; root.setPointerCapture && root.setPointerCapture(e.pointerId); ptrs.set(e.pointerId, { x: e.clientX, y: e.clientY }); pinch = 0; + const t = e.timeStamp || performance.now(); if (ptrs.size === 1 && t - lastTap < DOUBLE_TAP_MS){ soloClose(); return; } if (ptrs.size === 1) lastTap = t; e.preventDefault(); e.stopPropagation(); }); + root.addEventListener('pointermove', e => { const p = ptrs.get(e.pointerId); if (!p) return; e.preventDefault(); e.stopPropagation(); + if (ptrs.size === 1){ view.yaw -= (e.clientX - p.x) * 0.008; view.pitch = Math.max(-0.2, Math.min(1.5, view.pitch + (e.clientY - p.y) * 0.006)); } + p.x = e.clientX; p.y = e.clientY; + if (ptrs.size === 2){ const [a, b] = [...ptrs.values()], dd = Math.hypot(a.x - b.x, a.y - b.y); if (pinch) view.dist = Math.max(0.3, Math.min(20, view.dist * pinch / dd)); pinch = dd; } }); + const up = e => { ptrs.delete(e.pointerId); pinch = 0; e.stopPropagation(); }; + root.addEventListener('pointerup', up); root.addEventListener('pointercancel', up); + root.addEventListener('wheel', e => { e.preventDefault(); e.stopPropagation(); view.dist = Math.max(0.3, Math.min(20, view.dist * Math.exp(e.deltaY * 0.0015))); }, { passive: false }); + for (const ev of ['click', 'dblclick', 'contextmenu', 'touchstart', 'touchmove', 'touchend', 'mousedown', 'mouseup']) root.addEventListener(ev, e => { e.stopPropagation(); if (ev === 'contextmenu') e.preventDefault(); }); + close.addEventListener('click', e => { e.stopPropagation(); soloClose(); }); + S.onKey = e => { if (e.key === 'Escape'){ e.preventDefault(); e.stopPropagation(); soloClose(); } else if (/^(w|a|s|d|q|e|r|f|arrow\w+| )$/i.test(e.key || '')) e.stopPropagation(); }; + window.addEventListener('keydown', S.onKey, true); + // (the browser's full screen: asked for once; leaving it, Escape's first press in most browsers, shuts the view as well) + S.onFs = () => { if (!document.fullscreenElement && S.wasFs) soloClose(); if (document.fullscreenElement) S.wasFs = true; }; + document.addEventListener('fullscreenchange', S.onFs); + try { const pr = root.requestFullscreen && root.requestFullscreen(); if (pr && pr.catch) pr.catch(() => {}); } catch {} + frame(); +} +function soloClose(){ + const S = SOLO.open; if (!S) return; SOLO.open = null; + cancelAnimationFrame(S.raf); window.removeEventListener('keydown', S.onKey, true); document.removeEventListener('fullscreenchange', S.onFs); + try { if (document.fullscreenElement) document.exitFullscreen().catch(() => {}); } catch {} + for (const rec of S.meshes.values()){ rec.mesh.geometry.dispose(); rec.mesh.material.dispose(); } + try { S.R2.dispose(); S.R2.forceContextLoss && S.R2.forceContextLoss(); } catch {} + S.root.remove(); + try { window.fieldWake && window.fieldWake(); } catch {} +} +window.fieldSolo = { shot: () => { const S = SOLO.open; if (!S) return null; S.R2.render(S.scene2, S.cam); return S.R2.domElement.toDataURL('image/png'); }, open: (c, r) => { const a = window.getFieldApp && window.getFieldApp(); if (a) soloOpen(a, c, r); }, close: soloClose, get state(){ return SOLO.open ? { c: SOLO.open.c, r: SOLO.open.r, kinds: [...SOLO.open.meshes.entries()].map(([k, v]) => [k, v.n]), title: SOLO.open.root.querySelector('.solo-title').textContent } : null; } }; + /* ── App photos: whole images on boards as REAL textures. The face tier answers "how many tiles can this board afford"; this tier asks the better question — none. One texture per picture, GPU-resampled to diff --git a/tests/part5.mjs b/tests/part5.mjs index 8bc9df0..399b8eb 100644 --- a/tests/part5.mjs +++ b/tests/part5.mjs @@ -2056,6 +2056,24 @@ const game = { title: 'Words', size: l => 5 + Math.ceil(l / 2), console.log(`${ok ? 'ok ' : 'FAIL'} gravity lab, a spiral galaxy: smooth at the start (${sp.runs.map(r => r.a0).join(',')}); by 6 s the heavy disc ${H.map(r => r.m + '-fold ' + r.amp + ', bar ' + r.bar).join('; ')}; the light disc ${L.map(r => r.m + '-fold ' + r.amp + ', bar ' + r.bar).join('; ')}; "${(sp.title || '').slice(0, 120)}"`); } + // (Dec 1: "Double click a labs board to show it alone wth full screen."): a real double click on the board you are on opens it alone over the + // whole page, drawn from its own pieces, its title over it; a drag turns it; a double click shuts it and the field is back + for (const id of ['gaslab', 'gravity', 'charge']){ + current = id; + await page.evaluate(id => window.setFieldApp(window.FIELD_APPS.find(a => a.id === id)), id); + await drawn(page, 2000); await page.evaluate(() => window.__settle()); + const p = await page.evaluate(() => window.__aim(1, 0, 0)); + await page.mouse.dblclick(p.x, p.y); await drawn(page, 1500); + const on = await page.evaluate(() => { const s = window.fieldSolo.state, el = document.getElementById('soloView'), r = el && el.getBoundingClientRect(); + return s && { pieces: s.kinds.reduce((a, [, n]) => a + n, 0), title: s.title.slice(0, 40), full: !!r && r.width >= innerWidth - 1 && r.height >= innerHeight - 1 }; }); + await page.mouse.move(400, 300); await page.mouse.down(); await page.mouse.move(520, 340, { steps: 5 }); await page.mouse.up(); await drawn(page, 400); + await page.mouse.dblclick(600, 420); await drawn(page, 800); + const off = await page.evaluate(() => !window.fieldSolo.state && !document.getElementById('soloView')); + const ok = p.ok && on && on.pieces > 10 && on.full && /lab — /.test(on.title) && off; + if (!ok) failures.push('[lab alone] ' + id + ' ' + JSON.stringify({ p, on, off })); + console.log(`${ok ? 'ok ' : 'FAIL'} ${id}, a double click shows the board alone, full screen: ${on ? on.pieces + ' pieces, "' + on.title + '…"' : 'not opened'}; shut by a double click ${off}`); + } + } catch (e){ failures.push(`[${current}] ${e.message}`); }