castle-web-cli 0.4.237 → 0.4.239

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/dist/bundle.d.ts +24 -0
  2. package/dist/bundle.js +447 -4
  3. package/dist/bundleLatin1.d.ts +6 -0
  4. package/dist/bundleLatin1.js +333 -0
  5. package/dist/castle-host/host.d.ts +10 -1
  6. package/dist/castle-host/host.js +133 -9
  7. package/dist/castleJson.d.ts +2 -0
  8. package/dist/castleJson.js +1 -0
  9. package/dist/deckExports.d.ts +35 -0
  10. package/dist/deckExports.js +365 -0
  11. package/dist/importCheckHook.d.ts +1 -0
  12. package/dist/importCheckHook.js +1 -1
  13. package/dist/index.js +21 -0
  14. package/dist/init.js +2 -1
  15. package/dist/multiplayerDoc.d.ts +1 -1
  16. package/dist/multiplayerDoc.js +9 -0
  17. package/dist/platformDoc.js +2 -1
  18. package/dist/playPagePolicy.d.ts +1 -0
  19. package/dist/playPagePolicy.js +8 -3
  20. package/dist/roomLogs.d.ts +39 -0
  21. package/dist/roomLogs.js +166 -0
  22. package/dist/save-deck.js +4 -0
  23. package/kits/base/CLAUDE.md +1 -0
  24. package/kits/base/castle.json +1 -1
  25. package/kits/base/sdk/README.md +113 -2
  26. package/kits/base/sdk/castle.d.ts +6 -2
  27. package/kits/base/sdk/castle.js +2 -0
  28. package/kits/base/sdk/commands.d.ts +56 -1
  29. package/kits/base/sdk/commands.js +29 -1
  30. package/kits/base/sdk/hub.d.ts +17 -0
  31. package/kits/base/sdk/hub.js +33 -9
  32. package/kits/base/sdk/localCache.d.ts +27 -0
  33. package/kits/base/sdk/localCache.js +115 -0
  34. package/kits/base/sdk/localCacheStore.d.ts +15 -0
  35. package/kits/base/sdk/localCacheStore.js +358 -0
  36. package/kits/base/sdk/multiplayer.js +30 -0
  37. package/kits/base/sdk/rooms.d.ts +11 -0
  38. package/kits/base/sdk/rooms.js +22 -0
  39. package/kits/base/sdk/store.d.ts +8 -2
  40. package/kits/base/sdk/store.js +5 -1
  41. package/kits/base/sdk/transport.d.ts +1 -0
  42. package/kits/base/sdk/transport.js +4 -5
  43. package/kits/hub-game/CLAUDE.md +22 -2
  44. package/kits/hub-game/castle.json +8 -5
  45. package/kits/hub-game/code/client/act.js +66 -91
  46. package/kits/hub-game/code/client/actCore.js +134 -0
  47. package/kits/hub-game/code/client/car.js +35 -0
  48. package/kits/hub-game/code/client/chrome.js +208 -381
  49. package/kits/hub-game/code/client/crowdNames.js +2 -2
  50. package/kits/hub-game/code/client/emoteWheel.js +109 -0
  51. package/kits/hub-game/code/client/hats.js +2 -0
  52. package/kits/hub-game/code/client/hookLayer.js +99 -48
  53. package/kits/hub-game/code/client/hostGo.js +77 -0
  54. package/kits/hub-game/code/client/hubControls.js +125 -0
  55. package/kits/hub-game/code/client/hubEntry.js +187 -0
  56. package/kits/hub-game/code/client/hudSurface.js +148 -0
  57. package/kits/hub-game/code/client/hudTree.js +96 -0
  58. package/kits/hub-game/code/client/idle.js +59 -13
  59. package/kits/hub-game/code/client/invites.js +13 -4
  60. package/kits/hub-game/code/client/menuIcons.js +8 -0
  61. package/kits/hub-game/code/client/menuRows.js +8 -2
  62. package/kits/hub-game/code/client/noTrips.js +38 -0
  63. package/kits/hub-game/code/client/qualityEntry.js +6 -1
  64. package/kits/hub-game/code/client/rehello.js +3 -1
  65. package/kits/hub-game/code/client/riders.js +26 -0
  66. package/kits/hub-game/code/client/role.js +79 -0
  67. package/kits/hub-game/code/client/safeLayout.js +32 -3
  68. package/kits/hub-game/code/client/sound.js +10 -3
  69. package/kits/hub-game/code/client/soundscape.js +2 -2
  70. package/kits/hub-game/code/client/soundscapeAmbience.js +38 -8
  71. package/kits/hub-game/code/client/soundscapeBaked.js +24 -5
  72. package/kits/hub-game/code/client/soundscapeCues.js +2 -1
  73. package/kits/hub-game/code/client/state.js +19 -0
  74. package/kits/hub-game/code/client/stuck.js +2 -1
  75. package/kits/hub-game/code/client/talkSurface.js +178 -0
  76. package/kits/hub-game/code/client/talkTree.js +238 -0
  77. package/kits/hub-game/code/client/tiers.js +8 -5
  78. package/kits/hub-game/code/client/uiDom.js +600 -0
  79. package/kits/hub-game/code/client/uiTree.js +359 -0
  80. package/kits/hub-game/code/client/vehicle.js +156 -0
  81. package/kits/hub-game/code/client/wear.js +27 -5
  82. package/kits/hub-game/code/client/worldLabels.js +13 -3
  83. package/kits/hub-game/code/client/yours.js +10 -3
  84. package/kits/hub-game/code/server/actors.js +4 -3
  85. package/kits/hub-game/code/server/analytics.js +61 -18
  86. package/kits/hub-game/code/server/decor.js +56 -16
  87. package/kits/hub-game/code/server/doorAnalytics.js +2 -5
  88. package/kits/hub-game/code/server/hub.js +261 -46
  89. package/kits/hub-game/code/server/idle.js +118 -5
  90. package/kits/hub-game/code/server/loadAbandon.js +2 -5
  91. package/kits/hub-game/code/server/manifest.js +46 -4
  92. package/kits/hub-game/code/server/npcs.js +4 -2
  93. package/kits/hub-game/code/server/players.js +3 -0
  94. package/kits/hub-game/code/server/role.js +142 -0
  95. package/kits/hub-game/code/server/standing.js +6 -4
  96. package/kits/hub-game/code/server/trackQueue.js +29 -0
  97. package/kits/hub-game/code/server/vehicle.js +126 -0
  98. package/kits/hub-game/code/shared/car.js +52 -0
  99. package/kits/hub-game/code/shared/deckFlags.js +34 -0
  100. package/kits/hub-game/code/shared/deviceClass.js +39 -0
  101. package/kits/hub-game/code/shared/expression.js +9 -0
  102. package/kits/hub-game/code/systems/hub.js +281 -86
  103. package/kits/hub-game/docs/analytics.md +15 -3
  104. package/kits/hub-game/docs/contract.md +352 -14
  105. package/kits/hub-game/docs/vehicle-preset.md +132 -0
  106. package/kits/hub-game/models/hats/baker-cap.pxmodel +89 -0
  107. package/kits/hub-game/models/hats/chef-toque.pxmodel +60 -0
  108. package/kits/hub-game/models/hats/delivery-cap.pxmodel +105 -0
  109. package/kits/hub-game/models/hats/fire-helmet.pxmodel +87 -0
  110. package/kits/hub-game/models/hats/hard-hat.pxmodel +71 -0
  111. package/kits/hub-game/models/hats/nurse-cap.pxmodel +61 -0
  112. package/kits/hub-game/models/hats/police-cap.pxmodel +105 -0
  113. package/kits/hub-game/models/hats/teacher-beret.pxmodel +52 -0
  114. package/kits/hub-game/models/role/square/top-apron.pxmodel +109 -0
  115. package/kits/hub-game/models/role/square/top-cardigan.pxmodel +141 -0
  116. package/kits/hub-game/models/role/square/top-coat.pxmodel +157 -0
  117. package/kits/hub-game/models/role/square/top-scrubs.pxmodel +93 -0
  118. package/kits/hub-game/models/role/square/top-tabard.pxmodel +109 -0
  119. package/kits/hub-game/models/role/square/top-vest.pxmodel +109 -0
  120. package/kits/hub-game/models/role/tool-bag.pxmodel +75 -0
  121. package/kits/hub-game/models/role/tool-bell.pxmodel +71 -0
  122. package/kits/hub-game/models/role/tool-hose.pxmodel +60 -0
  123. package/kits/hub-game/models/role/tool-parcel.pxmodel +61 -0
  124. package/kits/hub-game/models/role/tool-torch.pxmodel +55 -0
  125. package/kits/hub-game/models/role/tool-tray.pxmodel +75 -0
  126. package/kits/hub-game/models/role/top-apron.pxmodel +70 -0
  127. package/kits/hub-game/models/role/top-cardigan.pxmodel +102 -0
  128. package/kits/hub-game/models/role/top-coat.pxmodel +79 -0
  129. package/kits/hub-game/models/role/top-scrubs.pxmodel +54 -0
  130. package/kits/hub-game/models/role/top-tabard.pxmodel +70 -0
  131. package/kits/hub-game/models/role/top-vest.pxmodel +70 -0
  132. package/kits/hub-game/package-lock.json +1 -1
  133. package/kits/hub-game/package.json +1 -1
  134. package/kits/hub-game/scripts/check.mjs +7 -4
  135. package/kits/hub-game/scripts/fixtures/car-vectors.json +279 -0
  136. package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +2 -1
  137. package/kits/hub-game/scripts/fixtures/hud-surface.json +670 -0
  138. package/kits/hub-game/scripts/fixtures/talk-surface.json +3930 -0
  139. package/kits/hub-game/scripts/gen-hats.mjs +46 -2
  140. package/kits/hub-game/scripts/gen-role.mjs +80 -0
  141. package/kits/hub-game/scripts/test-act-core.mjs +167 -0
  142. package/kits/hub-game/scripts/test-actions-client.mjs +34 -0
  143. package/kits/hub-game/scripts/test-actors.mjs +48 -0
  144. package/kits/hub-game/scripts/test-analytics.mjs +100 -6
  145. package/kits/hub-game/scripts/test-apply-deck.mjs +122 -0
  146. package/kits/hub-game/scripts/test-back-visibility.mjs +3 -1
  147. package/kits/hub-game/scripts/test-ballot.mjs +2 -0
  148. package/kits/hub-game/scripts/test-car.mjs +43 -0
  149. package/kits/hub-game/scripts/test-decor-client.mjs +2 -1
  150. package/kits/hub-game/scripts/test-decor.mjs +77 -0
  151. package/kits/hub-game/scripts/test-device-class.mjs +83 -0
  152. package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
  153. package/kits/hub-game/scripts/test-emote-wheel.mjs +374 -0
  154. package/kits/hub-game/scripts/test-hats.mjs +5 -4
  155. package/kits/hub-game/scripts/test-host-go.mjs +265 -0
  156. package/kits/hub-game/scripts/test-hub-controls.mjs +108 -0
  157. package/kits/hub-game/scripts/test-hub-entry.mjs +531 -0
  158. package/kits/hub-game/scripts/test-hub-ops.mjs +103 -0
  159. package/kits/hub-game/scripts/test-hub-trip.mjs +20 -1
  160. package/kits/hub-game/scripts/test-hud-clear.mjs +12 -2
  161. package/kits/hub-game/scripts/test-hud-rate.mjs +6 -2
  162. package/kits/hub-game/scripts/test-hud-surface.mjs +272 -0
  163. package/kits/hub-game/scripts/test-idle.mjs +347 -1
  164. package/kits/hub-game/scripts/test-interest-cells.mjs +8 -1
  165. package/kits/hub-game/scripts/test-invites-client.mjs +42 -1
  166. package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
  167. package/kits/hub-game/scripts/test-manifest.mjs +30 -0
  168. package/kits/hub-game/scripts/test-menu-client.mjs +1 -1
  169. package/kits/hub-game/scripts/test-no-trips.mjs +42 -0
  170. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  171. package/kits/hub-game/scripts/test-quality.mjs +13 -0
  172. package/kits/hub-game/scripts/test-rehello.mjs +258 -3
  173. package/kits/hub-game/scripts/test-resume-pose-server.mjs +203 -0
  174. package/kits/hub-game/scripts/test-resync.mjs +196 -0
  175. package/kits/hub-game/scripts/test-role-client.mjs +427 -0
  176. package/kits/hub-game/scripts/test-role.mjs +350 -0
  177. package/kits/hub-game/scripts/test-safe-layout.mjs +50 -1
  178. package/kits/hub-game/scripts/test-soundscape.mjs +124 -7
  179. package/kits/hub-game/scripts/test-standing.mjs +15 -1
  180. package/kits/hub-game/scripts/test-talk-surface.mjs +296 -0
  181. package/kits/hub-game/scripts/test-tiers.mjs +13 -0
  182. package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
  183. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +96 -0
  184. package/kits/hub-game/scripts/test-ui-tree.mjs +711 -0
  185. package/kits/hub-game/scripts/test-vehicle-client.mjs +168 -0
  186. package/kits/hub-game/scripts/test-vehicle.mjs +135 -0
  187. package/kits/hub-game/scripts/test-world-labels.mjs +40 -0
  188. package/kits/hub-game/scripts/test-yours.mjs +33 -0
  189. package/kits/hub-game/tools/hubScene/export.mjs +613 -0
  190. package/kits/hub-game/tools/hubScene/hubdata.mjs +921 -0
  191. package/kits/hub-game/tools/hubScene/merge-root.mjs +39 -0
  192. package/kits/hub-game/tools/hubScene/nodeworld.mjs +227 -0
  193. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +810 -0
  194. package/kits/hub-game/tools/hubScene/test/fixture.json +637 -0
  195. package/kits/hub-game/tools/hubScene/test/paint-export.mjs +40 -0
  196. package/kits/hub-game/tools/hubScene/test/upload.test.mjs +655 -0
  197. package/kits/hub-game/tools/hubScene/upload.mjs +636 -0
  198. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +301 -0
  199. package/kits/multiplayer-3d/castle.json +4 -4
  200. package/kits/multiplayer-3d/code/client/resumeGate.js +30 -2
  201. package/kits/multiplayer-3d/code/client/steer.js +3 -1
  202. package/kits/multiplayer-3d/code/systems/multiplayer.js +30 -2
  203. package/kits/multiplayer-3d/package-lock.json +1 -1
  204. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +74 -2
  205. package/kits/physics-3d/CLAUDE.md +1 -1
  206. package/kits/physics-3d/behaviors/Player.jsx +37 -27
  207. package/kits/physics-3d/castle.json +2 -2
  208. package/kits/physics-3d/docs/engine-geometry-memory.md +23 -0
  209. package/kits/physics-3d/engine3d/memoryprofile.js +17 -0
  210. package/kits/physics-3d/engine3d/playerRun.js +6 -1
  211. package/kits/physics-3d/engine3d/pxmodel.js +6 -1
  212. package/kits/physics-3d/engine3d/world3d.js +6 -3
  213. package/kits/physics-3d/package.json +1 -1
  214. package/kits/physics-3d/play/behaviors/Player.js +40 -28
  215. package/kits/physics-3d/scripts/test-memory-profile.mjs +237 -0
  216. package/kits/physics-3d/systems/physics3d.js +5 -2
  217. package/kits/real-time/castle.json +2 -2
  218. package/kits/real-time/code/client/messages.js +5 -0
  219. package/kits/real-time/code/server/session.js +28 -1
  220. package/kits/real-time/package-lock.json +1 -1
  221. package/package.json +5 -4
  222. package/vendor/three/LICENSE +21 -0
  223. package/vendor/three/build/three.core.js +58773 -0
  224. package/vendor/three/build/three.module.js +18251 -0
  225. package/vendor/three/examples/jsm/controls/OrbitControls.js +1860 -0
  226. package/vendor/three/examples/jsm/controls/TransformControls.js +1918 -0
  227. package/vendor/three/examples/jsm/exporters/GLTFExporter.js +3595 -0
  228. package/vendor/three/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
  229. package/vendor/three/examples/jsm/math/MeshSurfaceSampler.js +315 -0
  230. package/vendor/three/examples/jsm/postprocessing/EffectComposer.js +363 -0
  231. package/vendor/three/examples/jsm/postprocessing/MaskPass.js +195 -0
  232. package/vendor/three/examples/jsm/postprocessing/OutputPass.js +139 -0
  233. package/vendor/three/examples/jsm/postprocessing/Pass.js +191 -0
  234. package/vendor/three/examples/jsm/postprocessing/RenderPass.js +183 -0
  235. package/vendor/three/examples/jsm/postprocessing/ShaderPass.js +135 -0
  236. package/vendor/three/examples/jsm/shaders/CopyShader.js +52 -0
  237. package/vendor/three/examples/jsm/shaders/OutputShader.js +103 -0
  238. package/vendor/three/examples/jsm/utils/BufferGeometryUtils.js +1435 -0
  239. package/vendor/three/package.json +134 -0
@@ -6,7 +6,7 @@ export function drawMenuRows({ el, sheet, scroll, spec, signal, pick }) {
6
6
  const readOnly = spec.readOnly === true || item.readOnly === true;
7
7
  const row = el(readOnly ? 'div' : 'button', {
8
8
  width: '100%', boxSizing: 'border-box', minHeight: '32px', padding: '6px 8px',
9
- display: 'grid', gridTemplateColumns: item.columns ? 'minmax(0, 1fr) minmax(0, 4fr) minmax(0, 2fr)' : '1fr',
9
+ display: 'grid', gridTemplateColumns: item.columns ? 'minmax(0, 6em) minmax(4em, 1fr) minmax(0, max-content)' : '1fr',
10
10
  alignItems: 'center', gap: '8px', textAlign: 'left',
11
11
  color: 'inherit', font: 'inherit', lineHeight: '20px', background: 'transparent',
12
12
  border: '0', borderBottom: '1px solid var(--castle-border-2, rgba(255,255,255,.25))',
@@ -14,8 +14,14 @@ export function drawMenuRows({ el, sheet, scroll, spec, signal, pick }) {
14
14
  }, scroll);
15
15
  row.dataset.menuRow = '';
16
16
  row.dataset.id = item.id;
17
+ // The outer columns break between words where they can, so a narrow
18
+ // sheet (a phone held sideways) does not split a short name: the left
19
+ // one is a steady 6em so the middles line up, the right one takes its
20
+ // own width, and both shrink rather than overflow. The middle column
21
+ // keeps at least 4em, gets the rest and wraps anywhere.
17
22
  for (const [index, text] of (item.columns ?? [item.label]).entries()) {
18
- el('span', { minWidth: '0', whiteSpace: 'normal', ...(index === 2 ? { textAlign: 'right' } : {}) }, row).textContent = text;
23
+ const outer = item.columns && index !== 1;
24
+ el('span', { minWidth: '0', whiteSpace: 'normal', ...(outer ? { overflowWrap: 'break-word' } : {}), ...(index === 2 ? { textAlign: 'right' } : {}) }, row).textContent = text;
19
25
  }
20
26
  if (!readOnly) {
21
27
  row.type = 'button';
@@ -0,0 +1,38 @@
1
+ // Whether this page's host cannot go through doors (contract v1.156). A host
2
+ // from before hub commands (released iOS Castle 1.150 and 1.151) refuses each
3
+ // of them with UNKNOWN_COMMAND, `hub.go` among them; `Hub.doors` asks the same
4
+ // host without side effects. Any other answer -- rows, `unavailable` (a host
5
+ // with no hub ops, like the dev serve), a timeout -- says the host may go, and
6
+ // the player is counted on pads as before.
7
+ export async function hostHasNoTrips(sdk) {
8
+ if (typeof sdk?.Hub?.doors !== 'function') {
9
+ return false;
10
+ }
11
+ try {
12
+ await sdk.Hub.doors();
13
+ return false;
14
+ } catch (err) {
15
+ return err?.code === 'UNKNOWN_COMMAND';
16
+ }
17
+ }
18
+
19
+ // After each hello: an app that cannot go through doors tells the place so
20
+ // (`hub-no-trips`), once its host has answered, on that connection if it is
21
+ // still the current one. The host is asked once a page, and only in the app:
22
+ // every web host has door trips, so a web page sends and asks nothing new.
23
+ export function makeNoTrips(sdk, view = globalThis.window) {
24
+ let ask = null;
25
+ return {
26
+ afterHello(net, current) {
27
+ if (view?.CastleEmbed?.host !== 'mobile') {
28
+ return null;
29
+ }
30
+ ask ??= hostHasNoTrips(sdk);
31
+ return ask.then((none) => {
32
+ if (none && current() && !net.closed?.()) {
33
+ net.send({ k: 'hub-no-trips' });
34
+ }
35
+ });
36
+ },
37
+ };
38
+ }
@@ -5,6 +5,7 @@ import { SceneRuntime } from '@imports/castle.physics-2d/engine/scene';
5
5
  import { getBlueprintTemplate, mergeComponents } from '@imports/castle.physics-2d/engine/blueprint';
6
6
  import { drawInstances } from '@imports/castle.physics-3d/engine3d/optimize';
7
7
  import { syncActors } from '@imports/castle.physics-3d/engine3d/world3d';
8
+ import { lowMemoryDevice } from '@imports/castle.physics-3d/engine3d/memoryprofile.js';
8
9
  import { deck } from './state.js';
9
10
  import { makeTiers } from './tiers.js';
10
11
  import { readQuality } from '../shared/quality.js';
@@ -35,7 +36,11 @@ export function installQualityLoad(Runtime, { make = makeTiers, componentsOf, pr
35
36
  if (q) {resetQualityVisit(q);}
36
37
  return original.call(this, data);
37
38
  }
38
- const q = qualityFor(this) ?? makeQualityVisit(make({ weakest: deck.weakestTier === true }));
39
+ // The constructor's first load precedes world creation. Match the player
40
+ // profile then; later loads use the actual world's decision.
41
+ const lowMemory = this.three?.lowMemory ?? (typeof data.engine?.lowMemory === 'boolean'
42
+ ? data.engine.lowMemory : lowMemoryDevice().on);
43
+ const q = qualityFor(this) ?? makeQualityVisit(make({ weakest: deck.weakestTier === true, lowMemory }));
39
44
  pick(q.tiers, this.three?.renderer);
40
45
  q.build = build;
41
46
  q.refreshInstances = (scene) => {
@@ -68,7 +68,9 @@ export function watch(mp, net, onIdentity = null) {
68
68
  });
69
69
  }
70
70
  for (const msg of messages ?? []) {
71
- if (msg?.k === WORLD) {
71
+ // A resync's WORLD (`again`) re-admits nobody: the client asked
72
+ // for it, from a session that still has it.
73
+ if (msg?.k === WORLD && msg.again !== 1) {
72
74
  if (w.seen) {
73
75
  w.again += 1;
74
76
  } else {
@@ -0,0 +1,26 @@
1
+ // Riders on their seats (contract v1.160), apart from vehicle.js so the hook
2
+ // layer can pin them without loading the model builder.
3
+ import { seatPose } from '../shared/car.js';
4
+
5
+ const DEG = Math.PI / 180;
6
+ export function actorFor(scene, local, id) {
7
+ return id === scene.multiplayer?.net?.selfId?.() ? local : scene.getActor?.(scene.multiplayer?.avatars?.actors?.get(id));
8
+ }
9
+ // Transform is the pose multiplayer has interpolated for this viewer, rather
10
+ // than the latest server sample. This same Transform positions the car node.
11
+ export function pinRiders(scene, local, cars) {
12
+ for (const [id, car] of Object.entries(cars)) {
13
+ const driver = actorFor(scene, local, id), at = driver?.components.Transform;
14
+ for (const [seat, rider] of Object.entries(car.riders ?? {})) {
15
+ const actor = actorFor(scene, local, rider), t = actor?.components.Transform;
16
+ if (!t) {continue;}
17
+ if (!at) {t.y = -10000; continue;}
18
+ const facing = (at.rotationY ?? 0) * DEG;
19
+ Object.assign(t, seatPose(at, facing, car, Number(seat)), { rotationY: at.rotationY ?? 0 });
20
+ if (actor === local) {
21
+ scene.physics3d?.bodyOf?.(actor)?.setTranslation({ x: t.x, y: t.y, z: t.z }, true);
22
+ scene.physics3d?.setVelocity?.(actor, { x: 0, y: 0, z: 0 });
23
+ }
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,79 @@
1
+ // Visit-only role outfits and chips (contract §11, v1.157). Pure catalogue
2
+ // and descriptions, also read by the server; no resources without a role.
3
+ export const ROLE_TOPS = ['vest', 'scrubs', 'coat', 'apron', 'cardigan', 'tabard'];
4
+ export const ROLE_TOOLS = ['torch', 'bag', 'hose', 'tray', 'bell', 'parcel'];
5
+ export const ROLE_MAIN = '#3aa0d8';
6
+ export const roleFile = (kind, id, square = false) => `models/role/${square ? 'square/' : ''}${kind}-${id}.pxmodel`;
7
+ const mm = (n) => Math.round(n * 1000) / 1000;
8
+ const DEFAULT_FIT = { chest: [0.09, 0.6, 0.2, 20], waist: [0.37, 0.23, 0.23], sash: [0.51, 0.35, 0.26, 45], hand: [-0.33, 0.34, 0.01] };
9
+
10
+ export function roleLook(item, fit = null) {
11
+ const kind = item?.class;
12
+ if (!(kind === 'top' ? ROLE_TOPS : kind === 'tool' ? ROLE_TOOLS : []).includes(item?.shape) || typeof item?.color !== 'string' || !/^#[0-9a-f]{6}$/i.test(item.color)) { return null; }
13
+ const f = fit ?? DEFAULT_FIT;
14
+ const base = { shape: `${kind}-${item.shape}`, file: roleFile(kind, item.shape, kind === 'top' && f.square === true), color: item.color.toLowerCase(), yaw: 0, tilt: 0 };
15
+ if (kind === 'tool') {
16
+ const [x, y, z] = f.hand;
17
+ return { ...base, position: [x, mm(y - 0.7), z], scale: [1.2, 1.2, 1.2] };
18
+ }
19
+ const [y, rx, rz] = f.waist;
20
+ // Waist to just below the chest. One-piece bodies whose chest anchor is at
21
+ // waist height get a short band below it, leaving their face clear.
22
+ const high = Math.max(0.06, f.chest[1] - y - 0.03);
23
+ const bottom = Math.min(y, f.chest[1] - 0.03 - high);
24
+ const wide = Math.max(rx, f.sash[1] * Math.cos(f.sash[3] * Math.PI / 180));
25
+ return { ...base, position: [0, mm(bottom - 0.7), 0], scale: [mm(wide / 0.2), mm(high / 0.2), mm(Math.max(rz, f.sash[2]) / 0.2)] };
26
+ }
27
+
28
+ export function rolePieces(roles, kind) {
29
+ return new Map([...roles].filter(([, role]) => role?.[kind]).map(([id, role]) => [id, { class: kind, shape: role[kind], color: role.color }]));
30
+ }
31
+
32
+ // Role hats take the Look slot only when named. Clearing restores try-on or
33
+ // owned Look; role tops/tools mask only conflicting Earned classes.
34
+ export function roleWearing(wearing, roles) {
35
+ if (!roles.size) { return wearing; }
36
+ const out = new Map(wearing);
37
+ for (const [id, role] of roles) {
38
+ if (role?.hat) { out.set(id, { kind: `hat-${role.hat}`, color: role.color, rarity: 0 }); }
39
+ }
40
+ return out;
41
+ }
42
+
43
+ export function roleEarned(earned, roles) {
44
+ if (!roles.size) { return earned; }
45
+ return new Map([...earned].filter(([id, item]) => {
46
+ const role = roles.get(id);
47
+ return !(role?.top && ['belt', 'sash'].includes(item?.class)) && !(role?.tool && item?.class === 'held');
48
+ }));
49
+ }
50
+
51
+ // Reuse marks' chrome, contrast and label list. Anchor to the name tag, with
52
+ // the chip below the tag's projected bottom, independent of camera pitch.
53
+ export function roleItems(scene, local, cam, view, roles, project) {
54
+ const mp = scene.multiplayer;
55
+ const self = mp?.net?.selfId?.();
56
+ const out = [];
57
+ for (const [playerId, role] of roles) {
58
+ const actorId = playerId === self ? local?.id : mp?.avatars?.actors?.get(playerId);
59
+ const node = actorId ? scene.three?.nodes?.get(actorId)?.node : null;
60
+ let visible = Boolean(node);
61
+ for (let parent = node; parent; parent = parent.parent) {
62
+ if (parent.visible === false) { visible = false; break; }
63
+ }
64
+ const tag = mp?.avatars?.tags?.get(playerId === self ? 'self' : playerId)?.sprite;
65
+ // The kit intentionally hides the local name; the role is still shown
66
+ // over that body. Other players follow the name's distance/crowd hide.
67
+ if (playerId !== self && tag && (!tag.visible || !(tag.material?.opacity > 0))) { continue; }
68
+ const at = visible ? (playerId === self ? local : scene.getActor(actorId))?.components?.Transform : null;
69
+ const screen = at ? project(cam, at.x, at.y + 1.25, at.z, view) : null;
70
+ if (screen) {
71
+ const up = cam?.matrixWorld?.elements;
72
+ const half = Math.abs(tag?.scale?.y ?? 0) / 2;
73
+ const bottom = up && half ? project(cam, at.x - up[4] * half, at.y + 1.25 - up[5] * half, at.z - up[6] * half, view) : null;
74
+ // Marks' pill is about 30 px high including its border; leave 4 px.
75
+ out.push({ id: `role:${playerId}`, x: screen.x, y: (bottom?.y ?? screen.y + 15) + 34, text: role.label, color: role.color, opacity: playerId === self ? 1 : tag?.material?.opacity ?? 1 });
76
+ }
77
+ }
78
+ return out;
79
+ }
@@ -40,7 +40,7 @@ export function safePlacement(box, view, margin = {}, bands = []) {
40
40
 
41
41
  // A modal/card may scroll in a free vertical interval instead of covering the
42
42
  // controls it leaves visible. Unlike a projected label, it has no world anchor.
43
- export function panelPlacement(box, view, margin = {}, bands = []) {
43
+ export function panelPlacement(box, view, margin = {}, bands = [], minWidth = 160) {
44
44
  const base = safePlacement(box, view, margin);
45
45
  const top = Math.max(margin.top ?? 6, view.insets.top);
46
46
  const bottom = view.h - Math.max(margin.bottom ?? 6, view.insets.bottom);
@@ -52,7 +52,7 @@ export function panelPlacement(box, view, margin = {}, bands = []) {
52
52
  // when a wider vertical interval is available alongside the column.
53
53
  const starts = [base.x, left, ...bands.map((band) => band.right + 6)].filter((x) => x >= left && x < right);
54
54
  for (const x of starts) {
55
- const widths = [Math.min(base.w, right - x), ...bands.map((band) => Math.min(base.w, band.left - 6 - x))].filter((w) => w >= Math.min(160, base.w));
55
+ const widths = [Math.min(base.w, right - x), ...bands.map((band) => Math.min(base.w, band.left - 6 - x))].filter((w) => w >= Math.min(minWidth, base.w));
56
56
  for (const w of widths) {
57
57
  let intervals = [[top, bottom]];
58
58
  for (const band of bands) {
@@ -90,6 +90,25 @@ export function stackPlacement(sizes, view, ceiling, gap = 6) {
90
90
  });
91
91
  }
92
92
 
93
+ // A standing text line (the HUD prompt) beside the bottom-right control
94
+ // column: narrowed into the lane left of any column box it would cover, or
95
+ // lifted above that box when the lane is narrower than `minLane`.
96
+ export function besideColumn(placed, view, margin = {}, column = [], minLane = 160) {
97
+ const left = Math.max(margin.left ?? 6, view.insets.left);
98
+ let { x, y, w, h } = placed;
99
+ for (const box of [...column].sort((a, b) => b.bottom - a.bottom)) {
100
+ if (!overlaps(rect(x, y, w, h), box)) {continue;}
101
+ const lane = box.left - 6 - left;
102
+ if (lane >= Math.min(w, minLane)) {
103
+ w = Math.min(w, lane);
104
+ x = Math.max(left, Math.min(x, box.left - 6 - w));
105
+ } else {
106
+ y = Math.max(view.insets.top, box.top - 6 - h);
107
+ }
108
+ }
109
+ return { x, y, w, h };
110
+ }
111
+
93
112
  const visibleRect = (node) => {
94
113
  if (!node?.getBoundingClientRect || node.isConnected === false) {return null;}
95
114
  for (let parent = node; parent; parent = parent.parentElement ?? parent.parent) {
@@ -184,6 +203,8 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
184
203
  const at = placements[index];
185
204
  write(entry.stackNode ?? entry.node, 'translate', `${at.x - box.left}px ${at.y - box.top}px`);
186
205
  });
206
+ const column = stack.flatMap(({ entry }) => [entry.node, ...(entry.reportNodes?.() ?? []).map((item) => item.node)])
207
+ .map(visibleRect).filter(Boolean);
187
208
  const controls = [];
188
209
  const transient = [];
189
210
  // Controls are placed before transient text, which yields to their boxes.
@@ -192,6 +213,12 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
192
213
  for (const entry of current) {
193
214
  if (entry.projected) {continue;}
194
215
  const { node, kind, margin } = entry;
216
+ // A pinned card fits itself to the view; it is an obstacle, never moved.
217
+ if (entry.pinned) {
218
+ const own = visibleRect(node);
219
+ if (own) {controls.push(own);}
220
+ continue;
221
+ }
195
222
  let box = visibleRect(node);
196
223
  if (!box) {continue;}
197
224
  const bands = [...corners];
@@ -206,7 +233,9 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
206
233
  const hudBox = visibleRect(hud());
207
234
  if (hudBox) {bands.push(hudBox);}
208
235
  }
209
- const place = (value) => kind === 'card' ? panelPlacement(value, viewport, margin, bands) : safePlacement(value, viewport, margin, bands);
236
+ const place = (value) => kind === 'card' ? panelPlacement(value, viewport, margin, bands)
237
+ : kind === 'text' && !entry.transient && entry.stack === undefined ? besideColumn(safePlacement(value, viewport, margin, bands), viewport, margin, column)
238
+ : safePlacement(value, viewport, margin, bands);
210
239
  let placed = place(box);
211
240
  // The centered HUD title row has a lane between both native corners.
212
241
  if (kind === 'hud' && box.top < viewport.insets.top + 56) {
@@ -42,6 +42,13 @@ export function soundUrl(file, listed, content, ownMedia = initialMedia) {
42
42
  return Object.hasOwn(source, file) ? source[file] : null;
43
43
  }
44
44
 
45
+ // Where a one-shot plays from: its scene actor, or (a car's horn, v1.160) a
46
+ // player's drawn body -- this viewer's own Player actor for their own.
47
+ function sourceOf(scene, local, event) {
48
+ if (!event.player) {return event.actor;}
49
+ return event.player === scene.multiplayer?.net?.selfId?.() ? local?.id : scene.multiplayer?.avatars?.actors?.get(event.player);
50
+ }
51
+
45
52
  export function makeSound() {
46
53
  // actorId -> { key, el, volume, radius }
47
54
  const loops = new Map();
@@ -165,11 +172,11 @@ export function makeSound() {
165
172
  }
166
173
  for (const event of events) {
167
174
  const src = typeof event.file === 'string' ? url(event.file) : null;
168
- const d = distance(scene, me, event.actor);
175
+ const d = distance(scene, me, sourceOf(scene, local, event));
169
176
  if (!src || shots.size >= MAX_SHOTS || heard(event.volume, event.radius, d) <= 0) {
170
177
  continue;
171
178
  }
172
- const shot = { el: new Audio(src), actor: event.actor, volume: event.volume, radius: event.radius };
179
+ const shot = { el: new Audio(src), actor: event.actor, player: event.player, volume: event.volume, radius: event.radius };
173
180
  shot.el.volume = heard(shot.volume, shot.radius, d);
174
181
  shots.add(shot);
175
182
  const done = () => {
@@ -179,7 +186,7 @@ export function makeSound() {
179
186
  Promise.resolve(shot.el.play()).catch(done);
180
187
  }
181
188
  for (const shot of shots) {
182
- shot.el.volume = heard(shot.volume, shot.radius, distance(scene, me, shot.actor));
189
+ shot.el.volume = heard(shot.volume, shot.radius, distance(scene, me, sourceOf(scene, local, shot)));
183
190
  }
184
191
  },
185
192
  // Everything playing made silent where it stands, until the next frame
@@ -362,11 +362,11 @@ const gesturedPages = new WeakSet();
362
362
  // where the player's first gesture is heard, `onHide` is called as the page
363
363
  // is hidden (the hub system quiets the place's own sound files there, which
364
364
  // no frame would get to).
365
- export function makeSoundscape(options, { audio = Shared, storage = pageStorage(), doc = globalThis.document ?? null, win = globalThis.window ?? null, nav = globalThis.navigator ?? null, random = Math.random, onHide = () => {}, isOn = null, loudestLoop = () => 0, cueVoices, createOfflineContext } = {}) {
365
+ export function makeSoundscape(options, { audio = Shared, storage = pageStorage(), doc = globalThis.document ?? null, win = globalThis.window ?? null, nav = globalThis.navigator ?? null, random = Math.random, onHide = () => {}, isOn = null, loudestLoop = () => 0, cueVoices, createOfflineContext, lowMemory = false } = {}) {
366
366
  options = sanitiseSoundscape(options, BEDS, SURFACES);
367
367
  const want = { babble: options?.babble !== false, steps: options?.steps !== false };
368
368
  const map = options?.ambience || typeof options?.steps === 'object' ? makeSoundscapeMap(options, SURFACES) : null;
369
- const ambience = options?.ambience ? makeAmbience(options.ambience, { noise: noiseOf, seeded, hash: hashOf, loudestLoop, random, win, createOfflineContext, canBake: () => live() && ctx?.state === 'running' && Number.isFinite(ctx.currentTime) }) : null;
369
+ const ambience = options?.ambience ? makeAmbience(options.ambience, { noise: noiseOf, seeded, hash: hashOf, loudestLoop, random, win, createOfflineContext, lowMemory, canBake: () => live() && ctx?.state === 'running' && Number.isFinite(ctx.currentTime) }) : null;
370
370
  let mapScene = null;
371
371
  const settings = readSettings(storage);
372
372
  // The context once it has been asked for, and what hangs off it.
@@ -3,7 +3,7 @@
3
3
 
4
4
  import { makeZoneMusic, ZONE_SONGS } from './soundscapeMusic.js';
5
5
  import { HARBOUR_WAVE_RMS } from './soundscapeWaves.js';
6
- import { bakeBed, makeBedGenerator, offlineFactory, pauseBedBakes, LOOP_S } from './soundscapeBaked.js';
6
+ import { bakeBed, makeBedGenerator, offlineFactory, pauseBedBakes, retainBedBake, LOOP_S } from './soundscapeBaked.js';
7
7
  import { tracked } from './soundscapeSynthesis.js';
8
8
 
9
9
  const MUSIC_LEVEL = 0.0141804316 * 10 ** (1 / 20);
@@ -75,10 +75,10 @@ function makeBed(ctx, bus, name, music, noise, next, musicSeed, deps, requestBak
75
75
  const air = made(ctx.createGain());
76
76
  air.connect(mix);
77
77
  const levels = AMBIENCE_LEVELS[name];
78
- const bed = { name, nodes, mix, air, levels, p, next, animal: null, animalAt: ctx.currentTime + 3 + next() * 8, noteAt: ctx.currentTime + 0.03, note: 0, pattern: [], fade: null, gain: 0, ducked: null };
78
+ const bed = { lowMemory: deps.lowMemory === true, name, nodes, mix, air, levels, p, next, animal: null, animalAt: ctx.currentTime + 3 + next() * 8, noteAt: ctx.currentTime + 0.03, note: 0, pattern: [], fade: null, gain: 0, ducked: null };
79
79
  if (Object.hasOwn(LOOP_S, name)) {
80
80
  const factory = offlineFactory(deps.createOfflineContext, deps.win);
81
- if (factory) {
81
+ if (factory && (!deps.lowMemory || name === deps.bakedKind)) {
82
82
  bed.baked = true;
83
83
  // Completion only hands the buffer to the frame scheduler. It never
84
84
  // creates live nodes after quiet/dispose, or outside the sound gate.
@@ -163,6 +163,12 @@ function stopBed(bed) {
163
163
  bed.generator?.stop();
164
164
  bed.music?.player?.stop();
165
165
  release(bed.nodes);
166
+ if (bed.lowMemory) {
167
+ if (bed.source) { bed.source.buffer = null; }
168
+ bed.buffer = null;
169
+ bed.source = null;
170
+ bed.nodes.length = 0;
171
+ }
166
172
  }
167
173
  }
168
174
 
@@ -354,9 +360,13 @@ export function makeAmbience(options, deps) {
354
360
  let ducked = false;
355
361
  let sounding = false;
356
362
  const canBake = () => sounding && (deps.canBake?.() ?? true);
363
+ // Private ownership prevents the page-context cache from retaining every
364
+ // visited zone. Normal-profile callers retain the existing shared cache.
365
+ const bakeOwner = deps.lowMemory ? new WeakMap() : undefined;
366
+ let bakedKind = null;
357
367
  const requested = new Set();
358
368
  const requestBake = (name, factory, first = false) => {
359
- const promise = bakeBed(context, name, factory, canBake, first);
369
+ const promise = bakeBed(context, name, factory, canBake, first, bakeOwner);
360
370
  if (!requested.has(name)) {
361
371
  requested.add(name);
362
372
  // Prewarming has no live graph to fall back to; makeBed handles failure
@@ -369,11 +379,13 @@ export function makeAmbience(options, deps) {
369
379
  .filter((name) => Object.hasOwn(LOOP_S, name));
370
380
  const clear = () => {
371
381
  sounding = false;
372
- pauseBedBakes(context, canBake);
382
+ pauseBedBakes(context, canBake, bakeOwner);
383
+ if (bakeOwner) { retainBedBake(context, null, bakeOwner); }
373
384
  stopBed(current);
374
385
  stopBed(old);
375
386
  stopBed(spot);
376
387
  current = old = spot = null;
388
+ bakedKind = null;
377
389
  spotGain = 0;
378
390
  ducked = false;
379
391
  };
@@ -387,10 +399,28 @@ export function makeAmbience(options, deps) {
387
399
  }
388
400
  sounding = true;
389
401
  const factory = offlineFactory(deps.createOfflineContext, deps.win);
402
+ if (deps.lowMemory && factory) {
403
+ const selected = Object.hasOwn(LOOP_S, name) ? name :
404
+ near.gain > 0 && Object.hasOwn(LOOP_S, near.bed) ? near.bed : null;
405
+ if (selected !== bakedKind) {
406
+ // Heavy beds cut on a zone switch to avoid retaining both loops
407
+ // during a crossfade. Light beds keep their existing fades.
408
+ for (const bed of [current, old, spot]) {
409
+ if (bed && Object.hasOwn(LOOP_S, bed.name)) { stopBed(bed); }
410
+ }
411
+ if (current?.stopped) { current = null; }
412
+ if (old?.stopped) { old = null; }
413
+ if (spot?.stopped) { spot = null; }
414
+ bakedKind = selected;
415
+ requested.clear();
416
+ retainBedBake(context, selected, bakeOwner);
417
+ }
418
+ }
419
+ const bedDeps = deps.lowMemory ? { ...deps, bakedKind } : deps;
390
420
  if (factory) {
391
421
  // Current zone first, then only the heavy beds declared by this deck.
392
422
  // Direct callers may also select a zone/spot without mapped options.
393
- for (const bed of new Set([name, ...referenced, near.bed])) {
423
+ for (const bed of new Set(deps.lowMemory ? [bakedKind] : [name, ...referenced, near.bed])) {
394
424
  if (Object.hasOwn(LOOP_S, bed)) { requestBake(bed, factory, bed === name); }
395
425
  }
396
426
  }
@@ -410,7 +440,7 @@ export function makeAmbience(options, deps) {
410
440
  fade(old, 0, t);
411
441
  }
412
442
  if (!current && Object.hasOwn(BEDS, name)) {
413
- current = makeBed(ctx, bus, name, options.music === true, noise, seeded(hash(name)), sessionSeed ^ hash(name), deps, requestBake);
443
+ current = makeBed(ctx, bus, name, options.music === true, noise, seeded(hash(name)), sessionSeed ^ hash(name), bedDeps, requestBake);
414
444
  }
415
445
  if (current) {
416
446
  fade(current, 1, t);
@@ -418,7 +448,7 @@ export function makeAmbience(options, deps) {
418
448
  }
419
449
  if (spot?.name !== near.bed) {
420
450
  stopBed(spot);
421
- spot = Object.hasOwn(BEDS, near.bed) ? makeBed(ctx, bus, near.bed, false, noise, seeded(hash(`spot|${near.bed}`)), undefined, deps, requestBake) : null;
451
+ spot = Object.hasOwn(BEDS, near.bed) ? makeBed(ctx, bus, near.bed, false, noise, seeded(hash(`spot|${near.bed}`)), undefined, bedDeps, requestBake) : null;
422
452
  if (spot) {
423
453
  spot.spot = true;
424
454
  }
@@ -111,11 +111,11 @@ function pump(context, cache) {
111
111
  });
112
112
  }
113
113
 
114
- export function bakeBed(context, kind, factory, canStart = always, first = false) {
115
- let cache = buffers.get(context);
114
+ export function bakeBed(context, kind, factory, canStart = always, first = false, owner = buffers) {
115
+ let cache = owner.get(context);
116
116
  if (!cache) {
117
117
  cache = { kinds: new Map(), queue: [], running: false, scheduled: false };
118
- buffers.set(context, cache);
118
+ owner.set(context, cache);
119
119
  }
120
120
  let job = cache.kinds.get(kind);
121
121
  if (!job) {
@@ -137,7 +137,26 @@ export function bakeBed(context, kind, factory, canStart = always, first = false
137
137
 
138
138
  // Quiet/dispose removes the owner's queued gates; a running bake may finish.
139
139
  // A later visit can reattach to the same cached promise without retrying failures.
140
- export function pauseBedBakes(context, canStart) {
141
- const cache = buffers.get(context);
140
+ export function pauseBedBakes(context, canStart, owner = buffers) {
141
+ const cache = owner.get(context);
142
142
  for (const job of cache?.queue ?? []) { job.gates.delete(canStart); }
143
143
  }
144
+
145
+ // Low-memory ambience has a private cache. Drop inactive fulfilled promises
146
+ // too: a fulfilled promise retains its AudioBuffer, even without a live source.
147
+ // An in-flight render cannot be cancelled; its stopped bed ignores completion.
148
+ export function retainBedBake(context, kind, owner) {
149
+ const cache = owner.get(context);
150
+ if (!cache) { return; }
151
+ for (const [name, job] of cache.kinds) {
152
+ if (name === kind) { continue; }
153
+ cache.kinds.delete(name);
154
+ const index = cache.queue.indexOf(job);
155
+ if (index >= 0) {
156
+ cache.queue.splice(index, 1);
157
+ job.gates.clear();
158
+ job.factory = null;
159
+ job.reject(new Error('Inactive ambience bed'));
160
+ }
161
+ }
162
+ }
@@ -282,7 +282,8 @@ export const CUE_VOICES = Object.freeze({
282
282
  });
283
283
  export const ACTION_VOICES = Object.freeze({
284
284
  wave: emoteWaveB, dance: emoteDanceC, cheer: emoteCheer,
285
- bow: emoteBow, spin: emoteSpin, sit, chat: chatOpen,
285
+ bow: emoteBow, spin: emoteSpin, sleep: emoteBow, eat: emoteWaveB,
286
+ cry: emoteBow, laugh: emoteCheer, point: emoteWaveB, sit, chat: chatOpen,
286
287
  });
287
288
 
288
289
  function release(nodes) {
@@ -71,6 +71,10 @@ export const hub = {
71
71
  // own (`hub-try`) over it; both empty in a place that never tries one on
72
72
  tryAll: new Map(),
73
73
  tryMe: new Map(),
74
+ // Roles (v1.157), shared and per-viewer whole blocks.
75
+ roles: new Map(),
76
+ roleAll: new Map(),
77
+ roleMe: new Map(),
74
78
  // playerId -> { class, shape, color, name }: the earned item each player
75
79
  // shows (`hubEarned`, v1.53), with this player's own (`hub-earned`) over it,
76
80
  // as the wearables are; all empty in a place where nobody shows one
@@ -138,6 +142,7 @@ export const hub = {
138
142
  spawnTemplates: {},
139
143
  // this player's own controller tuning, { speed, jump } multipliers, or null
140
144
  tune: null,
145
+ cars: {},
141
146
  // player ids the place is holding still
142
147
  held: new Set(),
143
148
  // actor id -> { text, style }, and this player's own over them (an NPC's
@@ -166,6 +171,7 @@ export const hub = {
166
171
  // actorId -> { file, volume, radius, since } (a loop playing there), and the
167
172
  // one-shot sounds not yet played
168
173
  emotes: {},
174
+ roleEmotes: [],
169
175
  // v1.47: actor id -> an NPC's emote, empty until a body reacts.
170
176
  npcEmotes: {},
171
177
  seated: {},
@@ -216,6 +222,9 @@ export function clear() {
216
222
  hub.wearMe.clear();
217
223
  hub.tryAll.clear();
218
224
  hub.tryMe.clear();
225
+ hub.roles.clear();
226
+ hub.roleAll.clear();
227
+ hub.roleMe.clear();
219
228
  hub.earned.clear();
220
229
  hub.earnedAll.clear();
221
230
  hub.earnedMe.clear();
@@ -245,6 +254,7 @@ export function clear() {
245
254
  hub.spawned = {};
246
255
  hub.spawnTemplates = {};
247
256
  hub.tune = null;
257
+ hub.cars = {};
248
258
  hub.held.clear();
249
259
  hub.labels = {};
250
260
  hub.labelsMe = {};
@@ -254,6 +264,7 @@ export function clear() {
254
264
  hub.grabEvents.length = 0;
255
265
  hub.keptFor = new Map();
256
266
  hub.emotes = {};
267
+ hub.roleEmotes = [];
257
268
  hub.npcEmotes = {};
258
269
  hub.seated = {};
259
270
  hub.sounds = {};
@@ -324,3 +335,11 @@ export function avatarOf(playerId) {
324
335
  export function simNow() {
325
336
  return hub.lastT + (performance.now() - hub.lastTAt);
326
337
  }
338
+
339
+ export function rolesNow() {
340
+ const out = new Map(hub.roleAll);
341
+ for (const [id, role] of hub.roleMe) {
342
+ if (role != null) { out.set(id, role); }
343
+ }
344
+ return out;
345
+ }
@@ -235,7 +235,8 @@ export function chipShift(box, above, others, viewH, gap = HUD_GAP) {
235
235
  // it will put the player ("the square", "the street"), or null where it gives
236
236
  // none; `spot` (v1.39) whether that is a spot the place picks for a player
237
237
  // stuck where this one is (its `unstick` hook) rather than its arrival.
238
- export function stuckText(to, spot = false) {
238
+ export function stuckText(to, spot = false, driving = false) {
239
+ if (driving) {return 'Stuck? Tap to reset the car';}
239
240
  if (to) {
240
241
  return `Stuck? Tap to go to ${to}`;
241
242
  }