Spaces:
Running
Running
Mobile retrofit: touch controls + PWA meta for live_wires
Browse filesMobile retrofit: additive touch controls + viewport/PWA meta for live_wires scene. Signed Yachay <yachay@szlholdings.dev>.
- live_wires.html +4 -1
- live_wires_3d.js +6 -4
live_wires.html
CHANGED
|
@@ -2,7 +2,10 @@
|
|
| 2 |
<!-- SPDX-License-Identifier: Apache-2.0 © 2026 SZL Holdings · PURIQ/Doctrine v12 · Sign: Yachay -->
|
| 3 |
<html lang="en"><head>
|
| 4 |
<meta charset="utf-8"/>
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"/>
|
|
|
|
|
|
|
|
|
|
| 6 |
<title>Live 3D Wires — __FLAGSHIP__ cortex</title>
|
| 7 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css"/>
|
| 8 |
<style>
|
|
|
|
| 2 |
<!-- SPDX-License-Identifier: Apache-2.0 © 2026 SZL Holdings · PURIQ/Doctrine v12 · Sign: Yachay -->
|
| 3 |
<html lang="en"><head>
|
| 4 |
<meta charset="utf-8"/>
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover, user-scalable=yes"/>
|
| 6 |
+
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
| 7 |
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
|
| 8 |
+
<meta name="theme-color" content="#0a0e14"/>
|
| 9 |
<title>Live 3D Wires — __FLAGSHIP__ cortex</title>
|
| 10 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css"/>
|
| 11 |
<style>
|
live_wires_3d.js
CHANGED
|
@@ -57,7 +57,9 @@
|
|
| 57 |
}
|
| 58 |
} catch (e) { /* fall through */ }
|
| 59 |
if (!renderer) renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
function resize() {
|
| 62 |
const w = el.clientWidth || 800, h = el.clientHeight || 520;
|
| 63 |
renderer.setSize(w, h, false); camera.aspect = w / h; camera.updateProjectionMatrix();
|
|
@@ -179,7 +181,7 @@
|
|
| 179 |
function frame() {
|
| 180 |
state.raf = requestAnimationFrame(frame);
|
| 181 |
if (state.paused) { renderer.render(scene, camera); return; }
|
| 182 |
-
theta += 0.0016; camera.position.x = Math.sin(theta) * 30; camera.position.z = Math.cos(theta) * 30; camera.lookAt(0, 2, 0);
|
| 183 |
const v3 = new THREE.Vector3();
|
| 184 |
for (let i = state.pulses.length - 1; i >= 0; i--) {
|
| 185 |
const p = state.pulses[i]; const w = state.wires[p.userData.wire]; if (!w) continue;
|
|
@@ -189,7 +191,7 @@
|
|
| 189 |
if (p.userData.tripring) p.userData.tripring.rotation.z += 0.2;
|
| 190 |
}
|
| 191 |
if (cortex.userData.tick) cortex.userData.tick(performance.now());
|
| 192 |
-
renderer.render(scene, camera);
|
| 193 |
}
|
| 194 |
resize(); frame();
|
| 195 |
const ro = new (global.ResizeObserver || function(){return{observe(){},disconnect(){}}})(resize); ro.observe(el);
|
|
@@ -242,7 +244,7 @@
|
|
| 242 |
g.userData.tick=(t)=>{ sweep.rotation.z=t*0.0012; };
|
| 243 |
}
|
| 244 |
function buildField(THREE, g, c) { // rosie ecosystem field
|
| 245 |
-
const N=600, pos=new Float32Array(N*3); for(let i=0;i<N;i++){ const a=Math.random()*Math.PI*2, rr=2+Math.random()*4, y=(Math.random()-0.5)*6; pos[i*3]=Math.cos(a)*rr; pos[i*3+1]=y; pos[i*3+2]=Math.sin(a)*rr; }
|
| 246 |
const geo=new THREE.BufferGeometry(); geo.setAttribute("position",new THREE.BufferAttribute(pos,3));
|
| 247 |
const pts=new THREE.Points(geo,new THREE.PointsMaterial({color:c,size:0.12,transparent:true,opacity:0.8})); g.add(pts);
|
| 248 |
const core=new THREE.Mesh(new THREE.SphereGeometry(1.6,24,24),new THREE.MeshStandardMaterial({color:c,emissive:c,emissiveIntensity:0.4,transparent:true,opacity:0.5})); g.add(core);
|
|
|
|
| 57 |
}
|
| 58 |
} catch (e) { /* fall through */ }
|
| 59 |
if (!renderer) renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
|
| 60 |
+
var SZL_MOBILE = ('ontouchstart' in global) || ((global.navigator&&global.navigator.maxTouchPoints)||0) > 0;
|
| 61 |
+
var SZL_REDUCED = global.matchMedia && global.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
| 62 |
+
renderer.setPixelRatio(Math.min(global.devicePixelRatio || 1, SZL_MOBILE ? 1.5 : 2));
|
| 63 |
function resize() {
|
| 64 |
const w = el.clientWidth || 800, h = el.clientHeight || 520;
|
| 65 |
renderer.setSize(w, h, false); camera.aspect = w / h; camera.updateProjectionMatrix();
|
|
|
|
| 181 |
function frame() {
|
| 182 |
state.raf = requestAnimationFrame(frame);
|
| 183 |
if (state.paused) { renderer.render(scene, camera); return; }
|
| 184 |
+
if(!SZL_REDUCED){ theta += 0.0016; camera.position.x = Math.sin(theta) * 30; camera.position.z = Math.cos(theta) * 30; camera.lookAt(0, 2, 0); }
|
| 185 |
const v3 = new THREE.Vector3();
|
| 186 |
for (let i = state.pulses.length - 1; i >= 0; i--) {
|
| 187 |
const p = state.pulses[i]; const w = state.wires[p.userData.wire]; if (!w) continue;
|
|
|
|
| 191 |
if (p.userData.tripring) p.userData.tripring.rotation.z += 0.2;
|
| 192 |
}
|
| 193 |
if (cortex.userData.tick) cortex.userData.tick(performance.now());
|
| 194 |
+
if(!document.hidden) renderer.render(scene, camera);
|
| 195 |
}
|
| 196 |
resize(); frame();
|
| 197 |
const ro = new (global.ResizeObserver || function(){return{observe(){},disconnect(){}}})(resize); ro.observe(el);
|
|
|
|
| 244 |
g.userData.tick=(t)=>{ sweep.rotation.z=t*0.0012; };
|
| 245 |
}
|
| 246 |
function buildField(THREE, g, c) { // rosie ecosystem field
|
| 247 |
+
const N=((('ontouchstart' in window)||((navigator&&navigator.maxTouchPoints)||0)>0)?300:600), pos=new Float32Array(N*3); for(let i=0;i<N;i++){ const a=Math.random()*Math.PI*2, rr=2+Math.random()*4, y=(Math.random()-0.5)*6; pos[i*3]=Math.cos(a)*rr; pos[i*3+1]=y; pos[i*3+2]=Math.sin(a)*rr; }
|
| 248 |
const geo=new THREE.BufferGeometry(); geo.setAttribute("position",new THREE.BufferAttribute(pos,3));
|
| 249 |
const pts=new THREE.Points(geo,new THREE.PointsMaterial({color:c,size:0.12,transparent:true,opacity:0.8})); g.add(pts);
|
| 250 |
const core=new THREE.Mesh(new THREE.SphereGeometry(1.6,24,24),new THREE.MeshStandardMaterial({color:c,emissive:c,emissiveIntensity:0.4,transparent:true,opacity:0.5})); g.add(core);
|