castle-web-cli 0.4.230 → 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/castle-host/host.js +81 -0
- package/dist/devSaveStorage.d.ts +36 -0
- package/dist/devSaveStorage.js +469 -0
- package/dist/devSessionChild.js +22 -12
- package/dist/devSessionServer.js +8 -2
- package/dist/devSessionStorage.d.ts +9 -0
- package/dist/devSessionStorage.js +66 -1
- package/dist/init.js +1 -1
- package/dist/serve.js +5 -1
- package/dist/serverBundle.js +5 -3
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +148 -1
- package/kits/base/sdk/castle.d.ts +4 -0
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +15 -0
- package/kits/base/sdk/multiplayer.js +52 -4
- package/kits/base/sdk/save.d.ts +197 -0
- package/kits/base/sdk/save.js +525 -0
- package/kits/base/sdk/saveCoordinator.d.ts +39 -0
- package/kits/base/sdk/saveCoordinator.js +252 -0
- package/kits/base/sdk/server/storage.d.ts +3 -2
- package/kits/base/sdk/server/storage.js +25 -5
- package/kits/base/sdk/server/wrapper.d.ts +4 -0
- package/kits/base/sdk/server/wrapper.js +2 -0
- package/kits/base/sdk/store.d.ts +3 -2
- package/kits/base/sdk/store.js +5 -0
- package/kits/hub-game/CLAUDE.md +29 -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 +237 -13
- package/kits/hub-game/code/client/grab.js +166 -7
- package/kits/hub-game/code/client/hats.js +26 -0
- package/kits/hub-game/code/client/hookLayer.js +36 -3
- package/kits/hub-game/code/client/hudClear.js +126 -0
- package/kits/hub-game/code/client/state.js +35 -1
- package/kits/hub-game/code/client/talk.js +10 -36
- package/kits/hub-game/code/client/tiers.js +505 -0
- package/kits/hub-game/code/client/together.js +144 -4
- 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 +299 -13
- package/kits/hub-game/code/server/hub.js +162 -7
- package/kits/hub-game/code/server/manifest.js +80 -8
- package/kits/hub-game/code/server/npcs.js +21 -33
- package/kits/hub-game/code/server/party.js +75 -6
- 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 +386 -21
- package/kits/hub-game/docs/contract.md +285 -19
- 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 +511 -0
- 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 +721 -0
- package/kits/hub-game/scripts/test-hud-clear.mjs +676 -0
- package/kits/hub-game/scripts/test-manifest.mjs +122 -1
- package/kits/hub-game/scripts/test-npcs.mjs +34 -24
- package/kits/hub-game/scripts/test-party.mjs +108 -4
- package/kits/hub-game/scripts/test-say.mjs +59 -2
- package/kits/hub-game/scripts/test-tiers.mjs +854 -0
- package/kits/hub-game/scripts/test-together.mjs +33 -1
- package/kits/hub-game/scripts/test-try-on.mjs +940 -0
- package/kits/physics-2d/CLAUDE.md +2 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +127 -0
- package/kits/physics-2d/package.json +1 -1
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +298 -0
- package/kits/physics-3d/CLAUDE.md +531 -0
- package/kits/physics-3d/behaviors/Player.jsx +437 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/pxmodel-format.md +4 -0
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +33 -1
- package/kits/physics-3d/engine3d/actornode.js +253 -0
- package/kits/physics-3d/engine3d/nearshadows.js +600 -0
- package/kits/physics-3d/engine3d/optimize.js +49 -0
- package/kits/physics-3d/engine3d/orbitinput.js +277 -0
- package/kits/physics-3d/engine3d/unchanged.js +153 -0
- package/kits/physics-3d/engine3d/world3d.js +525 -11
- package/kits/physics-3d/package.json +1 -1
- 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 +543 -0
- 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-near-shadows.mjs +1073 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +667 -0
- package/kits/physics-3d/scripts/test-static-passes.mjs +459 -0
- package/kits/physics-3d/scripts/test-static-physics.mjs +128 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +633 -0
- package/kits/physics-3d/systems/physics3d.js +273 -9
- package/package.json +1 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// Hats (contract §11): a wearable kind `hat-<id>` is drawn as a few matte
|
|
2
|
+
// Shapes on the avatar's head (code/client/wear.js, hats.js, avatar.js
|
|
3
|
+
// `hatFit`), and every other wearable is drawn exactly as it was before hats.
|
|
4
|
+
// castle-web-sdk is stubbed (scripts/fixtures/sdk-stub.mjs). `npm run check`
|
|
5
|
+
// runs this.
|
|
6
|
+
|
|
7
|
+
import assert from 'node:assert/strict';
|
|
8
|
+
import { register } from 'node:module';
|
|
9
|
+
|
|
10
|
+
register(
|
|
11
|
+
'data:text/javascript,' +
|
|
12
|
+
encodeURIComponent(`
|
|
13
|
+
export async function resolve(specifier, context, next) {
|
|
14
|
+
if (specifier === 'castle-web-sdk') {
|
|
15
|
+
return { url: ${JSON.stringify(new URL('./fixtures/sdk-stub.mjs', import.meta.url).href)}, shortCircuit: true };
|
|
16
|
+
}
|
|
17
|
+
return next(specifier, context);
|
|
18
|
+
}`),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const Avatar = await import('../code/client/avatar.js');
|
|
22
|
+
const { HATS, HAT_SETS, hatId, hatKind } = await import('../code/client/hats.js');
|
|
23
|
+
const { HAT_IDS, makeWear, pieces } = await import('../code/client/wear.js');
|
|
24
|
+
const Wear = await import('../code/server/wear.js');
|
|
25
|
+
|
|
26
|
+
let n = 0;
|
|
27
|
+
function test(name, fn) {
|
|
28
|
+
fn();
|
|
29
|
+
n += 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const round = (p) => Object.fromEntries(Object.entries(p).map(([k, v]) => [k, Math.round(v * 1e6) / 1e6]));
|
|
33
|
+
const seen = (parts) => parts && parts.map((piece) => ({ keys: Object.keys(piece), shape: piece.shape, at0: round(piece.at(0)), at1: round(piece.at(1.3)) }));
|
|
34
|
+
|
|
35
|
+
test('every wearable from before hats is drawn exactly as it was', () => {
|
|
36
|
+
// Captured by running `pieces` as it was before hats: the Shape of each
|
|
37
|
+
// piece, field for field, and where it is at t = 0 and t = 1.3.
|
|
38
|
+
const glow = (kind, size, color, emissiveIntensity) => ({ kind, ...size, color, emissive: color, emissiveIntensity, roughness: 0.4, metalness: 0.1, solid: false });
|
|
39
|
+
const piece = (shape, at0, at1) => ({ keys: ['shape', 'at'], shape, at0, at1 });
|
|
40
|
+
const orb = glow('sphere', { radius: 0.09450000000000001 }, '#00ff88', 1.65);
|
|
41
|
+
const before = [
|
|
42
|
+
[[null], null],
|
|
43
|
+
[[undefined], null],
|
|
44
|
+
[[{ kind: 'halo', color: '#FFD700', rarity: 0 }], [piece(glow('cylinder', { radius: 0.35, height: 0.04 }, '#ffd700', 0.6), { x: 0, y: 1.1, z: 0 }, { x: 0, y: 1.115465, z: 0 })]],
|
|
45
|
+
[[{ kind: 'halo', color: '#ffd700', rarity: 4 }, 1.38], [piece(glow('cylinder', { radius: 0.42, height: 0.04 }, '#ffd700', 1.2), { x: 0, y: 0.83, z: 0 }, { x: 0, y: 0.845465, z: 0 })]],
|
|
46
|
+
[[{ kind: 'aura', color: '#9b5cff', rarity: 6 }, 1.5], [piece(glow('cylinder', { radius: 0.78, height: 0.02 }, '#9b5cff', 1.5), { x: 0, y: -0.83, z: 0 }, { x: 0, y: -0.83, z: 0 })]],
|
|
47
|
+
[[{ kind: 'orbit', color: '#00ff88', rarity: 0 }], [piece(glow('sphere', { radius: 0.07 }, '#00ff88', 0.6), { x: 0.5, y: 0.95, z: 0 }, { x: -0.243741, y: 0.907436, z: 0.436566 })]],
|
|
48
|
+
[
|
|
49
|
+
[{ kind: 'orbit', color: '#00ff88', rarity: 7 }, 1.7],
|
|
50
|
+
[
|
|
51
|
+
piece(orb, { x: 0.5, y: 1, z: 0 }, { x: -0.494266, y: 0.985072, z: 0.075506 }),
|
|
52
|
+
piece(orb, { x: -0.25, y: 0.956699, z: 0.433013 }, { x: 0.181743, y: 0.966138, z: -0.4658 }),
|
|
53
|
+
piece(orb, { x: -0.25, y: 1.043301, z: -0.433013 }, { x: 0.312523, y: 1.04879, z: 0.390294 }),
|
|
54
|
+
],
|
|
55
|
+
],
|
|
56
|
+
[[{ kind: 'crown', color: '#ffd700', rarity: 1 }], null],
|
|
57
|
+
[[{ kind: 'halo', color: 'red', rarity: 1 }], null],
|
|
58
|
+
[[{ kind: 'halo', color: '#ffd700' }, 1.31], [piece(glow('cylinder', { radius: 0.35, height: 0.04 }, '#ffd700', 0.6), { x: 0, y: 0.76, z: 0 }, { x: 0, y: 0.775465, z: 0 })]],
|
|
59
|
+
[[{ kind: 'aura', color: '#123456', rarity: 99 }], [piece(glow('cylinder', { radius: 0.87, height: 0.02 }, '#123456', 1.9499999999999997), { x: 0, y: -0.83, z: 0 }, { x: 0, y: -0.83, z: 0 })]],
|
|
60
|
+
];
|
|
61
|
+
for (const [args, expected] of before) {
|
|
62
|
+
assert.deepStrictEqual(seen(pieces(...args)), expected, JSON.stringify(args));
|
|
63
|
+
// A hat's fit changes nothing for a wearable that is not a hat.
|
|
64
|
+
assert.deepStrictEqual(seen(pieces(args[0], args[1], [1.2, 0.5, 0.1])), expected, JSON.stringify(args));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('the list a server reads is the catalogue the client draws', () => {
|
|
69
|
+
assert.deepEqual(HATS, HAT_IDS);
|
|
70
|
+
assert.equal(HATS.length, 16);
|
|
71
|
+
assert.equal(new Set(HATS).size, 16);
|
|
72
|
+
assert.deepEqual(Object.keys(HAT_SETS), ['stadium', 'hollow', 'sunny', 'harbour']);
|
|
73
|
+
for (const id of HATS) {
|
|
74
|
+
const kind = hatKind(id);
|
|
75
|
+
assert.equal(kind, `hat-${id}`);
|
|
76
|
+
assert.equal(hatId(kind), id);
|
|
77
|
+
// The kit's server and ghost take the kind as they take any other.
|
|
78
|
+
assert.ok(Wear.KIND.test(kind), kind);
|
|
79
|
+
assert.deepEqual(Wear.cleanWearable({ kind, color: '#AA3322', rarity: 3 }), { kind, color: '#aa3322', rarity: 3 });
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('a kind that is not one of the hats is not drawn', () => {
|
|
84
|
+
for (const kind of ['hat-nope', 'hat-', 'hat', 'hat-constructor', 'hat-toString', 'hat-cap-2', 'cap', 'Hat-cap', 7, null, undefined]) {
|
|
85
|
+
assert.equal(pieces({ kind, color: '#ffd700', rarity: 1 }), null, String(kind));
|
|
86
|
+
assert.equal(hatId(kind), null, String(kind));
|
|
87
|
+
}
|
|
88
|
+
assert.equal(pieces({ kind: 'hat-cap', color: 'javascript:', rarity: 1 }), null);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const COLOR = /^#[0-9a-f]{6}$/;
|
|
92
|
+
// The avatar's origin is 0.7 m over its model's feet, and its name tag 1.25 m
|
|
93
|
+
// over the origin (multiplayer-3d `nameTags.js`).
|
|
94
|
+
const MODEL_FEET_Y = -0.7;
|
|
95
|
+
const NAME_TAG_Y = 1.25;
|
|
96
|
+
|
|
97
|
+
test('every hat is one to three matte Shapes on the head of every avatar in every set', () => {
|
|
98
|
+
for (const id of HATS) {
|
|
99
|
+
for (const style of Avatar.STYLES) {
|
|
100
|
+
for (let index = 0; index < Avatar.AVATARS; index += 1) {
|
|
101
|
+
const where = `${id} on ${style} ${index}`;
|
|
102
|
+
const fit = Avatar.hatFit(index, style);
|
|
103
|
+
const top = Avatar.top(index, style);
|
|
104
|
+
const [seat, scale, rise] = fit;
|
|
105
|
+
// The seat is on the model, never over its top.
|
|
106
|
+
assert.ok(seat > 1 && seat <= top && scale >= 0.5 && scale <= 1.3 && rise >= 0 && rise <= 0.12, where);
|
|
107
|
+
const parts = pieces({ kind: `hat-${id}`, color: '#3AA0FF', rarity: 0 }, top, fit);
|
|
108
|
+
assert.ok(Array.isArray(parts) && parts.length >= 1 && parts.length <= 3, where);
|
|
109
|
+
let main = 0;
|
|
110
|
+
for (const part of parts) {
|
|
111
|
+
const s = part.shape;
|
|
112
|
+
assert.deepEqual(Object.keys(part), ['shape', 'at', 'turns', 'tilt'], where);
|
|
113
|
+
assert.ok(s.kind === 'cylinder' || s.kind === 'box', where);
|
|
114
|
+
const sizes = s.kind === 'cylinder' ? [s.radius, s.height] : [s.width, s.height, s.depth];
|
|
115
|
+
assert.deepEqual(Object.keys(s).sort(), [...(s.kind === 'cylinder' ? ['radius', 'height'] : ['width', 'height', 'depth']), 'kind', 'color', 'roughness', 'metalness', 'solid'].sort(), where);
|
|
116
|
+
assert.ok(sizes.every((v) => Number.isFinite(v) && v > 0 && v <= 0.8), where);
|
|
117
|
+
assert.ok(COLOR.test(s.color), where);
|
|
118
|
+
// Matte: no glow, and never solid.
|
|
119
|
+
assert.equal('emissive' in s || 'emissiveIntensity' in s, false, where);
|
|
120
|
+
assert.equal(s.solid, false, where);
|
|
121
|
+
assert.equal(part.turns, true, where);
|
|
122
|
+
assert.ok(Number.isFinite(part.tilt) && Math.abs(part.tilt) <= 20, where);
|
|
123
|
+
main += s.color === '#3aa0ff' ? 1 : 0;
|
|
124
|
+
// It stays where it is put (nothing bobs), within reach of the head,
|
|
125
|
+
// on it rather than in it, and under the name tag.
|
|
126
|
+
const at = part.at(0);
|
|
127
|
+
assert.deepEqual(part.at(7.5), at, where);
|
|
128
|
+
assert.ok(Math.hypot(at.x, at.z) <= 0.3 * scale, where);
|
|
129
|
+
const reach = (s.kind === 'cylinder' ? s.radius : Math.hypot(s.width, s.depth) / 2) * Math.sin((Math.abs(part.tilt) * Math.PI) / 180);
|
|
130
|
+
const low = at.y - s.height / 2 - reach;
|
|
131
|
+
const high = at.y + s.height / 2 + reach;
|
|
132
|
+
assert.ok(low >= MODEL_FEET_Y + seat - 0.06 * scale, `${where}: sinks`);
|
|
133
|
+
assert.ok(high <= MODEL_FEET_Y + seat + 0.36 * scale + rise + 1e-9, `${where}: too tall`);
|
|
134
|
+
assert.ok(high < NAME_TAG_Y - 0.08, `${where}: reaches the name tag`);
|
|
135
|
+
}
|
|
136
|
+
// The wearable's colour is the hat's main colour.
|
|
137
|
+
assert.ok(main >= 1, where);
|
|
138
|
+
// The lowest piece rests at the seat: the hat does not float.
|
|
139
|
+
const floor = Math.min(...parts.map((part) => part.at(0).y - part.shape.height / 2));
|
|
140
|
+
assert.ok(floor <= MODEL_FEET_Y + seat + rise + 0.05 * scale, `${where}: floats`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test('rarity and an unknown avatar change nothing a hat needs', () => {
|
|
147
|
+
const plain = seen(pieces({ kind: 'hat-straw', color: '#e8c96a', rarity: 0 }, 1.38, [1.31, 1, 0.05]));
|
|
148
|
+
assert.deepEqual(seen(pieces({ kind: 'hat-straw', color: '#e8c96a', rarity: 9 }, 1.38, [1.31, 1, 0.05])), plain);
|
|
149
|
+
// An avatar this kit has no fit for wears it just under its top.
|
|
150
|
+
assert.equal(Avatar.hatFit(9, 'toon'), null);
|
|
151
|
+
assert.equal(Avatar.hatFit(0, 'nope'), Avatar.hatFit(0, 'toon'));
|
|
152
|
+
const unknown = pieces({ kind: 'hat-straw', color: '#e8c96a', rarity: 0 });
|
|
153
|
+
assert.equal(unknown.length, 2);
|
|
154
|
+
assert.ok(unknown.every((part) => part.at(0).y > 0.8 && part.at(0).y < 1.1));
|
|
155
|
+
// The toon Star wears a smaller one.
|
|
156
|
+
const star = pieces({ kind: 'hat-straw', color: '#e8c96a', rarity: 0 }, 1.56, Avatar.hatFit(3, 'toon'));
|
|
157
|
+
assert.ok(star[0].shape.radius < plain[0].shape.radius);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// A scene that keeps actors by id, as the hub system's does.
|
|
161
|
+
function fakeScene(actors) {
|
|
162
|
+
const all = new Map(actors.map((actor) => [actor.id, actor]));
|
|
163
|
+
const calls = { spawned: [], despawned: [] };
|
|
164
|
+
return {
|
|
165
|
+
calls,
|
|
166
|
+
multiplayer: { net: { selfId: () => 'me' }, avatars: { actors: new Map([['p2', 'body-p2']]), retired: new Set() } },
|
|
167
|
+
getActor: (id) => all.get(id) ?? null,
|
|
168
|
+
spawnActor(actor) {
|
|
169
|
+
const made = { id: actor.id, components: { ...actor.components, Transform: { x: 0, y: 0, z: 0, rotationX: 0, rotationY: 0, rotationZ: 0, ...actor.components.Transform } } };
|
|
170
|
+
all.set(made.id, made);
|
|
171
|
+
calls.spawned.push(actor);
|
|
172
|
+
},
|
|
173
|
+
despawnActor(id) {
|
|
174
|
+
all.delete(id);
|
|
175
|
+
calls.despawned.push(id);
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
test('a hat follows its wearer and faces the way they face; a halo is moved as it was', () => {
|
|
181
|
+
const local = { id: 'me-body', components: { Transform: { x: 10, y: 1, z: 20, rotationY: 0 } } };
|
|
182
|
+
const other = { id: 'body-p2', components: { Transform: { x: -3, y: 1, z: 4, rotationY: 90 } } };
|
|
183
|
+
const scene = fakeScene([local, other]);
|
|
184
|
+
const wear = makeWear();
|
|
185
|
+
const wearing = new Map([
|
|
186
|
+
['me', { kind: 'halo', color: '#ffd700', rarity: 0 }],
|
|
187
|
+
['p2', { kind: 'hat-cap', color: '#d1453b', rarity: 0 }],
|
|
188
|
+
]);
|
|
189
|
+
const asked = [];
|
|
190
|
+
const fitOf = (playerId) => {
|
|
191
|
+
asked.push(playerId);
|
|
192
|
+
return Avatar.hatFit(1, 'blocky');
|
|
193
|
+
};
|
|
194
|
+
wear.frame(scene, local, wearing, () => 1.66, 0, fitOf);
|
|
195
|
+
// Only the hat's wearer is asked for a fit.
|
|
196
|
+
assert.deepEqual(asked, ['p2']);
|
|
197
|
+
assert.deepEqual(
|
|
198
|
+
scene.calls.spawned.map((a) => a.id),
|
|
199
|
+
['wear:me:0', 'wear:p2:0', 'wear:p2:1'],
|
|
200
|
+
);
|
|
201
|
+
// The halo's actor is spawned with the fields it always had.
|
|
202
|
+
assert.deepEqual(Object.keys(scene.calls.spawned[0].components.Transform), ['x', 'y', 'z']);
|
|
203
|
+
const halo = scene.getActor('wear:me:0').components.Transform;
|
|
204
|
+
assert.deepEqual([halo.x, halo.z, halo.rotationY], [10, 20, 0]);
|
|
205
|
+
// The cap's peak is in front of the head (0.27 m, times this avatar's 1.1):
|
|
206
|
+
// the wearer faces +x at 90 degrees, so it is there, turned with them.
|
|
207
|
+
const reach = 0.27 * 1.1;
|
|
208
|
+
const crown = scene.getActor('wear:p2:0').components.Transform;
|
|
209
|
+
const peak = scene.getActor('wear:p2:1').components.Transform;
|
|
210
|
+
assert.ok(Math.abs(crown.x + 3) < 1e-9 && Math.abs(crown.z - 4) < 1e-9);
|
|
211
|
+
assert.ok(Math.abs(peak.x - (-3 + reach)) < 1e-9 && Math.abs(peak.z - 4) < 1e-9);
|
|
212
|
+
assert.equal(peak.rotationY, 90);
|
|
213
|
+
assert.ok(Math.abs(crown.y - (1 + MODEL_FEET_Y + 1.48 + 0.075 * 1.1)) < 1e-3);
|
|
214
|
+
// They turn and walk: the hat goes with them, and nothing is spawned again.
|
|
215
|
+
other.components.Transform.rotationY = 180;
|
|
216
|
+
other.components.Transform.x = 0;
|
|
217
|
+
wear.frame(scene, local, wearing, () => 1.66, 16, fitOf);
|
|
218
|
+
assert.equal(scene.calls.spawned.length, 3);
|
|
219
|
+
assert.ok(Math.abs(peak.x) < 1e-9 && Math.abs(peak.z - (4 - reach)) < 1e-9);
|
|
220
|
+
// Another avatar set fits it again; taking it off takes the pieces down.
|
|
221
|
+
wear.frame(scene, local, wearing, () => 1.66, 32, () => Avatar.hatFit(1, 'toon'));
|
|
222
|
+
assert.deepEqual(scene.calls.despawned, ['wear:p2:0', 'wear:p2:1']);
|
|
223
|
+
wearing.delete('p2');
|
|
224
|
+
wear.frame(scene, local, wearing, () => 1.66, 48, fitOf);
|
|
225
|
+
assert.equal(scene.getActor('wear:p2:0'), null);
|
|
226
|
+
assert.ok(scene.getActor('wear:me:0'));
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
console.log(`test-hats: ${n} passed`);
|