castle-web-cli 0.4.204 → 0.4.206
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.d.ts +1 -0
- package/dist/agent-prompts.js +7 -2
- package/dist/agent.d.ts +3 -2
- package/dist/agent.js +29 -18
- 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/imports.d.ts +1 -1
- package/dist/imports.js +59 -19
- package/dist/index.js +4 -3
- package/dist/init.d.ts +9 -1
- package/dist/init.js +64 -25
- package/dist/kitCatalog.d.ts +13 -0
- package/dist/kitCatalog.js +111 -0
- package/dist/platformDoc.js +7 -2
- 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 +5 -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 +5 -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-2d/castle.json +1 -0
- package/kits/physics-3d/CLAUDE.md +65 -7
- package/kits/physics-3d/castle.json +4 -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/kits/turn-based/castle.json +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "pxmodel",
|
|
3
|
+
"name": "Wizard Hat",
|
|
4
|
+
"triangles": 850,
|
|
5
|
+
"parts": [
|
|
6
|
+
{
|
|
7
|
+
"id": "brim", "kind": "lathe", "segments": 24,
|
|
8
|
+
"profile": [[0.155, -0.004], [0.27, -0.016], [0.3, -0.006], [0.296, 0.006], [0.27, 0.0], [0.17, 0.016], [0.155, 0.016]],
|
|
9
|
+
"color": "#3b3f8f", "roughness": 0.9
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "crown", "kind": "sweep", "smooth": true, "scaleEnd": 0.06,
|
|
13
|
+
"path": [[0, 0.0, 0], [0, 0.16, -0.01], [0, 0.3, -0.05], [0, 0.4, -0.13], [0, 0.42, -0.23]],
|
|
14
|
+
"profile": [[0.165, 0.0], [0.1167, 0.1167], [0.0, 0.165], [-0.1167, 0.1167], [-0.165, 0.0], [-0.1167, -0.1167], [0.0, -0.165], [0.1167, -0.1167]],
|
|
15
|
+
"color": "#3b3f8f", "roughness": 0.9
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "band", "kind": "torus", "radius": 0.158, "tube": 0.02, "position": [0, 0.035, 0], "rotation": [90, 0, 0], "segments": 20,
|
|
19
|
+
"color": "#c9a13b", "roughness": 0.6
|
|
20
|
+
},
|
|
21
|
+
{ "id": "buckle", "size": [0.05, 0.045, 0.012], "position": [0, 0.035, 0.176], "color": "#e3d48a", "metalness": 0.7, "roughness": 0.35 },
|
|
22
|
+
{
|
|
23
|
+
"id": "star", "kind": "extrude", "position": [0, 0.2, 0.108], "rotation": [-12, 0, 0], "scale": 0.05, "depth": 0.3,
|
|
24
|
+
"outline": [[0, 1], [0.24, 0.33], [0.95, 0.31], [0.38, -0.12], [0.59, -0.81], [0, -0.4], [-0.59, -0.81], [-0.38, -0.12], [-0.95, 0.31], [-0.24, 0.33]],
|
|
25
|
+
"color": "#f2dc7a", "emissive": "#f2c94a", "emissiveIntensity": 0.4
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "pxmodel",
|
|
3
|
+
"name": "Stout Biped",
|
|
4
|
+
"triangles": 6000,
|
|
5
|
+
"parts": [
|
|
6
|
+
{ "id": "legL", "kind": "blob", "position": [0.1,0.36,0], "color": "#a3a3a3", "blend": 0.05, "resolution": 40,
|
|
7
|
+
"shapes": [
|
|
8
|
+
{"capsule": [[0,0,0],[0.005,-0.18,0.01]], "radius": 0.1, "radiusEnd": 0.085},
|
|
9
|
+
{"capsule": [[0.005,-0.18,0.01],[0,-0.28,0.01]], "radius": 0.08, "radiusEnd": 0.075},
|
|
10
|
+
{"sphere": [0,-0.31,0.04], "radius": [0.085,0.055,0.12]}
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
{ "id": "legR", "kind": "blob", "position": [-0.1,0.36,0], "color": "#a3a3a3", "blend": 0.05, "resolution": 40,
|
|
14
|
+
"shapes": [
|
|
15
|
+
{"capsule": [[0,0,0],[-0.005,-0.18,0.01]], "radius": 0.1, "radiusEnd": 0.085},
|
|
16
|
+
{"capsule": [[-0.005,-0.18,0.01],[0,-0.28,0.01]], "radius": 0.08, "radiusEnd": 0.075},
|
|
17
|
+
{"sphere": [0,-0.31,0.04], "radius": [0.085,0.055,0.12]}
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{ "id": "torso", "kind": "blob", "position": [0,0.36,0], "color": "#a3a3a3", "symmetric": "x", "blend": 0.07, "resolution": 48,
|
|
21
|
+
"shapes": [
|
|
22
|
+
{"sphere": [0,0.04,0], "radius": [0.2,0.1,0.15]},
|
|
23
|
+
{"sphere": [0,0.17,0.02], "radius": [0.23,0.17,0.19]},
|
|
24
|
+
{"sphere": [0,0.32,0], "radius": [0.24,0.14,0.17]},
|
|
25
|
+
{"capsule": [[0,0.4,-0.01],[0.19,0.39,-0.01]], "radius": 0.1},
|
|
26
|
+
{"capsule": [[0,0.42,0],[0,0.5,0.01]], "radius": 0.07, "blend": 0.03}
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{ "id": "head", "parent": "torso", "kind": "blob", "position": [0,0.47,0.01], "color": "#a3a3a3", "symmetric": "x", "blend": 0.04, "resolution": 48,
|
|
30
|
+
"shapes": [
|
|
31
|
+
{"sphere": [0,0.19,0], "radius": [0.155,0.165,0.155]},
|
|
32
|
+
{"sphere": [0,0.1,0.03], "radius": [0.13,0.09,0.12]}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{ "id": "armL", "parent": "torso", "kind": "blob", "position": [0.26,0.4,0], "color": "#a3a3a3", "blend": 0.04, "resolution": 40,
|
|
36
|
+
"shapes": [
|
|
37
|
+
{"capsule": [[0,0,0],[0.03,-0.18,0.01]], "radius": 0.085, "radiusEnd": 0.075},
|
|
38
|
+
{"capsule": [[0.03,-0.18,0.01],[0.04,-0.32,0.05]], "radius": 0.068, "radiusEnd": 0.058},
|
|
39
|
+
{"sphere": [0.04,-0.375,0.06], "radius": [0.055,0.06,0.055]}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{ "id": "armR", "parent": "torso", "kind": "blob", "position": [-0.26,0.4,0], "color": "#a3a3a3", "blend": 0.04, "resolution": 40,
|
|
43
|
+
"shapes": [
|
|
44
|
+
{"capsule": [[0,0,0],[-0.03,-0.18,0.01]], "radius": 0.085, "radiusEnd": 0.075},
|
|
45
|
+
{"capsule": [[-0.03,-0.18,0.01],[-0.04,-0.32,0.05]], "radius": 0.068, "radiusEnd": 0.058},
|
|
46
|
+
{"sphere": [-0.04,-0.375,0.06], "radius": [0.055,0.06,0.055]}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{ "id": "slot-head", "parent": "head", "kind": "model", "position": [0,0.2,0] },
|
|
50
|
+
{ "id": "slot-back", "parent": "torso", "kind": "model", "position": [0,0.26,-0.18] },
|
|
51
|
+
{ "id": "slot-belt", "parent": "torso", "kind": "model", "position": [0.13,0.1,0.18], "rotation": [0,40,0] },
|
|
52
|
+
{ "id": "slot-shoulderL", "parent": "torso", "kind": "model", "position": [0.24,0.47,-0.01] },
|
|
53
|
+
{ "id": "slot-shoulderR", "parent": "torso", "kind": "model", "position": [-0.24,0.47,-0.01], "scale": [-1,1,1] },
|
|
54
|
+
{ "id": "slot-forearmL", "parent": "armL", "kind": "model", "position": [0.035,-0.26,0.03] },
|
|
55
|
+
{ "id": "slot-forearmR", "parent": "armR", "kind": "model", "position": [-0.035,-0.26,0.03] },
|
|
56
|
+
{ "id": "slot-handL", "parent": "armL", "kind": "model", "position": [0.04,-0.38,0.06], "rotation": [60,0,0] },
|
|
57
|
+
{ "id": "slot-handR", "parent": "armR", "kind": "model", "position": [-0.04,-0.38,0.06], "rotation": [60,0,0] }
|
|
58
|
+
]
|
|
59
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "pxmodel",
|
|
3
|
+
"name": "Tall Biped",
|
|
4
|
+
"triangles": 6000,
|
|
5
|
+
"parts": [
|
|
6
|
+
{ "id": "legL", "kind": "blob", "position": [0.085,0.86,0], "color": "#a3a3a3", "blend": 0.04, "resolution": 48,
|
|
7
|
+
"shapes": [
|
|
8
|
+
{"capsule": [[0,0,0],[0.005,-0.4,0.01]], "radius": 0.075, "radiusEnd": 0.058},
|
|
9
|
+
{"capsule": [[0.005,-0.4,0.01],[0,-0.78,0]], "radius": 0.054, "radiusEnd": 0.046},
|
|
10
|
+
{"capsule": [[0.005,-0.52,0.005],[0,-0.78,0]], "radius": 0.06, "radiusEnd": 0.055, "blend": 0.01},
|
|
11
|
+
{"sphere": [0,-0.81,0.04], "radius": [0.06,0.05,0.11]}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
{ "id": "legR", "kind": "blob", "position": [-0.085,0.86,0], "color": "#a3a3a3", "blend": 0.04, "resolution": 48,
|
|
15
|
+
"shapes": [
|
|
16
|
+
{"capsule": [[0,0,0],[-0.005,-0.4,0.01]], "radius": 0.075, "radiusEnd": 0.058},
|
|
17
|
+
{"capsule": [[-0.005,-0.4,0.01],[0,-0.78,0]], "radius": 0.054, "radiusEnd": 0.046},
|
|
18
|
+
{"capsule": [[-0.005,-0.52,0.005],[0,-0.78,0]], "radius": 0.06, "radiusEnd": 0.055, "blend": 0.01},
|
|
19
|
+
{"sphere": [0,-0.81,0.04], "radius": [0.06,0.05,0.11]}
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{ "id": "torso", "kind": "blob", "position": [0,0.86,0], "color": "#a3a3a3", "symmetric": "x", "blend": 0.06, "resolution": 48,
|
|
23
|
+
"shapes": [
|
|
24
|
+
{"sphere": [0,0.03,0], "radius": [0.15,0.09,0.105]},
|
|
25
|
+
{"sphere": [0,0.18,0.005], "radius": [0.13,0.13,0.1]},
|
|
26
|
+
{"sphere": [0,0.36,0.01], "radius": [0.17,0.14,0.12]},
|
|
27
|
+
{"capsule": [[0,0.44,-0.01],[0.16,0.43,-0.01]], "radius": 0.065},
|
|
28
|
+
{"capsule": [[0,0.46,0],[0,0.56,0.01]], "radius": 0.045, "blend": 0.02}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{ "id": "head", "parent": "torso", "kind": "blob", "position": [0,0.55,0.01], "color": "#a3a3a3", "symmetric": "x", "blend": 0.03, "resolution": 48,
|
|
32
|
+
"shapes": [
|
|
33
|
+
{"sphere": [0,0.14,0], "radius": [0.105,0.12,0.11]},
|
|
34
|
+
{"sphere": [0,0.075,0.03], "radius": [0.08,0.065,0.08]}
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{ "id": "armL", "parent": "torso", "kind": "blob", "position": [0.2,0.43,0], "color": "#a3a3a3", "blend": 0.03, "resolution": 48,
|
|
38
|
+
"shapes": [
|
|
39
|
+
{"capsule": [[0,0,0],[0.02,-0.28,0]], "radius": 0.056, "radiusEnd": 0.05},
|
|
40
|
+
{"capsule": [[0.02,-0.28,0],[0.03,-0.5,0.04]], "radius": 0.047, "radiusEnd": 0.04},
|
|
41
|
+
{"capsule": [[0.028,-0.46,0.035],[0.03,-0.52,0.045]], "radius": 0.038},
|
|
42
|
+
{"sphere": [0.03,-0.575,0.05], "radius": [0.038,0.045,0.04]}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{ "id": "armR", "parent": "torso", "kind": "blob", "position": [-0.2,0.43,0], "color": "#a3a3a3", "blend": 0.03, "resolution": 48,
|
|
46
|
+
"shapes": [
|
|
47
|
+
{"capsule": [[0,0,0],[-0.02,-0.28,0]], "radius": 0.056, "radiusEnd": 0.05},
|
|
48
|
+
{"capsule": [[-0.02,-0.28,0],[-0.03,-0.5,0.04]], "radius": 0.047, "radiusEnd": 0.04},
|
|
49
|
+
{"capsule": [[-0.028,-0.46,0.035],[-0.03,-0.52,0.045]], "radius": 0.038},
|
|
50
|
+
{"sphere": [-0.03,-0.575,0.05], "radius": [0.038,0.045,0.04]}
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{ "id": "slot-head", "parent": "head", "kind": "model", "position": [0,0.15,0], "scale": 0.68 },
|
|
54
|
+
{ "id": "slot-back", "parent": "torso", "kind": "model", "position": [0,0.3,-0.12] },
|
|
55
|
+
{ "id": "slot-belt", "parent": "torso", "kind": "model", "position": [0.1,0.09,0.1], "rotation": [0,45,0] },
|
|
56
|
+
{ "id": "slot-shoulderL", "parent": "torso", "kind": "model", "position": [0.19,0.49,-0.01], "scale": 0.7 },
|
|
57
|
+
{ "id": "slot-shoulderR", "parent": "torso", "kind": "model", "position": [-0.19,0.49,-0.01], "scale": [-0.7,0.7,0.7] },
|
|
58
|
+
{ "id": "slot-forearmL", "parent": "armL", "kind": "model", "position": [0.027,-0.4,0.02], "scale": 0.75 },
|
|
59
|
+
{ "id": "slot-forearmR", "parent": "armR", "kind": "model", "position": [-0.027,-0.4,0.02], "scale": 0.75 },
|
|
60
|
+
{ "id": "slot-handL", "parent": "armL", "kind": "model", "position": [0.03,-0.58,0.05], "rotation": [60,0,0] },
|
|
61
|
+
{ "id": "slot-handR", "parent": "armR", "kind": "model", "position": [-0.03,-0.58,0.05], "rotation": [60,0,0] }
|
|
62
|
+
]
|
|
63
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "pxmodel",
|
|
3
|
+
"name": "Quadruped",
|
|
4
|
+
"triangles": 5000,
|
|
5
|
+
"parts": [
|
|
6
|
+
{ "id": "torso", "kind": "blob", "position": [0,0.3,0], "color": "#a3a3a3", "symmetric": "x", "blend": 0.06, "resolution": 56,
|
|
7
|
+
"shapes": [
|
|
8
|
+
{"sphere": [0,0.03,0.12], "radius": [0.1,0.11,0.14]},
|
|
9
|
+
{"sphere": [0,0.03,-0.12], "radius": [0.095,0.1,0.14]},
|
|
10
|
+
{"capsule": [[0,0.06,0.2],[0,0.15,0.29]], "radius": 0.065, "radiusEnd": 0.055}
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
{ "id": "head", "parent": "torso", "kind": "blob", "position": [0,0.13,0.26], "color": "#a3a3a3", "symmetric": "x", "blend": 0.04, "resolution": 48,
|
|
14
|
+
"shapes": [
|
|
15
|
+
{"sphere": [0,0.05,0.07], "radius": [0.075,0.07,0.08], "blend": 0.04},
|
|
16
|
+
{"capsule": [[0,0.035,0.11],[0,0.015,0.2]], "radius": 0.038, "radiusEnd": 0.022, "blend": 0.03}
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
{ "id": "tail", "parent": "torso", "kind": "sweep", "smooth": true, "scaleEnd": 0.25, "path": [[0,0,0],[0,0.05,-0.09],[0,0.05,-0.21],[0,0,-0.31]], "profile": [[0.035,0],[0.0247,0.0247],[0,0.035],[-0.0247,0.0247],[-0.035,0],[-0.0247,-0.0247],[0,-0.035],[0.0247,-0.0247]], "color": "#a3a3a3", "roughness": 0.9, "position": [0,0.05,-0.23] },
|
|
20
|
+
{ "id": "legFL", "kind": "blob", "position": [0.06,0.3,0.15], "color": "#a3a3a3", "blend": 0.03, "resolution": 40,
|
|
21
|
+
"shapes": [
|
|
22
|
+
{"capsule": [[0,0,0],[0.005,-0.16,0]], "radius": 0.045, "radiusEnd": 0.03},
|
|
23
|
+
{"capsule": [[0.005,-0.16,0],[0,-0.28,0.01]], "radius": 0.028, "radiusEnd": 0.026},
|
|
24
|
+
{"sphere": [0,-0.29,0.03], "radius": [0.032,0.02,0.045]}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{ "id": "legFR", "kind": "blob", "position": [-0.06,0.3,0.15], "color": "#a3a3a3", "blend": 0.03, "resolution": 40,
|
|
28
|
+
"shapes": [
|
|
29
|
+
{"capsule": [[0,0,0],[-0.005,-0.16,0]], "radius": 0.045, "radiusEnd": 0.03},
|
|
30
|
+
{"capsule": [[-0.005,-0.16,0],[0,-0.28,0.01]], "radius": 0.028, "radiusEnd": 0.026},
|
|
31
|
+
{"sphere": [0,-0.29,0.03], "radius": [0.032,0.02,0.045]}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{ "id": "legBL", "kind": "blob", "position": [0.06,0.3,-0.15], "color": "#a3a3a3", "blend": 0.03, "resolution": 40,
|
|
35
|
+
"shapes": [
|
|
36
|
+
{"capsule": [[0,0.02,0.01],[0.005,-0.13,0.04]], "radius": 0.06, "radiusEnd": 0.035},
|
|
37
|
+
{"capsule": [[0.005,-0.13,0.04],[0,-0.28,-0.01]], "radius": 0.028, "radiusEnd": 0.026},
|
|
38
|
+
{"sphere": [0,-0.29,0.02], "radius": [0.032,0.02,0.045]}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{ "id": "legBR", "kind": "blob", "position": [-0.06,0.3,-0.15], "color": "#a3a3a3", "blend": 0.03, "resolution": 40,
|
|
42
|
+
"shapes": [
|
|
43
|
+
{"capsule": [[0,0.02,0.01],[-0.005,-0.13,0.04]], "radius": 0.06, "radiusEnd": 0.035},
|
|
44
|
+
{"capsule": [[-0.005,-0.13,0.04],[0,-0.28,-0.01]], "radius": 0.028, "radiusEnd": 0.026},
|
|
45
|
+
{"sphere": [0,-0.29,0.02], "radius": [0.032,0.02,0.045]}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{ "id": "slot-head", "parent": "head", "kind": "model", "position": [0,0.105,0.07], "scale": 0.45 },
|
|
49
|
+
{ "id": "slot-neck", "parent": "torso", "kind": "model", "position": [0,0.11,0.245], "rotation": [-45,0,0] },
|
|
50
|
+
{ "id": "slot-back", "parent": "torso", "kind": "model", "position": [0,0.13,0] }
|
|
51
|
+
]
|
|
52
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// Filmstrip pages for `npm run render -- --motion`: the model as the game
|
|
2
|
+
// camera sees it, six frames a page, moved by the game's own animators
|
|
3
|
+
// (animateModelParts, then animateMotion) at 60 steps a second.
|
|
4
|
+
//
|
|
5
|
+
// 0 idle, over one cycle of its slowest motion
|
|
6
|
+
// 1 walking in place at 4 m/s, over one step
|
|
7
|
+
// 2 its first clip, from start to end
|
|
8
|
+
|
|
9
|
+
import * as THREE from 'three';
|
|
10
|
+
import { animateModelParts } from '/imports/castle.physics-3d/engine3d/pxmodel.js';
|
|
11
|
+
import { animateMotion, playModelClip } from '/imports/castle.physics-3d/engine3d/motion.js';
|
|
12
|
+
import { GAME_PIXEL } from '/imports/castle.physics-3d/engine3d/optimize.js';
|
|
13
|
+
|
|
14
|
+
const DEG = Math.PI / 180;
|
|
15
|
+
const STEP = 1 / 60;
|
|
16
|
+
const FRAMES = 6;
|
|
17
|
+
const COLUMNS = 2;
|
|
18
|
+
const LABEL_PX = 16;
|
|
19
|
+
const WALK_SPEED = 4;
|
|
20
|
+
|
|
21
|
+
// The game camera looks down 45 degrees from yaw -45 through a 15 degree
|
|
22
|
+
// lens, from far enough to frame 13 m of ground.
|
|
23
|
+
const GAME_FOV = 15;
|
|
24
|
+
const GAME_DISTANCE = 6.5 / Math.tan((GAME_FOV / 2) * DEG);
|
|
25
|
+
const GAME_DIRECTION = new THREE.Vector3(
|
|
26
|
+
Math.sin(-45 * DEG) * Math.cos(45 * DEG),
|
|
27
|
+
Math.sin(45 * DEG),
|
|
28
|
+
Math.cos(-45 * DEG) * Math.cos(45 * DEG)
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
//
|
|
32
|
+
// Running the animators
|
|
33
|
+
//
|
|
34
|
+
|
|
35
|
+
// The model sits in a node standing in for an actor's, as in world3d.js. The
|
|
36
|
+
// first page drawn records every object's rest transform, and each page
|
|
37
|
+
// starts again from it.
|
|
38
|
+
function simulation(entry) {
|
|
39
|
+
if (!entry.film) {
|
|
40
|
+
const holder = new THREE.Group();
|
|
41
|
+
entry.scene.remove(entry.node);
|
|
42
|
+
holder.add(entry.node);
|
|
43
|
+
holder.userData.modelParts = entry.node.userData.modelParts;
|
|
44
|
+
entry.scene.add(holder);
|
|
45
|
+
const rest = [];
|
|
46
|
+
entry.node.traverse((object) => {
|
|
47
|
+
rest.push([object, object.position.clone(), object.quaternion.clone(), object.scale.clone()]);
|
|
48
|
+
});
|
|
49
|
+
entry.film = { holder, rest };
|
|
50
|
+
}
|
|
51
|
+
for (const [object, position, quaternion, scale] of entry.film.rest) {
|
|
52
|
+
object.position.copy(position);
|
|
53
|
+
object.quaternion.copy(quaternion);
|
|
54
|
+
object.scale.copy(scale);
|
|
55
|
+
}
|
|
56
|
+
const actor = { id: '', runtime: {} };
|
|
57
|
+
return { actorEntry: { node: entry.film.holder }, actor, holder: entry.film.holder, z: 0 };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// One step, moving the node `speed` m/s along +z. The node is put back at
|
|
61
|
+
// the origin afterwards, so a walk happens in place.
|
|
62
|
+
function step(sim, speed) {
|
|
63
|
+
sim.z += speed * STEP;
|
|
64
|
+
sim.holder.position.z = sim.z;
|
|
65
|
+
animateModelParts(sim.actorEntry, STEP);
|
|
66
|
+
animateMotion(sim.actorEntry, STEP, sim.actor);
|
|
67
|
+
sim.holder.position.z = 0;
|
|
68
|
+
sim.holder.updateMatrixWorld(true);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function run(sim, seconds, speed) {
|
|
72
|
+
for (let t = 0; t < seconds - 1e-6; t += STEP) {
|
|
73
|
+
step(sim, speed);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// The slowest repeating motion's period, from 1 to 4 seconds.
|
|
78
|
+
function idlePeriod(animation) {
|
|
79
|
+
let period = 1;
|
|
80
|
+
for (const list of Object.values(animation?.motion ?? {})) {
|
|
81
|
+
for (const motion of list) {
|
|
82
|
+
if ((motion.rotate || motion.move || motion.scale) && motion.speed !== 0) {
|
|
83
|
+
period = Math.max(period, 1 / Math.abs(motion.speed));
|
|
84
|
+
}
|
|
85
|
+
const spin = Math.max(...(motion.spin ?? [0]).map(Math.abs));
|
|
86
|
+
if (spin > 0) {
|
|
87
|
+
period = Math.max(period, 360 / spin);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (animation?.parts.some((id) => ['tail', 'wingL', 'wingR', 'head'].includes(id))) {
|
|
92
|
+
period = Math.max(period, 2);
|
|
93
|
+
}
|
|
94
|
+
return Math.min(4, period);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Frames of a page, each a label and an `advance` that runs the simulation
|
|
98
|
+
// on to that frame.
|
|
99
|
+
function idleFrames(sim, animation) {
|
|
100
|
+
const period = idlePeriod(animation);
|
|
101
|
+
run(sim, STEP * 2, 0);
|
|
102
|
+
return framesOver(period, (seconds) => run(sim, seconds, 0), 'idle');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function walkFrames(sim) {
|
|
106
|
+
run(sim, 1.5, WALK_SPEED);
|
|
107
|
+
const period = (2 * Math.PI) / (WALK_SPEED * 2.4);
|
|
108
|
+
return framesOver(period, (seconds) => run(sim, seconds, WALK_SPEED), 'walk');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function clipFrames(sim, animation) {
|
|
112
|
+
const name = Object.keys(animation?.clips ?? {})[0];
|
|
113
|
+
if (!name) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
run(sim, STEP * 2, 0);
|
|
117
|
+
playModelClip(sim.actor, name);
|
|
118
|
+
step(sim, 0);
|
|
119
|
+
const duration = animation.clips[name].duration;
|
|
120
|
+
return framesOver(duration * 0.999, (seconds) => run(sim, seconds, 0), `clip "${name}"`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function framesOver(length, advance, label) {
|
|
124
|
+
const frames = [];
|
|
125
|
+
for (let n = 0; n < FRAMES; n++) {
|
|
126
|
+
const at = (length * n) / (FRAMES - 1);
|
|
127
|
+
const from = n === 0 ? 0 : (length * (n - 1)) / (FRAMES - 1);
|
|
128
|
+
frames.push({ label: `${label} ${at.toFixed(2)} s`, advance: () => advance(at - from) });
|
|
129
|
+
}
|
|
130
|
+
return frames;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//
|
|
134
|
+
// Drawing
|
|
135
|
+
//
|
|
136
|
+
|
|
137
|
+
// Three or two times game size when that fits, else game size, else as
|
|
138
|
+
// large as fits.
|
|
139
|
+
function tileZoom(bounds, width, height) {
|
|
140
|
+
const up = new THREE.Vector3(0, 1, 0);
|
|
141
|
+
const right = new THREE.Vector3().crossVectors(up, GAME_DIRECTION).normalize();
|
|
142
|
+
const cameraUp = new THREE.Vector3().crossVectors(GAME_DIRECTION, right);
|
|
143
|
+
const corners = [];
|
|
144
|
+
for (let n = 0; n < 8; n++) {
|
|
145
|
+
corners.push(
|
|
146
|
+
new THREE.Vector3(
|
|
147
|
+
n & 1 ? bounds.max.x : bounds.min.x,
|
|
148
|
+
n & 2 ? bounds.max.y : bounds.min.y,
|
|
149
|
+
n & 4 ? bounds.max.z : bounds.min.z
|
|
150
|
+
)
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
const extent = (axis) => {
|
|
154
|
+
const values = corners.map((corner) => corner.dot(axis));
|
|
155
|
+
return Math.max(...values) - Math.min(...values);
|
|
156
|
+
};
|
|
157
|
+
const needWidth = (extent(right) * 1.1) / GAME_PIXEL;
|
|
158
|
+
const needHeight = (extent(cameraUp) * 1.1) / GAME_PIXEL;
|
|
159
|
+
const fit = Math.min(width / needWidth, height / needHeight);
|
|
160
|
+
return fit >= 1 ? Math.min(3, Math.floor(fit)) : fit;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function tileCamera(bounds, width, height, zoom) {
|
|
164
|
+
const viewHeight = (height * GAME_PIXEL) / zoom;
|
|
165
|
+
const fov = 2 * Math.atan(viewHeight / 2 / GAME_DISTANCE);
|
|
166
|
+
const camera = new THREE.PerspectiveCamera(fov / DEG, width / height, 0.5, 400);
|
|
167
|
+
const center = bounds.getCenter(new THREE.Vector3());
|
|
168
|
+
camera.position.copy(center).add(GAME_DIRECTION.clone().multiplyScalar(GAME_DISTANCE));
|
|
169
|
+
camera.lookAt(center);
|
|
170
|
+
return camera;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function pageFrames(entry, pageNumber) {
|
|
174
|
+
const sim = simulation(entry);
|
|
175
|
+
const animation = entry.node.userData.animation;
|
|
176
|
+
if (pageNumber === 0) {
|
|
177
|
+
return idleFrames(sim, animation);
|
|
178
|
+
}
|
|
179
|
+
if (pageNumber === 1) {
|
|
180
|
+
return walkFrames(sim);
|
|
181
|
+
}
|
|
182
|
+
return clipFrames(sim, animation);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Draws one filmstrip page. `text(content, left, top, width, height)` puts a
|
|
186
|
+
// label on the page; `header` is the sheet's header lines.
|
|
187
|
+
export function drawMotionPage(renderer, entry, pageNumber, { width, height, header, text }) {
|
|
188
|
+
const frames = pageFrames(entry, pageNumber);
|
|
189
|
+
const headerHeight = 82 + LABEL_PX;
|
|
190
|
+
if (!frames) {
|
|
191
|
+
text(`${header}\nno clips`, 0, 0, width, headerHeight);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const rows = Math.ceil(FRAMES / COLUMNS);
|
|
195
|
+
const tileWidth = Math.floor(width / COLUMNS);
|
|
196
|
+
const tileHeight = Math.floor((height - headerHeight) / rows);
|
|
197
|
+
const zoom = tileZoom(entry.bounds, tileWidth - 2, tileHeight - LABEL_PX - 1);
|
|
198
|
+
const size = zoom === 1 ? 'game size' : `${zoom.toFixed(2)}x game size`;
|
|
199
|
+
text(
|
|
200
|
+
`${header}\n${['idle', 'walking in place', 'clip'][pageNumber]}, ${size}`,
|
|
201
|
+
0,
|
|
202
|
+
0,
|
|
203
|
+
width,
|
|
204
|
+
headerHeight
|
|
205
|
+
);
|
|
206
|
+
frames.forEach((frame, n) => {
|
|
207
|
+
frame.advance();
|
|
208
|
+
const left = (n % COLUMNS) * tileWidth + 1;
|
|
209
|
+
const top = headerHeight + Math.floor(n / COLUMNS) * tileHeight;
|
|
210
|
+
const viewHeight = tileHeight - LABEL_PX - 1;
|
|
211
|
+
const bottom = height - (top + LABEL_PX + viewHeight);
|
|
212
|
+
renderer.setViewport(left, bottom, tileWidth - 2, viewHeight);
|
|
213
|
+
renderer.setScissor(left, bottom, tileWidth - 2, viewHeight);
|
|
214
|
+
renderer.render(entry.scene, tileCamera(entry.bounds, tileWidth - 2, viewHeight, zoom));
|
|
215
|
+
text(frame.label, left, top, tileWidth - 2, LABEL_PX);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
|
5
|
+
<meta name="color-scheme" content="dark" />
|
|
6
|
+
<title>model sheet</title>
|
|
7
|
+
<!-- Safari won't repaint a composited iframe on a color-scheme change, so
|
|
8
|
+
the dark scheme is set here, before the JS-imported CSS loads. -->
|
|
9
|
+
<style>
|
|
10
|
+
html {
|
|
11
|
+
color-scheme: dark;
|
|
12
|
+
background: #0a0a0a;
|
|
13
|
+
}
|
|
14
|
+
</style>
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<div id="root"></div>
|
|
18
|
+
<script type="module" src="/sheet.js"></script>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|