@call-me-sensei/toonlab 0.4.21 → 0.4.23
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/NPM-LIBRARY.md +87 -27
- package/README.md +11 -10
- package/agents/PROMPTS.md +17 -3
- package/agents/README.md +13 -3
- package/agents/claude/CLAUDE.md +3 -0
- package/agents/codex/AGENTS.md +112 -159
- package/agents/cursor/toonlab.mdc +7 -3
- package/agents/examples/game-foundation.mjs +104 -0
- package/agents/references/game-lifecycle.md +57 -0
- package/agents/references/runtime-entry-points.md +26 -0
- package/agents/references/style-bundles.md +4 -1
- package/agents/skills/claude/asset-sourcing/SKILL.md +7 -4
- package/agents/skills/claude/environment/SKILL.md +4 -0
- package/agents/skills/claude/game-dev/SKILL.md +63 -87
- package/agents/skills/claude/lighting/SKILL.md +36 -0
- package/agents/skills/claude/post-processing/SKILL.md +8 -3
- package/agents/skills/claude/rock-ground-shaders/SKILL.md +10 -15
- package/agents/skills/claude/rockgen/SKILL.md +52 -21
- package/agents/skills/claude/scene-style-application/SKILL.md +4 -0
- package/agents/skills/claude/style-presets/SKILL.md +11 -8
- package/agents/skills/claude/toon-shading/SKILL.md +4 -0
- package/agents/skills/claude/vegetation-sky/SKILL.md +13 -7
- package/agents/skills/claude/visual-verification/SKILL.md +45 -119
- package/agents/skills/claude/water/SKILL.md +6 -2
- package/agents/skills/codex/asset-sourcing/SKILL.md +7 -4
- package/agents/skills/codex/environment/SKILL.md +4 -0
- package/agents/skills/codex/game-dev/SKILL.md +63 -87
- package/agents/skills/codex/lighting/SKILL.md +36 -0
- package/agents/skills/codex/post-processing/SKILL.md +8 -3
- package/agents/skills/codex/rock-ground-shaders/SKILL.md +10 -15
- package/agents/skills/codex/rockgen/SKILL.md +52 -21
- package/agents/skills/codex/scene-style-application/SKILL.md +4 -0
- package/agents/skills/codex/style-presets/SKILL.md +11 -8
- package/agents/skills/codex/toon-shading/SKILL.md +4 -0
- package/agents/skills/codex/vegetation-sky/SKILL.md +13 -7
- package/agents/skills/codex/visual-verification/SKILL.md +45 -119
- package/agents/skills/codex/water/SKILL.md +6 -2
- package/database/apply-one-catalog-seed.mjs +63 -0
- package/database/providers.mjs +1 -0
- package/database/seeds/catalog/0005_2026-08-c8-first12.sql +1101 -0
- package/database/seeds/catalog/0006_2026-09-c8-first100.sql +14245 -0
- package/database/seeds/catalog/0007_2026-09-c8-first100-primary-model.sql +14845 -0
- package/mcp/lab-management.mjs +11 -8
- package/mcp/public-catalog.mjs +0 -16
- package/mcp/tree-lab-contract.mjs +2381 -0
- package/mcp/vite-plugin.mjs +5 -1
- package/package.json +29 -18
- package/src/catalog/officialCatalog.js +1 -0
- package/src/catalog/officialCatalogAssetRuntime.js +98 -1
- package/src/catalog/officialCatalogLod.js +160 -16
- package/src/catalog/officialCatalogPlacement.js +52 -12
- package/src/catalog/officialCatalogProvider.js +79 -8
- package/src/catalog/officialCatalogRockPackage.js +172 -0
- package/src/cloud/cloudReprojection.js +40 -7
- package/src/cloud/cloudVolume.js +44 -7
- package/src/cloud/noise/baseShapeVolume.js +8 -6
- package/src/cloud/noise/cirrusMap.js +2 -1
- package/src/cloud/noise/curlNoise.js +2 -1
- package/src/cloud/noise/erosionVolume.js +2 -1
- package/src/cloud/noise/textureCache.js +77 -0
- package/src/cloud/noise/weatherMap.js +2 -1
- package/src/core/sha256.js +83 -0
- package/src/ground-shader/groundShaderMaterial.js +12 -3
- package/src/rock-shader/rockMaterial.js +205 -28
- package/src/rock-shader/rockShaderRuntime.js +17 -1
- package/src/rock-shader/rockShaderSettings.js +16 -0
- package/src/rockgen/index.js +9 -0
- package/src/rockgen/lod/index.js +1 -0
- package/src/rockgen/lod/rockDenseFieldPolicy.js +143 -0
- package/src/rockgen/rockDocument.js +899 -35
- package/src/rockgen/surface/c7GeologySurface.js +39 -9
- package/src/rockgen/surface/naturalRockSurface.js +1948 -0
- package/src/shaders-tsl/chunks/projected-water-caustics.js +14 -2
- package/src/shaders-tsl/chunks/water-foam.js +6 -6
- package/src/shaders-tsl/chunks/water-lighting.js +28 -5
- package/src/shaders-tsl/chunks/water-shore-state.js +5 -2
- package/src/shaders-tsl/chunks/water-waves.js +10 -5
- package/src/shaders-tsl/flower.js +7 -4
- package/src/shaders-tsl/grass.js +4 -3
- package/src/shaders-tsl/water-shore-state-simulation.js +3 -2
- package/src/shaders-tsl/water.js +209 -41
- package/src/sky/skySystem.js +30 -7
- package/src/toon/settings/perspectiveRemovalSettings.js +1 -1
- package/src/toon/toonSettings.js +74 -0
- package/src/vegetation/stylizedFlower.js +6 -0
- package/src/version.js +1 -1
- package/src/water/waterDetailSpectrum.js +91 -0
- package/src/water/waterDynamics.js +422 -0
- package/src/water/waterFoamParticles.js +196 -0
- package/src/water/waterFoamTexture.js +57 -0
- package/src/water/waterHydrodynamics.js +209 -0
- package/src/water/waterMaterial.js +1 -0
- package/src/water/waterRenderExtension.js +107 -0
- package/src/water/waterScenePasses.js +14 -6
- package/src/water/waterSettings.js +53 -26
- package/src/water/waterShoreMaterial.js +38 -14
- package/src/water/waterSpectralOcean.js +137 -0
- package/src/water/waterStageSettings.js +19 -1
- package/src/water/waterSurface.js +62 -18
- package/src/water/waterUnderwaterAtmosphere.js +30 -3
- package/types/catalog/officialCatalog.d.ts +1 -0
- package/types/catalog/officialCatalogPlacement.d.ts +4 -0
- package/types/catalog/officialCatalogRockPackage.d.ts +68 -0
- package/types/cloud/noise/baseShapeVolume.d.ts +1 -1
- package/types/cloud/noise/textureCache.d.ts +12 -0
- package/types/core/sha256.d.ts +2 -0
- package/types/index.d.ts +30 -0
- package/types/rock-shader/rockMaterial.d.ts +3 -0
- package/types/rock-shader/rockShaderSettings.d.ts +2 -0
- package/types/rockgen/index.d.ts +1 -0
- package/types/rockgen/lod/index.d.ts +1 -0
- package/types/rockgen/lod/rockDenseFieldPolicy.d.ts +181 -0
- package/types/rockgen/rockDocument.d.ts +654 -71
- package/types/rockgen/surface/naturalRockSurface.d.ts +100 -0
- package/types/shaders-tsl/chunks/projected-water-caustics.d.ts +7 -1
- package/types/shaders-tsl/chunks/water-lighting.d.ts +4 -3
- package/types/shaders-tsl/water.d.ts +2 -1
- package/types/version.d.ts +1 -1
- package/types/water/waterDetailSpectrum.d.ts +13 -0
- package/types/water/waterDynamics.d.ts +89 -0
- package/types/water/waterFoamParticles.d.ts +32 -0
- package/types/water/waterFoamTexture.d.ts +1 -0
- package/types/water/waterHydrodynamics.d.ts +49 -0
- package/types/water/waterRenderExtension.d.ts +16 -0
- package/types/water/waterScenePasses.d.ts +1 -1
- package/types/water/waterSettings.d.ts +1 -0
- package/types/water/waterSpectralOcean.d.ts +17 -0
- package/types/water/waterStageSettings.d.ts +1 -1
- package/types/water/waterUnderwaterAtmosphere.d.ts +19 -4
package/agents/codex/AGENTS.md
CHANGED
|
@@ -1,161 +1,114 @@
|
|
|
1
1
|
# ToonLab Agent Guide
|
|
2
2
|
|
|
3
|
-
Use
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
and `fetchStyleBundle` are optional. Scene discovery remains explicit;
|
|
116
|
-
manufactured assets have a conservative proposal/review/apply labeling path,
|
|
117
|
-
and strict bundle application reconciles declared roles against live slots
|
|
118
|
-
before the first mutation.
|
|
119
|
-
- New bundles use `treeShader`, `grassShader`, `flowerShader`, and
|
|
120
|
-
`groundShader`. V1 `vegetationShader`, `tree`, `grass`, and `flowers`
|
|
121
|
-
selections are migration inputs only and never serialize into v2. Do not
|
|
122
|
-
serialize asset recipes, tree geometry, scatter, or live wind/weather
|
|
123
|
-
into shader slots.
|
|
124
|
-
- Treat `call_me_sensei` as the first-party reference bundle. Optimize the
|
|
125
|
-
canonical domain implementations for the best coordinated result and apply
|
|
126
|
-
the completion gate in `agents/references/style-bundles.md`. Assigning the same
|
|
127
|
-
style id to every slot is not completion, and compatibility flattening for
|
|
128
|
-
incomplete assets must not define the signature look.
|
|
129
|
-
- For sourcing or generation, read
|
|
130
|
-
`agents/references/mcp-asset-discovery.md` and
|
|
131
|
-
`agents/references/asset-sourcing-policy.md`. Reuse an
|
|
132
|
-
accepted asset first. If a procedural family has an approved stylized base
|
|
133
|
-
set and passed the reliability gate, generate directly and skip gallery
|
|
134
|
-
search. Otherwise use curated CC0, then properly attributed CC-BY; reserve
|
|
135
|
-
image-to-3D for a named remaining gap. Preserve base-set version, recipe,
|
|
136
|
-
seed, domain/material labels, license provenance, and the Call Me Sensei
|
|
137
|
-
verification result. Pro may author/review base sets; OSS consumes portable
|
|
138
|
-
artifacts without a database.
|
|
139
|
-
- For Sky/Cloud and Water work, `.settings` is the portable authored baseline and
|
|
140
|
-
`.renderedSettings` is the current composition. Give Lighting, Weather, and
|
|
141
|
-
other transient owners unique `setSceneOverrideLayer` ids and clear only the
|
|
142
|
-
same id; never export composed scene state.
|
|
143
|
-
- In a composed-world test, use the public Lighting bundle slot and scene style
|
|
144
|
-
runtime for the coordinated sun, sky probe, and shared shadow contract. Keep
|
|
145
|
-
host-owned Weather and any custom local-light adapters coordinated with Sky,
|
|
146
|
-
Water, and vegetation scene inputs.
|
|
147
|
-
- Sky documents contain exactly 46 portable art fields. Radius and compile-time
|
|
148
|
-
quality are not portable: named tiers use 2/3/4 cloud octaves, custom quality
|
|
149
|
-
accepts `{ cloudOctaves: 1..5 }`, and `sky.setQuality()` rebuilds the material.
|
|
150
|
-
Water quality is chosen when constructing/replacing `WaterSurface`, not via
|
|
151
|
-
`applySettings()`.
|
|
152
|
-
- Do not depend on ToonLab sample assets, generated manifests, or lab-only
|
|
153
|
-
model/environment discovery.
|
|
154
|
-
- Keep these downloadable resources focused on runtime usage.
|
|
155
|
-
|
|
156
|
-
## Developer Verification
|
|
157
|
-
|
|
158
|
-
- For consumer apps, run that app's normal typecheck, test, build, and visual
|
|
159
|
-
smoke checks.
|
|
160
|
-
- For generated rock assets, use a fixed seed and compare the output your app
|
|
161
|
-
expects.
|
|
3
|
+
Use ToonLab's public runtime to develop the game the user requested. Build the
|
|
4
|
+
host game systems when needed; “host-owned” means your application implements
|
|
5
|
+
that part, not that the task must be refused or called an experiment. Preserve
|
|
6
|
+
existing gameplay and layout unless the request authorizes changing them.
|
|
7
|
+
|
|
8
|
+
## Find the installed contract
|
|
9
|
+
|
|
10
|
+
Resolve `@call-me-sensei/toonlab` in this project and read its `package.json`
|
|
11
|
+
version and export map. In this guide and the feature skills, `agents/...` and
|
|
12
|
+
`NPM-LIBRARY.md` are relative to that package root, normally
|
|
13
|
+
`node_modules/@call-me-sensei/toonlab/`, not the game repository root. In a
|
|
14
|
+
workspace with hoisted dependencies, resolve the installed location first.
|
|
15
|
+
|
|
16
|
+
Start with `NPM-LIBRARY.md`, `agents/references/runtime-entry-points.md`, and the
|
|
17
|
+
`game-dev` skill. Read other skills only for the systems the task uses. The
|
|
18
|
+
installed package has the supported guides and references; a source checkout,
|
|
19
|
+
Lab UI, Pro account, and generative AI are not prerequisites for building a game.
|
|
20
|
+
Do not overwrite the game's existing agent instructions when installing this guide.
|
|
21
|
+
|
|
22
|
+
## Divide responsibilities correctly
|
|
23
|
+
|
|
24
|
+
| Application work | ToonLab support |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| Game rules, input, camera, UI, objectives, spawning, scene layout, navigation, dynamic physics, networking, persistence | Host code composed with the runtime; do not invent ToonLab APIs for these |
|
|
27
|
+
| Renderer construction, resize, frame loop, shutdown | `renderer` helpers and scene-style configuration; use Three's `WebGPURenderer` for TSL, including its WebGL2 fallback |
|
|
28
|
+
| Character loading, rig/clips, conversion, animation update/disposal | `createCharacterRuntime()`; `createWalkableCharacterRuntime()` connects locomotion and grounding to host movement/physics |
|
|
29
|
+
| Terrain-bound placement, grass, shore and water-bed coordination | `createSceneSurfaceRuntime()` when the host supplies a heightfield |
|
|
30
|
+
| Labeled static blockers | `createSceneStyleRuntime().collision`; use explicit collision metadata or the Rapier adapter where needed |
|
|
31
|
+
| Coordinated lighting, sky inputs, ground field and shared shadows | `createSceneStyleRuntime()` and the public `lighting` domain |
|
|
32
|
+
| Materials, vegetation, water, sky/cloud, post and procedural assets | Focused exports listed in `agents/references/runtime-entry-points.md` |
|
|
33
|
+
|
|
34
|
+
A hand-built level is valid application work. Reliable automatic world layout,
|
|
35
|
+
terrain/geology synthesis, navigation, camera controllers, gameplay VFX and the
|
|
36
|
+
experimental species engine are not promises of the npm package. Do not import
|
|
37
|
+
repository-only implementations or turn a Lab route into a runtime dependency.
|
|
38
|
+
|
|
39
|
+
## Build in useful increments
|
|
40
|
+
|
|
41
|
+
For a new game, make a playable vertical slice first: controls, movement,
|
|
42
|
+
collision, camera, one objective, and restart. Then apply the selected art
|
|
43
|
+
direction and add assets. For an existing game, integrate the requested domains
|
|
44
|
+
without replacing its renderer or update loop unnecessarily. The `game-dev`
|
|
45
|
+
skill gives the integration order and the frame ownership contract.
|
|
46
|
+
|
|
47
|
+
Use focused package imports. Choose the selected bundle's treatment explicitly;
|
|
48
|
+
Call Me Sensei is the first-party default when the user has not chosen another.
|
|
49
|
+
Its bundle ID is `call-me-sensei`; many domain preset/style selectors instead
|
|
50
|
+
use `call_me_sensei`. Use the documented selector for each API.
|
|
51
|
+
|
|
52
|
+
Use `style-presets` before style-aware construction.
|
|
53
|
+
For anime treatment, read `agents/references/anime-art-direction.md` and
|
|
54
|
+
`agents/references/style-bundles.md`. Preserve source PBR maps and material
|
|
55
|
+
identity. Realistic rock maps are valid asset inputs and may also be the user's
|
|
56
|
+
requested output; do not confuse them with an accidentally unstyled anime scene.
|
|
57
|
+
|
|
58
|
+
Label style targets by domain and give every material slot a stable material
|
|
59
|
+
ID and semantic role. A root-only label is incomplete for a multi-material
|
|
60
|
+
asset. Strict mode blocks incomplete coverage. Use the manufactured-material proposal/review/apply
|
|
61
|
+
helpers for imported props. Report automatic and assisted results separately.
|
|
62
|
+
Do not infer a physical material solely from its color or filename. Split mixed
|
|
63
|
+
atlases or supply the required mask. Strict style application must reject
|
|
64
|
+
incomplete coverage before mutation; advisory results must disclose gaps.
|
|
65
|
+
|
|
66
|
+
Apply scene-wide styles through `styleRuntime.apply(...)`. It manages the
|
|
67
|
+
lighting, renderer, shadow, and collision integrations as well as material
|
|
68
|
+
transactions. Use the lower-level `applyStyleBundle()` only when the app owns
|
|
69
|
+
those integrations deliberately. A `createStyleTarget()` descriptor alone is
|
|
70
|
+
not durable labeling: use `labelStyleTarget()` for scene-label discovery.
|
|
71
|
+
|
|
72
|
+
## Assets and MCP
|
|
73
|
+
|
|
74
|
+
Use `asset-sourcing` when discovering/importing assets or requesting generation.
|
|
75
|
+
Inspect the connected server's tool schemas: local and Pro tools with the same
|
|
76
|
+
name can mean different things. Follow the project's actual policy; the strict
|
|
77
|
+
acceptance fixture is not a universal rule for every game.
|
|
78
|
+
|
|
79
|
+
Reuse project/Library assets, shortlist Gallery results from metadata, then
|
|
80
|
+
retrieve selected artifacts. Preserve IDs, license, provenance, dimensions,
|
|
81
|
+
recipe and seed. First-party rock dimensions and taxonomy support shortlisting
|
|
82
|
+
without rendering GLBs just to measure them. Use returned IDs and public labels;
|
|
83
|
+
internal production identifiers are not product names.
|
|
84
|
+
|
|
85
|
+
MCP also creates and mutates portable Lab documents. Call `list_live_labs`,
|
|
86
|
+
`get_lab_features`, then `create_lab_document`; its result wraps the portable
|
|
87
|
+
JSON in `document`. Save through the relevant Library tool when persistence is
|
|
88
|
+
part of the task. A valid document does not guarantee its preview or generated
|
|
89
|
+
asset has passed visual review.
|
|
90
|
+
|
|
91
|
+
Local `generate_asset` is procedural; local provider work uses
|
|
92
|
+
`generate_ai_asset` and the user's keys. Pro `generate_asset` spends separately
|
|
93
|
+
purchased credits. A free Pro month grants MCP access without AI credits.
|
|
94
|
+
Generation capability is not permission to spend; follow existing authorization
|
|
95
|
+
and the server's sourcing-policy requirements. Keep provider keys out of source
|
|
96
|
+
and portable documents.
|
|
97
|
+
|
|
98
|
+
## Verify and hand off
|
|
99
|
+
|
|
100
|
+
Test through the app's real input and render path. Run its applicable checks,
|
|
101
|
+
wait for asset/render readiness, inspect the console, and capture the requested
|
|
102
|
+
views. Test restart/teardown and verify that listeners, resources, and animation
|
|
103
|
+
loops are not duplicated. Each system has one update owner and each frame has
|
|
104
|
+
one final render owner. Read `visual-verification` for a visual review.
|
|
105
|
+
|
|
106
|
+
For a heightfield scene, run the shared surface audit after the required passes
|
|
107
|
+
have rendered. Run `styleRuntime.collision.assertReady()` before relying on its
|
|
108
|
+
blockers. Test actual movement around representative obstacles. Include LOD,
|
|
109
|
+
shadow and shoreline views only when those systems are used.
|
|
110
|
+
|
|
111
|
+
Record missing package capabilities and material-policy exceptions when they
|
|
112
|
+
matter to the requested result. Ordinary host gameplay code is not a ToonLab
|
|
113
|
+
failure. Report what works, what was tested, and any remaining limitation;
|
|
114
|
+
never describe a build alone as a finished or visually approved game.
|
|
@@ -8,8 +8,10 @@ alwaysApply: true
|
|
|
8
8
|
|
|
9
9
|
- Treat `node_modules/@call-me-sensei/toonlab/agents/codex/AGENTS.md` as the
|
|
10
10
|
shared developer guide.
|
|
11
|
-
-
|
|
12
|
-
|
|
11
|
+
- Build the requested host game or integrate ToonLab into supplied scenes.
|
|
12
|
+
For new games, use the game-dev skill and start with movement, collision,
|
|
13
|
+
one objective and restart. Host-owned gameplay and layout are authorized
|
|
14
|
+
development work when requested; ToonLab does not generate finished worlds.
|
|
13
15
|
- Prefer package subpath imports such as `@call-me-sensei/toonlab/toon`,
|
|
14
16
|
`@call-me-sensei/toonlab/water`,
|
|
15
17
|
`@call-me-sensei/toonlab/vegetation-shaders`,
|
|
@@ -20,7 +22,9 @@ alwaysApply: true
|
|
|
20
22
|
`ShaderMaterial`, or classic WebGL-only forks for ToonLab features.
|
|
21
23
|
- Treat ToonLab labs, sample assets, screenshots, captures, and generated
|
|
22
24
|
manifests as examples, not runtime API.
|
|
23
|
-
-
|
|
25
|
+
- Resolve `agents/` references from the installed package root, including
|
|
26
|
+
when a skill is copied. Use `agents/references/game-lifecycle.md` for update
|
|
27
|
+
ownership and cleanup, and `agents/skills/` for focused workflows.
|
|
24
28
|
- Material metadata is a blocking modeling deliverable. Every modeled,
|
|
25
29
|
generated, converted, or imported renderable needs a stable target ID and
|
|
26
30
|
domain; every material slot needs a stable material ID and semantic role in
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Copyable host-game example, not a ToonLab export. Requires a bundler and canvas.
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { WebGPURenderer } from 'three/webgpu';
|
|
4
|
+
import {
|
|
5
|
+
CALL_ME_SENSEI_STYLE_BUNDLE,
|
|
6
|
+
createSceneStyleRuntime,
|
|
7
|
+
createStyleMaterialContract,
|
|
8
|
+
createStyleTargetLabel,
|
|
9
|
+
labelStyleTarget,
|
|
10
|
+
} from '@call-me-sensei/toonlab/styles';
|
|
11
|
+
import { createCollisionMetadata } from '@call-me-sensei/toonlab/world-collision';
|
|
12
|
+
|
|
13
|
+
export async function startGame({ canvas, onState = () => {} }) {
|
|
14
|
+
const renderer = new WebGPURenderer({ canvas, antialias: true });
|
|
15
|
+
try { await renderer.init(); }
|
|
16
|
+
catch (error) { renderer.dispose(); throw error; }
|
|
17
|
+
const scene = new THREE.Scene();
|
|
18
|
+
scene.background = new THREE.Color('#b7d8ec');
|
|
19
|
+
const camera = new THREE.PerspectiveCamera(45, 1, 0.1, 100);
|
|
20
|
+
camera.position.set(8, 10, 12);
|
|
21
|
+
camera.lookAt(0, 0, 0);
|
|
22
|
+
const objects = [];
|
|
23
|
+
function add(id, domain, role, geometry, color, position, collision) {
|
|
24
|
+
const material = new THREE.MeshStandardMaterial({ color });
|
|
25
|
+
material.userData.toonlabMaterialId = id;
|
|
26
|
+
const mesh = new THREE.Mesh(geometry, material);
|
|
27
|
+
mesh.position.fromArray(position);
|
|
28
|
+
labelStyleTarget(mesh, createStyleTargetLabel(domain, {
|
|
29
|
+
targetId: id,
|
|
30
|
+
materials: createStyleMaterialContract(domain, { assignments: { [id]: { roles: [role] } } }),
|
|
31
|
+
...(collision ? { collision } : {}),
|
|
32
|
+
}));
|
|
33
|
+
scene.add(mesh); objects.push(mesh);
|
|
34
|
+
return mesh;
|
|
35
|
+
}
|
|
36
|
+
const floor = add('floor', 'terrain.ground', 'ground', new THREE.PlaneGeometry(14, 14), '#a3be76', [0, 0, 0]);
|
|
37
|
+
floor.rotation.x = -Math.PI / 2;
|
|
38
|
+
add('blocker', 'natural.rock', 'rock', new THREE.BoxGeometry(2, 2, 2), '#b4aea0', [0, 1, 0]);
|
|
39
|
+
const player = add('player', 'character', 'costume', new THREE.CapsuleGeometry(0.3, 0.8, 4, 8), '#bd6182', [-3, 0.7, 2]);
|
|
40
|
+
const goal = add('goal', 'prop', 'metal', new THREE.SphereGeometry(0.25, 12, 8), '#f5c45a', [3, 0.6, -3], createCollisionMetadata('none'));
|
|
41
|
+
scene.updateMatrixWorld(true);
|
|
42
|
+
const styleRuntime = createSceneStyleRuntime({ renderer, scene });
|
|
43
|
+
try {
|
|
44
|
+
await styleRuntime.apply(CALL_ME_SENSEI_STYLE_BUNDLE, { discovery: 'scene-labels', mode: 'strict', watch: false });
|
|
45
|
+
styleRuntime.collision.assertReady();
|
|
46
|
+
} catch (error) {
|
|
47
|
+
await styleRuntime.dispose();
|
|
48
|
+
for (const mesh of objects) { mesh.geometry.dispose(); mesh.material.dispose(); }
|
|
49
|
+
renderer.dispose(); throw error;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const keys = new Set();
|
|
53
|
+
const listeners = new AbortController();
|
|
54
|
+
let won = false, lastTime = null, disposed = false;
|
|
55
|
+
function restart() {
|
|
56
|
+
player.position.set(-3, 0.7, 2); goal.visible = true; won = false;
|
|
57
|
+
keys.clear(); lastTime = null; onState({ won });
|
|
58
|
+
}
|
|
59
|
+
window.addEventListener('keydown', (event) => {
|
|
60
|
+
if (/^(INPUT|TEXTAREA|SELECT)$/.test(event.target?.tagName) || event.target?.isContentEditable) return;
|
|
61
|
+
if (['KeyW', 'KeyA', 'KeyS', 'KeyD', 'ArrowUp', 'ArrowLeft', 'ArrowDown', 'ArrowRight'].includes(event.code)) {
|
|
62
|
+
event.preventDefault(); keys.add(event.code);
|
|
63
|
+
}
|
|
64
|
+
if (event.code === 'KeyR') restart();
|
|
65
|
+
}, { signal: listeners.signal });
|
|
66
|
+
window.addEventListener('keyup', (event) => keys.delete(event.code), { signal: listeners.signal });
|
|
67
|
+
window.addEventListener('blur', () => { keys.clear(); lastTime = null; }, { signal: listeners.signal });
|
|
68
|
+
function resize() {
|
|
69
|
+
const width = Math.max(canvas.clientWidth, 1), height = Math.max(canvas.clientHeight, 1);
|
|
70
|
+
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
|
|
71
|
+
renderer.setSize(width, height, false); camera.aspect = width / height; camera.updateProjectionMatrix();
|
|
72
|
+
}
|
|
73
|
+
window.addEventListener('resize', resize, { signal: listeners.signal });
|
|
74
|
+
resize(); restart();
|
|
75
|
+
renderer.setAnimationLoop((time) => {
|
|
76
|
+
const delta = lastTime === null ? 0 : Math.min((time - lastTime) / 1000, 0.05);
|
|
77
|
+
lastTime = time;
|
|
78
|
+
if (!won) {
|
|
79
|
+
const x = Number(keys.has('KeyD') || keys.has('ArrowRight')) - Number(keys.has('KeyA') || keys.has('ArrowLeft'));
|
|
80
|
+
const z = Number(keys.has('KeyS') || keys.has('ArrowDown')) - Number(keys.has('KeyW') || keys.has('ArrowUp'));
|
|
81
|
+
const length = Math.hypot(x, z) || 1;
|
|
82
|
+
player.position.x = THREE.MathUtils.clamp(player.position.x + x / length * delta * 3, -6.5, 6.5);
|
|
83
|
+
player.position.z = THREE.MathUtils.clamp(player.position.z + z / length * delta * 3, -6.5, 6.5);
|
|
84
|
+
styleRuntime.collision.world.resolve(player.position, 0.3);
|
|
85
|
+
if (Math.hypot(player.position.x - goal.position.x, player.position.z - goal.position.z) < 0.65) {
|
|
86
|
+
won = true; goal.visible = false; onState({ won });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
styleRuntime.update(delta, camera);
|
|
90
|
+
renderer.render(scene, camera);
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
restart,
|
|
94
|
+
// Read-only telemetry is useful for a host smoke test and debugging.
|
|
95
|
+
get state() { return { won, player: player.position.toArray(), collision: styleRuntime.collision.report }; },
|
|
96
|
+
async dispose() {
|
|
97
|
+
if (disposed) return; disposed = true;
|
|
98
|
+
renderer.setAnimationLoop(null); listeners.abort();
|
|
99
|
+
await styleRuntime.dispose();
|
|
100
|
+
for (const mesh of objects) { mesh.geometry.dispose(); mesh.material.dispose(); }
|
|
101
|
+
renderer.dispose();
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Game lifecycle and update ownership
|
|
2
|
+
|
|
3
|
+
The application owns the frame loop. Adding ToonLab should not create competing
|
|
4
|
+
loops, duplicate physics steps or double animation updates. For a new game,
|
|
5
|
+
author the host systems as part of the requested work. For integration, reuse
|
|
6
|
+
the existing owners.
|
|
7
|
+
|
|
8
|
+
## One owner per system
|
|
9
|
+
|
|
10
|
+
| System | Owner and update |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| Input, game rules and dynamic physics | Host; use a fixed physics timestep where the physics engine requires it |
|
|
13
|
+
| Character mixer/VRM | `character.update(delta)`; if a walkable runtime owns that character, let it perform the update instead |
|
|
14
|
+
| Camera | Host; update after movement and before camera-dependent scene passes |
|
|
15
|
+
| SkySystem | Host calls `sky.update(delta)` once; binding it to scene-style does not animate it |
|
|
16
|
+
| Lighting, shared shadows, ground field | `styleRuntime.update(delta, camera)` |
|
|
17
|
+
| Grass and other focused objects | Call their documented updates once, after the ground field they sample is current |
|
|
18
|
+
| WaterSurface | Host calls `water.update(delta, camera)` once |
|
|
19
|
+
| Final scene render | `post.render(delta)` when a post pipeline owns rendering; otherwise `renderer.render(scene, camera)` |
|
|
20
|
+
|
|
21
|
+
Check ownership in the actual runtime you instantiate. Do not call a lower
|
|
22
|
+
level character, physics or material update again when an owning controller
|
|
23
|
+
already does it. Update independent transient conditions through uniquely
|
|
24
|
+
named layers; clear only the owner's layer when it ends.
|
|
25
|
+
|
|
26
|
+
For a scene using these systems, a typical order is host movement/physics,
|
|
27
|
+
camera, sky, scene-style passes, grass/other animated content, water, then the
|
|
28
|
+
final render. Clamp the resumed frame delta and reset held keys on focus loss.
|
|
29
|
+
Make pause and restart explicit gameplay states rather than spawning new loops.
|
|
30
|
+
|
|
31
|
+
## Renderer and readiness
|
|
32
|
+
|
|
33
|
+
Create Three's `WebGPURenderer`, await `renderer.init()`, and use TSL-compatible
|
|
34
|
+
materials. Its WebGL2 fallback is not the classic `WebGLRenderer` material path.
|
|
35
|
+
Use `configureToonLabRenderer()` only when the scene-style runtime does not
|
|
36
|
+
already own that configuration. Pick a device-appropriate pixel ratio and
|
|
37
|
+
quality profile; measure before increasing shadow, cloud or water quality.
|
|
38
|
+
|
|
39
|
+
Await model/texture and scene application promises. Render the required passes
|
|
40
|
+
before calling the surface readiness audit. Validate collision registration and
|
|
41
|
+
probe movement against real blockers. A flag such as `castShadow` or a stable
|
|
42
|
+
triangle count is useful evidence, but neither proves the final image is valid.
|
|
43
|
+
|
|
44
|
+
## Resize and shutdown
|
|
45
|
+
|
|
46
|
+
On resize, update the camera projection, renderer size and any explicitly sized
|
|
47
|
+
post/target resources. Use the renderer's actual drawing-buffer size for pixel
|
|
48
|
+
budgets. On shutdown stop the animation loop and listeners, then await
|
|
49
|
+
`styleRuntime.dispose()` before disposing the host objects it styled. Dispose
|
|
50
|
+
each character, grass field, water, sky and post pipeline through its owner;
|
|
51
|
+
scene-style does not transfer ownership of supplied systems. Release acquired
|
|
52
|
+
asset handles and caller-owned textures only after their final consumer ends.
|
|
53
|
+
|
|
54
|
+
The copyable `agents/examples/game-foundation.mjs` demonstrates a flat blockout
|
|
55
|
+
with movement, labeled static collision, a collectible and restart. It makes no
|
|
56
|
+
claim to provide dynamic physics, navigation or finished art. Add those host
|
|
57
|
+
systems when the game requires them, and qualify them through real gameplay.
|
|
@@ -11,6 +11,8 @@ scene content. Prefer focused imports from these production-oriented areas:
|
|
|
11
11
|
- `post`, `post-processing`
|
|
12
12
|
- `rockgen`, `texgen`, `assetlib`
|
|
13
13
|
- `styles`, `asset-policy`, `loaders`
|
|
14
|
+
- `renderer`, `runtime`, `world-collision`, `official-catalog`, `scene-operations`
|
|
15
|
+
- `react` when using the optional React/React Three Fiber peers
|
|
14
16
|
|
|
15
17
|
`sky` and `cloud` are public because they are owned by the live Sky, Cloud, and
|
|
16
18
|
Sky & Cloud Labs. Weather, climate, debris, ambient-effects, fauna, debug, and
|
|
@@ -173,3 +175,27 @@ responsibilities.
|
|
|
173
175
|
Use the package README and exported functions/settings as the runtime source
|
|
174
176
|
of truth. Labs, internal comparison fixtures, local asset paths, and repository
|
|
175
177
|
documentation outside `agents/references/` are not installed public APIs.
|
|
178
|
+
|
|
179
|
+
## Realistic rock materials
|
|
180
|
+
|
|
181
|
+
The `rockgen` entry exposes `NATURAL_ROCK_SURFACE_PROFILES`,
|
|
182
|
+
`NATURAL_ROCK_MAP_ROLES`, `createNaturalRockMapData`,
|
|
183
|
+
`resolveNaturalRockProjection`, and `createNaturalRockSurfaceSpecification`.
|
|
184
|
+
Use these for deterministic realistic surface maps on procedural or edited
|
|
185
|
+
rocks. The host owns texture creation and material assignment. Preserve saved
|
|
186
|
+
surface recipes and geometry identities. Composite profiles require authored
|
|
187
|
+
semantic regions; do not substitute a homogeneous map or invent a residual bake.
|
|
188
|
+
|
|
189
|
+
## Host game and lifecycle
|
|
190
|
+
|
|
191
|
+
Building gameplay, cameras, level layout and UI is ordinary host work when the
|
|
192
|
+
user requests a new game. “Host-owned” does not prohibit the agent from doing
|
|
193
|
+
that work. Read `agents/references/game-lifecycle.md` for exact update owners.
|
|
194
|
+
The style runtime coordinates lighting, shadow and ground-field passes; it
|
|
195
|
+
does not advance bound sky, water, grass or character objects automatically.
|
|
196
|
+
|
|
197
|
+
Discover current sky fields through `SKY_PARAMS_FIELD_SCHEMA` and
|
|
198
|
+
`SKY_PARAMS_SCHEMA_VERSION`; modern `SkySystem` uses `toonlab/sky-params`.
|
|
199
|
+
`createSkySettings` and `StylizedSky` refer to the compatibility renderer and
|
|
200
|
+
its distinct settings contract. Do not mix those schemas or hardcode a field
|
|
201
|
+
count from older guides.
|
|
@@ -30,7 +30,10 @@ Prefer `createSceneStyleRuntime({ renderer, scene, sky, water })` for a complete
|
|
|
30
30
|
bundle application. It owns one stable lighting rig and automatically enables
|
|
31
31
|
the environment ground-field pass when the grass slot requests ground-color
|
|
32
32
|
adoption. Call `runtime.update(delta, camera)` before the scene render. Never
|
|
33
|
-
recreate those passes in each playground or scene.
|
|
33
|
+
recreate those passes in each playground or scene. Sky, Water, grass and
|
|
34
|
+
character animation retain their own update owners; see
|
|
35
|
+
`agents/references/game-lifecycle.md`. When post is bound, use its final
|
|
36
|
+
`render(delta)` path rather than bypassing it.
|
|
34
37
|
|
|
35
38
|
Strict application preflights every target before the first mutation. Missing
|
|
36
39
|
slots, unknown domains, mixed material roles without an ID mask, unsupported
|
|
@@ -3,6 +3,10 @@ name: asset-sourcing
|
|
|
3
3
|
description: Help agents source anime-game-ready models, textures, and presets through policy-aware ToonLab MCP discovery, provenance, supported shaders, and explicit custom-gap reporting.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
References beginning `agents/` resolve from the installed ToonLab package root
|
|
7
|
+
(normally `node_modules/@call-me-sensei/toonlab/`), even when this skill is copied.
|
|
8
|
+
|
|
9
|
+
|
|
6
10
|
# Asset Sourcing
|
|
7
11
|
|
|
8
12
|
Use this skill when a developer needs an asset — a model, texture, HDRI,
|
|
@@ -66,7 +70,7 @@ scene-kit role.
|
|
|
66
70
|
Never regenerate or re-download something already available.
|
|
67
71
|
3. **Use an approved procedural family only when policy permits it.** Discover
|
|
68
72
|
approved families through MCP, then use their focused runtime such as
|
|
69
|
-
`@call-me-sensei/toonlab/vegetation`, `rockgen
|
|
73
|
+
`@call-me-sensei/toonlab/vegetation`, `rockgen` or `texgen`.
|
|
70
74
|
This is the direct route only when the requested family has an approved,
|
|
71
75
|
versioned stylized base set and passes the policy/review gate described in
|
|
72
76
|
`agents/references/asset-sourcing-policy.md`. Preserve base-set version, generator version,
|
|
@@ -97,9 +101,8 @@ scene-kit role.
|
|
|
97
101
|
generation capability, polling, and save tools; follow the advertised schema.
|
|
98
102
|
6. **Author stable visual profiles in code.** Post profiles can be generated
|
|
99
103
|
deterministically through `@call-me-sensei/toonlab/post`; other stable
|
|
100
|
-
shader profiles resolve through the selected style bundle. Lighting
|
|
101
|
-
|
|
102
|
-
are not advertised by the packaged MCP server.
|
|
104
|
+
shader profiles resolve through the selected style bundle. Lighting is a supported public runtime and bundle slot. VFX, camera and
|
|
105
|
+
game-feel implementations remain host-owned; do not invent package APIs.
|
|
103
106
|
|
|
104
107
|
Persist anything worth keeping with `save_creation` (or write the JSON into
|
|
105
108
|
the repo); `.toonlab/creations/` is the shared surface labs and later
|
|
@@ -3,6 +3,10 @@ name: environment
|
|
|
3
3
|
description: Help developers use ToonLab environment shading, lighting rigs, ambient probes, reflections, fog, cloud shadows, or vertex AO in an app.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
References beginning `agents/` resolve from the installed ToonLab package root
|
|
7
|
+
(normally `node_modules/@call-me-sensei/toonlab/`), even when this skill is copied.
|
|
8
|
+
|
|
9
|
+
|
|
6
10
|
# Environment
|
|
7
11
|
|
|
8
12
|
Use this skill when a developer wants stylized scene materials, material-role
|