2Btainment commited on
Commit
07d40dd
·
verified ·
1 Parent(s): 9591b1d

STUDIUS v3: popups never cover core, labels avoid HUD panels, mobile tabs fit

Browse files
Files changed (3) hide show
  1. app.js +15 -8
  2. index.html +2 -2
  3. style.css +3 -1
app.js CHANGED
@@ -108,8 +108,8 @@ scene.add(new THREE.Points(spGeo, new THREE.PointsMaterial({ color: 0xfff1b0, si
108
  /* ---------- HUD, labels ---------- */
109
  let cat = 'Alle', sel = 0, openId = null;
110
  const cats = $('#cats');
111
- CATS.forEach(c => { const b = document.createElement('button'); b.textContent = c.toUpperCase(); b.onclick = () => setCat(c); cats.append(b); });
112
- function setCat(c) { cat = c; [...cats.children].forEach(b => b.classList.toggle('on', b.textContent === c.toUpperCase())); beep(520); const v = visible(); if (!v.includes(sel)) select(v[0]); }
113
  function visible() { return nodes.map((n, i) => i).filter(i => cat === 'Alle' || nodes[i].userData.s.cat === cat || nodes[i].userData.s.id === 'merge'); }
114
  const labels = STUDIOS.map((s, i) => { const d = document.createElement('div'); d.className = 'lbl'; d.innerHTML = `${icon(s.id)}<span>${s.name}</span>`; d.dataset.cat = s.cat; d.title = s.cat + ' · ' + s.like;
115
  d.onmouseenter = () => select(i); d.onclick = (e) => { e.stopPropagation(); select(i); open(i); }; $('#labels').append(d); return d; });
@@ -119,14 +119,16 @@ function open(i) {
119
  stopLoops(); openId = i; const s = STUDIOS[i]; beep(990, .08, 'triangle');
120
  pop.innerHTML = `<div class="ph"><span class="pi">${icon(s.id)}</span><span class="pt"><b>${s.name}</b><small>${s.cat === '+' ? 'Modul' : s.cat} · ${s.like}</small></span><button aria-label="schließen">${icon('close')}</button></div><div class="pb"></div><div class="pf"><span>STUDIO ${String(i + 1).padStart(2, '0')}/${STUDIOS.length}</span><span>● SIMULATION</span></div>`;
121
  pop.classList.remove('in'); void pop.offsetWidth; pop.classList.add('in'); focusNode(i);
122
- pop.hidden = false; pop.querySelector('.ph button').onclick = close; s.build(pop.querySelector('.pb')); placePop(); $('#wire').classList.add('on');
123
  }
124
  function close() { stopLoops(); if (openId != null) cam.tr = cam.base; openId = null; pop.hidden = true; $('#wire').classList.remove('on'); beep(300); }
125
  function placePop() {
126
- if (openId == null || isMobile && innerWidth < 700) return; const p = screenPos(nodes[openId]);
127
- const W = pop.offsetWidth, H = pop.offsetHeight; let x = p.x + (p.x < innerWidth / 2 ? 90 : -90 - W), y = Math.max(60, Math.min(innerHeight - H - 50, p.y - H / 2));
 
128
  pop.style.left = x + 'px'; pop.style.top = y + 'px';
129
  }
 
130
  // smooth camera focus: swing the orbit so the node faces the camera
131
  function focusNode(i) { if (!started) return; const n = nodes[i]; const a = Math.atan2(n.position.z, n.position.x);
132
  let d = a - cam.tth; d = Math.atan2(Math.sin(d), Math.cos(d)); cam.tth += d; cam.tr = Math.max(14, cam.base - 4); cam.tph = 1.12; }
@@ -135,7 +137,7 @@ window.addEventListener('studius-merge', () => { burst(); beep(200, .3, 'sawtoot
135
 
136
  /* ---------- input ---------- */
137
  const keys = {};
138
- let started = false;
139
  addEventListener('keydown', e => {
140
  if (!started) { start(); return; }
141
  if (e.target.matches('input,textarea')) return;
@@ -209,7 +211,9 @@ function frame() {
209
  cam.th += (cam.tth - cam.th) * kE + drift; cam.tth += drift;
210
  cam.ph += (cam.tph - cam.ph) * kE; cam.r += (cam.tr - cam.r) * kR;
211
  const mx = mouse.x < 5 ? mouse.x : 0, my = mouse.y < 5 ? mouse.y : 0;
212
- camera.position.set(cam.r * Math.sin(cam.ph) * Math.cos(cam.th) + mx * 1.5, cam.r * Math.cos(cam.ph) + my * 1.5, cam.r * Math.sin(cam.ph) * Math.sin(cam.th)); camera.lookAt(0, 0, 0);
 
 
213
  // core pulse
214
  const pulse = 1 + Math.sin(t * 2.4) * .06 + (bursting * .5);
215
  coreMesh.scale.setScalar(pulse); coreMesh.rotation.y += dt * .4; coreMesh.rotation.x += dt * .15; coreMat.emissiveIntensity = .4 + Math.sin(t * 2.4) * .15;
@@ -240,12 +244,14 @@ function frame() {
240
  // labels + wire
241
  if (started) {
242
  const placed = []; const camP = camera.position;
 
243
  nodes.map((n, i) => ({ n, i, d: n.position.distanceTo(camP) })).sort((a, b) => a.d - b.d).forEach(({ n, i, d }, rank) => {
244
  const p = screenPos(n); const l = labels[i]; if (p.z >= 1) { l.style.display = 'none'; return; } l.style.display = '';
245
  const far = rank > 9 && i !== sel && i !== openId; l.classList.toggle('far', far);
246
  const w = far ? 30 : l.offsetWidth || 110, h = 26; let y = p.y + 34;
247
  for (let k = 0; k < 6; k++) { const hit = placed.find(r => Math.abs(r.x - p.x) < (r.w + w) / 2 + 4 && Math.abs(r.y - y) < h); if (!hit) break; y = hit.y + (y >= hit.y ? h : -h); }
248
- placed.push({ x: p.x, y, w }); l.style.transform = `translate(${p.x}px,${y}px) translate(-50%,-50%)`; l.style.zIndex = 100 - rank;
 
249
  l.classList.toggle('dim', !v.includes(i)); });
250
  if ((mmT += dt) > .1) { mmT = 0; drawMinimap(v); }
251
  if (openId != null && !pop.hidden) { const p = screenPos(nodes[openId]); const r = pop.getBoundingClientRect(); const wl = $('#wl');
@@ -255,6 +261,7 @@ function frame() {
255
  }
256
  }
257
  applyQuality();
 
258
  if (gl3d) frame(); else {
259
  document.body.insertAdjacentHTML('beforeend', '<div style="position:fixed;left:14px;top:60px;z-index:16;color:#faa968;font-size:11px">⚠ WebGL nicht verfügbar – 2D-Modus</div>');
260
  // minimal 2D loop to keep labels in a ring
 
108
  /* ---------- HUD, labels ---------- */
109
  let cat = 'Alle', sel = 0, openId = null;
110
  const cats = $('#cats');
111
+ CATS.forEach(c => { const b = document.createElement('button'); b.textContent = c.toUpperCase(); b.dataset.c = c; b.onclick = () => setCat(c); cats.append(b); });
112
+ function setCat(c) { cat = c; [...cats.children].forEach(b => b.classList.toggle('on', b.dataset.c === c)); beep(520); const v = visible(); if (!v.includes(sel)) select(v[0]); }
113
  function visible() { return nodes.map((n, i) => i).filter(i => cat === 'Alle' || nodes[i].userData.s.cat === cat || nodes[i].userData.s.id === 'merge'); }
114
  const labels = STUDIOS.map((s, i) => { const d = document.createElement('div'); d.className = 'lbl'; d.innerHTML = `${icon(s.id)}<span>${s.name}</span>`; d.dataset.cat = s.cat; d.title = s.cat + ' · ' + s.like;
115
  d.onmouseenter = () => select(i); d.onclick = (e) => { e.stopPropagation(); select(i); open(i); }; $('#labels').append(d); return d; });
 
119
  stopLoops(); openId = i; const s = STUDIOS[i]; beep(990, .08, 'triangle');
120
  pop.innerHTML = `<div class="ph"><span class="pi">${icon(s.id)}</span><span class="pt"><b>${s.name}</b><small>${s.cat === '+' ? 'Modul' : s.cat} · ${s.like}</small></span><button aria-label="schließen">${icon('close')}</button></div><div class="pb"></div><div class="pf"><span>STUDIO ${String(i + 1).padStart(2, '0')}/${STUDIOS.length}</span><span>● SIMULATION</span></div>`;
121
  pop.classList.remove('in'); void pop.offsetWidth; pop.classList.add('in'); focusNode(i);
122
+ pop.hidden = false; pop.querySelector('.ph button').onclick = close; s.build(pop.querySelector('.pb')); placePop(); $('#wire').classList.add('on'); setTimeout(placePop, 60);
123
  }
124
  function close() { stopLoops(); if (openId != null) cam.tr = cam.base; openId = null; pop.hidden = true; $('#wire').classList.remove('on'); beep(300); }
125
  function placePop() {
126
+ if (openId == null || innerWidth < 700) return;
127
+ const W = pop.offsetWidth, H = pop.offsetHeight; const x = innerWidth - W - Math.max(40, innerWidth * .06);
128
+ const y = Math.max(76, Math.min((innerHeight - H) / 2, innerHeight - H - 200));
129
  pop.style.left = x + 'px'; pop.style.top = y + 'px';
130
  }
131
+
132
  // smooth camera focus: swing the orbit so the node faces the camera
133
  function focusNode(i) { if (!started) return; const n = nodes[i]; const a = Math.atan2(n.position.z, n.position.x);
134
  let d = a - cam.tth; d = Math.atan2(Math.sin(d), Math.cos(d)); cam.tth += d; cam.tr = Math.max(14, cam.base - 4); cam.tph = 1.12; }
 
137
 
138
  /* ---------- input ---------- */
139
  const keys = {};
140
+ let started = false, lookK = 0;
141
  addEventListener('keydown', e => {
142
  if (!started) { start(); return; }
143
  if (e.target.matches('input,textarea')) return;
 
211
  cam.th += (cam.tth - cam.th) * kE + drift; cam.tth += drift;
212
  cam.ph += (cam.tph - cam.ph) * kE; cam.r += (cam.tr - cam.r) * kR;
213
  const mx = mouse.x < 5 ? mouse.x : 0, my = mouse.y < 5 ? mouse.y : 0;
214
+ camera.position.set(cam.r * Math.sin(cam.ph) * Math.cos(cam.th) + mx * 1.5, cam.r * Math.cos(cam.ph) + my * 1.5, cam.r * Math.sin(cam.ph) * Math.sin(cam.th)); const mob = innerWidth < 700, want = openId == null ? 0 : 1; lookK += (want - lookK) * kE;
215
+ const ox = mob ? 0 : .19 * cam.r * camera.aspect * lookK, oy = mob ? -.27 * cam.r * lookK : 0;
216
+ camera.lookAt(Math.sin(cam.th) * ox, oy, -Math.cos(cam.th) * ox);
217
  // core pulse
218
  const pulse = 1 + Math.sin(t * 2.4) * .06 + (bursting * .5);
219
  coreMesh.scale.setScalar(pulse); coreMesh.rotation.y += dt * .4; coreMesh.rotation.x += dt * .15; coreMat.emissiveIntensity = .4 + Math.sin(t * 2.4) * .15;
 
244
  // labels + wire
245
  if (started) {
246
  const placed = []; const camP = camera.position;
247
+ const blk = ['#hud', '#core-stats', '#mm', '#pop', '#hint', '#bmc'].map(q => $(q)).filter(e => e && !e.hidden && e.offsetParent !== null).map(e => e.getBoundingClientRect());
248
  nodes.map((n, i) => ({ n, i, d: n.position.distanceTo(camP) })).sort((a, b) => a.d - b.d).forEach(({ n, i, d }, rank) => {
249
  const p = screenPos(n); const l = labels[i]; if (p.z >= 1) { l.style.display = 'none'; return; } l.style.display = '';
250
  const far = rank > 9 && i !== sel && i !== openId; l.classList.toggle('far', far);
251
  const w = far ? 30 : l.offsetWidth || 110, h = 26; let y = p.y + 34;
252
  for (let k = 0; k < 6; k++) { const hit = placed.find(r => Math.abs(r.x - p.x) < (r.w + w) / 2 + 4 && Math.abs(r.y - y) < h); if (!hit) break; y = hit.y + (y >= hit.y ? h : -h); }
253
+ placed.push({ x: p.x, y, w });
254
+ const lx0 = p.x - w / 2, lx1 = p.x + w / 2; l.classList.toggle('hid', blk.some(r => lx0 < r.right && lx1 > r.left && y - 13 < r.bottom && y + 13 > r.top)); l.style.transform = `translate(${p.x}px,${y}px) translate(-50%,-50%)`; l.style.zIndex = 100 - rank;
255
  l.classList.toggle('dim', !v.includes(i)); });
256
  if ((mmT += dt) > .1) { mmT = 0; drawMinimap(v); }
257
  if (openId != null && !pop.hidden) { const p = screenPos(nodes[openId]); const r = pop.getBoundingClientRect(); const wl = $('#wl');
 
261
  }
262
  }
263
  applyQuality();
264
+ window.__studius = { core: () => screenPos(core) };
265
  if (gl3d) frame(); else {
266
  document.body.insertAdjacentHTML('beforeend', '<div style="position:fixed;left:14px;top:60px;z-index:16;color:#faa968;font-size:11px">⚠ WebGL nicht verfügbar – 2D-Modus</div>');
267
  // minimal 2D loop to keep labels in a ring
index.html CHANGED
@@ -7,7 +7,7 @@
7
  <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
8
  <title>STUDIUS · DAS Studio — Einswarm</title>
9
  <link rel="icon" href="assets/einswarm-mascot.webp">
10
- <link rel="stylesheet" href="style.css?v=2">
11
  </head>
12
  <body>
13
  <canvas id="gl"></canvas>
@@ -46,6 +46,6 @@
46
 
47
  <a id="bmc" href="https://www.buymeacoffee.com/2btainment" target="_blank" rel="noopener noreferrer">Buy me a coffee</a>
48
  <noscript><p style="color:#f2c94c;padding:2em">STUDIUS braucht JavaScript.</p></noscript>
49
- <script type="module" src="app.js?v=4"></script>
50
  </body>
51
  </html>
 
7
  <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
8
  <title>STUDIUS · DAS Studio — Einswarm</title>
9
  <link rel="icon" href="assets/einswarm-mascot.webp">
10
+ <link rel="stylesheet" href="style.css?v=3">
11
  </head>
12
  <body>
13
  <canvas id="gl"></canvas>
 
46
 
47
  <a id="bmc" href="https://www.buymeacoffee.com/2btainment" target="_blank" rel="noopener noreferrer">Buy me a coffee</a>
48
  <noscript><p style="color:#f2c94c;padding:2em">STUDIUS braucht JavaScript.</p></noscript>
49
+ <script type="module" src="app.js?v=5"></script>
50
  </body>
51
  </html>
style.css CHANGED
@@ -85,6 +85,7 @@ body::before{content:"";position:fixed;inset:0;pointer-events:none;z-index:1;bac
85
  .lbl:hover,.lbl.sel{border-color:var(--gold);background:rgba(36,28,8,.92);color:#fff;box-shadow:0 0 18px rgba(242,201,76,.35),inset 0 0 0 1px rgba(242,201,76,.2)}
86
  .lbl.sel::before{content:"";position:absolute;left:-1px;top:-1px;bottom:-1px;width:3px;background:var(--gold)}
87
  .lbl.dim{opacity:.22}
 
88
  .lbl[data-cat="+"] .ic{color:var(--r-red)}
89
  #wire{position:fixed;inset:0;width:100%;height:100%;z-index:11;pointer-events:none}
90
  #wl{stroke:var(--gold);stroke-width:1;stroke-dasharray:4 4;opacity:0;transition:opacity .3s;animation:dash 1s linear infinite}
@@ -138,7 +139,8 @@ kbd{font:inherit;font-size:9px;color:var(--gold);border:1px solid var(--line);pa
138
  @media (max-width:1000px){#cats{justify-content:flex-start}}
139
  @media (max-width:700px){
140
  #hud{height:auto;flex-wrap:wrap;padding:8px 12px 0;gap:8px}.brand span{display:none}#cats{order:3;flex-basis:100%;margin:0 -12px;padding:0 6px}
141
- #cats button{padding:10px 9px}
 
142
  #frame,#mm{display:none!important}
143
  #core-stats{left:10px;bottom:62px;width:150px;font-size:9.5px;padding:8px 10px}
144
  #core-stats p,#core-stats .bar{display:none}
 
85
  .lbl:hover,.lbl.sel{border-color:var(--gold);background:rgba(36,28,8,.92);color:#fff;box-shadow:0 0 18px rgba(242,201,76,.35),inset 0 0 0 1px rgba(242,201,76,.2)}
86
  .lbl.sel::before{content:"";position:absolute;left:-1px;top:-1px;bottom:-1px;width:3px;background:var(--gold)}
87
  .lbl.dim{opacity:.22}
88
+ .lbl.hid{opacity:0!important;pointer-events:none}
89
  .lbl[data-cat="+"] .ic{color:var(--r-red)}
90
  #wire{position:fixed;inset:0;width:100%;height:100%;z-index:11;pointer-events:none}
91
  #wl{stroke:var(--gold);stroke-width:1;stroke-dasharray:4 4;opacity:0;transition:opacity .3s;animation:dash 1s linear infinite}
 
139
  @media (max-width:1000px){#cats{justify-content:flex-start}}
140
  @media (max-width:700px){
141
  #hud{height:auto;flex-wrap:wrap;padding:8px 12px 0;gap:8px}.brand span{display:none}#cats{order:3;flex-basis:100%;margin:0 -12px;padding:0 6px}
142
+ #cats{flex-wrap:wrap;justify-content:center;overflow:visible;gap:0 1px}
143
+ #cats button{padding:8px 5px 7px;font-size:9px;letter-spacing:.06em}
144
  #frame,#mm{display:none!important}
145
  #core-stats{left:10px;bottom:62px;width:150px;font-size:9.5px;padding:8px 10px}
146
  #core-stats p,#core-stats .bar{display:none}