Death242 commited on
Commit
831aef4
·
verified ·
1 Parent(s): 1e9fb9d

Static site

Browse files
Files changed (3) hide show
  1. index.html +2 -2
  2. static/main.js +11 -2
  3. static/race.js +1 -0
index.html CHANGED
@@ -8,7 +8,7 @@
8
  <meta name="theme-color" content="#10131b">
9
  <link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
  <link href="https://fonts.googleapis.com/css2?family=Unbounded:wght@500;800;900&family=Inter:wght@400;500;600;700&family=Noto+Kufi+Arabic:wght@700&display=swap" rel="stylesheet">
11
- <link rel="stylesheet" href="/static/style.css?v=1794761969">
12
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 64 64%27%3E%3Crect width=%2764%27 height=%2764%27 rx=%2714%27 fill=%27%23050506%27/%3E%3Ccircle cx=%2732%27 cy=%2732%27 r=%2716%27 fill=%27none%27 stroke=%27%23fff%27 stroke-width=%275%27/%3E%3C/svg%3E">
13
  <script type="importmap">
14
  { "imports": {
@@ -221,6 +221,6 @@
221
  <div id="toast" role="status"></div>
222
  <noscript><p style="position:fixed;inset:auto 0 0;padding:16px;background:#111;color:#fff;text-align:center">VOID needs JavaScript for the 3D car.</p></noscript>
223
  <script src="/static/hub.js" data-app="void" data-credit="none" defer></script>
224
- <script type="module" src="/static/main.js?v=1794761969"></script>
225
  </body>
226
  </html>
 
8
  <meta name="theme-color" content="#10131b">
9
  <link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
  <link href="https://fonts.googleapis.com/css2?family=Unbounded:wght@500;800;900&family=Inter:wght@400;500;600;700&family=Noto+Kufi+Arabic:wght@700&display=swap" rel="stylesheet">
11
+ <link rel="stylesheet" href="/static/style.css?v=1795094215">
12
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 64 64%27%3E%3Crect width=%2764%27 height=%2764%27 rx=%2714%27 fill=%27%23050506%27/%3E%3Ccircle cx=%2732%27 cy=%2732%27 r=%2716%27 fill=%27none%27 stroke=%27%23fff%27 stroke-width=%275%27/%3E%3C/svg%3E">
13
  <script type="importmap">
14
  { "imports": {
 
221
  <div id="toast" role="status"></div>
222
  <noscript><p style="position:fixed;inset:auto 0 0;padding:16px;background:#111;color:#fff;text-align:center">VOID needs JavaScript for the 3D car.</p></noscript>
223
  <script src="/static/hub.js" data-app="void" data-credit="none" defer></script>
224
+ <script type="module" src="/static/main.js?v=1795094215"></script>
225
  </body>
226
  </html>
static/main.js CHANGED
@@ -17,7 +17,9 @@ const [{ createPolice }, { createRaces }, { createNet, EMOTES }, { createNav },
17
  setLoad(40);
18
 
19
  const COARSE = matchMedia("(pointer: coarse)").matches, REDUCED = matchMedia("(prefers-reduced-motion: reduce)").matches;
20
- const store = { get(k) { try { return JSON.parse(localStorage.getItem(k)); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { } } };
 
 
21
  // a quick look at the machine before anything is built: built-in graphics or a small CPU (an i3 has 4 threads) gets the light build:
22
  // fewer cars, people and trees, a shorter view, no shadows or glow. Anyone can switch it in Settings (Graphics: Lite).
23
  const PROBE_GPU = (() => { try { const c = document.createElement("canvas").getContext("webgl2") || document.createElement("canvas").getContext("webgl"), e = c && c.getExtension("WEBGL_debug_renderer_info"); return e ? c.getParameter(e.UNMASKED_RENDERER_WEBGL) : ""; } catch { return ""; } })();
@@ -628,6 +630,7 @@ function frameLoop(fixed) {
628
  const gs = mode === "play" ? game.state : null;
629
  if (gs && gs.impacts && gs.impacts.length && car.damage) { carRoot.updateMatrixWorld(true); for (const im of gs.impacts.splice(0)) car.damage(carRoot.worldToLocal(new THREE.Vector3(im.x, im.y, im.z)), im.p); }
630
  if (S.wrecked && !wasWrecked) { car.wreck && car.wreck(); wreckPose = { p: carRoot.position.clone(), q: carRoot.quaternion.clone() }; }
 
631
  if (!S.wrecked && wasWrecked && wreckPose && inner) {
632
  const wg = inner.group; carRoot.remove(wg); wg.position.copy(wreckPose.p); wg.quaternion.copy(wreckPose.q); scene.add(wg);
633
  wrecks.push({ g: wg, t: 30 }); if (wrecks.length > 4) { const o = wrecks.shift(); scene.remove(o.g); }
@@ -744,7 +747,13 @@ let frameErr = 0;
744
  const loop = () => { raf = requestAnimationFrame(loop); try { frameLoop(); } catch (e) { if (frameErr++ < 3) console.error(e); } }; // one bad frame never stops the game
745
  loop();
746
  setLoad(100);
747
- setTimeout(() => { $("loader").classList.add("done"); setTimeout(() => { intro.t = 0; if (sound.on) sound.rev(); }, 450); }, 900);
 
 
 
 
 
 
748
  document.addEventListener("visibilitychange", () => {
749
  if (document.hidden) { cancelAnimationFrame(raf); if (mode === "watch" && w.playing) pause(); if (sound.ctx) sound.ctx.suspend(); }
750
  else { clock.getDelta(); loop(); if (sound.on && sound.ctx) sound.ctx.resume(); }
 
17
  setLoad(40);
18
 
19
  const COARSE = matchMedia("(pointer: coarse)").matches, REDUCED = matchMedia("(prefers-reduced-motion: reduce)").matches;
20
+ const store = { get(k) { try { return JSON.parse(localStorage.getItem(k)); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { } if (window.portalSave) window.portalSave(); } };
21
+ // game portals (CrazyGames, Poki): portal.js listens for these; on the normal site nobody does
22
+ const portalEvt = (n, d) => dispatchEvent(new CustomEvent("void:" + n, { detail: d }));
23
  // a quick look at the machine before anything is built: built-in graphics or a small CPU (an i3 has 4 threads) gets the light build:
24
  // fewer cars, people and trees, a shorter view, no shadows or glow. Anyone can switch it in Settings (Graphics: Lite).
25
  const PROBE_GPU = (() => { try { const c = document.createElement("canvas").getContext("webgl2") || document.createElement("canvas").getContext("webgl"), e = c && c.getExtension("WEBGL_debug_renderer_info"); return e ? c.getParameter(e.UNMASKED_RENDERER_WEBGL) : ""; } catch { return ""; } })();
 
630
  const gs = mode === "play" ? game.state : null;
631
  if (gs && gs.impacts && gs.impacts.length && car.damage) { carRoot.updateMatrixWorld(true); for (const im of gs.impacts.splice(0)) car.damage(carRoot.worldToLocal(new THREE.Vector3(im.x, im.y, im.z)), im.p); }
632
  if (S.wrecked && !wasWrecked) { car.wreck && car.wreck(); wreckPose = { p: carRoot.position.clone(), q: carRoot.quaternion.clone() }; }
633
+ if (!S.wrecked && wasWrecked) portalEvt("break");
634
  if (!S.wrecked && wasWrecked && wreckPose && inner) {
635
  const wg = inner.group; carRoot.remove(wg); wg.position.copy(wreckPose.p); wg.quaternion.copy(wreckPose.q); scene.add(wg);
636
  wrecks.push({ g: wg, t: 30 }); if (wrecks.length > 4) { const o = wrecks.shift(); scene.remove(o.g); }
 
747
  const loop = () => { raf = requestAnimationFrame(loop); try { frameLoop(); } catch (e) { if (frameErr++ < 3) console.error(e); } }; // one bad frame never stops the game
748
  loop();
749
  setLoad(100);
750
+ setTimeout(() => { $("loader").classList.add("done"); setTimeout(() => { intro.t = 0; if (sound.on) sound.rev(); }, 450); portalEvt("loaded"); if (window.PORTAL) go("play"); }, 900);
751
+ // portals: gameplay is "on" while you are driving with no menu, garage or ad over it; ads pause and silence everything
752
+ let portalPlay = false, adOn = false;
753
+ setInterval(() => { const on = mode === "play" && !paused0() && !adOn && !document.hidden && $("gReady").hidden && $("gOver").hidden; if (on !== portalPlay) { portalPlay = on; portalEvt("gameplay", on); } }, 250);
754
+ addEventListener("void:ad", e => { adOn = !!e.detail; if (!net.online()) game.pause(adOn || paused0()); if (sound.ctx) adOn ? sound.ctx.suspend() : (sound.on && !document.hidden && sound.ctx.resume()); });
755
+ let preMute = null; // the portal's own mute setting wins over ours, and lifting it puts ours back
756
+ addEventListener("void:mute", e => { if (e.detail) { if (preMute == null) preMute = sound.on; setSound(false); } else if (preMute != null) { setSound(preMute); preMute = null; } });
757
  document.addEventListener("visibilitychange", () => {
758
  if (document.hidden) { cancelAnimationFrame(raf); if (mode === "watch" && w.playing) pause(); if (sound.ctx) sound.ctx.suspend(); }
759
  else { clock.getDelta(); loop(); if (sound.on && sound.ctx) sound.ctx.resume(); }
static/race.js CHANGED
@@ -95,6 +95,7 @@ export function createRaces(scene, api, sound, canvasTex, net) {
95
  $("gRace").hidden = false; $("gRaceRes").hidden = true;
96
  }
97
  function finish(msg) {
 
98
  const p = api.state, best = store.get("void.race." + R.route.id);
99
  const me = R.done, rank = standings().findIndex(s => s.me) + 1;
100
  if (me && (!best || me < best)) { store.set("void.race." + R.route.id, me); if (R.rec.length >= 8) store.set("void.ghost." + R.route.id, { t: me, s: R.splits, p: R.rec.slice(0, 12000) }); }
 
95
  $("gRace").hidden = false; $("gRaceRes").hidden = true;
96
  }
97
  function finish(msg) {
98
+ if (msg !== "Race cancelled") dispatchEvent(new CustomEvent("void:break"));
99
  const p = api.state, best = store.get("void.race." + R.route.id);
100
  const me = R.done, rank = standings().findIndex(s => s.me) + 1;
101
  if (me && (!best || me < best)) { store.set("void.race." + R.route.id, me); if (R.rec.length >= 8) store.set("void.ghost." + R.route.id, { t: me, s: R.splits, p: R.rec.slice(0, 12000) }); }