Static site
Browse files- index.html +5 -2
- static/atmos.js +1 -1
- static/car.js +1 -1
- static/city.js +2 -2
- static/main.js +24 -6
- static/npc.js +0 -0
- static/police.js +10 -8
- static/style.css +4 -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=
|
| 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": {
|
|
@@ -99,6 +99,7 @@
|
|
| 99 |
|
| 100 |
<!-- Play -->
|
| 101 |
<div id="playUI" class="mode">
|
|
|
|
| 102 |
<div class="hud-tl">
|
| 103 |
<div class="g-score"><span>Cash this run</span><b id="gScore">$0</b><em id="gCombo"></em></div>
|
| 104 |
<div class="g-bars"><div class="bar hp" id="gHp"><i></i><span>Health</span></div><div class="bar nos" id="gNos"><i></i><span>Nitro</span></div><div class="bar fuel" id="gFuel"><i></i><span>Fuel</span></div></div>
|
|
@@ -159,6 +160,8 @@
|
|
| 159 |
<label class="set">Handling<span class="seg" data-set="handling"><button data-v="arcade">Arcade</button><button data-v="realistic">Realistic</button></span></label>
|
| 160 |
<label class="set">Screen shake and speed blur<span class="seg" data-set="motion"><button data-v="on">On</button><button data-v="off">Off</button></span></label>
|
| 161 |
<label class="set">Hoverboard<span class="seg" data-set="board"><button data-v="ion">Ion</button><button data-v="blaze">Blaze</button><button data-v="toxic">Toxic</button><button data-v="violet">Violet</button><button data-v="gold">Gold</button><button data-v="ghost">Ghost</button></span></label>
|
|
|
|
|
|
|
| 162 |
<label class="set">Text size<span class="seg" data-set="text"><button data-v="normal">Normal</button><button data-v="large">Large</button></span></label>
|
| 163 |
<label class="set">Touch steering<span class="seg" data-set="steer"><button data-v="stick">Joystick</button><button data-v="buttons">Buttons</button></span></label>
|
| 164 |
<div class="set save-row">Secret code<span><input id="gCode" maxlength="16" placeholder="type a code" autocomplete="off"><button class="pill" id="gCodeGo">Enter</button></span></div>
|
|
@@ -216,6 +219,6 @@
|
|
| 216 |
<div id="toast" role="status"></div>
|
| 217 |
<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>
|
| 218 |
<script src="/static/hub.js" data-app="void" defer></script>
|
| 219 |
-
<script type="module" src="/static/main.js?v=
|
| 220 |
</body>
|
| 221 |
</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=1793426655">
|
| 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": {
|
|
|
|
| 99 |
|
| 100 |
<!-- Play -->
|
| 101 |
<div id="playUI" class="mode">
|
| 102 |
+
<div class="fps-hud" id="gFpsHud">– fps</div>
|
| 103 |
<div class="hud-tl">
|
| 104 |
<div class="g-score"><span>Cash this run</span><b id="gScore">$0</b><em id="gCombo"></em></div>
|
| 105 |
<div class="g-bars"><div class="bar hp" id="gHp"><i></i><span>Health</span></div><div class="bar nos" id="gNos"><i></i><span>Nitro</span></div><div class="bar fuel" id="gFuel"><i></i><span>Fuel</span></div></div>
|
|
|
|
| 160 |
<label class="set">Handling<span class="seg" data-set="handling"><button data-v="arcade">Arcade</button><button data-v="realistic">Realistic</button></span></label>
|
| 161 |
<label class="set">Screen shake and speed blur<span class="seg" data-set="motion"><button data-v="on">On</button><button data-v="off">Off</button></span></label>
|
| 162 |
<label class="set">Hoverboard<span class="seg" data-set="board"><button data-v="ion">Ion</button><button data-v="blaze">Blaze</button><button data-v="toxic">Toxic</button><button data-v="violet">Violet</button><button data-v="gold">Gold</button><button data-v="ghost">Ghost</button></span></label>
|
| 163 |
+
<label class="set">Traffic & crowds<span class="seg" data-set="crowd"><button data-v="few">Few</button><button data-v="normal">Normal</button><button data-v="busy">Busy</button></span></label>
|
| 164 |
+
<label class="set">Show FPS<span class="seg" data-set="fps"><button data-v="off">Off</button><button data-v="on">On</button></span></label>
|
| 165 |
<label class="set">Text size<span class="seg" data-set="text"><button data-v="normal">Normal</button><button data-v="large">Large</button></span></label>
|
| 166 |
<label class="set">Touch steering<span class="seg" data-set="steer"><button data-v="stick">Joystick</button><button data-v="buttons">Buttons</button></span></label>
|
| 167 |
<div class="set save-row">Secret code<span><input id="gCode" maxlength="16" placeholder="type a code" autocomplete="off"><button class="pill" id="gCodeGo">Enter</button></span></div>
|
|
|
|
| 219 |
<div id="toast" role="status"></div>
|
| 220 |
<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>
|
| 221 |
<script src="/static/hub.js" data-app="void" defer></script>
|
| 222 |
+
<script type="module" src="/static/main.js?v=1793426655"></script>
|
| 223 |
</body>
|
| 224 |
</html>
|
static/atmos.js
CHANGED
|
@@ -31,7 +31,7 @@ export function createAtmos(W, sound, COARSE) {
|
|
| 31 |
clouds.frustumCulled = false; clouds.renderOrder = -1; scene.add(clouds);
|
| 32 |
|
| 33 |
// ---- sun lens flare ----
|
| 34 |
-
const flareLight = new THREE.
|
| 35 |
const lf = new Lensflare();
|
| 36 |
lf.addElement(new LensflareElement(radial([[0, "rgba(255,250,235,1)"], [.2, "rgba(255,230,180,.6)"], [1, "rgba(255,200,120,0)"]]), 380, 0));
|
| 37 |
const ring = radial([[0, "rgba(255,255,255,0)"], [.6, "rgba(255,255,255,0)"], [.7, "rgba(180,220,255,.35)"], [1, "rgba(255,255,255,0)"]]), dot = radial([[0, "rgba(255,220,180,.5)"], [1, "rgba(255,220,180,0)"]]);
|
|
|
|
| 31 |
clouds.frustumCulled = false; clouds.renderOrder = -1; scene.add(clouds);
|
| 32 |
|
| 33 |
// ---- sun lens flare ----
|
| 34 |
+
const flareLight = new THREE.Object3D(); scene.add(flareLight); // not a light: hiding a real light changes the light count and rebuilds every material
|
| 35 |
const lf = new Lensflare();
|
| 36 |
lf.addElement(new LensflareElement(radial([[0, "rgba(255,250,235,1)"], [.2, "rgba(255,230,180,.6)"], [1, "rgba(255,200,120,0)"]]), 380, 0));
|
| 37 |
const ring = radial([[0, "rgba(255,255,255,0)"], [.6, "rgba(255,255,255,0)"], [.7, "rgba(180,220,255,.35)"], [1, "rgba(255,255,255,0)"]]), dot = radial([[0, "rgba(255,220,180,.5)"], [1, "rgba(255,220,180,0)"]]);
|
static/car.js
CHANGED
|
@@ -355,7 +355,7 @@ export function buildCar(model = "hydra") {
|
|
| 355 |
const pr = new THREE.Mesh(new THREE.PlaneGeometry(.52, .13), plateM); pr.position.set(X0 - .005, curve(BS.bot, .03) + .22, 0); pr.rotation.y = -Math.PI / 2; solid.add(pr);
|
| 356 |
}
|
| 357 |
return {
|
| 358 |
-
group: car, wheels, clip, materials: { carbon, front }, model, name: M.name,
|
| 359 |
setSpoiler, setLivery,
|
| 360 |
setTint(k) { const T = { light: [0x1a2a3a, .32, .1], dark: [0x0a0d12, .6, .1], limo: [0x030405, .9, .1], mirror: [0x9aa4b0, .88, .95] }[k] || [0x0a0d12, .6, .1]; glass.color.setHex(T[0]); glass.opacity = T[1]; glass.metalness = T[2]; },
|
| 361 |
setFlameColor(hex) { flameMat.color.set(hex).multiplyScalar(3); },
|
|
|
|
| 355 |
const pr = new THREE.Mesh(new THREE.PlaneGeometry(.52, .13), plateM); pr.position.set(X0 - .005, curve(BS.bot, .03) + .22, 0); pr.rotation.y = -Math.PI / 2; solid.add(pr);
|
| 356 |
}
|
| 357 |
return {
|
| 358 |
+
group: car, wheels, clip, glowLight, materials: { carbon, front }, model, name: M.name,
|
| 359 |
setSpoiler, setLivery,
|
| 360 |
setTint(k) { const T = { light: [0x1a2a3a, .32, .1], dark: [0x0a0d12, .6, .1], limo: [0x030405, .9, .1], mirror: [0x9aa4b0, .88, .95] }[k] || [0x0a0d12, .6, .1]; glass.color.setHex(T[0]); glass.opacity = T[1]; glass.metalness = T[2]; },
|
| 361 |
setFlameColor(hex) { flameMat.color.set(hex).multiplyScalar(3); },
|
static/city.js
CHANGED
|
@@ -734,7 +734,7 @@ export async function buildCity(scene, canvasTex, COARSE) {
|
|
| 734 |
const tuftGeo = mergeGeometries([new THREE.PlaneGeometry(1.1, .6).translate(0, .3, 0), new THREE.PlaneGeometry(1.1, .6).translate(0, .3, 0).rotateY(Math.PI / 2)]);
|
| 735 |
const NTUFT = COARSE ? 0 : 3200, tufts = new THREE.InstancedMesh(tuftGeo, new THREE.MeshStandardMaterial({ map: bladeTex, alphaTest: .45, side: THREE.DoubleSide, roughness: .9 }), Math.max(1, NTUFT));
|
| 736 |
tufts.frustumCulled = false; tufts.count = 0; tufts.setColorAt(0, new THREE.Color(1, 1, 1)); scene.add(tufts);
|
| 737 |
-
let tuftAt = null;
|
| 738 |
const grassy = (x, z) => {
|
| 739 |
if (inPark(x, z)) return Math.hypot((x - lake.x) / (lake.rx + 6), (z - lake.z) / (lake.rz + 6)) > 1 ? .08 : -1;
|
| 740 |
if (x > MT.x0 && x < MT.x1 && z > MT.z0 && z < MT.z1 && terrain) { const h = terrain.height(x, z); return h > .3 && h < 165 ? h : -1; }
|
|
@@ -748,7 +748,7 @@ export async function buildCity(scene, canvasTex, COARSE) {
|
|
| 748 |
const hsh = Math.sin(gx * 127.1 + gz * 311.7) * 43758.5453, f = hsh - Math.floor(hsh), x = (gx + f) * S, z = (gz + (f * 7.3 % 1)) * S;
|
| 749 |
if ((x - cam.x) ** 2 + (z - cam.z) ** 2 > R * R || f < .25) continue;
|
| 750 |
const y = grassy(x, z); if (y < 0) continue;
|
| 751 |
-
m4.compose(v.set(x, y, z), q0.setFromAxisAngle(Y, f * 6.28), sc.set(.7 + f * .7, .7 + f * .8, .7 + f * .7)); tufts.setMatrixAt(k, m4); tufts.setColorAt(k++,
|
| 752 |
}
|
| 753 |
tufts.count = k; tufts.instanceMatrix.needsUpdate = true; if (tufts.instanceColor) tufts.instanceColor.needsUpdate = true;
|
| 754 |
}
|
|
|
|
| 734 |
const tuftGeo = mergeGeometries([new THREE.PlaneGeometry(1.1, .6).translate(0, .3, 0), new THREE.PlaneGeometry(1.1, .6).translate(0, .3, 0).rotateY(Math.PI / 2)]);
|
| 735 |
const NTUFT = COARSE ? 0 : 3200, tufts = new THREE.InstancedMesh(tuftGeo, new THREE.MeshStandardMaterial({ map: bladeTex, alphaTest: .45, side: THREE.DoubleSide, roughness: .9 }), Math.max(1, NTUFT));
|
| 736 |
tufts.frustumCulled = false; tufts.count = 0; tufts.setColorAt(0, new THREE.Color(1, 1, 1)); scene.add(tufts);
|
| 737 |
+
let tuftAt = null; const tuftC = new THREE.Color();
|
| 738 |
const grassy = (x, z) => {
|
| 739 |
if (inPark(x, z)) return Math.hypot((x - lake.x) / (lake.rx + 6), (z - lake.z) / (lake.rz + 6)) > 1 ? .08 : -1;
|
| 740 |
if (x > MT.x0 && x < MT.x1 && z > MT.z0 && z < MT.z1 && terrain) { const h = terrain.height(x, z); return h > .3 && h < 165 ? h : -1; }
|
|
|
|
| 748 |
const hsh = Math.sin(gx * 127.1 + gz * 311.7) * 43758.5453, f = hsh - Math.floor(hsh), x = (gx + f) * S, z = (gz + (f * 7.3 % 1)) * S;
|
| 749 |
if ((x - cam.x) ** 2 + (z - cam.z) ** 2 > R * R || f < .25) continue;
|
| 750 |
const y = grassy(x, z); if (y < 0) continue;
|
| 751 |
+
m4.compose(v.set(x, y, z), q0.setFromAxisAngle(Y, f * 6.28), sc.set(.7 + f * .7, .7 + f * .8, .7 + f * .7)); tufts.setMatrixAt(k, m4); tufts.setColorAt(k++, tuftC.setHSL(.24 + f * .06, .55, .32 + f * .14));
|
| 752 |
}
|
| 753 |
tufts.count = k; tufts.instanceMatrix.needsUpdate = true; if (tufts.instanceColor) tufts.instanceColor.needsUpdate = true;
|
| 754 |
}
|
static/main.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
| 3 |
import * as THREE from "three";
|
| 4 |
import { mergeGeometries } from "three/addons/utils/BufferGeometryUtils.js";
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
const V = new URL(import.meta.url).search;
|
| 7 |
const $ = id => document.getElementById(id);
|
| 8 |
const setLoad = p => { $("ldbar").style.width = p + "%"; $("ldpct").textContent = Math.round(p); };
|
|
@@ -27,11 +30,12 @@ setLoad(55);
|
|
| 27 |
const carRoot = new THREE.Group(); scene.add(carRoot);
|
| 28 |
const car = { group: carRoot, wheels: [] };
|
| 29 |
const carMats = new Set();
|
| 30 |
-
let inner = null;
|
| 31 |
function useModel(id, force) {
|
| 32 |
if (inner && inner.model === id && !force) return;
|
| 33 |
if (inner) carRoot.remove(inner.group);
|
| 34 |
inner = buildCar(id); carRoot.add(inner.group);
|
|
|
|
| 35 |
for (const k of Object.keys(inner)) if (typeof inner[k] === "function") car[k] = inner[k];
|
| 36 |
Object.assign(car, { wheels: inner.wheels, clip: car.clip || inner.clip, materials: inner.materials, model: id, name: inner.name });
|
| 37 |
carMats.clear();
|
|
@@ -49,7 +53,8 @@ setLoad(80);
|
|
| 49 |
const interior = addInterior(car, renderer);
|
| 50 |
const sound = new Sound();
|
| 51 |
const watch = createWatch(W, car, interior);
|
| 52 |
-
const
|
|
|
|
| 53 |
const TIMES = ["night", "sunset", "day"];
|
| 54 |
function cycleTime() { const k = TIMES[(TIMES.indexOf(W.timeOfDay) + 1) % 3]; W.setTime(k); store.set("void.time", k); toast({ night: "Night in the city", sunset: "Golden hour", day: "Daytime" }[k]); cubeN = 0; }
|
| 55 |
let police, races, nav;
|
|
@@ -60,7 +65,7 @@ setInterval(() => { if (document.hidden) net.tick(.5, null); }, 500); // a h
|
|
| 60 |
const GPU = (() => { try { const c = renderer.getContext(), e = c.getExtension("WEBGL_debug_renderer_info"); return e ? c.getParameter(e.UNMASKED_RENDERER_WEBGL) : ""; } catch { return ""; } })();
|
| 61 |
const STRONG = /RTX|GTX 1[06-9]|GTX 9[78]|Radeon RX|Radeon Pro|Apple M[1-9]/i.test(GPU) && !COARSE;
|
| 62 |
const TOP = /RTX\s?(40[6-9]0|50[5-9]0)|RTX\s?A?[45]\d{3}/i.test(GPU) && !COARSE; // recent RTX cards start on Ultra
|
| 63 |
-
const SET = Object.assign({ q: LITE ? "lite" : TOP ? "ultra" : STRONG ? "high" : COARSE ? "low" : "medium", sens: 1, autogas: "off", steer: "stick", weather: "clear", radio: "score", cycle: "off", handling: "arcade", motion: "on", text: "normal", board: "ion" }, store.get("void.settings") || {});
|
| 64 |
const gameOpts = {
|
| 65 |
handling: () => SET.handling, buyFood: () => { if (cash < 10) return false; cash -= 10; store.set("void.cash", cash); earn(0); return true; }, heroOwned: () => !!store.get("void.hero"), starter: () => { const m = life.models.find(m => m.id === "compact-3") || life.models.find(m => m.kind.id === "compact"); return { model: { ...m, top: 31, acc: .7, grip: .9 }, color: 0x6b5a44, rust: .75, owned: true }; }, onSteal: c => { police && police.event("steal"); goals.stats.steals = (goals.stats.steals || 0) + 1; },
|
| 66 |
garage: () => openGarage(true), cycleTime, hornType: () => build.horn, autoGas: () => SET.autogas === "on", onRepair: () => car.repair && car.repair(),
|
|
@@ -106,6 +111,7 @@ menuEl.addEventListener("click", e => { const t = e.target.closest(".tile"); if
|
|
| 106 |
menuEl.querySelectorAll("[data-veh]").forEach(b => b.onclick = () => game.api.setVehicle(b.dataset.veh));
|
| 107 |
document.getElementById("gFuelNav").onclick = () => { const st = game.state; if (!st) return; const best = W.city.stations.slice().sort((a, b) => Math.hypot(a.x - st.x, a.z - st.z) - Math.hypot(b.x - st.x, b.z - st.z))[0]; nav.setDest({ name: "⛽ Fuel station", x: best.x, z: best.z }); };
|
| 108 |
function applySettings(save = true) {
|
|
|
|
| 109 |
if (typeof boardMesh !== "undefined") paintBoard();
|
| 110 |
if (typeof life !== "undefined" && life.setVoidDetail) life.setVoidDetail(SET.q !== "lite"); // Lite: simple flying VOID cars
|
| 111 |
document.body.classList.toggle("big-ui", SET.text === "large");
|
|
@@ -119,7 +125,7 @@ function applySettings(save = true) {
|
|
| 119 |
const cap = W.setQuality(SET.q); perf.max = cap; perf.pr = Math.min(perf.pr, cap); if (renderer.getPixelRatio() > cap) { renderer.setPixelRatio(cap); composer.setPixelRatio(cap); } lastW = 0; resize();
|
| 120 |
if (save) store.set("void.settings", SET);
|
| 121 |
}
|
| 122 |
-
menuEl.querySelectorAll(".seg[data-set]").forEach(seg => seg.addEventListener("click", e => { const b = e.target.closest("button"); if (!b) return; e.preventDefault(); SET[seg.dataset.set] = b.dataset.v; if (seg.dataset.set === "q") { perf.pr = W.QUALITY[b.dataset.v].pr; perf.down = 0; } applySettings();
|
| 123 |
atmos.setWeather(SET.weather);
|
| 124 |
if (/Intel|UHD|Iris/i.test(GPU) && !COARSE && !store.get("void.gpuWarned")) { store.set("void.gpuWarned", 1); setTimeout(() => toast("Running on built-in graphics: see Menu → Settings to switch to your RTX"), 4000); } }));
|
| 125 |
document.getElementById("gSens").addEventListener("input", e => { SET.sens = +e.target.value; applySettings(); });
|
|
@@ -133,7 +139,7 @@ document.getElementById("gSens").addEventListener("input", e => { SET.sens = +e.
|
|
| 133 |
st.addEventListener("pointerup", end); st.addEventListener("pointercancel", end);
|
| 134 |
}
|
| 135 |
// headlights that light the road at night
|
| 136 |
-
const heads = new THREE.SpotLight(0xfff1d6, 0, 70, .55, .6, 1.2); heads.position.set(2.2, .7, 0); heads.target.position.set(18, -1.5, 0);
|
| 137 |
police = createPolice(scene, game.api, sound, life);
|
| 138 |
races = createRaces(scene, game.api, sound, W.canvasTex, net);
|
| 139 |
nav = createNav(scene, game.api, W, ZONES, races.starts, () => clock.elapsedTime);
|
|
@@ -486,7 +492,7 @@ function frameLoop(fixed) {
|
|
| 486 |
if (!fixed && raw < .5) {
|
| 487 |
perf.t += raw; perf.n++;
|
| 488 |
if (perf.t > 1.5) {
|
| 489 |
-
const avg = perf.t / perf.n, was = perf.pr; fpsNow = Math.round(1 / avg); const fe = document.getElementById("gFps"); if (fe) fe.textContent = fpsNow + " fps";
|
| 490 |
if (avg > 1 / 25 && mode === "play" && SET.q !== "lite") perf.down = 3; // very slow: skip straight to a lower level
|
| 491 |
if (avg > 1 / 45 && perf.pr > .75 && SET.q !== "lite" && perf.down < 3) perf.pr = Math.max(.75, perf.pr - .12); // below 75% everything turns to mush: drop a quality level instead
|
| 492 |
else if (avg > 1 / 40 && mode === "play" && ++perf.down >= 3 && SET.q !== "lite") { // still slow at the lowest resolution: drop a quality level
|
|
@@ -593,6 +599,9 @@ function frameLoop(fixed) {
|
|
| 593 |
const roll = S.speed / 3.6 * dt / .37;
|
| 594 |
if (heroDriven) for (const wh of car.wheels) wh.rotation.z -= S.air ? roll * .15 : roll;
|
| 595 |
car.group.updateMatrixWorld(true);
|
|
|
|
|
|
|
|
|
|
| 596 |
|
| 597 |
// shadow, underglow, exhaust, speed lines
|
| 598 |
const fr = S.fr, ground = clamp(1 - S.pos.y / 3) * (fr.u.y > .8 ? 1 : 0);
|
|
@@ -678,6 +687,15 @@ try {
|
|
| 678 |
} catch (e) { console.warn("VOID flyers keep the simple shape", e); }
|
| 679 |
setLoad(95);
|
| 680 |
renderer.compile(scene, camera);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 681 |
let raf;
|
| 682 |
let frameErr = 0;
|
| 683 |
const loop = () => { raf = requestAnimationFrame(loop); try { frameLoop(); } catch (e) { if (frameErr++ < 3) console.error(e); } }; // one bad frame never stops the game
|
|
|
|
| 3 |
import * as THREE from "three";
|
| 4 |
import { mergeGeometries } from "three/addons/utils/BufferGeometryUtils.js";
|
| 5 |
|
| 6 |
+
// every material draws in one pass. three.js draws see-through double-sided ones twice (back faces, then front) and
|
| 7 |
+
// rebuilds the material's whole shader setup both times, every frame: two dozen beacons, clouds and glass made 70 KB of garbage a frame
|
| 8 |
+
Object.defineProperty(THREE.Material.prototype, "forceSinglePass", { get: () => true, set() {} });
|
| 9 |
const V = new URL(import.meta.url).search;
|
| 10 |
const $ = id => document.getElementById(id);
|
| 11 |
const setLoad = p => { $("ldbar").style.width = p + "%"; $("ldpct").textContent = Math.round(p); };
|
|
|
|
| 30 |
const carRoot = new THREE.Group(); scene.add(carRoot);
|
| 31 |
const car = { group: carRoot, wheels: [] };
|
| 32 |
const carMats = new Set();
|
| 33 |
+
let inner = null, glowL = null;
|
| 34 |
function useModel(id, force) {
|
| 35 |
if (inner && inner.model === id && !force) return;
|
| 36 |
if (inner) carRoot.remove(inner.group);
|
| 37 |
inner = buildCar(id); carRoot.add(inner.group);
|
| 38 |
+
if (glowL) scene.remove(glowL); glowL = inner.glowLight || null; if (glowL) scene.add(glowL); // the thruster glow lives in the scene too
|
| 39 |
for (const k of Object.keys(inner)) if (typeof inner[k] === "function") car[k] = inner[k];
|
| 40 |
Object.assign(car, { wheels: inner.wheels, clip: car.clip || inner.clip, materials: inner.materials, model: id, name: inner.name });
|
| 41 |
carMats.clear();
|
|
|
|
| 53 |
const interior = addInterior(car, renderer);
|
| 54 |
const sound = new Sound();
|
| 55 |
const watch = createWatch(W, car, interior);
|
| 56 |
+
const DENSITY = { few: .55, normal: 1, busy: 1.3 }[(store.get("void.settings") || {}).crowd || (LITE ? "few" : "normal")] || 1;
|
| 57 |
+
const life = createLife(scene, W.roads, W.walkways, COARSE || LITE, DENSITY);
|
| 58 |
const TIMES = ["night", "sunset", "day"];
|
| 59 |
function cycleTime() { const k = TIMES[(TIMES.indexOf(W.timeOfDay) + 1) % 3]; W.setTime(k); store.set("void.time", k); toast({ night: "Night in the city", sunset: "Golden hour", day: "Daytime" }[k]); cubeN = 0; }
|
| 60 |
let police, races, nav;
|
|
|
|
| 65 |
const GPU = (() => { try { const c = renderer.getContext(), e = c.getExtension("WEBGL_debug_renderer_info"); return e ? c.getParameter(e.UNMASKED_RENDERER_WEBGL) : ""; } catch { return ""; } })();
|
| 66 |
const STRONG = /RTX|GTX 1[06-9]|GTX 9[78]|Radeon RX|Radeon Pro|Apple M[1-9]/i.test(GPU) && !COARSE;
|
| 67 |
const TOP = /RTX\s?(40[6-9]0|50[5-9]0)|RTX\s?A?[45]\d{3}/i.test(GPU) && !COARSE; // recent RTX cards start on Ultra
|
| 68 |
+
const SET = Object.assign({ q: LITE ? "lite" : TOP ? "ultra" : STRONG ? "high" : COARSE ? "low" : "medium", sens: 1, autogas: "off", steer: "stick", weather: "clear", radio: "score", cycle: "off", handling: "arcade", motion: "on", text: "normal", board: "ion", crowd: LITE ? "few" : "normal", fps: "off" }, store.get("void.settings") || {});
|
| 69 |
const gameOpts = {
|
| 70 |
handling: () => SET.handling, buyFood: () => { if (cash < 10) return false; cash -= 10; store.set("void.cash", cash); earn(0); return true; }, heroOwned: () => !!store.get("void.hero"), starter: () => { const m = life.models.find(m => m.id === "compact-3") || life.models.find(m => m.kind.id === "compact"); return { model: { ...m, top: 31, acc: .7, grip: .9 }, color: 0x6b5a44, rust: .75, owned: true }; }, onSteal: c => { police && police.event("steal"); goals.stats.steals = (goals.stats.steals || 0) + 1; },
|
| 71 |
garage: () => openGarage(true), cycleTime, hornType: () => build.horn, autoGas: () => SET.autogas === "on", onRepair: () => car.repair && car.repair(),
|
|
|
|
| 111 |
menuEl.querySelectorAll("[data-veh]").forEach(b => b.onclick = () => game.api.setVehicle(b.dataset.veh));
|
| 112 |
document.getElementById("gFuelNav").onclick = () => { const st = game.state; if (!st) return; const best = W.city.stations.slice().sort((a, b) => Math.hypot(a.x - st.x, a.z - st.z) - Math.hypot(b.x - st.x, b.z - st.z))[0]; nav.setDest({ name: "⛽ Fuel station", x: best.x, z: best.z }); };
|
| 113 |
function applySettings(save = true) {
|
| 114 |
+
document.body.classList.toggle("show-fps", SET.fps === "on");
|
| 115 |
if (typeof boardMesh !== "undefined") paintBoard();
|
| 116 |
if (typeof life !== "undefined" && life.setVoidDetail) life.setVoidDetail(SET.q !== "lite"); // Lite: simple flying VOID cars
|
| 117 |
document.body.classList.toggle("big-ui", SET.text === "large");
|
|
|
|
| 125 |
const cap = W.setQuality(SET.q); perf.max = cap; perf.pr = Math.min(perf.pr, cap); if (renderer.getPixelRatio() > cap) { renderer.setPixelRatio(cap); composer.setPixelRatio(cap); } lastW = 0; resize();
|
| 126 |
if (save) store.set("void.settings", SET);
|
| 127 |
}
|
| 128 |
+
menuEl.querySelectorAll(".seg[data-set]").forEach(seg => seg.addEventListener("click", e => { const b = e.target.closest("button"); if (!b) return; e.preventDefault(); SET[seg.dataset.set] = b.dataset.v; if (seg.dataset.set === "crowd") toast("Traffic & crowds change after a reload (F5)"); if (seg.dataset.set === "q") { perf.pr = W.QUALITY[b.dataset.v].pr; perf.down = 0; } applySettings();
|
| 129 |
atmos.setWeather(SET.weather);
|
| 130 |
if (/Intel|UHD|Iris/i.test(GPU) && !COARSE && !store.get("void.gpuWarned")) { store.set("void.gpuWarned", 1); setTimeout(() => toast("Running on built-in graphics: see Menu → Settings to switch to your RTX"), 4000); } }));
|
| 131 |
document.getElementById("gSens").addEventListener("input", e => { SET.sens = +e.target.value; applySettings(); });
|
|
|
|
| 139 |
st.addEventListener("pointerup", end); st.addEventListener("pointercancel", end);
|
| 140 |
}
|
| 141 |
// headlights that light the road at night
|
| 142 |
+
const heads = new THREE.SpotLight(0xfff1d6, 0, 70, .55, .6, 1.2); heads.position.set(2.2, .7, 0); heads.target.position.set(18, -1.5, 0); scene.add(heads, heads.target); // in the scene (it follows the car each frame), so it never disappears with the car
|
| 143 |
police = createPolice(scene, game.api, sound, life);
|
| 144 |
races = createRaces(scene, game.api, sound, W.canvasTex, net);
|
| 145 |
nav = createNav(scene, game.api, W, ZONES, races.starts, () => clock.elapsedTime);
|
|
|
|
| 492 |
if (!fixed && raw < .5) {
|
| 493 |
perf.t += raw; perf.n++;
|
| 494 |
if (perf.t > 1.5) {
|
| 495 |
+
const avg = perf.t / perf.n, was = perf.pr; fpsNow = Math.round(1 / avg); const fe = document.getElementById("gFps"); if (fe) fe.textContent = fpsNow + " fps"; const hf = document.getElementById("gFpsHud"); if (hf) { hf.textContent = fpsNow + " fps"; hf.className = "fps-hud " + (fpsNow >= 50 ? "ok" : fpsNow >= 30 ? "mid" : "low"); }
|
| 496 |
if (avg > 1 / 25 && mode === "play" && SET.q !== "lite") perf.down = 3; // very slow: skip straight to a lower level
|
| 497 |
if (avg > 1 / 45 && perf.pr > .75 && SET.q !== "lite" && perf.down < 3) perf.pr = Math.max(.75, perf.pr - .12); // below 75% everything turns to mush: drop a quality level instead
|
| 498 |
else if (avg > 1 / 40 && mode === "play" && ++perf.down >= 3 && SET.q !== "lite") { // still slow at the lowest resolution: drop a quality level
|
|
|
|
| 599 |
const roll = S.speed / 3.6 * dt / .37;
|
| 600 |
if (heroDriven) for (const wh of car.wheels) wh.rotation.z -= S.air ? roll * .15 : roll;
|
| 601 |
car.group.updateMatrixWorld(true);
|
| 602 |
+
heads.position.set(2.2, .7, 0).applyMatrix4(carRoot.matrixWorld); heads.target.position.set(18, -1.5, 0).applyMatrix4(carRoot.matrixWorld); heads.target.updateMatrixWorld();
|
| 603 |
+
if (glowL) { glowL.position.set(0, -.4, 0).applyMatrix4(carRoot.matrixWorld); if (!carRoot.visible) glowL.intensity = 0; }
|
| 604 |
+
if (!carRoot.visible) heads.intensity = 0;
|
| 605 |
|
| 606 |
// shadow, underglow, exhaust, speed lines
|
| 607 |
const fr = S.fr, ground = clamp(1 - S.pos.y / 3) * (fr.u.y > .8 ? 1 : 0);
|
|
|
|
| 687 |
} catch (e) { console.warn("VOID flyers keep the simple shape", e); }
|
| 688 |
setLoad(95);
|
| 689 |
renderer.compile(scene, camera);
|
| 690 |
+
// warm-up: draw every mesh once into a tiny target so its buffers and textures are on the graphics card before you play.
|
| 691 |
+
// Otherwise each new part of the city uploads the first time it comes into view, and that is a stutter.
|
| 692 |
+
try {
|
| 693 |
+
const saved = [], parents = [];
|
| 694 |
+
scene.traverse(o => { if (o === scene) return; if (o.isMesh || o.isPoints || o.isLine || o.isSprite) { saved.push([o, o.visible, o.frustumCulled, o.layers.mask]); o.visible = true; o.frustumCulled = false; o.layers.enableAll(); } else if (!o.isLight) { parents.push([o, o.visible]); o.visible = true; } });
|
| 695 |
+
const rt = new THREE.WebGLRenderTarget(8, 8), sh = renderer.shadowMap.autoUpdate; renderer.shadowMap.autoUpdate = false; renderer.shadowMap.needsUpdate = true;
|
| 696 |
+
renderer.setRenderTarget(rt); renderer.render(scene, camera); renderer.setRenderTarget(null); rt.dispose(); renderer.shadowMap.autoUpdate = sh;
|
| 697 |
+
for (const [o, v, f, m] of saved) { o.visible = v; o.frustumCulled = f; o.layers.mask = m; } for (const [o, v] of parents) o.visible = v;
|
| 698 |
+
} catch (e) { console.warn("warm-up skipped", e); }
|
| 699 |
let raf;
|
| 700 |
let frameErr = 0;
|
| 701 |
const loop = () => { raf = requestAnimationFrame(loop); try { frameLoop(); } catch (e) { if (frameErr++ < 3) console.error(e); } }; // one bad frame never stops the game
|
static/npc.js
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
static/police.js
CHANGED
|
@@ -41,13 +41,13 @@ export function createPolice(scene, api, sound, life) {
|
|
| 41 |
const D = makeDriver(api), P = KINDS.find(k => k.id === "police"), geo = vehicle(P);
|
| 42 |
const bodyMat = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: .3, metalness: .5 }), lightMat = new THREE.MeshBasicMaterial({ vertexColors: true, toneMapped: false, color: new THREE.Color(2.2, 2.2, 2.2) });
|
| 43 |
const red = new THREE.MeshBasicMaterial({ color: new THREE.Color(1, .1, .1).multiplyScalar(4), toneMapped: false }), blue = new THREE.MeshBasicMaterial({ color: new THREE.Color(.15, .3, 1).multiplyScalar(4), toneMapped: false });
|
| 44 |
-
const cops = [];
|
| 45 |
for (let k = 0; k < 8; k++) {
|
| 46 |
const g = new THREE.Group(), body = new THREE.Mesh(geo.body, bodyMat), lights = new THREE.Mesh(geo.lights, lightMat);
|
| 47 |
const r = new THREE.Mesh(new THREE.BoxGeometry(.32, .18, .5), red), b = new THREE.Mesh(new THREE.BoxGeometry(.32, .18, .5), blue);
|
| 48 |
r.position.set(-.2, 1.82, .32); b.position.set(-.2, 1.82, -.32);
|
| 49 |
-
const glow = new THREE.
|
| 50 |
-
body.castShadow = true; g.add(body, lights, r, b
|
| 51 |
cops.push({ g, r, b, glow, on: false, x: 0, z: 0, yaw: 0, v: 0, wreck: 0, bump: 0, y: 0, rz: 0 });
|
| 52 |
}
|
| 53 |
// the helicopter: body, tail, two rotors and a searchlight
|
|
@@ -62,7 +62,7 @@ export function createPolice(scene, api, sound, life) {
|
|
| 62 |
heli.tailRotor = new THREE.Mesh(new THREE.BoxGeometry(.06, 2, .2), m); heli.tailRotor.position.set(-6.4, .5, .3); heli.add(heli.tailRotor);
|
| 63 |
const beam = new THREE.Mesh(new THREE.ConeGeometry(9, 60, 24, 1, true).translate(0, -30, 0), new THREE.MeshBasicMaterial({ color: 0xdfe8ff, transparent: true, opacity: .08, blending: THREE.AdditiveBlending, depthWrite: false, side: THREE.DoubleSide }));
|
| 64 |
heli.beam = beam; heli.add(beam);
|
| 65 |
-
heli.spot = new THREE.SpotLight(0xffffff, 0, 160, .35, .5, 1.2);
|
| 66 |
heli.blink = new THREE.Mesh(new THREE.SphereGeometry(.2, 8, 6), red); heli.blink.position.set(-6.3, 1.2, 0); heli.add(heli.blink);
|
| 67 |
heli.visible = false; scene.add(heli);
|
| 68 |
}
|
|
@@ -99,7 +99,8 @@ export function createPolice(scene, api, sound, life) {
|
|
| 99 |
if (kind === "ped") addHeat(.6, "Hit and run");
|
| 100 |
},
|
| 101 |
update(dt, time) {
|
| 102 |
-
const p = api.state; if (!p || !p.started) return;
|
|
|
|
| 103 |
if (p.wreck > 0) { if (stars) clear(); return; }
|
| 104 |
const ps = Math.hypot(p.vel.x, p.vel.z), air = p.mode === "air" && p.y > 6;
|
| 105 |
// speeding past a traffic cop
|
|
@@ -113,7 +114,7 @@ export function createPolice(scene, api, sound, life) {
|
|
| 113 |
for (const c of cops) {
|
| 114 |
if (!c.on) continue;
|
| 115 |
const flash = Math.sin(time * 18 + c.x) > 0;
|
| 116 |
-
c.r.visible = flash; c.b.visible = !flash; c.glow.color.setHex(flash ? 0xff2020 : 0x2040ff); c.glow.intensity = 30;
|
| 117 |
if (c.wreck > 0) {
|
| 118 |
c.wreck -= dt; c.v *= Math.pow(.2, dt); c.x += Math.cos(c.yaw) * c.v * dt; c.z += Math.sin(c.yaw) * c.v * dt; c.rz = Math.min(Math.PI * .9, c.rz + dt * 6);
|
| 119 |
c.glow.intensity = 0; c.r.visible = c.b.visible = false;
|
|
@@ -138,6 +139,7 @@ export function createPolice(scene, api, sound, life) {
|
|
| 138 |
}
|
| 139 |
c.g.position.set(c.x, api.terrainH ? api.terrainH(c.x, c.z) : 0, c.z); c.g.rotation.set(c.rz, -c.yaw, 0, "YXZ");
|
| 140 |
}
|
|
|
|
| 141 |
// the helicopter from three stars
|
| 142 |
if (stars >= 3) {
|
| 143 |
if (!H.on) { H.on = true; H.x = p.x - 300; H.z = p.z - 300; H.y = 120; heli.visible = true; api.say("Police helicopter overhead", 2.5); }
|
|
@@ -145,9 +147,9 @@ export function createPolice(scene, api, sound, life) {
|
|
| 145 |
H.x += dx / (d || 1) * sp * dt; H.z += dz / (d || 1) * sp * dt; H.y += (ty - H.y) * Math.min(1, dt * .8); H.yaw = Math.atan2(dz, dx);
|
| 146 |
heli.position.set(H.x, H.y, H.z); heli.rotation.set(0, -H.yaw, Math.min(.25, sp / 250));
|
| 147 |
heli.rotor.rotation.y += dt * 40; heli.tailRotor.rotation.x += dt * 50; heli.blink.visible = Math.sin(time * 6) > 0;
|
| 148 |
-
heli.beam.lookAt(p.x, p.y, p.z); heli.beam.rotateX(-Math.PI / 2); heli.spot.intensity = d < 160 ? 900 : 0; heli.spot.
|
| 149 |
if (d < 120) nearest = Math.min(nearest, d * .5);
|
| 150 |
-
} else if (H.on) { H.on = false; heli.visible = false; }
|
| 151 |
// busted: stopped with a cruiser right beside you
|
| 152 |
if (close && ps < 4 && !air) { bust += dt; if (bust > 3) { const lost = Math.round(p.score * .15); p.score -= lost; api.busted(`BUSTED! The police fined you ${lost} points`); clear(); return; } } else bust = Math.max(0, bust - dt * 2);
|
| 153 |
// losing them
|
|
|
|
| 41 |
const D = makeDriver(api), P = KINDS.find(k => k.id === "police"), geo = vehicle(P);
|
| 42 |
const bodyMat = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: .3, metalness: .5 }), lightMat = new THREE.MeshBasicMaterial({ vertexColors: true, toneMapped: false, color: new THREE.Color(2.2, 2.2, 2.2) });
|
| 43 |
const red = new THREE.MeshBasicMaterial({ color: new THREE.Color(1, .1, .1).multiplyScalar(4), toneMapped: false }), blue = new THREE.MeshBasicMaterial({ color: new THREE.Color(.15, .3, 1).multiplyScalar(4), toneMapped: false });
|
| 44 |
+
const cops = [], copGlow = new THREE.PointLight(0xff2020, 0, 30, 2); scene.add(copGlow); // one flashing light, on the nearest cruiser
|
| 45 |
for (let k = 0; k < 8; k++) {
|
| 46 |
const g = new THREE.Group(), body = new THREE.Mesh(geo.body, bodyMat), lights = new THREE.Mesh(geo.lights, lightMat);
|
| 47 |
const r = new THREE.Mesh(new THREE.BoxGeometry(.32, .18, .5), red), b = new THREE.Mesh(new THREE.BoxGeometry(.32, .18, .5), blue);
|
| 48 |
r.position.set(-.2, 1.82, .32); b.position.set(-.2, 1.82, -.32);
|
| 49 |
+
const glow = { color: new THREE.Color(), intensity: 0 }; // (the real light is shared: see copGlow)
|
| 50 |
+
body.castShadow = true; g.add(body, lights, r, b); g.visible = false; scene.add(g);
|
| 51 |
cops.push({ g, r, b, glow, on: false, x: 0, z: 0, yaw: 0, v: 0, wreck: 0, bump: 0, y: 0, rz: 0 });
|
| 52 |
}
|
| 53 |
// the helicopter: body, tail, two rotors and a searchlight
|
|
|
|
| 62 |
heli.tailRotor = new THREE.Mesh(new THREE.BoxGeometry(.06, 2, .2), m); heli.tailRotor.position.set(-6.4, .5, .3); heli.add(heli.tailRotor);
|
| 63 |
const beam = new THREE.Mesh(new THREE.ConeGeometry(9, 60, 24, 1, true).translate(0, -30, 0), new THREE.MeshBasicMaterial({ color: 0xdfe8ff, transparent: true, opacity: .08, blending: THREE.AdditiveBlending, depthWrite: false, side: THREE.DoubleSide }));
|
| 64 |
heli.beam = beam; heli.add(beam);
|
| 65 |
+
heli.spot = new THREE.SpotLight(0xffffff, 0, 160, .35, .5, 1.2); scene.add(heli.spot, heli.spot.target); // in the scene, not the helicopter: it never vanishes
|
| 66 |
heli.blink = new THREE.Mesh(new THREE.SphereGeometry(.2, 8, 6), red); heli.blink.position.set(-6.3, 1.2, 0); heli.add(heli.blink);
|
| 67 |
heli.visible = false; scene.add(heli);
|
| 68 |
}
|
|
|
|
| 99 |
if (kind === "ped") addHeat(.6, "Hit and run");
|
| 100 |
},
|
| 101 |
update(dt, time) {
|
| 102 |
+
const p = api.state; if (!p || !p.started) { copGlow.intensity = 0; return; }
|
| 103 |
+
let glowD = 1e9;
|
| 104 |
if (p.wreck > 0) { if (stars) clear(); return; }
|
| 105 |
const ps = Math.hypot(p.vel.x, p.vel.z), air = p.mode === "air" && p.y > 6;
|
| 106 |
// speeding past a traffic cop
|
|
|
|
| 114 |
for (const c of cops) {
|
| 115 |
if (!c.on) continue;
|
| 116 |
const flash = Math.sin(time * 18 + c.x) > 0;
|
| 117 |
+
c.r.visible = flash; c.b.visible = !flash; c.glow.color.setHex(flash ? 0xff2020 : 0x2040ff); c.glow.intensity = 30; { const d = Math.hypot(c.x - p.x, c.z - p.z); if (d < glowD) { glowD = d; copGlow.position.set(c.x, (c.y || 0) + 2.4, c.z); copGlow.color.setHex(flash ? 0xff2020 : 0x2040ff); } }
|
| 118 |
if (c.wreck > 0) {
|
| 119 |
c.wreck -= dt; c.v *= Math.pow(.2, dt); c.x += Math.cos(c.yaw) * c.v * dt; c.z += Math.sin(c.yaw) * c.v * dt; c.rz = Math.min(Math.PI * .9, c.rz + dt * 6);
|
| 120 |
c.glow.intensity = 0; c.r.visible = c.b.visible = false;
|
|
|
|
| 139 |
}
|
| 140 |
c.g.position.set(c.x, api.terrainH ? api.terrainH(c.x, c.z) : 0, c.z); c.g.rotation.set(c.rz, -c.yaw, 0, "YXZ");
|
| 141 |
}
|
| 142 |
+
copGlow.intensity = glowD < 200 ? 30 : 0;
|
| 143 |
// the helicopter from three stars
|
| 144 |
if (stars >= 3) {
|
| 145 |
if (!H.on) { H.on = true; H.x = p.x - 300; H.z = p.z - 300; H.y = 120; heli.visible = true; api.say("Police helicopter overhead", 2.5); }
|
|
|
|
| 147 |
H.x += dx / (d || 1) * sp * dt; H.z += dz / (d || 1) * sp * dt; H.y += (ty - H.y) * Math.min(1, dt * .8); H.yaw = Math.atan2(dz, dx);
|
| 148 |
heli.position.set(H.x, H.y, H.z); heli.rotation.set(0, -H.yaw, Math.min(.25, sp / 250));
|
| 149 |
heli.rotor.rotation.y += dt * 40; heli.tailRotor.rotation.x += dt * 50; heli.blink.visible = Math.sin(time * 6) > 0;
|
| 150 |
+
heli.beam.lookAt(p.x, p.y, p.z); heli.beam.rotateX(-Math.PI / 2); heli.spot.intensity = d < 160 ? 900 : 0; heli.spot.position.set(H.x, H.y - 1.5, H.z); heli.spot.target.position.set(p.x, p.y, p.z); heli.spot.target.updateMatrixWorld();
|
| 151 |
if (d < 120) nearest = Math.min(nearest, d * .5);
|
| 152 |
+
} else if (H.on) { H.on = false; heli.visible = false; heli.spot.intensity = 0; }
|
| 153 |
// busted: stopped with a cruiser right beside you
|
| 154 |
if (close && ps < 4 && !air) { bust += dt; if (bust > 3) { const lost = Math.round(p.score * .15); p.score -= lost; api.busted(`BUSTED! The police fined you ${lost} points`); clear(); return; } } else bust = Math.max(0, bust - dt * 2);
|
| 155 |
// losing them
|
static/style.css
CHANGED
|
@@ -449,3 +449,7 @@ body[data-mode="play"] .hub-chip { display: none !important; }
|
|
| 449 |
.deal-go { justify-self: start; } .deal-go:disabled { opacity: .45; cursor: not-allowed; }
|
| 450 |
@media (max-width: 820px) { .deal-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; } .deal-info { max-height: 42vh; } .g-deal { inset: 8px; } }
|
| 451 |
body.big-ui .g-hint, body.big-ui .g-job, body.big-ui .g-tut, body.big-ui .g-gps { font-size: 17px; } body.big-ui .g-menu { font-size: 16px; } body.big-ui .tile { font-size: 14px; } body.big-ui .goal small, body.big-ui .small { font-size: 14px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 449 |
.deal-go { justify-self: start; } .deal-go:disabled { opacity: .45; cursor: not-allowed; }
|
| 450 |
@media (max-width: 820px) { .deal-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; } .deal-info { max-height: 42vh; } .g-deal { inset: 8px; } }
|
| 451 |
body.big-ui .g-hint, body.big-ui .g-job, body.big-ui .g-tut, body.big-ui .g-gps { font-size: 17px; } body.big-ui .g-menu { font-size: 16px; } body.big-ui .tile { font-size: 14px; } body.big-ui .goal small, body.big-ui .small { font-size: 14px; }
|
| 452 |
+
|
| 453 |
+
/* fps counter (Settings → Show FPS) */
|
| 454 |
+
.fps-hud { display: none; position: absolute; left: 50%; bottom: calc(10px + var(--bot, 0px)); transform: translateX(-50%); padding: 3px 10px; border-radius: 999px; background: rgba(0,0,0,.6); font: 700 12px var(--body); color: #9dffb0; pointer-events: none; z-index: 5; }
|
| 455 |
+
body.show-fps .fps-hud { display: block; } .fps-hud.mid { color: #ffd23d; } .fps-hud.low { color: #ff6b6b; }
|