castle-web-cli 0.4.231 → 0.4.232
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.
- package/dist/serverBundle.js +5 -3
- package/kits/hub-game/CLAUDE.md +26 -4
- package/kits/hub-game/code/client/avatar.js +39 -0
- package/kits/hub-game/code/client/chat.js +12 -0
- package/kits/hub-game/code/client/chrome.js +194 -4
- package/kits/hub-game/code/client/grab.js +31 -7
- package/kits/hub-game/code/client/hats.js +26 -0
- package/kits/hub-game/code/client/hookLayer.js +30 -3
- package/kits/hub-game/code/client/hudClear.js +126 -0
- package/kits/hub-game/code/client/state.js +22 -0
- package/kits/hub-game/code/client/tiers.js +31 -6
- package/kits/hub-game/code/client/together.js +66 -1
- package/kits/hub-game/code/client/wear.js +96 -14
- package/kits/hub-game/code/server/actors.js +5 -0
- package/kits/hub-game/code/server/grab.js +296 -11
- package/kits/hub-game/code/server/hub.js +63 -2
- package/kits/hub-game/code/server/manifest.js +48 -3
- package/kits/hub-game/code/server/party.js +11 -0
- package/kits/hub-game/code/server/say.js +8 -2
- package/kits/hub-game/code/server/wear.js +116 -11
- package/kits/hub-game/code/systems/hub.js +253 -5
- package/kits/hub-game/docs/contract.md +204 -8
- package/kits/hub-game/package.json +1 -1
- package/kits/hub-game/scripts/test-chat.mjs +32 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +186 -3
- package/kits/hub-game/scripts/test-grab.mjs +857 -3
- package/kits/hub-game/scripts/test-hats.mjs +229 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +513 -0
- package/kits/hub-game/scripts/test-hud-clear.mjs +676 -0
- package/kits/hub-game/scripts/test-manifest.mjs +75 -0
- package/kits/hub-game/scripts/test-party.mjs +22 -1
- package/kits/hub-game/scripts/test-say.mjs +59 -2
- package/kits/hub-game/scripts/test-tiers.mjs +190 -2
- package/kits/hub-game/scripts/test-try-on.mjs +940 -0
- package/kits/physics-2d/castle.json +1 -1
- package/kits/physics-2d/engine/scene.js +35 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +44 -0
- package/kits/physics-3d/CLAUDE.md +252 -0
- package/kits/physics-3d/behaviors/Player.jsx +363 -2
- package/kits/physics-3d/castle.json +2 -2
- package/kits/physics-3d/docs/pxmodel-format.md +4 -0
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +32 -0
- package/kits/physics-3d/engine3d/optimize.js +49 -0
- package/kits/physics-3d/engine3d/orbitinput.js +277 -0
- package/kits/physics-3d/engine3d/world3d.js +81 -25
- package/kits/physics-3d/scripts/Player.before-orbit.mjs +310 -0
- package/kits/physics-3d/scripts/Scene3DPlayer.before-orbit.jsx +337 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +12 -2
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +2105 -0
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +787 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +6 -1
- package/kits/physics-3d/scripts/test-static-passes.mjs +1 -1
- package/kits/physics-3d/scripts/test-steady-hover.mjs +633 -0
- package/kits/physics-3d/systems/physics3d.js +91 -6
- package/package.json +1 -1
package/dist/serverBundle.js
CHANGED
|
@@ -2,11 +2,13 @@ import { createHash } from 'crypto';
|
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { build } from 'vite';
|
|
5
|
-
import { resolveServerConfig
|
|
5
|
+
import { resolveServerConfig } from './castleJson.js';
|
|
6
6
|
import { forksOverlayPlugin, importsAliasPlugin, sdkAliasPlugin } from './vitePlugins.js';
|
|
7
7
|
import { resolveSdkSpecifier, SDK_PACKAGE } from './sdkResolve.js';
|
|
8
8
|
const WARN_BYTES = 1024 * 1024;
|
|
9
|
-
|
|
9
|
+
// Ghost accepts 20MB from an admin or on an admin's deck, and 5MB from
|
|
10
|
+
// everyone else.
|
|
11
|
+
const MAX_BYTES = 20 * 1024 * 1024;
|
|
10
12
|
const VIRTUAL_ENTRY = '\0castle-server-entry';
|
|
11
13
|
// Build the artifact Cauldron executes. A deck without a valid server entry is
|
|
12
14
|
// not an error: multiplayer is opt-in, so callers can handle that as a skip (or
|
|
@@ -18,7 +20,7 @@ export async function buildServerBundle(projectDir) {
|
|
|
18
20
|
const code = await bundleServerModule(projectDir, config, true);
|
|
19
21
|
const sizeBytes = Buffer.byteLength(code, 'utf8');
|
|
20
22
|
if (sizeBytes > MAX_BYTES) {
|
|
21
|
-
throw new Error(`Server bundle is ${(sizeBytes / 1024 / 1024).toFixed(2)}MB; the maximum is
|
|
23
|
+
throw new Error(`Server bundle is ${(sizeBytes / 1024 / 1024).toFixed(2)}MB; the maximum is ${MAX_BYTES / 1024 / 1024}MB.`);
|
|
22
24
|
}
|
|
23
25
|
if (sizeBytes > WARN_BYTES) {
|
|
24
26
|
console.warn(`Warning: Server bundle is ${(sizeBytes / 1024 / 1024).toFixed(2)}MB. ` +
|
package/kits/hub-game/CLAUDE.md
CHANGED
|
@@ -40,13 +40,19 @@ it is what every published hub game depends on.
|
|
|
40
40
|
gates), `tint(actorId, '#rrggbb' | null)` (a Shape actor's colour),
|
|
41
41
|
`mark(playerId, { text, color } | null)` (a coloured tag over a player's
|
|
42
42
|
avatar: a team, who is it), `wear(playerId, { kind, color, rarity } | null)`
|
|
43
|
-
(v1.4: `halo`, `aura
|
|
44
|
-
|
|
43
|
+
(v1.4: `halo`, `aura`, `orbit` or a hat `hat-<id>`, the ids in
|
|
44
|
+
`code/client/hats.js` `HATS`; in `#rrggbb`, rarity 0-9, worn on the
|
|
45
|
+
player's avatar in every hub place once ghost keeps it),
|
|
46
|
+
`tryOn(playerId, { kind, color, rarity } | null)` (v1.28: the same wearable
|
|
47
|
+
shown in this place only and never saved -- a shop's try-on, a costume for
|
|
48
|
+
the visit; the one the player owns is untouched and is drawn again on
|
|
49
|
+
`null`, when they leave or when the place ends), `spawn(fromActorId, at)` / `despawn(id)` (a
|
|
45
50
|
copy of a scene actor, often a hidden prototype), `pose(actorId)` /
|
|
46
51
|
`reset(actorId, at?)` (read a body; put a loose object back, at rest),
|
|
47
52
|
`tune(playerId, { speed,
|
|
48
53
|
jump } | null)` (one player's own walk, as multipliers of the preset),
|
|
49
|
-
`label(actorId, text)`, `drop(playerId?)` / `holding(playerId)`
|
|
54
|
+
`label(actorId, text)`, `drop(playerId?)` / `holding(playerId)` /
|
|
55
|
+
`keepFor(actorId, playerId | null)` (grab, below),
|
|
50
56
|
`result(playerId, { outcome, score, stats })`, `results(playerId)` (ghost's
|
|
51
57
|
recent results and records of a player), `end(playerIds?)`,
|
|
52
58
|
`go(door, playerIds)`, `send`, `broadcast`, `session`, `sim`, `place`.
|
|
@@ -75,7 +81,21 @@ it is what every published hub game depends on.
|
|
|
75
81
|
someone holds. Never a player, one object at a time. `reach` (1.6-3 m) and
|
|
76
82
|
`steady: true` (contract v1.22) offer objects from farther away and keep
|
|
77
83
|
the button up through a moment at the reach, the cone or a shared owner --
|
|
78
|
-
for places played on phones.
|
|
84
|
+
for places played on phones. `keepHeld: true` (contract v1.25) keeps a
|
|
85
|
+
held object its holder's when another player stands nearer; without it the
|
|
86
|
+
nearer player is handed it and the hold ends.
|
|
87
|
+
`hub.keepFor(actorId, playerId | null)` (contract v1.27) keeps a loose
|
|
88
|
+
object for one player (a pillow of their own): nobody else is offered it or
|
|
89
|
+
may grab it, and the `grab` hook is not asked about their tries. It ends
|
|
90
|
+
with `null`, `hub.hide` and the player's leaving, and outlives `hub.reset`.
|
|
91
|
+
It does not change who simulates the object, so its keeper is offered it
|
|
92
|
+
only while nearest to it: put it beside them (`hub.reset(actorId, at)`).
|
|
93
|
+
- **A clear HUD** (contract v1.26): `"hud": { "clear": true }` in the `hub`
|
|
94
|
+
block, for places played on phones. A big line with a text line under it
|
|
95
|
+
is drawn at 32 px on one line (alone it keeps 56 px), labels, speech, marks
|
|
96
|
+
and goal pointers that would lie over the HUD are moved to just under it,
|
|
97
|
+
and on a phone on its side the text keeps to two lines. Without it the HUD
|
|
98
|
+
and labels are drawn as they always were.
|
|
79
99
|
- **Idle play** (contract v1.6): `"idle": true` in the `hub` block (or
|
|
80
100
|
`{ emotes, seats, sounds: ["sounds/x.mp3"] }`) gives players an emote picker
|
|
81
101
|
(wave, dance, cheer, bow, spin, drawn on their avatar) and Sit on scene
|
|
@@ -114,6 +134,8 @@ it is what every published hub game depends on.
|
|
|
114
134
|
| `code/client/chat.js` | free-text chat (v1.12): polls the host for what this player may read and whom they reach, sends through it; who may chat is ghost's rule, never the kit's |
|
|
115
135
|
| `code/server/party.js` | parties in a town (v1.10): invitations, a door proposed to the party, members put on its pad, `hub.coming`; a member away through a door is kept |
|
|
116
136
|
| `code/client/together.js` | finding a friend in a town (v1.9): who here is one, the People list's rows, the pointers; the server's half (`hub-where`, `hub-goto`, the `where` hook) is in `code/server/hub.js` |
|
|
137
|
+
| `code/server/wear.js` | wearables on the server: `hub.wear` (kept here and sent to ghost) and `hub.tryOn` (v1.28: kept here only, never sent to ghost), and what each client is told of both |
|
|
138
|
+
| `code/client/wear.js`, `code/client/hats.js` | what players wear (v1.4) and how each hat is built; the hat ids, a list a place's server may import; each avatar's hat fit is in `avatar.js` |
|
|
117
139
|
| `code/server/manifest.js` | reads and checks the `hub` block and results (plain JS, shared with the check) |
|
|
118
140
|
| `code/server/place.js` | which place a session runs, from the session alone |
|
|
119
141
|
| `code/server/game.js` | the starter game (Flag Dash), copied into a new deck |
|
|
@@ -33,6 +33,39 @@ const TOPS = {
|
|
|
33
33
|
};
|
|
34
34
|
const DEFAULT_TOP = 1.65;
|
|
35
35
|
|
|
36
|
+
// How a hat sits on each avatar (`wear.js`), `[seat, scale, rise]`: how big the
|
|
37
|
+
// hat is drawn for the size of the head (toon's Star wears a small one on its
|
|
38
|
+
// top point); the height over its feet of the ring of its head that the hat's
|
|
39
|
+
// rim, 0.2 m times the scale, rests on, measured down onto each model, not
|
|
40
|
+
// its top, which is often an ear, a bow or a leaf; and how far the crown of
|
|
41
|
+
// the head stands over the seat, for a hat narrower than the rim.
|
|
42
|
+
const HAT_FITS = {
|
|
43
|
+
toon: [
|
|
44
|
+
[1.27, 1.3, 0.08],
|
|
45
|
+
[1.21, 1.1, 0.07],
|
|
46
|
+
[1.18, 1.1, 0.08],
|
|
47
|
+
[1.43, 0.6, 0.06],
|
|
48
|
+
],
|
|
49
|
+
blocky: [
|
|
50
|
+
[1.39, 1.1, 0.04],
|
|
51
|
+
[1.48, 1.1, 0],
|
|
52
|
+
[1.47, 1.1, 0],
|
|
53
|
+
[1.48, 1.1, 0],
|
|
54
|
+
],
|
|
55
|
+
bean: [
|
|
56
|
+
[1.27, 1.3, 0.08],
|
|
57
|
+
[1.16, 1.3, 0.11],
|
|
58
|
+
[1.22, 1, 0.1],
|
|
59
|
+
[1.18, 1.3, 0.06],
|
|
60
|
+
],
|
|
61
|
+
pixel: [
|
|
62
|
+
[1.33, 1.2, 0.04],
|
|
63
|
+
[1.33, 1.15, 0.07],
|
|
64
|
+
[1.27, 1.15, 0.06],
|
|
65
|
+
[1.33, 1.15, 0.01],
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
|
|
36
69
|
// Where the kit's blueprints are: inside the import in a deck, at the root
|
|
37
70
|
// while this kit is served as itself.
|
|
38
71
|
const ROOTS = ['imports/castle.hub-game/', ''];
|
|
@@ -257,6 +290,12 @@ export function top(index, which = style()) {
|
|
|
257
290
|
return usable(index) ? TOPS[STYLES.includes(which) ? which : DEFAULT_STYLE][index] : DEFAULT_TOP;
|
|
258
291
|
}
|
|
259
292
|
|
|
293
|
+
// How a hat sits on the avatar in a set (`HAT_FITS`), or null for one this kit
|
|
294
|
+
// does not have. The same array every time: nothing is made per frame.
|
|
295
|
+
export function hatFit(index, which = style()) {
|
|
296
|
+
return usable(index) ? HAT_FITS[STYLES.includes(which) ? which : DEFAULT_STYLE][index] : null;
|
|
297
|
+
}
|
|
298
|
+
|
|
260
299
|
// The blueprint other players are drawn from, as a path the live files map
|
|
261
300
|
// has, or null before the files are known. A set these files do not have is
|
|
262
301
|
// drawn from toon's.
|
|
@@ -11,6 +11,9 @@ import * as castleSdk from 'castle-web-sdk';
|
|
|
11
11
|
// while nobody can (a friend may arrive).
|
|
12
12
|
const POLL_MS = 2500;
|
|
13
13
|
const IDLE_POLL_MS = 15000;
|
|
14
|
+
// Cues (v1.23): someone came into the roster while nobody could be chatted
|
|
15
|
+
// with: the host is asked again this soon, not at the end of the idle wait.
|
|
16
|
+
const SOON_MS = 1000;
|
|
14
17
|
// A chat line stays over its speaker this long.
|
|
15
18
|
export const CHAT_BUBBLE_MS = 6000;
|
|
16
19
|
|
|
@@ -84,6 +87,15 @@ export function makeChat() {
|
|
|
84
87
|
});
|
|
85
88
|
},
|
|
86
89
|
|
|
90
|
+
// Cues (v1.23): a player just came in, who may be one this player can
|
|
91
|
+
// chat with. Brings the next ask forward when the idle wait is on; a
|
|
92
|
+
// crowd coming in together is still one ask.
|
|
93
|
+
soon(now) {
|
|
94
|
+
if (!c.peers?.length && askedAt !== -Infinity) {
|
|
95
|
+
askedAt = Math.min(askedAt, now - IDLE_POLL_MS + SOON_MS);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
|
|
87
99
|
// Sends `text`; `done(status)` hears ghost's answer: "sent", "none"
|
|
88
100
|
// (nobody here may read it), "limited", "refused" or "unavailable".
|
|
89
101
|
send(text, done = () => {}) {
|
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
// reports), the pointers to friends out of sight,
|
|
8
8
|
// the Grab / Throw button (a place with `grab`, v1.3), the emote picker and
|
|
9
9
|
// the Sit / Stand button (a place with `idle`, v1.6), an arcade cabinet's
|
|
10
|
-
// board card (v1.7), and the frame-rate readout behind `?hubstats`.
|
|
10
|
+
// board card (v1.7), and the frame-rate readout behind `?hubstats`. In a place
|
|
11
|
+
// that asks (`hud.clear`, v1.26) the HUD is kept short and what is drawn over
|
|
12
|
+
// the world is kept out from under it (`hudClear.js`).
|
|
11
13
|
|
|
12
14
|
import { cardMode, makeCardView, tapCard } from './cabinets.js';
|
|
15
|
+
import { boxAt, fitPx, hudLayout, pushBelow } from './hudClear.js';
|
|
13
16
|
import { guardScrollKeys } from './keys.js';
|
|
14
17
|
|
|
15
18
|
const Z = 2147480000;
|
|
@@ -21,6 +24,11 @@ function el(tag, style, parent = document.body) {
|
|
|
21
24
|
return node;
|
|
22
25
|
}
|
|
23
26
|
|
|
27
|
+
// White text drawn straight over the world (the HUD, the feed): an outline
|
|
28
|
+
// close around each letter as well as the soft drop shadow, so it reads over a
|
|
29
|
+
// pale sky as it does over a dark street.
|
|
30
|
+
const BARE_TEXT_SHADOW = '0 0 2px rgba(0,0,0,0.95), 0 0 2px rgba(0,0,0,0.95), 0 1px 4px rgba(0,0,0,0.75), 0 0 10px rgba(0,0,0,0.45)';
|
|
31
|
+
|
|
24
32
|
export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {}, onJumpDoor = () => {}, onReport = () => {}, onAsk = () => {}, onLeaveParty = () => {}, onReportChat = () => {} }) {
|
|
25
33
|
const unguardKeys = guardScrollKeys();
|
|
26
34
|
// A desktop stage (a mouse, room to spare): NPC lines are narrower and the
|
|
@@ -42,7 +50,7 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
42
50
|
onBack();
|
|
43
51
|
});
|
|
44
52
|
|
|
45
|
-
const hud = el('div', { position: 'absolute', top: 'max(12px, env(safe-area-inset-top))', left: '50%', transform: 'translateX(-50%)', textAlign: 'center', textShadow:
|
|
53
|
+
const hud = el('div', { position: 'absolute', top: 'max(12px, env(safe-area-inset-top))', left: '50%', transform: 'translateX(-50%)', textAlign: 'center', textShadow: BARE_TEXT_SHADOW, display: 'none', maxWidth: '70vw' }, root);
|
|
46
54
|
const hudTitle = el('div', { fontSize: '13px', opacity: '0.85', letterSpacing: '0.06em', textTransform: 'uppercase' }, hud);
|
|
47
55
|
const hudBig = el('div', { fontSize: '56px', fontWeight: '800', lineHeight: '1.05' }, hud);
|
|
48
56
|
const hudText = el('div', { fontSize: '14px', fontWeight: '500' }, hud);
|
|
@@ -320,7 +328,7 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
320
328
|
setSayOpen(!sayOpen);
|
|
321
329
|
setEmotesOpen(false);
|
|
322
330
|
});
|
|
323
|
-
const feed = el('div', { position: 'absolute', left: '10px', bottom: 'max(70px, calc(env(safe-area-inset-bottom) + 60px))', maxWidth: '62vw', display: 'flex', flexDirection: 'column', gap: '2px', font: '500 12px/1.3 system-ui, sans-serif', textShadow:
|
|
331
|
+
const feed = el('div', { position: 'absolute', left: '10px', bottom: 'max(70px, calc(env(safe-area-inset-bottom) + 60px))', maxWidth: '62vw', display: 'flex', flexDirection: 'column', gap: '2px', font: '500 12px/1.3 system-ui, sans-serif', textShadow: BARE_TEXT_SHADOW, opacity: '0.92' }, root);
|
|
324
332
|
let feedKey = '';
|
|
325
333
|
const sitButton = el('button', { position: 'absolute', bottom: 'max(112px, calc(env(safe-area-inset-bottom) + 102px))', left: '50%', transform: 'translateX(-50%)', pointerEvents: 'auto', padding: '10px 22px', borderRadius: '22px', border: '1px solid rgba(255,255,255,0.45)', background: 'rgba(20,16,12,0.8)', color: '#fff', font: 'inherit', display: 'none', cursor: 'pointer', touchAction: 'manipulation' }, root);
|
|
326
334
|
sitButton.addEventListener('pointerdown', (event) => {
|
|
@@ -472,6 +480,133 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
472
480
|
|
|
473
481
|
const stats = el('div', { position: 'absolute', right: '8px', top: 'max(8px, env(safe-area-inset-top))', font: '11px/1.3 ui-monospace, monospace', opacity: '0.7', textAlign: 'right', whiteSpace: 'pre' }, root);
|
|
474
482
|
|
|
483
|
+
// A clear HUD (v1.26, `hudClear.js`), in a place whose manifest asks for it
|
|
484
|
+
// (`setHudClear`). Everything below runs only then, or once as the option
|
|
485
|
+
// goes to put the HUD back as it always was: a place that never asks is
|
|
486
|
+
// drawn by the code above and below with none of this in its way.
|
|
487
|
+
let hudClear = false;
|
|
488
|
+
let hudClearDrawn = false;
|
|
489
|
+
let hudClearKey = '';
|
|
490
|
+
let hudClearRect = null;
|
|
491
|
+
const hudClearSizes = new WeakMap();
|
|
492
|
+
// The place before asked and this one does not: the styles of old, put
|
|
493
|
+
// back the moment the option goes, whether or not a HUD is drawn after.
|
|
494
|
+
function restoreHudClear() {
|
|
495
|
+
hudBig.style.fontSize = '56px';
|
|
496
|
+
for (const key of ['whiteSpace', 'overflow', 'textOverflow', 'maxWidth', 'marginLeft', 'marginRight']) {
|
|
497
|
+
hudBig.style[key] = '';
|
|
498
|
+
}
|
|
499
|
+
for (const key of ['display', 'overflow', 'webkitLineClamp', 'webkitBoxOrient']) {
|
|
500
|
+
hudText.style[key] = '';
|
|
501
|
+
}
|
|
502
|
+
hud.style.maxHeight = '';
|
|
503
|
+
hud.style.overflow = '';
|
|
504
|
+
hudClearDrawn = false;
|
|
505
|
+
hudClearKey = '';
|
|
506
|
+
hudClearRect = null;
|
|
507
|
+
hudClearPending.clear();
|
|
508
|
+
}
|
|
509
|
+
function layoutHudClear(big, text) {
|
|
510
|
+
hudClearDrawn = true;
|
|
511
|
+
const backShown = back.style.display !== 'none';
|
|
512
|
+
const key = [hudTitle.textContent, big, text, window.innerWidth, window.innerHeight, backShown ? back.textContent : ''].join('\u0001');
|
|
513
|
+
if (key === hudClearKey) {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
hudClearKey = key;
|
|
517
|
+
const layout = hudLayout({
|
|
518
|
+
big,
|
|
519
|
+
text,
|
|
520
|
+
viewW: window.innerWidth,
|
|
521
|
+
viewH: window.innerHeight,
|
|
522
|
+
// The big line's row is the Back button's: it keeps out of its way.
|
|
523
|
+
reserve: backShown ? back.offsetLeft + back.offsetWidth + 8 : 0,
|
|
524
|
+
});
|
|
525
|
+
hudBig.style.fontSize = `${layout.bigPx}px`;
|
|
526
|
+
hudBig.style.whiteSpace = layout.bigOneLine ? 'nowrap' : '';
|
|
527
|
+
hudBig.style.overflow = layout.bigOneLine ? 'hidden' : '';
|
|
528
|
+
hudBig.style.textOverflow = layout.bigOneLine ? 'ellipsis' : '';
|
|
529
|
+
hudBig.style.maxWidth = layout.bigMaxWidth === null ? '' : `${layout.bigMaxWidth}px`;
|
|
530
|
+
hudBig.style.marginLeft = layout.bigMaxWidth === null ? '' : 'auto';
|
|
531
|
+
hudBig.style.marginRight = layout.bigMaxWidth === null ? '' : 'auto';
|
|
532
|
+
hudText.style.display = layout.textLines === null ? '' : '-webkit-box';
|
|
533
|
+
hudText.style.overflow = layout.textLines === null ? '' : 'hidden';
|
|
534
|
+
hudText.style.webkitLineClamp = layout.textLines === null ? '' : String(layout.textLines);
|
|
535
|
+
hudText.style.webkitBoxOrient = layout.textLines === null ? '' : 'vertical';
|
|
536
|
+
hud.style.maxHeight = layout.maxHeight === null ? '' : `${layout.maxHeight}px`;
|
|
537
|
+
hud.style.overflow = layout.maxHeight === null ? '' : 'hidden';
|
|
538
|
+
if (layout.bigOneLine) {
|
|
539
|
+
// The estimate fell short of this face: shrink to what was drawn.
|
|
540
|
+
const px = fitPx(layout.bigPx, hudBig.clientWidth, hudBig.scrollWidth);
|
|
541
|
+
if (px !== layout.bigPx) {
|
|
542
|
+
hudBig.style.fontSize = `${px}px`;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
// The box as it is drawn now; it changes only with what the key holds.
|
|
546
|
+
const r = hud.getBoundingClientRect();
|
|
547
|
+
hudClearRect = r.width > 0 && r.height > 0 ? { left: r.left, right: r.right, top: r.top, bottom: r.bottom } : null;
|
|
548
|
+
}
|
|
549
|
+
// What a frame's setters ask to be kept clear of the HUD, by group
|
|
550
|
+
// ("labels", "pointers", "cabinet", "ribbon"): each entry is [node, x, y,
|
|
551
|
+
// anchor, text] -- `node`, hung from (x, y) by `anchor` (`boxAt`), is moved
|
|
552
|
+
// to just under the HUD's box when it would lie over it, never past the
|
|
553
|
+
// bottom of the view. Nothing is measured or moved as it is asked: the
|
|
554
|
+
// whole frame is flushed once (`flushHudClear`, said by the hub system when
|
|
555
|
+
// it has drawn everything), every size that must be measured read first and
|
|
556
|
+
// only then anything moved. A write between two reads would have the
|
|
557
|
+
// browser lay the page out again for each, and a crowd of bubbles drifting
|
|
558
|
+
// sideways is measured every frame. A setter called with no flush after it
|
|
559
|
+
// is still flushed, before the browser paints (a microtask).
|
|
560
|
+
const hudClearPending = new Map();
|
|
561
|
+
let hudClearQueued = false;
|
|
562
|
+
function keepClearOfHud(group, entries) {
|
|
563
|
+
hudClearPending.set(group, entries);
|
|
564
|
+
if (!hudClearQueued) {
|
|
565
|
+
hudClearQueued = true;
|
|
566
|
+
(globalThis.queueMicrotask ?? ((fn) => Promise.resolve().then(fn)))(() => {
|
|
567
|
+
hudClearQueued = false;
|
|
568
|
+
flushHudClear();
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
function flushHudClear() {
|
|
573
|
+
if (!hudClearPending.size) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
const groups = [...hudClearPending.values()];
|
|
577
|
+
hudClearPending.clear();
|
|
578
|
+
const rect = hudClear && hud.style.display !== 'none' ? hudClearRect : null;
|
|
579
|
+
if (!rect) {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
const moves = [];
|
|
583
|
+
for (const entries of groups) {
|
|
584
|
+
for (const [node, x, y, anchor, text] of entries) {
|
|
585
|
+
// One since hidden or taken away is left alone.
|
|
586
|
+
if (!node || node.style.display === 'none' || !Number.isFinite(x) || !Number.isFinite(y)) {
|
|
587
|
+
continue;
|
|
588
|
+
}
|
|
589
|
+
// Its size is measured once for each `text` it shows -- and, for a
|
|
590
|
+
// bubble that wraps by the room to its right (speech with no width
|
|
591
|
+
// of its own), again whenever it moves sideways.
|
|
592
|
+
const wraps = node.style.whiteSpace === 'normal' && node.style.width !== 'max-content';
|
|
593
|
+
const key = [text, node.style.fontSize, node.style.maxWidth, node.style.padding, window.innerWidth, wraps ? node.style.left : ''].join('\u0001');
|
|
594
|
+
let box = hudClearSizes.get(node);
|
|
595
|
+
if (!box || box.key !== key) {
|
|
596
|
+
box = { key, w: node.offsetWidth, h: node.offsetHeight };
|
|
597
|
+
hudClearSizes.set(node, box);
|
|
598
|
+
}
|
|
599
|
+
const down = pushBelow(boxAt(x, y, box.w, box.h, anchor), rect, undefined, window.innerHeight);
|
|
600
|
+
if (down > 0) {
|
|
601
|
+
moves.push([node, y + down]);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
for (const [node, top] of moves) {
|
|
606
|
+
node.style.top = `${top}px`;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
475
610
|
return {
|
|
476
611
|
setCover(alpha, text) {
|
|
477
612
|
cover.style.opacity = String(alpha);
|
|
@@ -498,7 +633,25 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
498
633
|
hudBig.textContent = big;
|
|
499
634
|
hudBig.style.display = big ? 'block' : 'none';
|
|
500
635
|
hudText.textContent = spec.text ?? '';
|
|
636
|
+
if (hudClear) {
|
|
637
|
+
layoutHudClear(big, spec.text ?? '');
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
// Whether this place asks for a clear HUD (`hud.clear`, v1.26). Said each
|
|
641
|
+
// frame before `setHud`; never said true, nothing of it is drawn.
|
|
642
|
+
setHudClear(on) {
|
|
643
|
+
hudClear = on === true;
|
|
644
|
+
if (!hudClear && hudClearDrawn) {
|
|
645
|
+
restoreHudClear();
|
|
646
|
+
}
|
|
647
|
+
if (!hudClear) {
|
|
648
|
+
hudClearPending.clear();
|
|
649
|
+
}
|
|
501
650
|
},
|
|
651
|
+
// The end of a frame's drawing in a place with a clear HUD: everything
|
|
652
|
+
// the setters above asked to be kept clear of it is measured, then moved.
|
|
653
|
+
// Nothing asked (a place without the option): nothing read or written.
|
|
654
|
+
flushHudClear,
|
|
502
655
|
// `items` is [{ id, x, y, text, speech, npc, color }] in CSS pixels (a
|
|
503
656
|
// `color` is a player's mark); anything not
|
|
504
657
|
// listed is removed.
|
|
@@ -563,6 +716,15 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
563
716
|
labelNodes.delete(id);
|
|
564
717
|
}
|
|
565
718
|
}
|
|
719
|
+
if (hudClear) {
|
|
720
|
+
keepClearOfHud(
|
|
721
|
+
'labels',
|
|
722
|
+
items.map((item) => {
|
|
723
|
+
const node = labelNodes.get(item.id);
|
|
724
|
+
return [node, parseFloat(node.style.left), item.y, 'bottom', item.text];
|
|
725
|
+
}),
|
|
726
|
+
);
|
|
727
|
+
}
|
|
566
728
|
},
|
|
567
729
|
// `item` is { id, rev, card, x, y, opacity } in CSS pixels, or null for no
|
|
568
730
|
// card; `imageOf(value)` is a picture's `src`, or null for none.
|
|
@@ -586,6 +748,9 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
586
748
|
const half = cabinet.offsetWidth / 2;
|
|
587
749
|
cabinet.style.left = `${Math.min(Math.max(item.x, half + 6), window.innerWidth - half - 6)}px`;
|
|
588
750
|
cabinet.style.top = `${Math.max(item.y, cabinet.offsetHeight + 6)}px`;
|
|
751
|
+
if (hudClear) {
|
|
752
|
+
keepClearOfHud('cabinet', [[cabinet, parseFloat(cabinet.style.left), parseFloat(cabinet.style.top), 'bottom', cabinetKey]]);
|
|
753
|
+
}
|
|
589
754
|
// A board the player asked for is read whole, wherever they stand by it.
|
|
590
755
|
cabinet.style.opacity = String(open ? 1 : item.opacity);
|
|
591
756
|
},
|
|
@@ -600,6 +765,9 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
600
765
|
if (ribbon.textContent !== text) {
|
|
601
766
|
ribbon.textContent = text;
|
|
602
767
|
}
|
|
768
|
+
if (hudClear) {
|
|
769
|
+
keepClearOfHud('ribbon', [[ribbon, pos.x, pos.y, 'bottom', text]]);
|
|
770
|
+
}
|
|
603
771
|
},
|
|
604
772
|
setToast(text) {
|
|
605
773
|
toast.style.display = text ? 'block' : 'none';
|
|
@@ -681,6 +849,12 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
681
849
|
if (key === sayKey && sayNote && chat && sayNote.textContent !== (chat.note ?? '')) {
|
|
682
850
|
sayNote.textContent = chat.note ?? '';
|
|
683
851
|
}
|
|
852
|
+
// The field's own words (a deck with cues, v1.23): rewritten in place
|
|
853
|
+
// too. A chat part that names none keeps 'Message…'.
|
|
854
|
+
if (key === sayKey && sayInput && chat?.placeholder && sayInput.placeholder !== chat.placeholder) {
|
|
855
|
+
sayInput.placeholder = chat.placeholder;
|
|
856
|
+
sayInput.setAttribute('aria-label', chat.label ?? chat.placeholder);
|
|
857
|
+
}
|
|
684
858
|
if (key === sayKey) {
|
|
685
859
|
return;
|
|
686
860
|
}
|
|
@@ -718,7 +892,10 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
718
892
|
const line = el('div', { display: 'flex', gap: '6px', opacity: chat.input ? '1' : '0.5' }, sayCard);
|
|
719
893
|
const input = el('input', { flex: '1', minWidth: '0', padding: '7px 9px', borderRadius: '8px', border: '1px solid rgba(255,255,255,0.3)', background: 'rgba(255,255,255,0.1)', color: '#fff', font: '500 14px system-ui, sans-serif' }, line);
|
|
720
894
|
input.maxLength = 200;
|
|
721
|
-
input.placeholder = 'Message…';
|
|
895
|
+
input.placeholder = chat.placeholder ?? 'Message…';
|
|
896
|
+
if (chat.placeholder) {
|
|
897
|
+
input.setAttribute('aria-label', chat.label ?? chat.placeholder);
|
|
898
|
+
}
|
|
722
899
|
// Shown even when it cannot be used, so chat can be found; the note says why.
|
|
723
900
|
input.disabled = !chat.input;
|
|
724
901
|
input.enterKeyHint = 'send';
|
|
@@ -978,6 +1155,16 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
978
1155
|
pointerNodes.delete(id);
|
|
979
1156
|
}
|
|
980
1157
|
}
|
|
1158
|
+
if (hudClear) {
|
|
1159
|
+
keepClearOfHud(
|
|
1160
|
+
'pointers',
|
|
1161
|
+
items.map((item) => {
|
|
1162
|
+
const chip = pointerNodes.get(item.id).chip;
|
|
1163
|
+
const edge = item.angle !== null && item.angle !== undefined;
|
|
1164
|
+
return [chip, parseFloat(chip.style.left), item.y, edge ? 'center' : 'bottom', `${edge ? '>' : ''}${item.text}`];
|
|
1165
|
+
}),
|
|
1166
|
+
);
|
|
1167
|
+
}
|
|
981
1168
|
},
|
|
982
1169
|
// `ask` is { key, text, yes, no } (the words and the two buttons'), or
|
|
983
1170
|
// null for none; an answer goes to `onAsk(ask, true | false)`.
|
|
@@ -1020,6 +1207,9 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
1020
1207
|
}
|
|
1021
1208
|
},
|
|
1022
1209
|
dispose() {
|
|
1210
|
+
if (hudClearDrawn) {
|
|
1211
|
+
restoreHudClear();
|
|
1212
|
+
}
|
|
1023
1213
|
unguardKeys();
|
|
1024
1214
|
desktopQuery?.removeEventListener?.('change', layoutPanel);
|
|
1025
1215
|
root.remove();
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
// A place may ask for a steadier offer (v1.22, `grab.reach` and
|
|
15
15
|
// `grab.steady`): a longer reach, and an offer that does not flicker at its
|
|
16
16
|
// edges. A place that asks for neither runs exactly the code it always did.
|
|
17
|
+
//
|
|
18
|
+
// A place may keep an object for one player (v1.27, `hub.keepFor`): it is
|
|
19
|
+
// never offered to anyone else, so the nearest object a player may take is
|
|
20
|
+
// the one offered. Where nothing is kept the offer is exactly what it was.
|
|
17
21
|
|
|
18
22
|
import { hub } from './state.js';
|
|
19
23
|
|
|
@@ -71,6 +75,9 @@ export const KEEP_MARGIN_M = 0.4;
|
|
|
71
75
|
const KEEP_COS = 0;
|
|
72
76
|
export const STEADY_GRACE_MS = 600;
|
|
73
77
|
export const PRESS_WAIT_MS = 500;
|
|
78
|
+
// v1.25 `grab.keepHeld`: how often the server is told a hold goes on (its
|
|
79
|
+
// pin on the held object lasts 2.5 s past the last word).
|
|
80
|
+
export const KEEP_TELL_MS = 1000;
|
|
74
81
|
// Where the walk preset's capsule stands (physics-3d `Player`): its radius and
|
|
75
82
|
// height, and how far it hovers.
|
|
76
83
|
const PLAYER = { radius: 0.35, height: 1.4, hover: 0.15 };
|
|
@@ -158,6 +165,15 @@ function frame(t, scene, mp, local, idle) {
|
|
|
158
165
|
throwHeld(t, scene, body, local, config, net, now);
|
|
159
166
|
} else {
|
|
160
167
|
carry(t, scene, body, local, config, dt);
|
|
168
|
+
if (config.keepHeld === true) {
|
|
169
|
+
// v1.25: the server keeps a held object this client's only while it
|
|
170
|
+
// hears the hold goes on.
|
|
171
|
+
t.held.toldAt ??= now;
|
|
172
|
+
if (now - t.held.toldAt >= KEEP_TELL_MS) {
|
|
173
|
+
t.held.toldAt = now;
|
|
174
|
+
net.send({ k: 'hub-grab', actor: id, op: 'hold' });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
161
177
|
}
|
|
162
178
|
}
|
|
163
179
|
if (t.held) {
|
|
@@ -213,10 +229,10 @@ function steadyFrame(t, scene, mp, local, config, net, active, pressed, now, dt)
|
|
|
213
229
|
grabbable(scene, mp, local, reach, FRONT_COS, capFor(scene, local));
|
|
214
230
|
if (ready) {
|
|
215
231
|
t.offer = { id: ready.id, okAt: now };
|
|
216
|
-
} else if (kept && (now - kept.okAt > STEADY_GRACE_MS || !stillThere(scene, kept.id))) {
|
|
232
|
+
} else if (kept && (now - kept.okAt > STEADY_GRACE_MS || !stillThere(scene, kept.id, mp))) {
|
|
217
233
|
t.offer = null;
|
|
218
234
|
}
|
|
219
|
-
if (t.waiting && (now > t.waiting.until || !stillThere(scene, t.waiting.id))) {
|
|
235
|
+
if (t.waiting && (now > t.waiting.until || !stillThere(scene, t.waiting.id, mp))) {
|
|
220
236
|
t.waiting = null;
|
|
221
237
|
}
|
|
222
238
|
if (pressed && (ready || t.offer)) {
|
|
@@ -243,12 +259,20 @@ function steadyFrame(t, scene, mp, local, config, net, active, pressed, now, dt)
|
|
|
243
259
|
}
|
|
244
260
|
|
|
245
261
|
// Whether an object kept on offer can still come back: in the scene, not
|
|
246
|
-
// hidden by the place. Anything else may
|
|
247
|
-
|
|
248
|
-
|
|
262
|
+
// hidden by the place, not kept for someone else (v1.27). Anything else may
|
|
263
|
+
// change within a grace.
|
|
264
|
+
function stillThere(scene, id, mp) {
|
|
265
|
+
return Boolean(scene.getActor(id)) && !hub.hidden.has(id) && !keptFromMe(mp, id);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// v1.27 `hub.keepFor`: whether the place keeps this object for another player.
|
|
269
|
+
// False for every object where nothing is kept.
|
|
270
|
+
function keptFromMe(mp, id) {
|
|
271
|
+
return hub.keptFor.size > 0 && hub.keptFor.has(id) && hub.keptFor.get(id) !== mp.net?.selfId?.();
|
|
249
272
|
}
|
|
250
273
|
|
|
251
|
-
// The nearest object this client owns in front of the player, or null
|
|
274
|
+
// The nearest object this client owns in front of the player, or null; one the
|
|
275
|
+
// place keeps for someone else (v1.27) is passed over for the next nearest. With
|
|
252
276
|
// no more arguments it is the test every place had before v1.22; `reach`,
|
|
253
277
|
// `cos` and `centre` (the farthest an object's centre may be from the
|
|
254
278
|
// player's) carry a place's `grab.reach` and `grab.steady`, and `only` limits
|
|
@@ -272,7 +296,7 @@ function grabbable(
|
|
|
272
296
|
const fz = Math.cos(f);
|
|
273
297
|
let best = null;
|
|
274
298
|
for (const [id, at] of mp.claimable(scene)) {
|
|
275
|
-
if ((only !== null && id !== only) || !mine.has(id) || hub.hidden.has(id)) {
|
|
299
|
+
if ((only !== null && id !== only) || !mine.has(id) || hub.hidden.has(id) || keptFromMe(mp, id)) {
|
|
276
300
|
continue;
|
|
277
301
|
}
|
|
278
302
|
const actor = scene.getActor(id);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// The hats this kit draws (contract §11): a wearable whose `kind` is
|
|
2
|
+
// `hat-<id>` for an id here. Ids only, and nothing imported, so a place's
|
|
3
|
+
// server may read the list (`@imports/castle.hub-game/code/client/hats.js`)
|
|
4
|
+
// to offer exactly the hats every client can draw; how each one is built is
|
|
5
|
+
// `wear.js`'s.
|
|
6
|
+
export const HAT_PREFIX = 'hat-';
|
|
7
|
+
|
|
8
|
+
export const HAT_SETS = {
|
|
9
|
+
stadium: ['sweatband', 'cap', 'foam-crown', 'laurel'],
|
|
10
|
+
hollow: ['bat-clip', 'witch', 'lantern', 'crooked-top'],
|
|
11
|
+
sunny: ['straw', 'flower-crown', 'beekeeper', 'sunflower'],
|
|
12
|
+
harbour: ['sailor', 'souwester', 'captain', 'lighthouse'],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const HATS = Object.values(HAT_SETS).flat();
|
|
16
|
+
|
|
17
|
+
// The wearable kind of a hat id, and the hat id of a kind (null for a kind
|
|
18
|
+
// that is not one of these hats).
|
|
19
|
+
export function hatKind(id) {
|
|
20
|
+
return `${HAT_PREFIX}${id}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function hatId(kind) {
|
|
24
|
+
const id = typeof kind === 'string' && kind.startsWith(HAT_PREFIX) ? kind.slice(HAT_PREFIX.length) : null;
|
|
25
|
+
return HATS.includes(id) ? id : null;
|
|
26
|
+
}
|
|
@@ -9,11 +9,12 @@ import * as Avatars from '@imports/castle.multiplayer-3d/code/client/avatars.js'
|
|
|
9
9
|
import * as Avatar from './avatar.js';
|
|
10
10
|
import * as Cabinets from './cabinets.js';
|
|
11
11
|
import { firstJoinFor } from './firstJoin.js';
|
|
12
|
-
import { deck, hub } from './state.js';
|
|
12
|
+
import { deck, hub, wearingNow } from './state.js';
|
|
13
13
|
|
|
14
14
|
// Root-anchored: the deck's own castle.json once this kit is imported.
|
|
15
15
|
const castleJson = Object.values(import.meta.glob('/castle.json', { eager: true, import: 'default' }))[0] ?? {};
|
|
16
16
|
deck.tiers = castleJson?.hub?.tiers === true;
|
|
17
|
+
deck.cues = castleJson?.hub?.cues === true;
|
|
17
18
|
|
|
18
19
|
let files = null;
|
|
19
20
|
// The scene and multiplayer system of the newest snapshot, for a message that
|
|
@@ -42,9 +43,10 @@ function setAvatars(scene, system) {
|
|
|
42
43
|
hub.avatars = next;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
// Everyone's wearables with this player's own over them (v1.4)
|
|
46
|
+
// Everyone's wearables with this player's own over them (v1.4), and over
|
|
47
|
+
// those whatever the place is showing on a player (v1.28, `hub.tryOn`).
|
|
46
48
|
function setWearing() {
|
|
47
|
-
hub.wearing =
|
|
49
|
+
hub.wearing = wearingNow();
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
function wearMap(value) {
|
|
@@ -85,6 +87,10 @@ export default {
|
|
|
85
87
|
// A jump to a door: the camera turns to look at it.
|
|
86
88
|
if (typeof msg.facing === 'number') {
|
|
87
89
|
(scene.persistent ??= {}).camAngle = Math.PI - msg.facing;
|
|
90
|
+
// Under the engine's orbit camera key the facing is asked for.
|
|
91
|
+
if (scene.cameraControl === 'orbit') {
|
|
92
|
+
scene.faceRequest = msg.facing;
|
|
93
|
+
}
|
|
88
94
|
}
|
|
89
95
|
// Beside a player: the hub system says whom (a start next to a friend).
|
|
90
96
|
if (typeof msg.to === 'string') {
|
|
@@ -122,6 +128,11 @@ export default {
|
|
|
122
128
|
hub.wearMe = wearMap(msg.hubWear);
|
|
123
129
|
setWearing();
|
|
124
130
|
break;
|
|
131
|
+
case 'hub-try':
|
|
132
|
+
// v1.28: try-ons of players in a hidden pair this player may see.
|
|
133
|
+
hub.tryMe = wearMap(msg.hubTry);
|
|
134
|
+
setWearing();
|
|
135
|
+
break;
|
|
125
136
|
case 'hub-labels':
|
|
126
137
|
hub.labelsMe = msg.labels && typeof msg.labels === 'object' ? msg.labels : {};
|
|
127
138
|
break;
|
|
@@ -182,6 +193,18 @@ export default {
|
|
|
182
193
|
hub.wearAll = wearMap(msg.hubWear);
|
|
183
194
|
setWearing();
|
|
184
195
|
}
|
|
196
|
+
// v1.28: only a place that shows a try-on sends this. A snapshot (it
|
|
197
|
+
// carries `hubPlace`) without one means none is up. `tryMe` is not the
|
|
198
|
+
// snapshot's to clear: the place sends `hub-try` on the tick before a
|
|
199
|
+
// joiner's snapshot, and sends it again, empty or not, to a client that
|
|
200
|
+
// rejoins.
|
|
201
|
+
if (msg.hubTry && typeof msg.hubTry === 'object') {
|
|
202
|
+
hub.tryAll = wearMap(msg.hubTry);
|
|
203
|
+
setWearing();
|
|
204
|
+
} else if (msg.hubPlace && hub.tryAll.size > 0) {
|
|
205
|
+
hub.tryAll = new Map();
|
|
206
|
+
setWearing();
|
|
207
|
+
}
|
|
185
208
|
if ('hud' in msg) {
|
|
186
209
|
hub.hud = msg.hud ?? null;
|
|
187
210
|
}
|
|
@@ -209,6 +232,10 @@ export default {
|
|
|
209
232
|
if (msg.labels) {
|
|
210
233
|
hub.labels = msg.labels;
|
|
211
234
|
}
|
|
235
|
+
// v1.27: only a place that keeps an object for a player sends this.
|
|
236
|
+
if (msg.hubKept && typeof msg.hubKept === 'object') {
|
|
237
|
+
hub.keptFor = new Map(Object.entries(msg.hubKept));
|
|
238
|
+
}
|
|
212
239
|
// v1.6: only a place that turns idle play on sends these.
|
|
213
240
|
if (msg.hubEmotes && typeof msg.hubEmotes === 'object') {
|
|
214
241
|
hub.emotes = msg.hubEmotes;
|