@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.
Files changed (129) hide show
  1. package/NPM-LIBRARY.md +87 -27
  2. package/README.md +11 -10
  3. package/agents/PROMPTS.md +17 -3
  4. package/agents/README.md +13 -3
  5. package/agents/claude/CLAUDE.md +3 -0
  6. package/agents/codex/AGENTS.md +112 -159
  7. package/agents/cursor/toonlab.mdc +7 -3
  8. package/agents/examples/game-foundation.mjs +104 -0
  9. package/agents/references/game-lifecycle.md +57 -0
  10. package/agents/references/runtime-entry-points.md +26 -0
  11. package/agents/references/style-bundles.md +4 -1
  12. package/agents/skills/claude/asset-sourcing/SKILL.md +7 -4
  13. package/agents/skills/claude/environment/SKILL.md +4 -0
  14. package/agents/skills/claude/game-dev/SKILL.md +63 -87
  15. package/agents/skills/claude/lighting/SKILL.md +36 -0
  16. package/agents/skills/claude/post-processing/SKILL.md +8 -3
  17. package/agents/skills/claude/rock-ground-shaders/SKILL.md +10 -15
  18. package/agents/skills/claude/rockgen/SKILL.md +52 -21
  19. package/agents/skills/claude/scene-style-application/SKILL.md +4 -0
  20. package/agents/skills/claude/style-presets/SKILL.md +11 -8
  21. package/agents/skills/claude/toon-shading/SKILL.md +4 -0
  22. package/agents/skills/claude/vegetation-sky/SKILL.md +13 -7
  23. package/agents/skills/claude/visual-verification/SKILL.md +45 -119
  24. package/agents/skills/claude/water/SKILL.md +6 -2
  25. package/agents/skills/codex/asset-sourcing/SKILL.md +7 -4
  26. package/agents/skills/codex/environment/SKILL.md +4 -0
  27. package/agents/skills/codex/game-dev/SKILL.md +63 -87
  28. package/agents/skills/codex/lighting/SKILL.md +36 -0
  29. package/agents/skills/codex/post-processing/SKILL.md +8 -3
  30. package/agents/skills/codex/rock-ground-shaders/SKILL.md +10 -15
  31. package/agents/skills/codex/rockgen/SKILL.md +52 -21
  32. package/agents/skills/codex/scene-style-application/SKILL.md +4 -0
  33. package/agents/skills/codex/style-presets/SKILL.md +11 -8
  34. package/agents/skills/codex/toon-shading/SKILL.md +4 -0
  35. package/agents/skills/codex/vegetation-sky/SKILL.md +13 -7
  36. package/agents/skills/codex/visual-verification/SKILL.md +45 -119
  37. package/agents/skills/codex/water/SKILL.md +6 -2
  38. package/database/apply-one-catalog-seed.mjs +63 -0
  39. package/database/providers.mjs +1 -0
  40. package/database/seeds/catalog/0005_2026-08-c8-first12.sql +1101 -0
  41. package/database/seeds/catalog/0006_2026-09-c8-first100.sql +14245 -0
  42. package/database/seeds/catalog/0007_2026-09-c8-first100-primary-model.sql +14845 -0
  43. package/mcp/lab-management.mjs +11 -8
  44. package/mcp/public-catalog.mjs +0 -16
  45. package/mcp/tree-lab-contract.mjs +2381 -0
  46. package/mcp/vite-plugin.mjs +5 -1
  47. package/package.json +29 -18
  48. package/src/catalog/officialCatalog.js +1 -0
  49. package/src/catalog/officialCatalogAssetRuntime.js +98 -1
  50. package/src/catalog/officialCatalogLod.js +160 -16
  51. package/src/catalog/officialCatalogPlacement.js +52 -12
  52. package/src/catalog/officialCatalogProvider.js +79 -8
  53. package/src/catalog/officialCatalogRockPackage.js +172 -0
  54. package/src/cloud/cloudReprojection.js +40 -7
  55. package/src/cloud/cloudVolume.js +44 -7
  56. package/src/cloud/noise/baseShapeVolume.js +8 -6
  57. package/src/cloud/noise/cirrusMap.js +2 -1
  58. package/src/cloud/noise/curlNoise.js +2 -1
  59. package/src/cloud/noise/erosionVolume.js +2 -1
  60. package/src/cloud/noise/textureCache.js +77 -0
  61. package/src/cloud/noise/weatherMap.js +2 -1
  62. package/src/core/sha256.js +83 -0
  63. package/src/ground-shader/groundShaderMaterial.js +12 -3
  64. package/src/rock-shader/rockMaterial.js +205 -28
  65. package/src/rock-shader/rockShaderRuntime.js +17 -1
  66. package/src/rock-shader/rockShaderSettings.js +16 -0
  67. package/src/rockgen/index.js +9 -0
  68. package/src/rockgen/lod/index.js +1 -0
  69. package/src/rockgen/lod/rockDenseFieldPolicy.js +143 -0
  70. package/src/rockgen/rockDocument.js +899 -35
  71. package/src/rockgen/surface/c7GeologySurface.js +39 -9
  72. package/src/rockgen/surface/naturalRockSurface.js +1948 -0
  73. package/src/shaders-tsl/chunks/projected-water-caustics.js +14 -2
  74. package/src/shaders-tsl/chunks/water-foam.js +6 -6
  75. package/src/shaders-tsl/chunks/water-lighting.js +28 -5
  76. package/src/shaders-tsl/chunks/water-shore-state.js +5 -2
  77. package/src/shaders-tsl/chunks/water-waves.js +10 -5
  78. package/src/shaders-tsl/flower.js +7 -4
  79. package/src/shaders-tsl/grass.js +4 -3
  80. package/src/shaders-tsl/water-shore-state-simulation.js +3 -2
  81. package/src/shaders-tsl/water.js +209 -41
  82. package/src/sky/skySystem.js +30 -7
  83. package/src/toon/settings/perspectiveRemovalSettings.js +1 -1
  84. package/src/toon/toonSettings.js +74 -0
  85. package/src/vegetation/stylizedFlower.js +6 -0
  86. package/src/version.js +1 -1
  87. package/src/water/waterDetailSpectrum.js +91 -0
  88. package/src/water/waterDynamics.js +422 -0
  89. package/src/water/waterFoamParticles.js +196 -0
  90. package/src/water/waterFoamTexture.js +57 -0
  91. package/src/water/waterHydrodynamics.js +209 -0
  92. package/src/water/waterMaterial.js +1 -0
  93. package/src/water/waterRenderExtension.js +107 -0
  94. package/src/water/waterScenePasses.js +14 -6
  95. package/src/water/waterSettings.js +53 -26
  96. package/src/water/waterShoreMaterial.js +38 -14
  97. package/src/water/waterSpectralOcean.js +137 -0
  98. package/src/water/waterStageSettings.js +19 -1
  99. package/src/water/waterSurface.js +62 -18
  100. package/src/water/waterUnderwaterAtmosphere.js +30 -3
  101. package/types/catalog/officialCatalog.d.ts +1 -0
  102. package/types/catalog/officialCatalogPlacement.d.ts +4 -0
  103. package/types/catalog/officialCatalogRockPackage.d.ts +68 -0
  104. package/types/cloud/noise/baseShapeVolume.d.ts +1 -1
  105. package/types/cloud/noise/textureCache.d.ts +12 -0
  106. package/types/core/sha256.d.ts +2 -0
  107. package/types/index.d.ts +30 -0
  108. package/types/rock-shader/rockMaterial.d.ts +3 -0
  109. package/types/rock-shader/rockShaderSettings.d.ts +2 -0
  110. package/types/rockgen/index.d.ts +1 -0
  111. package/types/rockgen/lod/index.d.ts +1 -0
  112. package/types/rockgen/lod/rockDenseFieldPolicy.d.ts +181 -0
  113. package/types/rockgen/rockDocument.d.ts +654 -71
  114. package/types/rockgen/surface/naturalRockSurface.d.ts +100 -0
  115. package/types/shaders-tsl/chunks/projected-water-caustics.d.ts +7 -1
  116. package/types/shaders-tsl/chunks/water-lighting.d.ts +4 -3
  117. package/types/shaders-tsl/water.d.ts +2 -1
  118. package/types/version.d.ts +1 -1
  119. package/types/water/waterDetailSpectrum.d.ts +13 -0
  120. package/types/water/waterDynamics.d.ts +89 -0
  121. package/types/water/waterFoamParticles.d.ts +32 -0
  122. package/types/water/waterFoamTexture.d.ts +1 -0
  123. package/types/water/waterHydrodynamics.d.ts +49 -0
  124. package/types/water/waterRenderExtension.d.ts +16 -0
  125. package/types/water/waterScenePasses.d.ts +1 -1
  126. package/types/water/waterSettings.d.ts +1 -0
  127. package/types/water/waterSpectralOcean.d.ts +17 -0
  128. package/types/water/waterStageSettings.d.ts +1 -1
  129. package/types/water/waterUnderwaterAtmosphere.d.ts +19 -4
@@ -1,161 +1,114 @@
1
1
  # ToonLab Agent Guide
2
2
 
3
- Use this file when helping a developer build an anime-style game, character,
4
- or environment with ToonLab's runtime library in their own Three.js app.
5
-
6
- ## Anime-Game Product Contract
7
-
8
- - ToonLab is specifically an anime-game toolkit, not a generic stylization
9
- library. Read `agents/references/anime-art-direction.md` before making
10
- visual, shader, material, or asset decisions.
11
- - Load the selected bundle's `artDirection` and treat it as authoritative.
12
- Call Me Sensei is the first-party coordinated reference.
13
- - Never accept unintended photorealism, generic low-poly styling, undirected
14
- cartoon rendering, or untreated PBR materials as a finished ToonLab result.
15
- - If supported shaders or approved assets are insufficient, document the
16
- customization and why your project needs it.
17
-
18
- ## Runtime Boundary
19
-
20
- - `@call-me-sensei/toonlab` is primarily a runtime library for applying
21
- Three.js shaders, stylized materials, focused vegetation/water, settings,
22
- and preset documents to supplied scene content.
23
- - Prefer public package imports such as `@call-me-sensei/toonlab/toon`,
24
- `@call-me-sensei/toonlab/environment`, `@call-me-sensei/toonlab/water`,
25
- `@call-me-sensei/toonlab/vegetation`, `@call-me-sensei/toonlab/post`,
26
- `@call-me-sensei/toonlab/styles`,
27
- `@call-me-sensei/toonlab/texgen`, and `@call-me-sensei/toonlab/rockgen`.
28
- - Use `@call-me-sensei/toonlab/sky` and `/cloud` for the live Sky, Cloud, and
29
- Sky & Cloud Lab contracts. Weather, Climate, ambient effects, and fauna are
30
- not public package entry points in this release.
31
- - Use `@call-me-sensei/toonlab/vegetation-shaders` and
32
- `@call-me-sensei/toonlab/grass-palettes` when a consumer needs only those
33
- focused contracts. They are the same bindings exposed by the vegetation and
34
- root barrels.
35
- - Keep root imports lightweight in examples. Import only the feature subpath a
36
- developer needs.
37
- - Public export status and product maturity are different. Toon,
38
- Environment/Ground/Rock, Tree/Grass/Flower, Water on a host-authored
39
- footprint/shore/bed, Post, Gallery/MCP asset workflows, loaders, portable
40
- settings, Sky/Cloud, and qualified focused generators are the recommended
41
- path. Whole terrain/biome/coast/cliff construction,
42
- automatic set dressing, and cross-system world assembly are experimental.
43
- - ToonLab's labs, sample assets, local manifests, screenshots, captures, and
44
- app routes are examples. Do not treat them as part of the runtime API or copy
45
- their local asset assumptions into user apps.
46
- - The host app owns scene layout and major geometry, asset placement, cameras,
47
- collision, asset loading, decoder hosting, storage, routing, persistence,
48
- collaboration, and final art direction. Renderer construction stays
49
- host-owned, while the public renderer helper and scene style runtime apply
50
- reversible Call Me Sensei renderer, lighting, probe, and shadow settings.
51
- - VFX, camera, game-feel, and renderer selection are not style-bundle domains.
52
- Treat project-local implementations as custom adapters and record a gap when
53
- they affect the selected look. Lighting is a supported bundle domain.
54
-
55
- ## Usage Rules
56
-
57
- - Use the README and docs pages first; feature skills in `agents/skills/codex/`
58
- are short usage guides for public runtime APIs.
59
- - For existing-scene or multi-system integration, start with the `game-dev`
60
- skill (boundary, frame-loop contract, task→skill routing). When sourcing or generating
61
- assets, use the `asset-sourcing` skill. Feature-detect the connected ToonLab
62
- OSS local and/or ToonLab Pro remote MCP surface before calling tools; their
63
- overlapping tool names have different discovery roles and schemas.
64
- First-party rock search must shortlist from meter dimensions and taxonomy;
65
- do not load or render catalog GLBs merely to determine their size.
66
- - Whole-world and natural-cliff construction skills are not shipped in the npm
67
- package. Prefer bounded work on an existing terrain, asset family,
68
- vegetation field, or water body.
69
- - For any style-aware construction, use `style-presets` to record the intended
70
- selector and distinguish neutral defaults from domains that already default
71
- to Call Me Sensei. Before visual approval or reporting a package gap, use
72
- `visual-verification` for readiness, isolation, multi-view, measurement, and
73
- outlier checks. These routes apply to every agent integration, not only Codex
74
- or Claude.
75
- - ToonLab materials are TSL/NodeMaterial-first for Three.js WebGPU with WebGL2
76
- fallback through the same TSL path. Do not guide developers toward raw GLSL,
77
- `ShaderMaterial`, or classic WebGL-only forks for ToonLab features.
78
- - Keep developer examples focused on documented settings, preset documents,
79
- public constructors/helpers, and app-owned Three.js objects.
80
- - Keep artifact scope explicit: Shader Labs author IP profiles, Asset Labs
81
- author geometry/material data, and Water Lab authors a focused runtime
82
- system preset with embedded shader controls. Sky, Cloud, and Sky & Cloud are
83
- live focused authoring surfaces. Vegetation is one shared
84
- implementation family with separate Tree, Grass, and Flower shader profiles;
85
- their Generation Labs own geometry/material data. The public package ships
86
- tree construction and shader capability, not predefined tree assets. Search
87
- reviewed authored tree recipes through MCP; use `StylizedTree` or
88
- `BranchTree` to instantiate or deliberately author them. Repository species
89
- work is experimental and must not be presented as supported. Ground is a
90
- separate shader domain. Scene weather,
91
- lighting, camera, interactions, and complete Sky/Cloud composition stay
92
- host-owned or experimental.
93
- - For style-bundle, multi-shader, or arbitrary-asset work, read
94
- `agents/references/style-bundles.md` first. A bundle selects coordinated treatments;
95
- explicit asset labels select rendering destinations; scene state selects
96
- current conditions. Inventory and label every renderable root and material.
97
- Every newly modeled, generated, or imported material slot requires a stable
98
- ID and valid semantic role in the versioned material contract. A root domain
99
- label is not sufficient for a multi-material asset; missing roles and mixed
100
- atlases without a split or ID mask block strict handoff.
101
- Character anatomy, clothing, held weapons, and worn hero accessories
102
- normally route to toon; manufactured props, vegetation, rocks/debris,
103
- water/sky, and VFX retain their owning runtimes. For an imported manufactured
104
- prop, call `proposeManufacturedStyleTargetLabel()` first, review every issue,
105
- provide explicit `materialOverrides` for unresolved slots, then call
106
- `applyManufacturedStyleTargetLabelProposal()`. Never collapse assisted
107
- results into the automatic success rate.
108
- - Report unknown domains and material roles, mixed atlases without masks,
109
- unsupported transparency, and custom-renderer exemptions. Never silently
110
- infer a production-safe route from names, texture colors, or scene
111
- parenting. Preserve asset identity and runtime conditions when changing
112
- style.
113
- - Local style bundle creation, validation, serialization, parsing, and
114
- resolution are OSS `/styles` APIs and require no database. Hosted storage
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
- - Help developers stylize and populate supplied scenes with ToonLab runtime,
12
- Gallery, and MCP workflows. Do not promise one-shot world construction.
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
- - Use `agents/skills/` as reference material for feature-specific workflows.
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`, `debrisgen`, or `texgen`.
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, VFX,
101
- camera, and game-feel generation are host-owned or pre-beta in the public package and
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