Spaces:
Running
Running
Upload index.html
Browse files- index.html +566 -441
index.html
CHANGED
|
@@ -3,488 +3,613 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
-
<title>Mala-Motion Suite β
|
| 7 |
<style>
|
| 8 |
-
* { box-sizing:border-box; margin:0; padding:0; }
|
| 9 |
:root {
|
| 10 |
-
--bg:#0f1013;
|
| 11 |
-
--
|
| 12 |
-
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
-
body {
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
.
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
.spacer { flex:1; }
|
| 25 |
-
.btn { font-size:12px; border:1px solid var(--border); background:var(--panel2);
|
| 26 |
-
padding:7px 12px; border-radius:8px; cursor:pointer;
|
| 27 |
-
.btn
|
| 28 |
-
.btn
|
| 29 |
-
|
|
|
|
| 30 |
.main { flex:1; display:flex; min-height:0; }
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
.
|
| 35 |
-
|
| 36 |
-
.
|
| 37 |
-
.
|
| 38 |
-
.dot { width:
|
| 39 |
-
.
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
.
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
#
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
.
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
.
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
.
|
| 75 |
-
background:
|
| 76 |
-
.
|
| 77 |
-
padding:
|
| 78 |
-
.
|
| 79 |
-
.
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
.
|
| 86 |
-
.
|
| 87 |
-
|
| 88 |
-
.
|
| 89 |
-
.
|
| 90 |
-
|
| 91 |
-
.
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
.
|
| 96 |
-
.
|
| 97 |
-
.
|
| 98 |
-
.
|
| 99 |
-
|
| 100 |
-
.
|
| 101 |
-
|
| 102 |
-
.
|
| 103 |
-
.
|
| 104 |
-
|
| 105 |
-
.
|
| 106 |
-
.
|
| 107 |
-
|
| 108 |
-
font:12px/1.6 Inter,Segoe UI,system-ui,sans-serif; padding:6px 9px 9px; min-height:64px; }
|
| 109 |
-
.note textarea::placeholder { color:#5b5f6c; }
|
| 110 |
-
/* Studio notebook */
|
| 111 |
-
.notebook { width:248px; background:var(--panel); border-left:1px solid var(--border); display:flex;
|
| 112 |
-
flex-direction:column; flex-shrink:0; min-height:0; }
|
| 113 |
-
.notebook.hide { display:none; }
|
| 114 |
-
.nb-head { padding:11px 12px 8px; border-bottom:1px solid var(--border); }
|
| 115 |
-
.nb-head .t { font-size:10px; font-weight:800; letter-spacing:.14em; text-transform:uppercase; }
|
| 116 |
-
.nb-head .t span { color:var(--orange2); }
|
| 117 |
-
.nb-head .s { font-size:10px; color:var(--muted); margin-top:3px; }
|
| 118 |
-
#nbText { flex:1; background:#121319; color:var(--text); border:none; outline:none; resize:none;
|
| 119 |
-
font:12px/1.7 ui-monospace,Consolas,monospace; padding:12px; }
|
| 120 |
-
#nbText[readonly] { opacity:.55; }
|
| 121 |
-
.nb-foot { display:flex; align-items:center; gap:6px; padding:8px 10px; border-top:1px solid var(--border); font-size:10px; color:var(--muted); }
|
| 122 |
.mini-btn { font-size:10px; font-weight:700; border:1px solid var(--border); background:#121319; color:var(--text);
|
| 123 |
-
padding:4px
|
| 124 |
.mini-btn:hover { border-color:var(--orange); color:var(--orange2); }
|
| 125 |
.mini-btn.acc { background:var(--orange); border-color:var(--orange); color:#111; }
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
.status b { color:var(--text); }
|
| 129 |
.live { width:8px; height:8px; border-radius:50%; background:#38e06c; box-shadow:0 0 7px #38e06c; display:inline-block; margin-right:6px; }
|
| 130 |
-
body.locked .live { background:var(--orange); box-shadow:0 0 7px var(--orange); }
|
| 131 |
</style>
|
| 132 |
</head>
|
| 133 |
-
<body
|
| 134 |
|
| 135 |
<div class="topbar">
|
| 136 |
<div class="logo">M</div>
|
| 137 |
-
<div class="title">Mala-Motion <span>
|
| 138 |
-
<div class="pill"
|
| 139 |
<div class="spacer"></div>
|
| 140 |
-
<button class="btn"
|
| 141 |
-
<button class="btn
|
| 142 |
</div>
|
| 143 |
|
| 144 |
<div class="main">
|
|
|
|
| 145 |
<div class="sidebar">
|
| 146 |
-
<h3>
|
| 147 |
-
<div class="
|
| 148 |
-
<
|
| 149 |
-
<div
|
| 150 |
-
<div class="
|
| 151 |
-
<h3>
|
| 152 |
-
<div class="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
</div>
|
| 154 |
|
| 155 |
-
<
|
|
|
|
| 156 |
<canvas id="fogGL"></canvas>
|
| 157 |
-
<div
|
| 158 |
-
<svg id="
|
| 159 |
-
|
| 160 |
-
<div class="
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
</div>
|
| 171 |
-
</div>
|
| 172 |
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
</div>
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
</div>
|
| 182 |
|
| 183 |
<div class="status">
|
| 184 |
-
<span><span class="live"></span><b
|
| 185 |
-
<span
|
| 186 |
-
<span style="margin-left:auto">Mala-Motion Suite Β·
|
| 187 |
</div>
|
| 188 |
|
| 189 |
<script>
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
const
|
| 193 |
-
|
| 194 |
-
hint = document.getElementById('hint'), toast = document.getElementById('toast'),
|
| 195 |
-
zoomLbl = document.getElementById('zoomLbl');
|
| 196 |
-
const cam = { x: 0, y: 0, k: 1 };
|
| 197 |
-
let locked = localStorage.getItem('mala-mode') !== 'studio';
|
| 198 |
-
const tiles = [], notes = [];
|
| 199 |
-
let toastT = null;
|
| 200 |
-
function say(m){ toast.textContent = m; toast.style.opacity = 1; clearTimeout(toastT); toastT = setTimeout(()=>toast.style.opacity=0, 1800); }
|
| 201 |
-
|
| 202 |
-
/* ---------- camera: pan + zoom ---------- */
|
| 203 |
-
function applyCam(){
|
| 204 |
-
const r = vp.getBoundingClientRect();
|
| 205 |
-
const ox = r.width/2 - cam.x*cam.k, oy = r.height/2 - cam.y*cam.k;
|
| 206 |
-
world.style.transform = `translate(${ox}px,${oy}px) scale(${cam.k})`;
|
| 207 |
-
const g = 26*cam.k;
|
| 208 |
-
grid.style.backgroundSize = `${g}px ${g}px`;
|
| 209 |
-
grid.style.backgroundPosition = `${ox % g}px ${oy % g}px`;
|
| 210 |
-
zoomLbl.textContent = Math.round(cam.k*100) + '%';
|
| 211 |
-
renderLinks();
|
| 212 |
-
}
|
| 213 |
-
function toWorld(cx, cy){ const r = vp.getBoundingClientRect();
|
| 214 |
-
return { x: (cx - r.left - r.width/2)/cam.k + cam.x, y: (cy - r.top - r.height/2)/cam.k + cam.y }; }
|
| 215 |
-
function toScreen(wx, wy){ const r = vp.getBoundingClientRect();
|
| 216 |
-
return { x: (wx - cam.x)*cam.k + r.width/2, y: (wy - cam.y)*cam.k + r.height/2 }; }
|
| 217 |
-
function sizeLinks(){ const r = vp.getBoundingClientRect();
|
| 218 |
-
links.setAttribute('viewBox', `0 0 ${r.width} ${r.height}`); }
|
| 219 |
-
window.addEventListener('resize', ()=>{ sizeLinks(); applyCam(); sizeFog(); });
|
| 220 |
-
|
| 221 |
-
let pan = null;
|
| 222 |
-
vp.addEventListener('pointerdown', e => {
|
| 223 |
-
if (e.target.closest('.tile,.note,button,textarea,input,.zoomctl,.hint')) return;
|
| 224 |
-
pan = { sx: e.clientX, sy: e.clientY, cx: cam.x, cy: cam.y, moved: 0 };
|
| 225 |
-
vp.setPointerCapture(e.pointerId); vp.classList.add('panning');
|
| 226 |
-
});
|
| 227 |
-
vp.addEventListener('pointermove', e => {
|
| 228 |
-
if (!pan) return;
|
| 229 |
-
const dx = e.clientX - pan.sx, dy = e.clientY - pan.sy;
|
| 230 |
-
pan.moved = Math.max(pan.moved, Math.abs(dx) + Math.abs(dy));
|
| 231 |
-
cam.x = pan.cx - dx/cam.k; cam.y = pan.cy - dy/cam.k; applyCam();
|
| 232 |
-
});
|
| 233 |
-
vp.addEventListener('pointerup', ()=>{ pan = null; vp.classList.remove('panning'); });
|
| 234 |
-
vp.addEventListener('wheel', e => {
|
| 235 |
-
e.preventDefault();
|
| 236 |
-
const r = vp.getBoundingClientRect();
|
| 237 |
-
const k2 = Math.min(2.5, Math.max(0.3, cam.k * Math.exp(-e.deltaY * 0.0015)));
|
| 238 |
-
const wx = (e.clientX - r.left - r.width/2)/cam.k + cam.x;
|
| 239 |
-
const wy = (e.clientY - r.top - r.height/2)/cam.k + cam.y;
|
| 240 |
-
cam.x = wx - (e.clientX - r.left - r.width/2)/k2;
|
| 241 |
-
cam.y = wy - (e.clientY - r.top - r.height/2)/k2;
|
| 242 |
-
cam.k = k2; applyCam();
|
| 243 |
-
}, { passive: false });
|
| 244 |
-
document.getElementById('zin').onclick = ()=>{ cam.k = Math.min(2.5, cam.k*1.2); applyCam(); };
|
| 245 |
-
document.getElementById('zout').onclick = ()=>{ cam.k = Math.max(0.3, cam.k/1.2); applyCam(); };
|
| 246 |
-
document.getElementById('zreset').onclick = ()=>{ cam.x = 0; cam.y = 0; cam.k = 1; applyCam(); };
|
| 247 |
-
/* Floating CTA: one click drops a note at view center (same as double-click) */
|
| 248 |
-
document.getElementById('noteCta').onclick = () => {
|
| 249 |
-
const r = vp.getBoundingClientRect();
|
| 250 |
-
const p = toWorld(r.left + r.width/2, r.top + r.height/2);
|
| 251 |
-
addNote(p.x - 98, p.y - 20, '', true);
|
| 252 |
-
say('π note dropped β type, then double-click anywhere for more');
|
| 253 |
-
};
|
| 254 |
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
const el = document.createElement('div');
|
| 259 |
-
el.className = 'tile'; el.style.width = (w || 420) + 'px';
|
| 260 |
-
el.style.left = (-210 + tiles.length*40) + 'px'; el.style.top = (-160 + tiles.length*30) + 'px';
|
| 261 |
-
el.innerHTML = `<img src="${src}" alt="" draggable="false" />
|
| 262 |
-
<div class="cap"><span class="dot"></span><b>${name}</b><button class="x" title="remove">Γ</button></div>`;
|
| 263 |
-
world.appendChild(el);
|
| 264 |
-
const t = { id, el, x: parseFloat(el.style.left), y: parseFloat(el.style.top), w: w || 420, h: 220, src, name };
|
| 265 |
-
el.querySelector('img').addEventListener('load', ev => {
|
| 266 |
-
const im = ev.target; t.h = (w || 420) * im.naturalHeight / Math.max(1, im.naturalWidth) + 34;
|
| 267 |
-
renderLinks(); counts();
|
| 268 |
-
});
|
| 269 |
-
el.querySelector('.x').onclick = e => { e.stopPropagation(); removeTile(id); };
|
| 270 |
-
el.addEventListener('pointerdown', e => {
|
| 271 |
-
if (e.target.closest('button')) return;
|
| 272 |
-
if (locked) { say('π visitor mode β artwork is locked'); return; }
|
| 273 |
-
e.stopPropagation();
|
| 274 |
-
const sx = e.clientX, sy = e.clientY, ox = t.x, oy = t.y;
|
| 275 |
-
const mv = ev => { t.x = ox + (ev.clientX - sx)/cam.k; t.y = oy + (ev.clientY - sy)/cam.k;
|
| 276 |
-
el.style.left = t.x + 'px'; el.style.top = t.y + 'px'; renderLinks(); };
|
| 277 |
-
const up = () => { window.removeEventListener('pointermove', mv); window.removeEventListener('pointerup', up); };
|
| 278 |
-
window.addEventListener('pointermove', mv); window.addEventListener('pointerup', up);
|
| 279 |
-
});
|
| 280 |
-
tiles.push(t); renderLinks(); counts(); return t;
|
| 281 |
-
}
|
| 282 |
-
function removeTile(id){
|
| 283 |
-
if (locked) { say('π visitor mode β artwork is locked'); return; }
|
| 284 |
-
const i = tiles.findIndex(t => t.id === id);
|
| 285 |
-
if (i > -1) { tiles[i].el.remove(); tiles.splice(i, 1); renderLinks(); counts(); }
|
| 286 |
-
}
|
| 287 |
-
function addTextTile(){
|
| 288 |
-
const el = document.createElement('div');
|
| 289 |
-
el.className = 'tile textile'; el.style.left = '-560px'; el.style.top = '-140px';
|
| 290 |
-
el.innerHTML = `<h2>Watercolor <em>bus studies</em> β reel β26</h2>
|
| 291 |
-
<p>Frame-by-frame anidoodle rigs β WebGL preview β Lottie export. Drag to pan, scroll to zoom, double-click anywhere to sign the wall.</p>`;
|
| 292 |
-
world.appendChild(el);
|
| 293 |
-
tiles.push({ id: 'text0', el, x: -560, y: -140, w: 340, h: 190, text: true });
|
| 294 |
-
}
|
| 295 |
-
|
| 296 |
-
/* ---------- sticky notes + connector pins ---------- */
|
| 297 |
-
vp.addEventListener('dblclick', e => {
|
| 298 |
-
if (e.target.closest('.tile,.note,button,textarea,input,.zoomctl,.sidebar,.notebook')) return;
|
| 299 |
-
const p = toWorld(e.clientX, e.clientY);
|
| 300 |
-
addNote(p.x - 98, p.y - 20, '', true);
|
| 301 |
-
});
|
| 302 |
-
function addNote(x, y, text, focus){
|
| 303 |
-
const id = 'n' + Date.now() + Math.floor(Math.random()*999);
|
| 304 |
-
const el = document.createElement('div');
|
| 305 |
-
el.className = 'note'; el.style.left = x + 'px'; el.style.top = y + 'px';
|
| 306 |
-
const now = new Date();
|
| 307 |
-
el.innerHTML = `<div class="note-head"><span class="dot"></span><span class="who">guest</span>
|
| 308 |
-
<time>${String(now.getHours()).padStart(2,'0')}:${String(now.getMinutes()).padStart(2,'0')}</time>
|
| 309 |
-
<button class="nx" title="remove note">Γ</button></div>
|
| 310 |
-
<textarea placeholder="leave feedback or sign hereβ¦" rows="3"></textarea>`;
|
| 311 |
-
const ta = el.querySelector('textarea');
|
| 312 |
-
ta.value = text || '';
|
| 313 |
-
ta.spellcheck = false;
|
| 314 |
-
world.appendChild(el);
|
| 315 |
-
const n = { id, el, ta, x, y };
|
| 316 |
-
el.querySelector('.nx').onclick = e => { e.stopPropagation();
|
| 317 |
-
el.remove(); notes.splice(notes.indexOf(n), 1); renderLinks(); counts(); };
|
| 318 |
-
el.querySelector('.note-head').addEventListener('pointerdown', e => {
|
| 319 |
-
if (e.target.closest('button')) return;
|
| 320 |
-
e.stopPropagation();
|
| 321 |
-
const sx = e.clientX, sy = e.clientY, ox = n.x, oy = n.y;
|
| 322 |
-
const mv = ev => { n.x = ox + (ev.clientX - sx)/cam.k; n.y = oy + (ev.clientY - sy)/cam.k;
|
| 323 |
-
el.style.left = n.x + 'px'; el.style.top = n.y + 'px'; renderLinks(); };
|
| 324 |
-
const up = () => { window.removeEventListener('pointermove', mv); window.removeEventListener('pointerup', up); };
|
| 325 |
-
window.addEventListener('pointermove', mv); window.addEventListener('pointerup', up);
|
| 326 |
-
});
|
| 327 |
-
ta.addEventListener('input', () => { ta.style.height = 'auto'; ta.style.height = ta.scrollHeight + 'px'; });
|
| 328 |
-
notes.push(n); renderLinks(); counts();
|
| 329 |
-
if (focus) { const who = el.querySelector('.who'); who.textContent = 'guest Β· ' + (notes.length); ta.focus(); }
|
| 330 |
-
return n;
|
| 331 |
-
}
|
| 332 |
-
function nearestTile(nx, ny){
|
| 333 |
-
let best = null, bd = 1e12;
|
| 334 |
-
for (const t of tiles) {
|
| 335 |
-
const cx = Math.min(Math.max(nx, t.x), t.x + t.w);
|
| 336 |
-
const cy = Math.min(Math.max(ny, t.y), t.y + t.h);
|
| 337 |
-
const d = (nx - cx)**2 + (ny - cy)**2;
|
| 338 |
-
if (d < bd) { bd = d; best = { t, cx, cy }; }
|
| 339 |
}
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
}
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
|
| 360 |
-
/
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
|
| 378 |
-
/
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
const
|
| 386 |
-
const
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
};
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
const
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
}
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
const a = document.createElement('a');
|
| 414 |
-
a.href = URL.createObjectURL(new Blob([nbText.value], { type: 'text/markdown' }));
|
| 415 |
-
a.download = 'mala-notes.md'; a.click(); setTimeout(()=>URL.revokeObjectURL(a.href), 2000); };
|
| 416 |
-
document.getElementById('nbToggle').onclick = () =>
|
| 417 |
-
document.getElementById('notebook').classList.toggle('hide');
|
| 418 |
|
| 419 |
-
/
|
| 420 |
-
|
| 421 |
-
(
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
}
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
const dpr = Math.min(window.devicePixelRatio||1, 1.25);
|
| 469 |
-
const w = Math.max(1, Math.floor(vp.clientWidth*dpr)), h = Math.max(1, Math.floor(vp.clientHeight*dpr));
|
| 470 |
-
if (cv.width!==w || cv.height!==h){ cv.width=w; cv.height=h; gl.viewport(0,0,w,h); }
|
| 471 |
-
};
|
| 472 |
-
fogSize();
|
| 473 |
-
const t0 = performance.now();
|
| 474 |
-
(function frame(){ requestAnimationFrame(frame);
|
| 475 |
-
if (document.hidden) return;
|
| 476 |
-
fogSize(); mx += (tmx-mx)*.06; my += (tmy-my)*.06;
|
| 477 |
-
gl.uniform2f(uRes,cv.width,cv.height); gl.uniform1f(uTime,(performance.now()-t0)/1000);
|
| 478 |
-
gl.uniform2f(uMouse,mx,my); gl.drawArrays(gl.TRIANGLES,0,3);
|
| 479 |
})();
|
| 480 |
-
})();
|
| 481 |
-
function sizeFog(){ if (fogSize) fogSize(); }
|
| 482 |
|
| 483 |
-
/
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 488 |
</script>
|
| 489 |
</body>
|
| 490 |
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>Mala-Motion Suite β Node Workspace</title>
|
| 7 |
<style>
|
| 8 |
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
| 9 |
:root {
|
| 10 |
+
--bg: #0f1013;
|
| 11 |
+
--panel: #17181d;
|
| 12 |
+
--panel2: #1e2027;
|
| 13 |
+
--border: #2a2d36;
|
| 14 |
+
--text: #e8e9ec;
|
| 15 |
+
--muted: #8b8f9c;
|
| 16 |
+
--orange: #ff6b1a;
|
| 17 |
+
--orange2: #ffa25e;
|
| 18 |
+
--orange-dim: rgba(255,107,26,.14);
|
| 19 |
}
|
| 20 |
+
body {
|
| 21 |
+
font-family: Inter, Segoe UI, system-ui, -apple-system, sans-serif;
|
| 22 |
+
background: var(--bg); color: var(--text);
|
| 23 |
+
height: 100vh; display: flex; flex-direction: column; overflow: hidden;
|
| 24 |
+
}
|
| 25 |
+
/* Top bar */
|
| 26 |
+
.topbar {
|
| 27 |
+
height: 48px; background: var(--panel); border-bottom: 1px solid var(--border);
|
| 28 |
+
display: flex; align-items: center; gap: 12px; padding: 0 14px; flex-shrink: 0;
|
| 29 |
+
}
|
| 30 |
+
.logo { width: 26px; height: 26px; border-radius: 7px;
|
| 31 |
+
background: linear-gradient(135deg, var(--orange), #ff2e63);
|
| 32 |
+
display:grid; place-items:center; font-weight:800; font-size:14px; color:#fff;
|
| 33 |
+
}
|
| 34 |
+
.title { font-weight: 650; font-size: 14px; letter-spacing:.2px; }
|
| 35 |
+
.title span { color: var(--orange2); }
|
| 36 |
+
.pill { font-size:11px; color:var(--muted); border:1px solid var(--border);
|
| 37 |
+
padding:4px 9px; border-radius:999px; background:#121319; }
|
| 38 |
+
.pill b { color:#7CFF6B; font-weight:700; }
|
| 39 |
.spacer { flex:1; }
|
| 40 |
+
.btn { font-size:12px; border:1px solid var(--border); background:var(--panel2);
|
| 41 |
+
color:var(--text); padding:7px 12px; border-radius:8px; cursor:pointer; }
|
| 42 |
+
.btn.primary { background:var(--orange); border-color:var(--orange); color:#111; font-weight:700; }
|
| 43 |
+
.btn:hover { filter:brightness(1.1); }
|
| 44 |
+
|
| 45 |
+
/* Layout */
|
| 46 |
.main { flex:1; display:flex; min-height:0; }
|
| 47 |
+
.sidebar { width:220px; background:var(--panel); border-right:1px solid var(--border);
|
| 48 |
+
padding:12px; display:flex; flex-direction:column; gap:10px; flex-shrink:0; }
|
| 49 |
+
.sidebar h3, .inspector h3 { font-size:11px; text-transform:uppercase; letter-spacing:.12em; color:var(--muted); margin:4px 2px 6px; }
|
| 50 |
+
.asset { background:var(--panel2); border:1px solid var(--border); border-radius:10px;
|
| 51 |
+
padding:10px 11px; cursor:grab; transition:.15s; }
|
| 52 |
+
.asset:hover { border-color:var(--orange); background:var(--orange-dim); }
|
| 53 |
+
.asset .k { font-size:12px; font-weight:650; display:flex; align-items:center; gap:8px; }
|
| 54 |
+
.dot { width:9px; height:9px; border-radius:50%; background:var(--orange); box-shadow:0 0 8px var(--orange); flex-shrink:0; }
|
| 55 |
+
.asset small { color:var(--muted); font-size:11px; display:block; margin-top:4px; line-height:1.4; }
|
| 56 |
+
.asset .tag { display:inline-block; margin-top:7px; font-size:10px; padding:2px 7px; border-radius:999px;
|
| 57 |
+
background:#121319; border:1px solid var(--border); color:var(--orange2); }
|
| 58 |
+
|
| 59 |
+
/* Canvas */
|
| 60 |
+
.canvas-wrap { flex:1; position:relative; overflow:hidden;
|
| 61 |
+
background:
|
| 62 |
+
radial-gradient(circle, #2b2e38 1px, transparent 1px);
|
| 63 |
+
background-size:22px 22px; background-color:#0b0c0f;
|
| 64 |
+
}
|
| 65 |
+
.canvas-hint { position:absolute; top:12px; left:50%; transform:translateX(-50%);
|
| 66 |
+
font-size:11px; color:var(--muted); background:rgba(23,24,29,.9);
|
| 67 |
+
border:1px solid var(--border); padding:6px 12px; border-radius:999px; pointer-events:none; }
|
| 68 |
+
svg.wires { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; z-index:1; }
|
| 69 |
+
svg.wires path { stroke: var(--orange); stroke-width:2; fill:none; opacity:.9; filter: drop-shadow(0 0 4px rgba(255,107,26,.6)); }
|
| 70 |
+
svg.wires path.ghost { stroke:#3a3e4b; opacity:.9; filter:none; }
|
| 71 |
+
/* Fluid orange fog layer (WebGL) β sits over the grid, under nodes */
|
| 72 |
+
#fogGL { position:absolute; inset:0; width:100%; height:100%; z-index:0; display:block; pointer-events:none; }
|
| 73 |
+
.canvas-hint { z-index:4; }
|
| 74 |
+
.node { z-index:2; }
|
| 75 |
+
.mood { z-index:3; }
|
| 76 |
+
.fog-controls { display:flex; gap:6px; }
|
| 77 |
+
.fog-controls button { flex:1; font-size:11px; font-weight:700; border:1px solid var(--orange);
|
| 78 |
+
background:var(--orange-dim); color:var(--orange2); padding:6px 0; border-radius:7px; cursor:pointer; }
|
| 79 |
+
.fog-controls button:hover { background:var(--orange); color:#111; }
|
| 80 |
+
.fog-controls button.off { border-color:var(--border); background:#121319; color:var(--muted); }
|
| 81 |
+
.fog-lab { font-size:10px; color:var(--muted); display:flex; align-items:center; gap:8px; }
|
| 82 |
+
.fog-lab input { flex:1; accent-color:var(--orange); }
|
| 83 |
+
|
| 84 |
+
.node {
|
| 85 |
+
position:absolute; width:230px; background:var(--panel2);
|
| 86 |
+
border:1px solid var(--border); border-radius:12px; overflow:hidden;
|
| 87 |
+
box-shadow:0 10px 30px rgba(0,0,0,.5); user-select:none;
|
| 88 |
+
}
|
| 89 |
+
.node.selected { border-color:var(--orange); box-shadow:0 0 0 1px var(--orange), 0 10px 30px rgba(0,0,0,.5); }
|
| 90 |
+
.node-head { padding:9px 12px; font-size:12px; font-weight:700; display:flex; align-items:center; gap:8px;
|
| 91 |
+
background:#23252e; border-bottom:1px solid var(--border); cursor:grab; }
|
| 92 |
+
.node-head .type { margin-left:auto; font-size:10px; font-weight:700; color:#111;
|
| 93 |
+
background:var(--orange2); padding:2px 7px; border-radius:999px; }
|
| 94 |
+
.node-body { padding:10px 12px 12px; display:flex; flex-direction:column; gap:8px; }
|
| 95 |
+
.row { display:flex; align-items:center; gap:8px; font-size:12px; color:#cfd2da; }
|
| 96 |
+
.row .port { width:12px; height:12px; border-radius:50%; background:var(--orange);
|
| 97 |
+
border:2px solid #0b0c0f; outline:2px solid var(--orange); flex-shrink:0; }
|
| 98 |
+
.row.in { justify-content:flex-start; } .row.out { justify-content:flex-end; }
|
| 99 |
+
.row .val { margin-left:auto; font-size:11px; color:var(--muted); background:#121319;
|
| 100 |
+
border:1px solid var(--border); padding:2px 7px; border-radius:6px; }
|
| 101 |
+
.row.out .val { margin-left:0; margin-right:auto; }
|
| 102 |
+
.bar { height:6px; background:#121319; border-radius:999px; overflow:hidden; border:1px solid var(--border); }
|
| 103 |
+
.bar i { display:block; height:100%; width:68%; background:linear-gradient(90deg, var(--orange), var(--orange2)); }
|
| 104 |
+
.node-foot { padding:8px 12px; border-top:1px solid var(--border); font-size:11px; color:var(--muted); display:flex; justify-content:space-between; }
|
| 105 |
+
.node-foot b { color:var(--orange2); }
|
| 106 |
+
/* Anidoodle live preview */
|
| 107 |
+
.bus-preview { border-radius:9px; overflow:hidden; border:1px solid var(--border); background:#0b0c0f; position:relative; }
|
| 108 |
+
.bus-preview img { width:100%; height:110px; object-fit:cover; display:block; transition:transform .25s ease; }
|
| 109 |
+
.bus-preview.playing img { animation: busFloat 2.2s ease-in-out infinite; }
|
| 110 |
+
@keyframes busFloat { 0%,100% { transform:translateY(0) rotate(0deg);} 50% { transform:translateY(-4px) rotate(-.4deg);} }
|
| 111 |
+
.bus-preview:hover img { transform:scale(1.04); }
|
| 112 |
+
.bus-preview.playing:hover img { animation-play-state:paused; transform:scale(1.04); }
|
| 113 |
+
.bus-meta { display:flex; align-items:center; gap:6px; font-size:10px; color:var(--muted); margin-top:6px; }
|
| 114 |
+
.bus-meta b { color:var(--orange2); }
|
| 115 |
+
.bus-controls { display:flex; gap:6px; margin-top:8px; }
|
| 116 |
+
.bus-controls button { flex:1; font-size:11px; font-weight:700; border:1px solid var(--orange);
|
| 117 |
+
background:var(--orange-dim); color:var(--orange2); padding:6px 0; border-radius:7px; cursor:pointer; }
|
| 118 |
+
.bus-controls button:hover { background:var(--orange); color:#111; }
|
| 119 |
+
.bus-controls input[type=range] { flex:1.4; accent-color:var(--orange); }
|
| 120 |
+
/* Local Asset Browser (folder tree) */
|
| 121 |
+
.tree-head { display:flex; align-items:center; gap:8px; margin:6px 2px; }
|
| 122 |
+
.tree-head code { font-size:10px; color:var(--orange2); background:#121319; border:1px solid var(--border);
|
| 123 |
+
padding:3px 7px; border-radius:6px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; flex:1; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
.mini-btn { font-size:10px; font-weight:700; border:1px solid var(--border); background:#121319; color:var(--text);
|
| 125 |
+
padding:4px 8px; border-radius:7px; cursor:pointer; white-space:nowrap; }
|
| 126 |
.mini-btn:hover { border-color:var(--orange); color:var(--orange2); }
|
| 127 |
.mini-btn.acc { background:var(--orange); border-color:var(--orange); color:#111; }
|
| 128 |
+
#assetTree { display:flex; flex-direction:column; gap:6px; max-height:260px; overflow:auto; padding-right:2px; }
|
| 129 |
+
.tree-folder { font-size:11px; color:var(--text); font-weight:700; display:flex; align-items:center; gap:6px;
|
| 130 |
+
padding:6px 8px; border:1px solid var(--border); border-radius:8px; background:#121319; }
|
| 131 |
+
.tree-folder .count { margin-left:auto; font-size:10px; color:var(--orange2); background:var(--orange-dim);
|
| 132 |
+
border:1px solid rgba(255,107,26,.35); padding:1px 7px; border-radius:999px; }
|
| 133 |
+
.tree-file { display:flex; align-items:center; gap:8px; padding:6px; border:1px solid var(--border);
|
| 134 |
+
border-radius:8px; background:var(--panel2); cursor:grab; transition:.12s; }
|
| 135 |
+
.tree-file:hover { border-color:var(--orange); }
|
| 136 |
+
.tree-file img.th { width:34px; height:34px; object-fit:cover; border-radius:6px; border:1px solid var(--border); flex-shrink:0; }
|
| 137 |
+
.tree-file .nm { font-size:11px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
| 138 |
+
.tree-file .sz { font-size:10px; color:var(--muted); }
|
| 139 |
+
.tree-file .acts { margin-left:auto; display:flex; gap:4px; }
|
| 140 |
+
.tree-empty, .tree-err { font-size:11px; color:var(--muted); border:1px dashed var(--border); border-radius:8px;
|
| 141 |
+
padding:9px; text-align:center; line-height:1.5; }
|
| 142 |
+
/* Editorial Moodboard dock */
|
| 143 |
+
.mood { position:absolute; left:12px; right:12px; bottom:12px; background:rgba(23,24,29,.96);
|
| 144 |
+
border:1px solid var(--border); border-radius:12px; overflow:hidden; backdrop-filter:blur(6px); }
|
| 145 |
+
.mood-head { display:flex; align-items:center; gap:8px; padding:8px 12px; border-bottom:1px solid var(--border); }
|
| 146 |
+
.mood-head .t { font-size:11px; font-weight:800; letter-spacing:.14em; text-transform:uppercase; }
|
| 147 |
+
.mood-head .t span { color:var(--orange2); }
|
| 148 |
+
.mood-head .sub { font-size:10px; color:var(--muted); }
|
| 149 |
+
.mood-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(118px, 1fr)); gap:8px;
|
| 150 |
+
padding:10px 12px 12px; max-height:172px; overflow:auto; }
|
| 151 |
+
.mood-grid.dense { grid-template-columns:repeat(auto-fill, minmax(88px, 1fr)); }
|
| 152 |
+
.mood-grid.drover { outline:1px dashed var(--orange); outline-offset:-6px; }
|
| 153 |
+
.tile { position:relative; border:1px solid var(--border); border-radius:9px; overflow:hidden;
|
| 154 |
+
background:#0b0c0f; cursor:grab; aspect-ratio:4/3; }
|
| 155 |
+
.tile img { width:100%; height:100%; object-fit:cover; display:block; }
|
| 156 |
+
.tile.pinned { border-color:var(--orange); box-shadow:0 0 0 1px var(--orange); }
|
| 157 |
+
.tile .pin { position:absolute; top:5px; right:5px; font-size:11px; line-height:1; background:rgba(0,0,0,.65);
|
| 158 |
+
border:1px solid var(--border); border-radius:999px; padding:3px 6px; cursor:pointer; color:#fff; }
|
| 159 |
+
.tile.pinned .pin { border-color:var(--orange); color:var(--orange2); }
|
| 160 |
+
.tile .cap { position:absolute; left:0; right:0; bottom:0; font-size:9px; padding:3px 6px;
|
| 161 |
+
background:linear-gradient(transparent, rgba(0,0,0,.75)); color:#dfe1e7; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
| 162 |
+
.tile .x { position:absolute; top:5px; left:5px; font-size:10px; background:rgba(0,0,0,.65); color:#fff;
|
| 163 |
+
border:1px solid var(--border); border-radius:999px; width:18px; height:18px; cursor:pointer; display:grid; place-items:center; }
|
| 164 |
+
.tile .x:hover { border-color:#ff4d4d; color:#ff8080; }
|
| 165 |
+
.mood-empty { grid-column:1/-1; font-size:11px; color:var(--muted); border:1px dashed var(--border);
|
| 166 |
+
border-radius:8px; padding:12px; text-align:center; }
|
| 167 |
+
|
| 168 |
+
/* Inspector */
|
| 169 |
+
.inspector { width:250px; background:var(--panel); border-left:1px solid var(--border); padding:12px; flex-shrink:0; overflow:auto; }
|
| 170 |
+
.field { margin-bottom:11px; }
|
| 171 |
+
.field label { font-size:11px; color:var(--muted); display:block; margin-bottom:5px; }
|
| 172 |
+
.field input, .field select { width:100%; background:#121319; border:1px solid var(--border);
|
| 173 |
+
color:var(--text); font-size:12px; padding:8px 9px; border-radius:8px; outline:none; }
|
| 174 |
+
.field input:focus, .field select:focus { border-color:var(--orange); }
|
| 175 |
+
.check { display:flex; align-items:center; gap:8px; font-size:12px; color:#cfd2da;
|
| 176 |
+
background:var(--orange-dim); border:1px solid rgba(255,107,26,.35); padding:8px 10px; border-radius:8px; }
|
| 177 |
+
|
| 178 |
+
/* Status bar */
|
| 179 |
+
.status { height:30px; background:var(--panel); border-top:1px solid var(--border);
|
| 180 |
+
display:flex; align-items:center; gap:14px; padding:0 14px; font-size:11px; color:var(--muted); flex-shrink:0; }
|
| 181 |
.status b { color:var(--text); }
|
| 182 |
.live { width:8px; height:8px; border-radius:50%; background:#38e06c; box-shadow:0 0 7px #38e06c; display:inline-block; margin-right:6px; }
|
|
|
|
| 183 |
</style>
|
| 184 |
</head>
|
| 185 |
+
<body>
|
| 186 |
|
| 187 |
<div class="topbar">
|
| 188 |
<div class="logo">M</div>
|
| 189 |
+
<div class="title">Mala-Motion <span>Suite</span></div>
|
| 190 |
+
<div class="pill"><b>β</b> local :8080 Β· anidoodle / WebGL / Lottie</div>
|
| 191 |
<div class="spacer"></div>
|
| 192 |
+
<button class="btn" onclick="alert('Add node: drag an asset from the left library onto the canvas.')">+ Add Node</button>
|
| 193 |
+
<button class="btn primary" onclick="document.getElementById('exp').innerText='Export queued β lottie JSON + webgl bundle ready.'; ">βΆ Run Graph</button>
|
| 194 |
</div>
|
| 195 |
|
| 196 |
<div class="main">
|
| 197 |
+
<!-- Left -->
|
| 198 |
<div class="sidebar">
|
| 199 |
+
<h3>Asset Library</h3>
|
| 200 |
+
<div class="asset"><div class="k"><span class="dot"></span>Anidoodle Rig</div><small>2D frame-by-frame character rig (.ani)</small><span class="tag">anidoodle</span></div>
|
| 201 |
+
<div class="asset"><div class="k"><span class="dot"></span>WebGL Scene</div><small>Realtime preview Β· three.js renderer</small><span class="tag">webgl Β· shader</span></div>
|
| 202 |
+
<div class="asset"><div class="k"><span class="dot"></span>Lottie Export</div><small>Bodymovin JSON for web / mobile</small><span class="tag">lottie Β· json</span></div>
|
| 203 |
+
<div class="asset"><div class="k"><span class="dot"></span>Motion Curve</div><small>Ease Β· overshoot Β· bounce presets</small><span class="tag">utility</span></div>
|
| 204 |
+
<h3 style="margin-top:6px">Graph</h3>
|
| 205 |
+
<div class="pill" id="exp" style="line-height:1.5">3 nodes Β· 2 links Β· clean</div>
|
| 206 |
+
<h3 style="margin-top:8px">Project Assets</h3>
|
| 207 |
+
<div class="tree-head"><code title="local project assets dir">public\assets\</code><button class="mini-btn" id="assetRefresh" title="re-read manifest">β»</button></div>
|
| 208 |
+
<div id="assetTree"><div class="tree-empty">reading manifestβ¦</div></div>
|
| 209 |
+
<div style="display:flex;gap:6px;margin-top:8px">
|
| 210 |
+
<button class="mini-btn acc" id="assetLinkBtn" style="flex:1" title="pick the public/assets folder for a live handle">β link folder</button>
|
| 211 |
+
<button class="mini-btn" id="assetAddBtn" style="flex:1" title="drop files straight onto the moodboard">οΌ drop files</button>
|
| 212 |
+
</div>
|
| 213 |
+
<input type="file" id="assetFilePick" accept="image/*" multiple hidden />
|
| 214 |
+
<div class="pill" id="assetStatus" style="line-height:1.5;margin-top:8px">browser idle</div>
|
| 215 |
</div>
|
| 216 |
|
| 217 |
+
<!-- Canvas -->
|
| 218 |
+
<div class="canvas-wrap" id="canvas">
|
| 219 |
<canvas id="fogGL"></canvas>
|
| 220 |
+
<div class="canvas-hint">drag nodes to rearrange Β· figma-style canvas Β· orange = live link</div>
|
| 221 |
+
<svg class="wires" id="wires" preserveAspectRatio="none"></svg>
|
| 222 |
+
|
| 223 |
+
<div class="node selected" id="n1" style="left:60px; top:60px; width:260px;">
|
| 224 |
+
<div class="node-head"><span class="dot"></span>Anidoodle Bus Rig<span class="type">ANI β’ LIVE</span></div>
|
| 225 |
+
<div class="node-body">
|
| 226 |
+
<div class="bus-preview playing" id="busPreview">
|
| 227 |
+
<img id="busImg" src="public/assets/watercolor_bus.png" alt="watercolor bus" draggable="false" />
|
| 228 |
+
</div>
|
| 229 |
+
<div class="bus-meta"><span class="dot"></span><span id="busStatus">linking <b>public/assets/watercolor_bus.png</b>β¦</span></div>
|
| 230 |
+
<div class="bus-controls">
|
| 231 |
+
<button id="busPlay" title="play/pause idle motion">βΈ pause</button>
|
| 232 |
+
<input id="busSpeed" type="range" min="0.5" max="3" step="0.1" value="1" title="motion speed" />
|
| 233 |
+
</div>
|
| 234 |
+
<div class="row out">frames <span class="val">48f</span><span class="port"></span></div>
|
| 235 |
+
<div class="row out">rig <span class="val">watercolor_bus.png</span><span class="port"></span></div>
|
| 236 |
+
<div class="bar"><i id="busBar" style="width:82%"></i></div>
|
| 237 |
+
</div>
|
| 238 |
+
<div class="node-foot"><span>anidoodle</span><b id="busFoot">β ready</b></div>
|
| 239 |
</div>
|
|
|
|
| 240 |
|
| 241 |
+
<div class="node" id="n2" style="left:360px; top:160px;">
|
| 242 |
+
<div class="node-head"><span class="dot"></span>WebGL Fog Node<span class="type">GL β’ LIVE</span></div>
|
| 243 |
+
<div class="node-body">
|
| 244 |
+
<div class="row in"><span class="port"></span>rig-in <span class="val" id="fogLink">connected</span></div>
|
| 245 |
+
<div class="fog-controls"><button id="fogToggle" title="toggle fog layer">β fog on</button></div>
|
| 246 |
+
<label class="fog-lab">density<input id="fogDensity" type="range" min="0" max="100" value="55" title="fog density" /></label>
|
| 247 |
+
<label class="fog-lab">flow<input id="fogFlow" type="range" min="10" max="200" value="100" title="flow speed" /></label>
|
| 248 |
+
<div class="row out">preview <span class="val">60 fps</span><span class="port"></span></div>
|
| 249 |
+
</div>
|
| 250 |
+
<div class="node-foot"><span id="fogStat">webgl Β· fbm fog</span><b id="fogFoot">β live</b></div>
|
| 251 |
</div>
|
| 252 |
+
|
| 253 |
+
<div class="node" id="n3" style="left:660px; top:70px;">
|
| 254 |
+
<div class="node-head"><span class="dot"></span>Lottie Export<span class="type">JSON</span></div>
|
| 255 |
+
<div class="node-body">
|
| 256 |
+
<div class="row in"><span class="port"></span>frames-in <span class="val">linked</span></div>
|
| 257 |
+
<div class="row in"><span class="port"></span>preview-in <span class="val">linked</span></div>
|
| 258 |
+
<div class="bar"><i style="width:45%"></i></div>
|
| 259 |
+
</div>
|
| 260 |
+
<div class="node-foot"><span>bodymovin</span><b>β idle</b></div>
|
| 261 |
+
</div>
|
| 262 |
+
|
| 263 |
+
<!-- Editorial Interactive Moodboard -->
|
| 264 |
+
<section class="mood" id="mood" aria-label="Editorial moodboard">
|
| 265 |
+
<div class="mood-head">
|
| 266 |
+
<span class="dot"></span><span class="t">Moodboard <span>β editorial</span></span>
|
| 267 |
+
<span class="sub" id="moodCount">0 pinned Β· 0 tiles</span>
|
| 268 |
+
<span style="flex:1"></span>
|
| 269 |
+
<button class="mini-btn" id="moodDensity" title="toggle grid density">β¦ dense</button>
|
| 270 |
+
<button class="mini-btn" id="moodSend" title="send first tile to anidoodle node">β ani</button>
|
| 271 |
+
<button class="mini-btn" id="moodClear" title="remove unpinned tiles">clear</button>
|
| 272 |
+
</div>
|
| 273 |
+
<div class="mood-grid" id="moodGrid"></div>
|
| 274 |
+
</section>
|
| 275 |
+
|
| 276 |
+
</div>
|
| 277 |
+
|
| 278 |
+
<!-- Right -->
|
| 279 |
+
<div class="inspector">
|
| 280 |
+
<h3>Inspector</h3>
|
| 281 |
+
<div class="field"><label>Selected node</label><input id="inspNode" value="Anidoodle Bus Rig β watercolor_bus" readonly /></div>
|
| 282 |
+
<div class="field"><label>Asset source (dynamic link)</label><input id="inspSrc" value="public/assets/watercolor_bus.png" readonly /></div>
|
| 283 |
+
<div class="field"><label>Renderer</label><select><option>WebGL β three.js</option><option>Canvas 2D fallback</option><option>SVG sequence</option></select></div>
|
| 284 |
+
<div class="field"><label>Export target</label><select><option>Lottie JSON (.json)</option><option>WebGL bundle (.js)</option><option>Anidoodle (.ani)</option></select></div>
|
| 285 |
+
<div class="field"><label>Frame rate</label><input value="60" /></div>
|
| 286 |
+
<div class="check">β Drive-free local session β serves from :8080</div>
|
| 287 |
+
<p style="font-size:11px;color:var(--muted);line-height:1.6;margin-top:10px">Tip: press <b>Run Graph</b> to chain Anidoodle β WebGL β Lottie. Orange wires are live links.</p>
|
| 288 |
+
</div>
|
| 289 |
</div>
|
| 290 |
|
| 291 |
<div class="status">
|
| 292 |
+
<span><span class="live"></span><b>localhost:8080</b> serving index.html</span>
|
| 293 |
+
<span>GPU: browser WebGL</span>
|
| 294 |
+
<span style="margin-left:auto">Mala-Motion Suite Β· minimal build Β· dark + orange</span>
|
| 295 |
</div>
|
| 296 |
|
| 297 |
<script>
|
| 298 |
+
// Draw orange bezier wires between nodes + make nodes draggable
|
| 299 |
+
const canvas = document.getElementById('canvas');
|
| 300 |
+
const wires = document.getElementById('wires');
|
| 301 |
+
const links = [ ['n1','n2'], ['n2','n3'] ];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
|
| 303 |
+
function center(el, side) {
|
| 304 |
+
const c = canvas.getBoundingClientRect(), r = el.getBoundingClientRect();
|
| 305 |
+
return { x: side === 'l' ? r.left - c.left : r.right - c.left, y: r.top - c.top + r.height/2 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
}
|
| 307 |
+
function draw() {
|
| 308 |
+
const c = canvas.getBoundingClientRect();
|
| 309 |
+
wires.setAttribute('viewBox', `0 0 ${c.width} ${c.height}`);
|
| 310 |
+
wires.innerHTML = '';
|
| 311 |
+
links.forEach(([a,b]) => {
|
| 312 |
+
const A = document.getElementById(a), B = document.getElementById(b);
|
| 313 |
+
const p1 = { x: A.offsetLeft + A.offsetWidth, y: A.offsetTop + 90 };
|
| 314 |
+
const p2 = { x: B.offsetLeft, y: B.offsetTop + 60 };
|
| 315 |
+
const dx = Math.max(40, Math.abs(p2.x-p1.x)/2);
|
| 316 |
+
const d = `M ${p1.x} ${p1.y} C ${p1.x+dx} ${p1.y}, ${p2.x-dx} ${p2.y}, ${p2.x} ${p2.y}`;
|
| 317 |
+
const path = document.createElementNS('http://www.w3.org/2000/svg','path');
|
| 318 |
+
path.setAttribute('d', d); wires.appendChild(path);
|
| 319 |
+
});
|
| 320 |
}
|
| 321 |
+
// drag
|
| 322 |
+
document.querySelectorAll('.node').forEach(n => {
|
| 323 |
+
const head = n.querySelector('.node-head');
|
| 324 |
+
head.addEventListener('mousedown', e => {
|
| 325 |
+
document.querySelectorAll('.node').forEach(m=>m.classList.remove('selected'));
|
| 326 |
+
n.classList.add('selected');
|
| 327 |
+
const sx = e.clientX - n.offsetLeft, sy = e.clientY - n.offsetTop;
|
| 328 |
+
const mv = ev => { n.style.left = (ev.clientX - sx)+'px'; n.style.top = (ev.clientY - sy)+'px'; draw(); };
|
| 329 |
+
const up = () => { window.removeEventListener('mousemove', mv); window.removeEventListener('mouseup', up); };
|
| 330 |
+
window.addEventListener('mousemove', mv); window.addEventListener('mouseup', up);
|
| 331 |
+
});
|
| 332 |
+
});
|
| 333 |
+
window.addEventListener('resize', draw); draw();
|
| 334 |
+
setTimeout(draw, 50);
|
| 335 |
|
| 336 |
+
// Anidoodle live link β tries suite-root and public/ bases so
|
| 337 |
+
// both Mala-Motion Suite/index.html and public/index.html resolve. No C: paths.
|
| 338 |
+
const ASSET_CANDIDATES = ['public/assets/watercolor_bus.png', 'assets/watercolor_bus.png'];
|
| 339 |
+
const MANIFEST_CANDIDATES = ['public/assets/manifest.json', 'assets/manifest.json'];
|
| 340 |
+
function setAnidoodleSrc(src, label){
|
| 341 |
+
const img = document.getElementById('busImg');
|
| 342 |
+
const status = document.getElementById('busStatus');
|
| 343 |
+
if (label) status.innerHTML = `linking <b>${label}</b>β¦`;
|
| 344 |
+
img.dataset.try = '0'; img.src = src;
|
| 345 |
+
}
|
| 346 |
+
(function(){
|
| 347 |
+
const img = document.getElementById('busImg');
|
| 348 |
+
const preview = document.getElementById('busPreview');
|
| 349 |
+
const status = document.getElementById('busStatus');
|
| 350 |
+
const foot = document.getElementById('busFoot');
|
| 351 |
+
const bar = document.getElementById('busBar');
|
| 352 |
+
const playBtn = document.getElementById('busPlay');
|
| 353 |
+
const speed = document.getElementById('busSpeed');
|
| 354 |
+
function setPlaying(p){
|
| 355 |
+
preview.classList.toggle('playing', p);
|
| 356 |
+
playBtn.textContent = p ? 'βΈ pause' : 'βΆ play';
|
| 357 |
+
}
|
| 358 |
+
playBtn.onclick = e => { e.stopPropagation(); setPlaying(!preview.classList.contains('playing')); };
|
| 359 |
+
preview.onclick = e => { e.stopPropagation(); setPlaying(!preview.classList.contains('playing')); };
|
| 360 |
+
speed.oninput = () => { img.style.animationDuration = (2.2 / parseFloat(speed.value)) + 's';
|
| 361 |
+
img.style.filter = `saturate(${0.9 + parseFloat(speed.value)*0.15})`; };
|
| 362 |
+
img.addEventListener('load', () => {
|
| 363 |
+
status.innerHTML = `live β <b>${img.getAttribute('src')}</b> Β· ${img.naturalWidth}Γ${img.naturalHeight}px`;
|
| 364 |
+
const insp = document.getElementById('inspSrc'); if (insp) insp.value = img.getAttribute('src');
|
| 365 |
+
foot.textContent = 'β live link'; bar.style.width = '100%';
|
| 366 |
+
});
|
| 367 |
+
img.addEventListener('error', () => {
|
| 368 |
+
const i = parseInt(img.dataset.try || '0', 10);
|
| 369 |
+
if (i + 1 < ASSET_CANDIDATES.length) { img.dataset.try = String(i + 1); img.src = ASSET_CANDIDATES[i + 1]; return; }
|
| 370 |
+
status.innerHTML = `missing β expected at <b>${ASSET_CANDIDATES.join('</b> or <b>')}</b>.`;
|
| 371 |
+
foot.textContent = 'β missing asset'; bar.style.width = '12%';
|
| 372 |
+
});
|
| 373 |
+
if (!(img.complete && img.naturalWidth)) { img.dataset.try = '0'; img.src = ASSET_CANDIDATES[0]; }
|
| 374 |
+
window.MalaBus = { setSrc: setAnidoodleSrc, candidates: ASSET_CANDIDATES };
|
| 375 |
+
})();
|
| 376 |
|
| 377 |
+
// Local Asset Browser β reads public/assets via manifest.json (generated
|
| 378 |
+
// from the real folder), plus optional live folder handle. No C: paths.
|
| 379 |
+
(function(){
|
| 380 |
+
const tree = document.getElementById('assetTree');
|
| 381 |
+
const st = document.getElementById('assetStatus');
|
| 382 |
+
const refresh = document.getElementById('assetRefresh');
|
| 383 |
+
const linkBtn = document.getElementById('assetLinkBtn');
|
| 384 |
+
const addBtn = document.getElementById('assetAddBtn');
|
| 385 |
+
const pick = document.getElementById('assetFilePick');
|
| 386 |
+
let files = [];
|
| 387 |
+
const fmt = n => n > 1048576 ? (n/1048576).toFixed(1)+' MB' : Math.max(1, Math.round(n/1024))+' KB';
|
| 388 |
+
async function loadManifest(){
|
| 389 |
+
tree.innerHTML = '<div class="tree-empty">reading manifestβ¦</div>';
|
| 390 |
+
for (const url of MANIFEST_CANDIDATES) {
|
| 391 |
+
try {
|
| 392 |
+
const r = await fetch(url, { cache: 'no-store' });
|
| 393 |
+
if (!r.ok) continue;
|
| 394 |
+
const j = await r.json();
|
| 395 |
+
if (Array.isArray(j.files) && j.files.length) {
|
| 396 |
+
files = j.files.map(f => ({ name: f.name, size: f.size || 0,
|
| 397 |
+
src: (url.startsWith('assets/') ? 'assets/' : 'public/assets/') + f.name }));
|
| 398 |
+
render(`live Β· ${url} Β· ${files.length} file(s)`);
|
| 399 |
+
return;
|
| 400 |
+
}
|
| 401 |
+
} catch(e) { /* try next candidate */ }
|
| 402 |
+
}
|
| 403 |
+
// static fallback: known asset, keeps browser usable offline / file://
|
| 404 |
+
files = [{ name: 'watercolor_bus.png', size: 2442461, src: ASSET_CANDIDATES[0] }];
|
| 405 |
+
render('fallback Β· manifest not served β showing known asset. Serve via Start_Suite.bat for full listing.');
|
| 406 |
+
}
|
| 407 |
+
function render(msg){
|
| 408 |
+
st.textContent = msg;
|
| 409 |
+
tree.innerHTML = `<div class="tree-folder">βΎ assets/ <span class="count">${files.length}</span></div>`;
|
| 410 |
+
files.forEach((f, i) => {
|
| 411 |
+
const el = document.createElement('div');
|
| 412 |
+
el.className = 'tree-file'; el.draggable = true;
|
| 413 |
+
el.innerHTML = `<img class="th" loading="lazy" src="${f.src}" alt="" />
|
| 414 |
+
<div><div class="nm">${f.name}</div><div class="sz">${fmt(f.size)}</div></div>
|
| 415 |
+
<div class="acts"><button class="mini-btn" data-a="use">use</button><button class="mini-btn" data-a="pin">οΌ</button></div>`;
|
| 416 |
+
el.title = 'drag onto moodboard or canvas';
|
| 417 |
+
el.addEventListener('dragstart', ev => { ev.dataTransfer.setData('text/mala-asset', JSON.stringify(f)); });
|
| 418 |
+
el.querySelector('[data-a=use]').onclick = () => window.MalaBus.setSrc(f.src, f.src);
|
| 419 |
+
el.querySelector('[data-a=pin]').onclick = () => window.MalaBoard.add(f.src, f.name);
|
| 420 |
+
el.ondblclick = () => window.MalaBus.setSrc(f.src, f.src);
|
| 421 |
+
tree.appendChild(el);
|
| 422 |
+
});
|
| 423 |
+
}
|
| 424 |
+
refresh.onclick = loadManifest;
|
| 425 |
+
addBtn.onclick = () => pick.click();
|
| 426 |
+
pick.onchange = () => {
|
| 427 |
+
[...pick.files].forEach(file => {
|
| 428 |
+
const rd = new FileReader();
|
| 429 |
+
rd.onload = () => window.MalaBoard.add(rd.result, file.name);
|
| 430 |
+
rd.readAsDataURL(file);
|
| 431 |
+
});
|
| 432 |
+
pick.value = '';
|
| 433 |
};
|
| 434 |
+
linkBtn.onclick = async () => {
|
| 435 |
+
try {
|
| 436 |
+
if (!window.showDirectoryPicker) { st.textContent = 'browser has no folder picker β use οΌ drop files instead.'; pick.click(); return; }
|
| 437 |
+
const h = await window.showDirectoryPicker({ mode: 'read' });
|
| 438 |
+
let n = 0;
|
| 439 |
+
for await (const e of h.values()) {
|
| 440 |
+
if (e.kind !== 'file') continue;
|
| 441 |
+
const f = await e.getFile();
|
| 442 |
+
if (!f.type.startsWith('image/')) continue;
|
| 443 |
+
window.MalaBoard.add(URL.createObjectURL(f), f.name); n++;
|
| 444 |
+
}
|
| 445 |
+
st.textContent = n ? `linked folder handle Β· added ${n} image(s) to moodboard` : 'folder linked Β· no images found inside';
|
| 446 |
+
} catch(e) { st.textContent = 'folder link cancelled'; }
|
| 447 |
+
};
|
| 448 |
+
window.MalaAssets = { reload: loadManifest };
|
| 449 |
+
loadManifest();
|
| 450 |
+
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
|
| 452 |
+
// Editorial Interactive Moodboard β drop / pin / drag, responsive grid.
|
| 453 |
+
(function(){
|
| 454 |
+
const grid = document.getElementById('moodGrid');
|
| 455 |
+
const count = document.getElementById('moodCount');
|
| 456 |
+
let tiles = [];
|
| 457 |
+
try { tiles = JSON.parse(localStorage.getItem('mala-mood') || '[]').slice(0, 24); } catch(e) { tiles = []; }
|
| 458 |
+
function save(){ try { localStorage.setItem('mala-mood', JSON.stringify(tiles.filter(t => !t.src.startsWith('blob:')).slice(0, 24))); } catch(e){} }
|
| 459 |
+
function paint(){
|
| 460 |
+
const pinned = tiles.filter(t => t.pinned).length;
|
| 461 |
+
count.textContent = `${pinned} pinned Β· ${tiles.length} tiles`;
|
| 462 |
+
grid.innerHTML = tiles.length ? '' : '<div class="mood-empty">drop images here β from the asset browser, your desktop, or the οΌ button. Click π to pin, drag to reorder.</div>';
|
| 463 |
+
tiles.forEach((t, i) => {
|
| 464 |
+
const d = document.createElement('div');
|
| 465 |
+
d.className = 'tile' + (t.pinned ? ' pinned' : ''); d.draggable = true;
|
| 466 |
+
d.innerHTML = `<img src="${t.src}" alt="" draggable="false" /><button class="x" title="remove">Γ</button>
|
| 467 |
+
<button class="pin" title="pin / unpin">${t.pinned ? 'π' : 'π'}</button><div class="cap">${t.name}</div>`;
|
| 468 |
+
d.querySelector('.pin').onclick = e => { e.stopPropagation(); t.pinned = !t.pinned; save(); paint(); };
|
| 469 |
+
d.querySelector('.x').onclick = e => { e.stopPropagation(); tiles.splice(i, 1); save(); paint(); };
|
| 470 |
+
d.ondblclick = () => window.MalaBus.setSrc(t.src, t.name);
|
| 471 |
+
d.addEventListener('dragstart', ev => ev.dataTransfer.setData('text/mala-tile', String(i)));
|
| 472 |
+
d.addEventListener('dragover', ev => ev.preventDefault());
|
| 473 |
+
d.addEventListener('drop', ev => {
|
| 474 |
+
ev.preventDefault(); ev.stopPropagation();
|
| 475 |
+
const from = ev.dataTransfer.getData('text/mala-tile');
|
| 476 |
+
if (from !== '') { const m = tiles.splice(parseInt(from, 10), 1)[0]; tiles.splice(i, 0, m); save(); paint(); }
|
| 477 |
+
});
|
| 478 |
+
grid.appendChild(d);
|
| 479 |
+
});
|
| 480 |
+
}
|
| 481 |
+
function add(src, name){ tiles.unshift({ src, name: name || 'pasted', pinned: false }); tiles = tiles.slice(0, 24); save(); paint(); }
|
| 482 |
+
grid.addEventListener('dragover', ev => { ev.preventDefault(); grid.classList.add('drover'); });
|
| 483 |
+
grid.addEventListener('dragleave', () => grid.classList.remove('drover'));
|
| 484 |
+
grid.addEventListener('drop', ev => {
|
| 485 |
+
ev.preventDefault(); grid.classList.remove('drover');
|
| 486 |
+
const js = ev.dataTransfer.getData('text/mala-asset');
|
| 487 |
+
if (js) { try { const f = JSON.parse(js); add(f.src, f.name); return; } catch(e){} }
|
| 488 |
+
[...(ev.dataTransfer.files || [])].forEach(file => {
|
| 489 |
+
if (!file.type.startsWith('image/')) return;
|
| 490 |
+
const rd = new FileReader(); rd.onload = () => add(rd.result, file.name); rd.readAsDataURL(file);
|
| 491 |
+
});
|
| 492 |
+
});
|
| 493 |
+
document.getElementById('moodDensity').onclick = e => {
|
| 494 |
+
grid.classList.toggle('dense'); e.target.textContent = grid.classList.contains('dense') ? 'β¦ cozy' : 'β¦ dense';
|
| 495 |
+
};
|
| 496 |
+
document.getElementById('moodClear').onclick = () => { tiles = tiles.filter(t => t.pinned); save(); paint(); };
|
| 497 |
+
document.getElementById('moodSend').onclick = () => { if (tiles[0]) window.MalaBus.setSrc(tiles[0].src, tiles[0].name); };
|
| 498 |
+
window.MalaBoard = { add };
|
| 499 |
+
if (!tiles.length) add(ASSET_CANDIDATES[0], 'watercolor_bus.png');
|
| 500 |
+
else paint();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
})();
|
|
|
|
|
|
|
| 502 |
|
| 503 |
+
// WebGL Fog Node β fluid mouse-responsive orange fog over the grid workspace.
|
| 504 |
+
(function(){
|
| 505 |
+
const cv = document.getElementById('fogGL');
|
| 506 |
+
const wrap = document.getElementById('canvas');
|
| 507 |
+
const btn = document.getElementById('fogToggle');
|
| 508 |
+
const dens = document.getElementById('fogDensity');
|
| 509 |
+
const flow = document.getElementById('fogFlow');
|
| 510 |
+
const stat = document.getElementById('fogStat');
|
| 511 |
+
const foot = document.getElementById('fogFoot');
|
| 512 |
+
const gpuLbl = document.querySelector('.status span:nth-child(2)');
|
| 513 |
+
const state = { on: true, density: 0.55, speed: 1.0, mx: 0.5, my: 0.5, tmx: 0.5, tmy: 0.5 };
|
| 514 |
+
function fallback(msg){
|
| 515 |
+
cv.style.display = 'none';
|
| 516 |
+
stat.textContent = '2d fallback Β· ' + msg; foot.textContent = 'β fallback';
|
| 517 |
+
if (gpuLbl) gpuLbl.textContent = 'GPU: unavailable β CSS grid';
|
| 518 |
+
}
|
| 519 |
+
let gl = null;
|
| 520 |
+
try { gl = cv.getContext('webgl', { antialias: false, alpha: false }) || cv.getContext('experimental-webgl'); } catch(e) {}
|
| 521 |
+
if (!gl) { fallback('no webgl'); wireToggle(true); return; }
|
| 522 |
+
const VS = 'attribute vec2 p;void main(){gl_Position=vec4(p,0.,1.);}';
|
| 523 |
+
const FS = `precision mediump float;
|
| 524 |
+
uniform vec2 u_res; uniform float u_time; uniform vec2 u_mouse;
|
| 525 |
+
uniform float u_density; uniform float u_speed;
|
| 526 |
+
float hash(vec2 p){ return fract(sin(dot(p, vec2(127.1,311.7)))*43758.5453); }
|
| 527 |
+
float noise(vec2 p){ vec2 i=floor(p), f=fract(p); f=f*f*(3.-2.*f);
|
| 528 |
+
return mix(mix(hash(i),hash(i+vec2(1,0)),f.x), mix(hash(i+vec2(0,1)),hash(i+vec2(1,1)),f.x), f.y); }
|
| 529 |
+
float fbm(vec2 p){ float v=0., a=.5; for(int i=0;i<4;i++){ v+=a*noise(p); p*=2.03; a*=.5; } return v; }
|
| 530 |
+
void main(){
|
| 531 |
+
vec2 uv = gl_FragCoord.xy/u_res;
|
| 532 |
+
vec2 asp = vec2(u_res.x/u_res.y, 1.0);
|
| 533 |
+
vec2 p = (uv-.5)*asp;
|
| 534 |
+
vec2 m = (u_mouse-.5)*asp;
|
| 535 |
+
float md = length(p-m);
|
| 536 |
+
float t = u_time*u_speed;
|
| 537 |
+
vec2 pull = (m-p)*exp(-md*3.0)*0.9;
|
| 538 |
+
vec2 q = p*1.4 + pull + vec2(t*.05, t*.03);
|
| 539 |
+
float n = fbm(q + fbm(q + t*.04));
|
| 540 |
+
float fog = smoothstep(.32,.92,n)*u_density;
|
| 541 |
+
float glow = exp(-md*4.0)*.55;
|
| 542 |
+
vec3 base = vec3(.043,.047,.059);
|
| 543 |
+
vec3 orange = vec3(1.,.42,.10);
|
| 544 |
+
vec3 orange2 = vec3(1.,.63,.37);
|
| 545 |
+
vec3 col = mix(base, mix(orange,orange2,n), fog*.85);
|
| 546 |
+
col += orange2*glow*(.25+fog);
|
| 547 |
+
col *= 1.-.35*length(uv-.5);
|
| 548 |
+
gl_FragColor = vec4(col,1.);
|
| 549 |
+
}`;
|
| 550 |
+
function sh(type, src){
|
| 551 |
+
const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s);
|
| 552 |
+
if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) { fallback('shader error'); return null; }
|
| 553 |
+
return s;
|
| 554 |
+
}
|
| 555 |
+
const vs = sh(gl.VERTEX_SHADER, VS); if (!vs) { wireToggle(true); return; }
|
| 556 |
+
const fs = sh(gl.FRAGMENT_SHADER, FS); if (!fs) { wireToggle(true); return; }
|
| 557 |
+
const pr = gl.createProgram();
|
| 558 |
+
gl.attachShader(pr, vs); gl.attachShader(pr, fs); gl.linkProgram(pr);
|
| 559 |
+
if (!gl.getProgramParameter(pr, gl.LINK_STATUS)) { fallback('link error'); wireToggle(true); return; }
|
| 560 |
+
gl.useProgram(pr);
|
| 561 |
+
const buf = gl.createBuffer();
|
| 562 |
+
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
|
| 563 |
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1,-1, 3,-1, -1,3]), gl.STATIC_DRAW);
|
| 564 |
+
const loc = gl.getAttribLocation(pr, 'p');
|
| 565 |
+
gl.enableVertexAttribArray(loc); gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);
|
| 566 |
+
const U = n => gl.getUniformLocation(pr, n);
|
| 567 |
+
const uRes = U('u_res'), uTime = U('u_time'), uMouse = U('u_mouse'), uDen = U('u_density'), uSpd = U('u_speed');
|
| 568 |
+
function size(){
|
| 569 |
+
const dpr = Math.min(window.devicePixelRatio || 1, 1.25);
|
| 570 |
+
const w = Math.max(1, Math.floor(wrap.clientWidth * dpr));
|
| 571 |
+
const h = Math.max(1, Math.floor(wrap.clientHeight * dpr));
|
| 572 |
+
if (cv.width !== w || cv.height !== h) { cv.width = w; cv.height = h; gl.viewport(0, 0, w, h); }
|
| 573 |
+
}
|
| 574 |
+
size(); window.addEventListener('resize', size);
|
| 575 |
+
wrap.addEventListener('mousemove', e => {
|
| 576 |
+
const r = wrap.getBoundingClientRect();
|
| 577 |
+
state.tmx = (e.clientX - r.left) / Math.max(1, r.width);
|
| 578 |
+
state.tmy = 1 - (e.clientY - r.top) / Math.max(1, r.height);
|
| 579 |
+
});
|
| 580 |
+
wrap.addEventListener('mouseleave', () => { state.tmx = 0.5; state.tmy = 0.5; });
|
| 581 |
+
const t0 = performance.now();
|
| 582 |
+
(function frame(){
|
| 583 |
+
requestAnimationFrame(frame);
|
| 584 |
+
if (!state.on || document.hidden) return;
|
| 585 |
+
size();
|
| 586 |
+
state.mx += (state.tmx - state.mx) * 0.06;
|
| 587 |
+
state.my += (state.tmy - state.my) * 0.06;
|
| 588 |
+
gl.uniform2f(uRes, cv.width, cv.height);
|
| 589 |
+
gl.uniform1f(uTime, (performance.now() - t0) / 1000);
|
| 590 |
+
gl.uniform2f(uMouse, state.mx, state.my);
|
| 591 |
+
gl.uniform1f(uDen, state.density);
|
| 592 |
+
gl.uniform1f(uSpd, state.speed);
|
| 593 |
+
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
| 594 |
+
})();
|
| 595 |
+
function paintBtn(){ btn.textContent = state.on ? 'β fog on' : 'β fog off'; btn.classList.toggle('off', !state.on); }
|
| 596 |
+
function wireToggle(dead){
|
| 597 |
+
btn.onclick = e => {
|
| 598 |
+
e.stopPropagation();
|
| 599 |
+
if (dead) return;
|
| 600 |
+
state.on = !state.on;
|
| 601 |
+
cv.style.display = state.on ? 'block' : 'none';
|
| 602 |
+
foot.textContent = state.on ? 'β live' : 'β paused';
|
| 603 |
+
paintBtn();
|
| 604 |
+
};
|
| 605 |
+
}
|
| 606 |
+
wireToggle(false);
|
| 607 |
+
dens.oninput = () => { state.density = dens.value / 100; };
|
| 608 |
+
flow.oninput = () => { state.speed = flow.value / 100; };
|
| 609 |
+
paintBtn();
|
| 610 |
+
if (gpuLbl) gpuLbl.textContent = 'GPU: WebGL fog live';
|
| 611 |
+
window.MalaFog = state;
|
| 612 |
+
})();
|
| 613 |
</script>
|
| 614 |
</body>
|
| 615 |
</html>
|