castle-web-cli 0.4.204 → 0.4.205
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/agent-failures.d.ts +3 -1
- package/dist/agent-failures.js +19 -0
- package/dist/agent-prompts.js +2 -1
- package/dist/agent.d.ts +3 -2
- package/dist/agent.js +19 -10
- package/dist/castle-host/host.d.ts +17 -0
- package/dist/castle-host/host.js +551 -4
- package/dist/devSessionStorage.js +65 -4
- package/dist/effortSupport.d.ts +7 -0
- package/dist/effortSupport.js +31 -0
- package/dist/init.js +13 -3
- package/dist/platformDoc.js +6 -1
- package/dist/serve.js +35 -2
- package/dist/shell/assets/{index-DHzA0-Sj.js → index-hWQTC8q6.js} +5 -5
- package/dist/shell/index.html +1 -1
- package/dist/vitePlugins.js +19 -1
- package/kits/base/CLAUDE.md +2 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +131 -0
- package/kits/base/sdk/agent.d.ts +6 -0
- package/kits/base/sdk/agent.js +70 -0
- package/kits/base/sdk/castle.d.ts +4 -0
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +106 -0
- package/kits/base/sdk/commands.js +21 -0
- package/kits/base/sdk/decks.d.ts +7 -0
- package/kits/base/sdk/decks.js +31 -0
- package/kits/base/sdk/runtime.d.ts +4 -2
- package/kits/base/sdk/runtime.js +51 -40
- package/kits/base/sdk/server/storage.d.ts +44 -0
- package/kits/base/sdk/server/storage.js +54 -0
- package/kits/base/sdk/transport.d.ts +5 -1
- package/kits/base/sdk/transport.js +106 -23
- package/kits/multiplayer-2d/castle.json +4 -4
- package/kits/multiplayer-2d/code/client/poses.js +7 -0
- package/kits/multiplayer-2d/code/server/limits.js +3 -0
- package/kits/multiplayer-2d/code/server/ownership.js +36 -8
- package/kits/multiplayer-2d/code/systems/multiplayer.js +23 -2
- package/kits/multiplayer-3d/CLAUDE.md +12 -1
- package/kits/multiplayer-3d/castle.json +4 -4
- package/kits/multiplayer-3d/code/client/avatars.js +7 -1
- package/kits/multiplayer-3d/code/client/poses.js +61 -1
- package/kits/multiplayer-3d/code/client/steer.js +383 -0
- package/kits/multiplayer-3d/code/server/limits.js +3 -0
- package/kits/multiplayer-3d/code/server/ownership.js +114 -18
- package/kits/multiplayer-3d/code/server/world.js +12 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +315 -34
- package/kits/physics-3d/CLAUDE.md +65 -7
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/pxmodel-format.md +916 -15
- package/kits/physics-3d/engine3d/PxModelEditor.jsx +2 -2
- package/kits/physics-3d/engine3d/artobjects.js +218 -0
- package/kits/physics-3d/engine3d/blob.js +1058 -0
- package/kits/physics-3d/engine3d/branches.js +300 -0
- package/kits/physics-3d/engine3d/cage.js +496 -0
- package/kits/physics-3d/engine3d/cageops.js +516 -0
- package/kits/physics-3d/engine3d/frame.js +669 -0
- package/kits/physics-3d/engine3d/look.js +675 -0
- package/kits/physics-3d/engine3d/materialpresets.js +486 -0
- package/kits/physics-3d/engine3d/modelEditorWorld.js +3 -2
- package/kits/physics-3d/engine3d/modelrefs.js +120 -0
- package/kits/physics-3d/engine3d/motion.js +560 -0
- package/kits/physics-3d/engine3d/objtext.js +37 -0
- package/kits/physics-3d/engine3d/optimize.js +1083 -0
- package/kits/physics-3d/engine3d/paint.js +674 -0
- package/kits/physics-3d/engine3d/partgeometry.js +467 -0
- package/kits/physics-3d/engine3d/paths.js +324 -0
- package/kits/physics-3d/engine3d/pxmodel.js +429 -26
- package/kits/physics-3d/engine3d/scatter.js +102 -0
- package/kits/physics-3d/engine3d/sculpt.js +1148 -0
- package/kits/physics-3d/engine3d/surfacedetail.js +267 -0
- package/kits/physics-3d/engine3d/sweep.js +480 -0
- package/kits/physics-3d/engine3d/thumbnails.js +6 -4
- package/kits/physics-3d/engine3d/world3d.js +119 -17
- package/kits/physics-3d/eslint.config.js +13 -0
- package/kits/physics-3d/models/parts/axe.pxmodel +40 -0
- package/kits/physics-3d/models/parts/backpack.pxmodel +47 -0
- package/kits/physics-3d/models/parts/barrel.pxmodel +22 -0
- package/kits/physics-3d/models/parts/bedroll.pxmodel +28 -0
- package/kits/physics-3d/models/parts/belt-pouch.pxmodel +22 -0
- package/kits/physics-3d/models/parts/bolt.pxmodel +10 -0
- package/kits/physics-3d/models/parts/bracer.pxmodel +26 -0
- package/kits/physics-3d/models/parts/chain-span.pxmodel +12 -0
- package/kits/physics-3d/models/parts/chimney.pxmodel +11 -0
- package/kits/physics-3d/models/parts/crate.pxmodel +44 -0
- package/kits/physics-3d/models/parts/crystal.pxmodel +22 -0
- package/kits/physics-3d/models/parts/door-arched.pxmodel +12 -0
- package/kits/physics-3d/models/parts/engine-block.pxmodel +39 -0
- package/kits/physics-3d/models/parts/exhaust-pipe.pxmodel +30 -0
- package/kits/physics-3d/models/parts/fence-span.pxmodel +10 -0
- package/kits/physics-3d/models/parts/fender.pxmodel +19 -0
- package/kits/physics-3d/models/parts/headlight.pxmodel +24 -0
- package/kits/physics-3d/models/parts/hood.pxmodel +17 -0
- package/kits/physics-3d/models/parts/horned-helmet.pxmodel +37 -0
- package/kits/physics-3d/models/parts/jerry-can.pxmodel +26 -0
- package/kits/physics-3d/models/parts/ladder.pxmodel +10 -0
- package/kits/physics-3d/models/parts/lamp.pxmodel +20 -0
- package/kits/physics-3d/models/parts/lantern.pxmodel +30 -0
- package/kits/physics-3d/models/parts/leaf-cluster.pxmodel +21 -0
- package/kits/physics-3d/models/parts/offroad-tire.pxmodel +48 -0
- package/kits/physics-3d/models/parts/pauldron.pxmodel +26 -0
- package/kits/physics-3d/models/parts/rivet.pxmodel +8 -0
- package/kits/physics-3d/models/parts/rock.pxmodel +21 -0
- package/kits/physics-3d/models/parts/roll-bar-light.pxmodel +26 -0
- package/kits/physics-3d/models/parts/round-shield.pxmodel +31 -0
- package/kits/physics-3d/models/parts/saddlebag.pxmodel +30 -0
- package/kits/physics-3d/models/parts/spoked-wheel.pxmodel +39 -0
- package/kits/physics-3d/models/parts/staff.pxmodel +33 -0
- package/kits/physics-3d/models/parts/stepping-stones.pxmodel +8 -0
- package/kits/physics-3d/models/parts/stone-base.pxmodel +10 -0
- package/kits/physics-3d/models/parts/sword.pxmodel +33 -0
- package/kits/physics-3d/models/parts/window-lit.pxmodel +13 -0
- package/kits/physics-3d/models/parts/wizard-hat.pxmodel +28 -0
- package/kits/physics-3d/models/templates/biped-stout.pxmodel +59 -0
- package/kits/physics-3d/models/templates/biped-tall.pxmodel +63 -0
- package/kits/physics-3d/models/templates/quadruped.pxmodel +52 -0
- package/kits/physics-3d/scripts/render/filmstrip.js +217 -0
- package/kits/physics-3d/scripts/render/index.html +20 -0
- package/kits/physics-3d/scripts/render/sheet.js +411 -0
- package/kits/physics-3d/scripts/render.mjs +646 -0
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/ownership.js +14 -4
- package/kits/real-time/code/client/smooth.js +2 -2
- package/kits/real-time/code/server/session.js +20 -4
- package/package.json +2 -2
|
@@ -148,7 +148,7 @@ export function PxModelEditor({ path }) {
|
|
|
148
148
|
useEffect(() => {
|
|
149
149
|
const med = medRef.current;
|
|
150
150
|
if (!med || !model || med.gizmoDragging) return;
|
|
151
|
-
setEditorModel(med, model, sprites);
|
|
151
|
+
setEditorModel(med, model, sprites, files, path);
|
|
152
152
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
153
153
|
}, [text, dataVersion]);
|
|
154
154
|
useEffect(() => {
|
|
@@ -252,7 +252,7 @@ export function PxModelEditor({ path }) {
|
|
|
252
252
|
const med = medRef.current;
|
|
253
253
|
if (!next && med && model) {
|
|
254
254
|
med.walkClock = 0;
|
|
255
|
-
setEditorModel(med, model, sprites); // restore the authored pose
|
|
255
|
+
setEditorModel(med, model, sprites, files, path); // restore the authored pose
|
|
256
256
|
}
|
|
257
257
|
};
|
|
258
258
|
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// Art objects and material extras on `.pxmodel` parts. See the Art section
|
|
2
|
+
// of docs/pxmodel-format.md.
|
|
3
|
+
//
|
|
4
|
+
// Anywhere an art ref string goes, an object `{ ref, repeat, offset, rotation }`
|
|
5
|
+
// can go instead, and a per-face `art` names faces on cylinders, cones and
|
|
6
|
+
// extrusions as well as boxes. `brightness`, `alphaTest` and `doubleSided`
|
|
7
|
+
// change a part's materials after they are built.
|
|
8
|
+
|
|
9
|
+
import * as THREE from 'three';
|
|
10
|
+
import { makeMaterial, resolveArtTexture } from './materials';
|
|
11
|
+
import { needsModelGeometry } from './partgeometry';
|
|
12
|
+
|
|
13
|
+
const DEG = Math.PI / 180;
|
|
14
|
+
|
|
15
|
+
// The face names each material slot answers to, by material index. A face
|
|
16
|
+
// takes the first name the art has. The box order is three's, and matches
|
|
17
|
+
// boxFaceMaterials in materials.js.
|
|
18
|
+
const FACE_SLOTS = {
|
|
19
|
+
box: [
|
|
20
|
+
['right', 'sides', 'all'],
|
|
21
|
+
['left', 'sides', 'all'],
|
|
22
|
+
['top', 'all'],
|
|
23
|
+
['bottom', 'top', 'all'],
|
|
24
|
+
['front', 'all'],
|
|
25
|
+
['back', 'sides', 'all'],
|
|
26
|
+
],
|
|
27
|
+
cylinder: [
|
|
28
|
+
['side', 'all'],
|
|
29
|
+
['top', 'caps', 'all'],
|
|
30
|
+
['bottom', 'caps', 'all'],
|
|
31
|
+
],
|
|
32
|
+
extrude: [
|
|
33
|
+
['caps', 'all'],
|
|
34
|
+
['sides', 'all'],
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// An art value as `{ ref, repeat, offset, rotation }`, or null when it is
|
|
39
|
+
// not a single ref.
|
|
40
|
+
function artSpec(value) {
|
|
41
|
+
if (typeof value === 'string' && value) {
|
|
42
|
+
return { ref: value };
|
|
43
|
+
}
|
|
44
|
+
if (value && typeof value === 'object' && typeof value.ref === 'string' && value.ref) {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function isPerFaceArt(art) {
|
|
51
|
+
return Boolean(art) && typeof art === 'object' && !artSpec(art);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Every art ref a part uses, for change signatures and sprite loading.
|
|
55
|
+
export function partArtRefs(part) {
|
|
56
|
+
const values = isPerFaceArt(part.art) ? Object.values(part.art) : [part.art];
|
|
57
|
+
return values
|
|
58
|
+
.map(artSpec)
|
|
59
|
+
.filter(Boolean)
|
|
60
|
+
.map((spec) => spec.ref);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Whether the part asks for something the plain material path does not
|
|
64
|
+
// draw: an art object, `artOffset` or `artRotation`, or per-face art on
|
|
65
|
+
// anything but a plain box.
|
|
66
|
+
function usesArtObjects(part) {
|
|
67
|
+
if (part.artOffset || part.artRotation) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
if (!part.art || typeof part.art !== 'object') {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (!isPerFaceArt(part.art)) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
if (part.kind !== 'box' || needsModelGeometry(part)) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
return Object.values(part.art).some((value) => value && typeof value === 'object');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// A texture with its own repeat, offset or rotation is a clone of the cached
|
|
83
|
+
// one. Clones are kept per setting, so parts asking for the same setting
|
|
84
|
+
// share one texture.
|
|
85
|
+
const textureVariants = new WeakMap();
|
|
86
|
+
|
|
87
|
+
function specTexture(spec, part, sprites) {
|
|
88
|
+
const base = resolveArtTexture(spec.ref, sprites, null);
|
|
89
|
+
if (!base) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const repeat = spec.repeat ?? part.artRepeat;
|
|
93
|
+
const offset = spec.offset ?? part.artOffset;
|
|
94
|
+
const rotation = spec.rotation ?? part.artRotation ?? 0;
|
|
95
|
+
if (!repeat && !offset && !rotation) {
|
|
96
|
+
return base;
|
|
97
|
+
}
|
|
98
|
+
let variants = textureVariants.get(base);
|
|
99
|
+
if (!variants) {
|
|
100
|
+
variants = new Map();
|
|
101
|
+
textureVariants.set(base, variants);
|
|
102
|
+
}
|
|
103
|
+
const key = JSON.stringify([repeat, offset, rotation]);
|
|
104
|
+
let texture = variants.get(key);
|
|
105
|
+
if (!texture) {
|
|
106
|
+
texture = base.clone();
|
|
107
|
+
texture.wrapS = THREE.RepeatWrapping;
|
|
108
|
+
texture.wrapT = THREE.RepeatWrapping;
|
|
109
|
+
if (repeat) {
|
|
110
|
+
texture.repeat.set(repeat[0] ?? 1, repeat[1] ?? 1);
|
|
111
|
+
}
|
|
112
|
+
if (offset) {
|
|
113
|
+
texture.offset.set(offset[0] ?? 0, offset[1] ?? 0);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Rotation turns the art about the middle of the face.
|
|
117
|
+
texture.center.set(0.5, 0.5);
|
|
118
|
+
texture.rotation = rotation * DEG;
|
|
119
|
+
texture.needsUpdate = true;
|
|
120
|
+
variants.set(key, texture);
|
|
121
|
+
}
|
|
122
|
+
return texture;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function specMaterial(shape, part, value, sprites) {
|
|
126
|
+
const spec = artSpec(value);
|
|
127
|
+
return makeMaterial(shape, spec ? specTexture(spec, part, sprites) : null);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function slotsFor(part, geometry) {
|
|
131
|
+
if (geometry.groups.length === 0) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
if (part.kind === 'box' && geometry.groups.length === 6) {
|
|
135
|
+
return FACE_SLOTS.box;
|
|
136
|
+
}
|
|
137
|
+
if (part.kind === 'cylinder' || part.kind === 'cone') {
|
|
138
|
+
return FACE_SLOTS.cylinder;
|
|
139
|
+
}
|
|
140
|
+
if (part.kind === 'extrude') {
|
|
141
|
+
return FACE_SLOTS.extrude;
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Replace the mesh's material with one per face slot, or one for the whole
|
|
147
|
+
// part, when the part uses art objects. `shape` is the part in the Shape
|
|
148
|
+
// vocabulary that makeMaterial takes. A cone has no top cap, but its bottom
|
|
149
|
+
// keeps material index 2, so the list always has every slot.
|
|
150
|
+
export function applyArtObjects(mesh, part, shape, sprites) {
|
|
151
|
+
if (!mesh.isMesh || !usesArtObjects(part)) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const art = part.art;
|
|
155
|
+
const slots = isPerFaceArt(art) ? slotsFor(part, mesh.geometry) : null;
|
|
156
|
+
let material;
|
|
157
|
+
if (slots) {
|
|
158
|
+
material = slots.map((names) => {
|
|
159
|
+
const value = names.map((name) => art[name]).find((found) => found !== undefined);
|
|
160
|
+
return specMaterial(shape, part, value, sprites);
|
|
161
|
+
});
|
|
162
|
+
} else {
|
|
163
|
+
material = specMaterial(shape, part, isPerFaceArt(art) ? art.all : art, sprites);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// A blob with colored shapes keeps its per-vertex colors.
|
|
167
|
+
const vertexColors = [mesh.material].flat().some((old) => old.vertexColors);
|
|
168
|
+
for (const old of [mesh.material].flat()) {
|
|
169
|
+
old.dispose();
|
|
170
|
+
}
|
|
171
|
+
if (vertexColors) {
|
|
172
|
+
for (const each of [material].flat()) {
|
|
173
|
+
each.color.set('#ffffff');
|
|
174
|
+
each.vertexColors = true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
mesh.material = material;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function hasMaterialExtras(part) {
|
|
181
|
+
return (
|
|
182
|
+
(Number.isFinite(part.brightness) && part.brightness !== 1) ||
|
|
183
|
+
part.alphaTest > 0 ||
|
|
184
|
+
Boolean(part.doubleSided)
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// `brightness` multiplies the color, art included, so above 1 lightens,
|
|
189
|
+
// which `tint` cannot. `alphaTest` drops art pixels whose alpha is below it,
|
|
190
|
+
// in the shadow too. `doubleSided` draws both sides of every face. Copies
|
|
191
|
+
// made by `mirror` and `repeat` share materials; each is changed once.
|
|
192
|
+
export function applyMaterialExtras(object, part) {
|
|
193
|
+
if (!hasMaterialExtras(part)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const done = new Set();
|
|
197
|
+
object.traverse((child) => {
|
|
198
|
+
if (!child.isMesh || child.userData.lookOutline) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
for (const material of [child.material].flat()) {
|
|
202
|
+
if (done.has(material)) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
done.add(material);
|
|
206
|
+
if (Number.isFinite(part.brightness) && part.brightness !== 1) {
|
|
207
|
+
material.color.multiplyScalar(Math.max(0, part.brightness));
|
|
208
|
+
}
|
|
209
|
+
if (part.alphaTest > 0) {
|
|
210
|
+
material.alphaTest = Math.min(1, part.alphaTest);
|
|
211
|
+
}
|
|
212
|
+
if (part.doubleSided) {
|
|
213
|
+
material.side = THREE.DoubleSide;
|
|
214
|
+
}
|
|
215
|
+
material.needsUpdate = true;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|