@genex-ai/cli-demo 0.71.0-dev.186 → 0.71.0

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 (39) hide show
  1. package/dist/index.js +8 -354
  2. package/package.json +1 -2
  3. package/templates/controllers/character/vrm/vrm-loader.ts +11 -74
  4. package/templates/skills/genex-ai-hud/SKILL.md +2 -8
  5. package/templates/skills/genex-ai-menu/SKILL.md +2 -14
  6. package/templates/skills/genex-ai-skybox/SKILL.md +4 -15
  7. package/templates/skills/genex-ai-texture/SKILL.md +1 -1
  8. package/templates/skills/genex-ai-video/SKILL.md +1 -1
  9. package/templates/skills/genex-explore/SKILL.md +1 -1
  10. package/templates/skills/genex-getting-started/SKILL.md +2 -2
  11. package/templates/skills/genex-threejs-bloom/SKILL.md +1 -4
  12. package/templates/skills/genex-threejs-bloom/references/bloom.md +1 -1
  13. package/templates/skills/genex-threejs-camera-direction/SKILL.md +8 -48
  14. package/templates/skills/genex-threejs-camera-direction/references/camera-rigs.md +0 -62
  15. package/templates/skills/genex-threejs-embed-auth/SKILL.md +1 -4
  16. package/templates/skills/genex-threejs-game-feel/SKILL.md +1 -4
  17. package/templates/skills/genex-threejs-game-ui/SKILL.md +26 -90
  18. package/templates/skills/genex-threejs-game-ui/references/style-capsules.md +1 -2
  19. package/templates/skills/genex-threejs-image-pipeline/SKILL.md +0 -5
  20. package/templates/skills/genex-threejs-image-pipeline/references/image-pipeline.md +1 -1
  21. package/templates/skills/genex-threejs-lighting-design/SKILL.md +1 -5
  22. package/templates/skills/genex-threejs-multiplayer/SKILL.md +1 -7
  23. package/templates/skills/genex-threejs-multiplayer/references/host-physics.md +3 -6
  24. package/templates/skills/genex-threejs-physics-rapier/references/colliders-from-assets.md +0 -1
  25. package/templates/skills/genex-threejs-screen-space-ambient-occlusion/references/ambient-occlusion.md +1 -1
  26. package/templates/skills/genex-threejs-shadow-systems/SKILL.md +0 -6
  27. package/templates/skills/genex-threejs-shadow-systems/references/shadow-systems.md +1 -1
  28. package/templates/skills/genex-threejs-skill-router/SKILL.md +5 -26
  29. package/templates/skills/genex-threejs-skill-router/references/routing-map.md +9 -25
  30. package/templates/skills/genex-threejs-spectral-ocean/references/spectral-ocean.md +1 -1
  31. package/templates/skills/genex-threejs-touch-controls/SKILL.md +0 -11
  32. package/templates/skills/genex-threejs-visual-validation/SKILL.md +12 -29
  33. package/templates/skills/genex-threejs-water-optics/references/water-optics.md +1 -1
  34. package/templates/skills/genex-updates/SKILL.md +1 -1
  35. package/templates/controllers/quality/governor.ts +0 -147
  36. package/templates/controllers/quality/pick-asset.ts +0 -57
  37. package/templates/controllers/quality/tier.ts +0 -170
  38. package/templates/skills/genex-threejs-adaptive-quality/SKILL.md +0 -141
  39. package/templates/skills/genex-threejs-adaptive-quality/references/adaptive-quality.md +0 -105
@@ -1,141 +0,0 @@
1
- ---
2
- name: genex-threejs-adaptive-quality
3
- description: Make a Genex Three.js game phone-survivable with the vendored adaptive-quality kit — device-tier detection, tier-budgeted renderer settings, a runtime governor that steps quality down before phones run out of memory, per-tier asset rungs for generated skyboxes/textures, and a Quality picker in settings. Load for every game at boot wiring time, and whenever a game is heavy, crashes on phones, or gets flagged desktop-only.
4
- ---
5
-
6
- # Genex Three.js Adaptive Quality
7
-
8
- Phones enforce a hard GPU-memory ceiling desktops don't have: iOS silently
9
- kills the page when a game allocates too much, and the kill arrives at BOOT —
10
- exactly when a skybox, models, and the post stack all decode at once. This
11
- skill wires the vendored quality kit so the game boots conservatively on
12
- phones, steps quality UP when the device proves smooth, and never gets uglier
13
- on desktop. **You can recover from ugly; you cannot recover from a killed
14
- page.**
15
-
16
- This is a completion gate like the post stack: every game wires the tier at
17
- boot before it is called done. It costs three lines, not a testing burden —
18
- you still verify on desktop only.
19
-
20
- ## Install
21
-
22
- ```bash
23
- npx genex controller quality
24
- ```
25
-
26
- Installs `src/controllers/quality/{tier.ts, governor.ts, pick-asset.ts}` —
27
- game-owned code, edit freely.
28
-
29
- ## Wire the tier at boot (before renderer construction)
30
-
31
- ```ts
32
- import { detectTier } from "./controllers/quality/tier.ts";
33
- import { QualityGovernor } from "./controllers/quality/governor.ts";
34
-
35
- const tier = detectTier(); // phone-low | phone | desktop; manual Quality setting wins
36
- const renderer = new THREE.WebGLRenderer({ antialias: tier.antialias });
37
- renderer.setPixelRatio(Math.min(window.devicePixelRatio, tier.dprCap));
38
- ```
39
-
40
- The tier owns every budget decision: `dprCap` (1.5 on phones — the single
41
- biggest framebuffer lever), `antialias` (off on phones; it is fixed at context
42
- creation and can never change live), `shadowMapSize` (1024 phone / 2048
43
- desktop), `postLevel` (`'light'` = tone mapping + cheap passes on phones;
44
- `'full'` = the named stack on desktop), `particleScale`, `drawDistanceScale`,
45
- `frameCap`, and `remoteAvatarCap` for multiplayer. The exact ladder and which
46
- knobs may change at runtime vs load time vs never: [references/adaptive-quality.md](references/adaptive-quality.md).
47
-
48
- ## Wire the governor (runtime — phones throttle over minutes)
49
-
50
- ```ts
51
- const governor = new QualityGovernor(tier, {
52
- setDprScale: (m) => renderer.setPixelRatio(Math.min(window.devicePixelRatio, tier.dprCap * m)),
53
- setPostEnabled: (on) => (composerEnabled = on),
54
- setDrawDistanceScale: (m) => (scene.fog!.far = baseFogFar * tier.drawDistanceScale * m),
55
- }, renderer);
56
-
57
- // In the render loop, with the same performance.now() delta the loop already computes:
58
- governor.frame(deltaMs);
59
- ```
60
-
61
- Sustained slow frames step down (DPR ×0.8 → post off → draw distance →
62
- 30 fps cap); twenty smooth seconds step back up; a knob that failed twice
63
- stays down for the session. It keeps governing forever — thermal throttling
64
- arrives at minute eight, not second thirty. It also pauses judgment when the
65
- tab is hidden and publishes memory counts the platform's crash telemetry
66
- reads; pause your own loop and audio on `visibilitychange` too.
67
-
68
- ## Generated assets: load through the rungs
69
-
70
- Generated skyboxes are 8192×4096 — about 178 MB decoded, over half a phone's
71
- whole budget in one texture. Every generated image asset ships with downscale
72
- rungs; phones must load through them:
73
-
74
- ```ts
75
- import { detectTier } from "./controllers/quality/tier.ts";
76
- import { loadTextureWithFallback } from "./controllers/quality/pick-asset.ts";
77
-
78
- const texture = await loadTextureWithFallback(SKYBOX_URL, tier, (u) =>
79
- new THREE.TextureLoader().loadAsync(u),
80
- );
81
- ```
82
-
83
- Desktop loads the original, phones the `@2048` rung (~11 MB), and a missing
84
- rung falls back to the original — never a broken boot. The `$genex-ai-skybox`
85
- and `$genex-ai-texture` skills show the wiring in place.
86
-
87
- ## Quality picker in settings
88
-
89
- The pause/settings screen (see `$genex-threejs-game-ui`) always carries a
90
- Quality entry: **Auto / Low / Medium / High**, wired to
91
- `setQualitySetting(...)` from `tier.ts` + a reload or re-tier. Persisted
92
- per-device in localStorage on purpose — quality is a property of the phone,
93
- not the player's account. Default Auto.
94
-
95
- ## Budgets that ride the tier (not separate rules)
96
-
97
- - Shadows: `tier.shadowMapSize`, `shadow.autoUpdate = false` for static scenes,
98
- at most 2 cascades on phones (`$genex-threejs-shadow-systems`).
99
- - Post: phone floor is a BUILT tone-mapping/output pass (`postLevel: 'light'`
100
- adds FXAA/vignette); SSAO, volumetrics, and DoF are desktop-tier only
101
- (`$genex-threejs-skill-router` owns the floor wording).
102
- - Particles/scatter: multiply counts by `tier.particleScale`; render heavy
103
- transparency at half resolution and upsample.
104
- - Animation: distant mixers update at 1/2–1/4 rate; multiplayer remotes above
105
- `tier.remoteAvatarCap` billboard instead of animating
106
- (`$genex-threejs-multiplayer`).
107
- - Physics: phone tiers prefer hull/cuboid colliders for props — trimesh only
108
- where gameplay demands it (`$genex-threejs-physics-rapier`).
109
- - Shaders: default `mediump` (iOS exception: float-texture sampling needs
110
- `highp sampler2D`); precompile with `renderer.compileAsync(scene, camera)`
111
- during the loader screen so first-frame jank doesn't read as a stall; skip
112
- max anisotropy on phones.
113
- - Disposal: level swaps traverse the outgoing scene and dispose geometry,
114
- materials, AND textures (three never frees them for you); watch
115
- `renderer.info.memory` while testing — if textures/geometries climb across
116
- swaps, you leak toward the kill.
117
-
118
- ## WebGPU games
119
-
120
- The scaffold ships WebGL and stays the default; if this project already uses
121
- `WebGPURenderer`, keep it (never switch renderers mid-project). Context loss
122
- differs: WebGL fires `webglcontextlost` events; WebGPU exposes a
123
- `device.lost` promise — attach a handler that pauses the loop and rebuilds,
124
- mirroring the scaffold's WebGL pattern. All tier knobs apply identically
125
- except `antialias` (WebGPU MSAA is per-render-target and CAN change at
126
- runtime).
127
-
128
- ## Failure conditions
129
-
130
- - Renderer constructed before `detectTier()` → context-creation knobs
131
- (antialias) are locked wrong for the session. Tier first, renderer second.
132
- - Governor wired to context-creation flags → no-op at best. Runtime knobs
133
- only: DPR, post toggles, distances, frame cap.
134
- - Skybox loaded with a bare `TextureLoader.loadAsync(SKYBOX_URL)` on a game
135
- that targets phones → ~178 MB decoded; route it through
136
- `loadTextureWithFallback`.
137
- - Quality stepping on every spike → shader compiles read as slowness. The
138
- governor requires SUSTAINED slow windows; do not shorten them.
139
- - Testing quality tiers by resizing the desktop window → tiers key off touch +
140
- OS, not viewport. Trust desktop verification plus the preflight report
141
- `genex preview` prints.
@@ -1,105 +0,0 @@
1
- # Genex adaptive quality — tiers, knobs, and the governor in depth
2
-
3
- Use this reference when tuning the tier ladder, deciding which knob may change
4
- when, or teaching the governor a game-specific step.
5
-
6
- ## Why boot-conservative
7
-
8
- The phone budget is a hard ceiling that includes GPU memory (textures,
9
- framebuffers), and the OS kill arrives with no catchable event. Boot is the
10
- danger window: skybox + models + post targets decode together. So phone tiers
11
- START one notch below what the heuristics suggest and the governor steps UP
12
- after ~20 smooth seconds. The cost of guessing low is moments of softness; the
13
- cost of guessing high is a dead page.
14
-
15
- ## The tier ladder
16
-
17
- | Knob | phone-low | phone | desktop |
18
- |---|---|---|---|
19
- | DPR cap | 1.0 | 1.5 | 2 |
20
- | antialias (context) | off | off | on |
21
- | Shadow map | 512 (static-cached) | 1024 | 2048 |
22
- | Post level | tone map only | + FXAA/vignette | full named stack |
23
- | Skybox rung | @2048 (~11 MB) | @4096 (~45 MB) | original |
24
- | Texture rung (props) | @1024 | @2048 | original |
25
- | Particles/scatter | 0.25× | 0.5× | 1× |
26
- | Draw distance | 0.5× | 0.75× | 1× |
27
- | Frame target | stable 30 | 60 | 60 |
28
- | Remote avatars animated | 4 | 8 | all |
29
- | Prop colliders | hull/cuboid | hull | as designed |
30
-
31
- A DPR drop from 3 (raw iPhone) to 1.5 cuts every full-screen surface — color,
32
- depth, and each post target — to a quarter of the bytes. It is the single
33
- strongest lever the tier owns.
34
-
35
- ## The knob split — what may change when
36
-
37
- Getting this wrong produces silent no-ops or a session stuck ugly:
38
-
39
- - **Context-creation-fixed (never changes live):** `antialias`, `alpha`,
40
- `stencil`, `powerPreference` on WebGL. Changing them means a new context and
41
- a full re-init — the tier must decide them BEFORE the renderer exists.
42
- (WebGPU differs: MSAA is per-render-target sample count and is runtime-
43
- changeable.)
44
- - **Load-time (fixed for the session once fetched):** asset rungs (skybox and
45
- texture resolutions), model LOD sets. `pickAsset` decides them from the tier
46
- at load; switching later means a re-fetch — treat as fixed.
47
- - **Runtime-free (the governor's domain):** `setPixelRatio`, post passes on/off
48
- and their target resolutions, shadow map size (realloc), draw distance and
49
- fog, LOD bias, particle counts, mixer update rates, frame cap, remote-avatar
50
- animation count.
51
-
52
- ## Governor mechanics
53
-
54
- - Slow = frame delta over budget for a SUSTAINED window (4 s) — never single
55
- spikes, which are usually shader compiles or GC. Precompiling with
56
- `renderer.compileAsync` during the loader screen removes most spikes at the
57
- source (and keeps first-frame jank from reading as a stall to the platform's
58
- telemetry).
59
- - Step-down order: DPR ×0.8 → post off → draw distance ×0.6 → 30 fps cap.
60
- Each step is the cheapest remaining lever with the biggest headroom return.
61
- - Step-up needs 20 smooth seconds (hysteresis), and a step that had to be
62
- re-applied twice is pinned for the session — oscillating quality reads worse
63
- than stable-low.
64
- - The governor never stops: thermal throttling degrades phones after minutes
65
- of play, so a boot-time benchmark alone always ends up wrong.
66
- - A stable 30 fps cap beats a stuttery 40–50: consistent frame pacing reads
67
- smoother and halves GPU work per second (heat, battery, memory bandwidth).
68
- - Backgrounded tab (`visibilitychange`): pause the render loop and audio, not
69
- just the governor — a hidden game burning GPU is pure thermal debt on the
70
- device class that can least afford it.
71
-
72
- ## Detection honesty
73
-
74
- - Apple devices mask the GPU renderer string ("Apple GPU") — screen dims + DPR
75
- + iOS major version are the usable signals there, and the governor corrects
76
- the rest from measured frames.
77
- - Android exposes real renderer strings (Adreno/Mali/Xclipse); the vendored
78
- lookup in `tier.ts` promotes strong GPUs to the `phone` tier. It is a
79
- heuristic on purpose — extend the regex when field data shows a
80
- misclassified family, and let the governor absorb the rest.
81
- - Never burn a probe context on a memory-strapped phone at play time; the one
82
- probe in `tier.ts` runs at boot and frees its context immediately.
83
-
84
- ## Memory discipline that rides the tier
85
-
86
- - Dispose on every level swap: traverse the outgoing scene and call
87
- `.dispose()` on geometry, material, AND each material's textures — material
88
- dispose does not free textures, and three frees nothing automatically.
89
- - Watch `renderer.info.memory.{textures,geometries}` across swaps in dev; a
90
- monotonic climb is a leak marching toward the OS kill. The governor
91
- publishes these counts for the platform's field telemetry.
92
- - Prefer meshopt/instanced geometry for repeats; `BatchedMesh` batches
93
- HETEROGENEOUS static meshes into one draw where instancing (identical
94
- meshes only) can't.
95
- - Half-resolution transparency: render heavy particle/transparency passes to a
96
- half-size target and composite up — fill-rate is the phone bottleneck.
97
-
98
- ## Multiplayer at tier
99
-
100
- Remotes are visual-only; with the shared avatar file, `loadVrmClone` gives N
101
- remotes one set of GPU geometry/textures. Animate and fully draw only the
102
- nearest `tier.remoteAvatarCap`; beyond it, freeze the mixer and billboard or
103
- hide. Matchmade games can also declare a lower `maxPlayers` in
104
- `genex.matchmaking` for phone-heavy audiences — capacity is a server-owned
105
- knob.