Something went wrong. Try again.
data endpoint for entity 90008 (aka. a website)
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286// stop: shelter, bench, live route-ring sign, approaching-bus mirror, and spare puppet hook.import * as THREE from 'three';import * as worldMod from './world.js';import { cam, scene, stops, STOPS, LOOP, bus, busInfo, rideTo, V, state, onFrame } from './world.js';import { you } from './you.js';import { mat } from './look.js';import { phys } from './phys.js';import { STATIONS, LOG, SHELTER_MEDIA, onLive } from './data.js';import { bag, ctex, JP, leash } from './kit.js';import { build as farSide } from './far.js';
const ringSigns = [];
function drawRing(rs, busProg, dwelling, wantStop) { const { k, c, tex } = rs, x = c.getContext('2d'); x.fillStyle = '#fff'; x.fillRect(0, 0, 512, 512); x.strokeStyle = '#000'; x.lineWidth = 14; x.beginPath(); x.arc(256, 256, 246, 0, 7); x.stroke(); x.lineWidth = 6; x.beginPath(); x.arc(256, 256, 150, 0, 7); x.stroke(); x.fillStyle = '#000'; x.textAlign = 'center'; x.textBaseline = 'middle'; x.font = `900 74px ${JP}`; x.fillText(STATIONS[k].jp, 256, 222); x.font = 'bold 28px cookmono'; x.fillText(STATIONS[k].name, 256, 280); x.fillStyle = '#f00'; x.font = 'bold 20px cookmono'; x.fillText(STATIONS[k].sub, 256, 312); x.fillStyle = wantStop !== null && wantStop !== 'any' ? '#0f0' : '#f00'; x.fillRect(188, 332, 136, 6);
for (let i = 0; i < STOPS; i++) { const a = -Math.PI / 2 + i / STOPS * Math.PI * 2; const gx = 256 + Math.cos(a) * 205, gy = 256 + Math.sin(a) * 205; if (wantStop === i) { x.strokeStyle = '#f00'; x.lineWidth = 6; x.beginPath(); x.arc(256 + Math.cos(a) * 150, 256 + Math.sin(a) * 150, 28, 0, 7); x.stroke(); } x.fillStyle = i === k ? '#f00' : (wantStop === i ? '#f00' : '#000'); x.font = `900 23px ${JP}`; x.fillText(STATIONS[i].jp, gx, gy - 9); x.font = 'bold 16px cookmono'; x.fillText(STATIONS[i].short, gx, gy + 13); }
// Live scheduled bus pip orbiting the route ring (#0f0 -> phase accent, #f00 -> blood) const ba = -Math.PI / 2 + (busProg / STOPS) * Math.PI * 2; const bx = 256 + Math.cos(ba) * 150, by = 256 + Math.sin(ba) * 150; x.fillStyle = '#0f0'; x.beginPath(); x.arc(bx, by, dwelling ? 17 : 13, 0, 7); x.fill(); x.strokeStyle = '#000'; x.lineWidth = 4; x.beginPath(); x.arc(bx, by, dwelling ? 17 : 13, 0, 7); x.stroke(); tex.needsUpdate = true;}
const R = .44; let backMat = null;function pole(s, b) { const fxz = V(s.face.x, 0, s.face.z).normalize(), at = V().copy(s.spot).addScaledVector(s.right, 1.6).addScaledVector(fxz, .4); b.add('stick', new THREE.BoxGeometry(.05, 1.88, .05), at.x, .94, at.z, .02, 0, -.02); b.add('stick', new THREE.BoxGeometry(.5, .06, .3), at.x, .03, at.z); const g = new THREE.Group(); g.position.set(at.x, 1.82, at.z); g.lookAt(s.camAt.x, 1.82, s.camAt.z); g.translateZ(.05); g.rotateZ(.035 * (s.k % 2 ? 1 : -1)); scene.add(g);
const c = document.createElement('canvas'); c.width = c.height = 512; const tex = ctex(c), rs = { k: s.k, c, tex, stamp: '' }; drawRing(rs, 0, true, null); ringSigns.push(rs);
g.add(new THREE.Mesh(new THREE.CircleGeometry(R, 20), mat('paper', { map: tex, legible: .85, side: THREE.FrontSide }))); const back = new THREE.Mesh(new THREE.CircleGeometry(R, 20), backMat ||= mat('flat', { colors: ['#0b0b12', '#000000', '#1c1c4a'], hatch: .12 })); back.rotation.y = Math.PI; back.position.z = -.012; g.add(back); g.updateMatrixWorld(true); for (let i = 0; i < STOPS; i++) { const a = -Math.PI / 2 + i / STOPS * Math.PI * 2, here = i === s.k; const n = new THREE.Mesh(new THREE.CircleGeometry(here ? .075 : .06, 10), mat(here ? 'metal' : 'blood')); n.position.set(Math.cos(a) * R * .586, -Math.sin(a) * R * .586, .012); g.add(n); if (here) continue; let lastBtnTap = 0; phys.grabbable({ kind: 'stopbtn', mesh: n, points: [phys.point(g.localToWorld(n.position.clone()), { pinned: true })] }, { onTap: () => { const now = performance.now(); if (now - lastBtnTap < 440 && !state.ride) { lastBtnTap = 0; if (worldMod.warpTo) worldMod.warpTo(i); else { state.here = i; you.home?.(); } return; } lastBtnTap = now; rideTo(i); }, }); }}
export const benchPos = (k) => V(2.86, .40, stops[k].pos.z + 2.35);function bench(s, b) { const p = benchPos(s.k), ry = .42; const part = (key, w, h, d, lx, ly, lz) => { const geo = new THREE.BoxGeometry(w, h, d); geo.translate(lx, ly, lz); geo.rotateY(ry); geo.translate(p.x, 0, p.z); b.add(key, geo); }; part('plank', .78, .035, .15, 0, .382, -.085); part('plank', .78, .035, .15, 0, .382, .085); for (const sx of [-.31, .31]) { part('stick', .045, .37, .045, sx, .185, -.11); part('stick', .045, .37, .045, sx, .185, .11); part('stick', .035, .035, .26, sx, .14, 0); }}
// Spare wooden marionette crossbar hung under the shelter eave: tap to reroll your puppetlet hookTagTex = null;function rerollHook(s) { if (!hookTagTex) { const c = document.createElement('canvas'); c.width = 160; c.height = 112; const x = c.getContext('2d'); x.fillStyle = '#fff'; x.fillRect(0, 0, 160, 112); x.fillStyle = '#000'; x.textAlign = 'center'; x.textBaseline = 'top'; x.font = `900 44px ${JP}`; x.fillText('姿', 80, 10); x.fillStyle = '#f00'; x.font = '22px cookmono'; x.fillText('[who]', 80, 68); hookTagTex = ctex(c); } const top = phys.point(V(1.64, 2.24, s.pos.z - 2.35), { pinned: true }); const g = new THREE.Group(); const bar = new THREE.Mesh(new THREE.BoxGeometry(.38, .022, .028), mat('ink')); const cross = new THREE.Mesh(new THREE.BoxGeometry(.024, .02, .16), mat('ink')); const bead = new THREE.Mesh(new THREE.SphereGeometry(.052, 8, 6), mat('bone')); bead.position.set(0, -.12, 0); const tag = new THREE.Mesh(new THREE.PlaneGeometry(.19, .135), mat('paper', { map: hookTagTex, legible: .9 })); tag.position.set(.10, -.11, .02); g.add(bar, cross, bead, tag); phys.grabbable(leash(phys.body(g, { hangFrom: top, len: .30, radius: .08, billboard: true, mass: 1.2 }), onFrame), { onTap: () => you.reroll(), });}
let shelterBenchMat = null;function shelter(s, b) { const z = s.pos.z - 3.5, x = 1.15; for (const [dx, dz, lean] of [[-.5, -1.2, .03], [-.5, 1.2, -.02], [.55, -1.2, -.03], [.55, 1.2, .04]]) b.add('stick', new THREE.BoxGeometry(.04, 2.3, .04), x + dx, 1.15, z + dz, lean, 0, lean * .7); b.box('roof', 1.45, .05, 2.9, x + .05, 2.32, z, 0, 0, -.06); for (let i = 0; i < 3; i++) b.box('wall', .03, 1.25 - (i === 1 ? .3 : 0), .74, x - .52, 1.25 - (i === 1 ? .15 : 0), z - .8 + i * .8, 0, 0, (i - 1) * .015); for (const dz of [-.8, .8]) b.box('stick', .05, .46, .05, x - .2, .23, z + dz); const benchPlank = new THREE.Mesh(new THREE.BoxGeometry(.38, .052, 1.92), shelterBenchMat ||= mat('ink', { hatch: .28 })); benchPlank.position.set(x - .2, .46, z); benchPlank.rotation.z = .02; benchPlank.frustumCulled = false; scene.add(benchPlank); const benchPick = new THREE.Mesh(new THREE.BoxGeometry(.56, .34, 1.98), new THREE.MeshBasicMaterial({ colorWrite: false, depthWrite: false })); benchPick.position.set(x - .16, .52, z); benchPick.renderOrder = -20; benchPick.frustumCulled = false; scene.add(benchPick); phys.grabbable({ kind: 'bench', mesh: benchPick, points: [phys.point(V(x - .16, .52, z), { pinned: true })], outline: [benchPlank], pickPoints: false }, { onTap: (o, e) => you.sitBench?.(s.k, e), }); rerollHook(s);}
function shelterStickers(s) { if (s.k !== 1 && s.k !== 2) return; const c = document.createElement('canvas'); c.width = 320; c.height = 240; const x = c.getContext('2d'); x.fillStyle = '#fff'; x.fillRect(0, 0, 320, 240); x.strokeStyle = '#000'; x.lineWidth = 4; x.strokeRect(4, 4, 312, 232); x.fillStyle = '#f00'; x.fillRect(4, 4, 312, 34); x.fillStyle = '#fff'; x.font = 'bold 19px cookmono'; x.textBaseline = 'top'; x.fillText('media!!', 14, 11); x.fillStyle = '#000'; x.font = '18px cookmono'; SHELTER_MEDIA.slice(0, 7).forEach((m, i) => x.fillText('· ' + m, 14, 46 + i * 26)); const map = ctex(c); const z = s.pos.z - 3.5; const pm = new THREE.Mesh(new THREE.PlaneGeometry(.46, .34), mat('paper', { map, legible: .92, side: THREE.DoubleSide })); pm.position.set(.655, 1.54, z + .78); pm.rotation.y = Math.PI / 2; pm.rotation.z = -.03; scene.add(pm); const card = phys.grabbable(phys.slip(.54, .40, { map, legible: .95, rows: 2, pocket: true, noTear: true }), { onTap: () => window.open('https://ptr.pet/about/media', '_blank', 'noopener'), }); const pt = phys.point(V(.66, 1.54, z + .78), { pinned: true }); phys.grabbable({ kind: 'poster', mesh: pm, points: [pt], outline: [pm], pickPoints: false }, { onTap: () => phys.openCard(card, pt.p), });}
function timetable(s) { const c = document.createElement('canvas'), x = c.getContext('2d'); c.width = 580; c.height = 412; const map = ctex(c), draw = () => { const rows = LOG.slice(0, 10).map((l) => [l.t.padEnd(5), l.x.replace(/<[^>]+>/g, '').replace(/[\u{1F000}-\u{1FFFF}]/gu, '').replace(/\s+/g, ' ')]); x.fillStyle = '#fff'; x.fillRect(0, 0, c.width, c.height); x.strokeStyle = '#000'; x.lineWidth = 4; x.strokeRect(2, 2, c.width - 4, c.height - 4); x.fillStyle = '#000'; x.fillRect(0, 0, c.width, 46); x.fillStyle = '#fff'; x.textBaseline = 'top'; x.font = `900 26px ${JP}`; x.fillText('電線ログ', 14, 9); x.font = 'bold 21px cookmono'; x.fillText('bluesky wire · @ptr.pet', 132, 12); rows.forEach(([t, tx], i) => { const y = 56 + i * 33; if (i) { x.fillStyle = '#000'; x.fillRect(14, y - 4, c.width - 28, 1); } x.fillStyle = '#f00'; x.font = 'bold 18px cookmono'; x.fillText(t, 14, y); x.fillStyle = '#000'; x.font = '18px cookmono'; x.fillText(tx.length > 36 ? tx.slice(0, 35) + '…' : tx, 78, y); }); x.fillStyle = '#f00'; x.font = 'bold 16px cookmono'; x.textAlign = 'right'; x.fillText('@ptr.pet ->', c.width - 14, c.height - 24); x.textAlign = 'left'; map.needsUpdate = true; }; draw(); onLive(draw); const w = 1.68, h = 1.19, z = s.pos.z + .92; const grp = new THREE.Group(); grp.position.set(-.64, 1.56, z); grp.lookAt(s.camAt.x, 1.68, s.camAt.z); for (const sx of [-w * .44, w * .44]) { const leg = new THREE.Mesh(new THREE.BoxGeometry(.055, 2.48, .055), mat('ink', { hatch: .25 })); leg.position.set(sx, -.45, -.03); grp.add(leg); } const backing = new THREE.Mesh(new THREE.BoxGeometry(w + .08, h + .08, .04), mat('metal', { hatch: .12 })); grp.add(backing); const face = new THREE.Mesh(new THREE.PlaneGeometry(w, h), mat('paper', { map, legible: .92, side: THREE.FrontSide })); face.position.z = .024; grp.add(face); scene.add(grp); const card = phys.grabbable(phys.slip(.72, .52, { map, legible: .96, rows: 2, pocket: true, noTear: true }), { onTap: () => window.open(LOG[0]?.url || 'https://bsky.app/profile/ptr.pet', '_blank', 'noopener'), }); const pt = phys.point(V(-.64, 1.56, z), { pinned: true }); phys.grabbable({ kind: 'board', mesh: face, points: [pt], outline: [backing, face], pickPoints: false }, { onTap: () => phys.openCard(card, pt.p), });}
function mirrors(b) { const c = document.createElement('canvas'); c.width = c.height = 128; const x = c.getContext('2d'), map = ctex(c); let mode = '', lx = 9, ly = 9; const draw = (m, ex = 0, ey = 0, sc = 1) => { x.fillStyle = '#fff'; x.fillRect(0, 0, 128, 128); x.fillStyle = '#000'; x.strokeStyle = '#000'; x.lineWidth = 3; if (m === 'eye') { x.fillRect(0, 0, 128, 128); x.fillStyle = '#fff'; x.beginPath(); x.ellipse(64, 64, 52, 30, 0, 0, 7); x.fill(); x.fillStyle = '#0f0'; x.beginPath(); x.arc(64 + ex * 22, 64 - ey * 10, 19, 0, 7); x.fill(); x.fillStyle = '#000'; x.beginPath(); x.arc(64 + ex * 26, 64 - ey * 12, 8, 0, 7); x.fill(); } else { x.fillRect(0, 70, 128, 3); x.beginPath(); x.moveTo(20, 128); x.lineTo(58, 72); x.moveTo(108, 128); x.lineTo(70, 72); x.stroke(); for (let i = 0; i < 4; i++) x.fillRect(62, 80 + i * 13, 3, 6 + i); if (m === 'bus') { const bw = Math.round(50 * sc), bh = Math.round(46 * sc), bx0 = 64 - Math.round(bw / 2), by0 = 72 - Math.round(bh * .6); x.fillStyle = '#000'; x.fillRect(bx0, by0, bw, bh); x.fillStyle = '#fff'; x.fillRect(bx0 + 4, by0 + 5, Math.max(4, bw - 8), Math.max(4, Math.round(15 * sc))); x.fillStyle = '#f00'; x.fillRect(bx0 + 4, by0 + Math.round(24 * sc), Math.max(4, bw - 8), Math.max(3, Math.round(5 * sc))); } } map.needsUpdate = true; }; draw('road'); const eyes = [], tv = V(); const face = mat('paper', { map, legible: 1 }), rim = mat('flat', { colors: ['#e8641a', '#f4f3dc', '#c6f03a'] }); for (const s of stops) { const at = V(-.9, 0, s.pos.z - 5.2); b.add('stick', new THREE.BoxGeometry(.05, 3.1, .05), at.x, 1.55, at.z, -.03, 0, .02); const g = new THREE.Group(); g.position.set(at.x, 3.1, at.z + .06); g.lookAt(s.camAt.x, 1.6, s.camAt.z); g.scale.setScalar(1.5); scene.add(g); const r = new THREE.Mesh(new THREE.CircleGeometry(.5, 18), rim), f = new THREE.Mesh(new THREE.CircleGeometry(.43, 18), face); f.position.z = .012; const bk = new THREE.Mesh(new THREE.CircleGeometry(.5, 18), rim); bk.rotation.y = Math.PI; bk.position.z = -.012; g.add(r, f, bk); eyes.push(g); } onFrame(() => { const night = state.band > 1.5; let dz = bus.position.z - stops[state.here].park.z; while (dz < -LOOP / 2) dz += LOOP; while (dz > LOOP / 2) dz -= LOOP; const busApproaching = !state.ride && dz >= -3 && dz < 56; const scStep = busApproaching ? Math.max(1, Math.round((1 - Math.max(0, dz) / 56) * 4)) : 0; const m = night ? 'eye' : busApproaching ? 'bus:' + scStep : 'road'; if (night) { const g = eyes[state.here]; g.worldToLocal(tv.copy(state.ride ? cam.position : you.pos).setY(state.ride ? cam.position.y : .5)); const d = Math.max(.5, tv.z), q = (v) => Math.round(THREE.MathUtils.clamp(v / d * 2.4, -1, 1) * 8) / 8, ex = q(tv.x), ey = q(tv.y); if (m !== mode || ex !== lx || ey !== ly) { lx = ex; ly = ey; mode = m; draw('eye', ex, ey); } } else if (m !== mode) { mode = m; if (busApproaching) draw('bus', 0, 0, .35 + scStep * .16); else draw('road'); } });}
export function init() { const b = bag(); for (const s of stops) { pole(s, b); bench(s, b); shelter(s, b); shelterStickers(s); } timetable(stops[3]); mirrors(b); const extra = farSide(b); b.build(scene, { stick: mat('ink', { hatch: .3 }), roof: mat('metal', { hatch: .15 }), wall: mat('bone', { hatch: .4 }), plank: mat('bone', { hatch: .18 }), stone: mat('flat', { colors: ['#b9b7a4', '#f4f3dc', '#8f93c9'], hatch: .1 }), ...extra });
// Redraw only the current stop's route-ring sign at ~5Hz as the bus orbits onFrame(() => { const rs = ringSigns[state.here]; if (!rs) return; const prog = busInfo.stop + (busInfo.stage === 'go' ? Math.round(busInfo.u * 24) / 24 : 0); const dw = busInfo.stage === 'dwell' ? 1 : 0; const w = busInfo.want; const stamp = `${prog.toFixed(2)}|${dw}|${w}`; if (rs.stamp !== stamp) { rs.stamp = stamp; drawRing(rs, prog, !!dw, w); } });}