@vib3code/sdk 2.0.1 → 2.0.3-canary.0a63e71

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 (192) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/DOCS/AGENT_HARNESS_ARCHITECTURE.md +245 -0
  3. package/DOCS/ANDROID_DEPLOYMENT.md +59 -0
  4. package/DOCS/ARCHITECTURE.md +1 -0
  5. package/DOCS/CI_TESTING.md +2 -0
  6. package/DOCS/CLI_ONBOARDING.md +3 -1
  7. package/DOCS/CONTROL_REFERENCE.md +2 -0
  8. package/DOCS/CROSS_SITE_DESIGN_PATTERNS.md +119 -0
  9. package/DOCS/ENV_SETUP.md +2 -0
  10. package/DOCS/EPIC_SCROLL_EVENTS.md +775 -0
  11. package/DOCS/EXPANSION_DESIGN.md +979 -0
  12. package/DOCS/EXPANSION_DESIGN_ULTRA.md +389 -0
  13. package/DOCS/EXPORT_FORMATS.md +2 -0
  14. package/DOCS/GPU_DISPOSAL_GUIDE.md +2 -0
  15. package/DOCS/HANDOFF_LANDING_PAGE.md +156 -0
  16. package/DOCS/HANDOFF_SDK_DEVELOPMENT.md +495 -0
  17. package/DOCS/LICENSING_TIERS.md +2 -0
  18. package/DOCS/MASTER_PLAN_2026-01-31.md +4 -2
  19. package/DOCS/MULTIVIZ_CHOREOGRAPHY_PATTERNS.md +939 -0
  20. package/DOCS/OBS_SETUP_GUIDE.md +2 -0
  21. package/DOCS/OPTIMIZATION_PLAN_MATH.md +119 -0
  22. package/DOCS/PRODUCT_STRATEGY.md +65 -0
  23. package/DOCS/PROJECT_SETUP.md +2 -0
  24. package/DOCS/README.md +105 -0
  25. package/DOCS/REFERENCE_SCROLL_ANALYSIS.md +99 -0
  26. package/DOCS/RENDERER_LIFECYCLE.md +2 -0
  27. package/DOCS/REPO_MANIFEST.md +2 -0
  28. package/DOCS/ROADMAP.md +113 -0
  29. package/DOCS/SCROLL_TIMELINE_v3.md +271 -0
  30. package/DOCS/SITE_REFACTOR_PLAN.md +102 -0
  31. package/DOCS/STATUS.md +26 -0
  32. package/DOCS/SYSTEM_INVENTORY.md +37 -32
  33. package/DOCS/TELEMETRY_EXPORTS.md +2 -0
  34. package/DOCS/VISUAL_ANALYSIS_CLICKERSS.md +87 -0
  35. package/DOCS/VISUAL_ANALYSIS_FACETAD.md +135 -0
  36. package/DOCS/VISUAL_ANALYSIS_SIMONE.md +97 -0
  37. package/DOCS/VISUAL_ANALYSIS_TABLESIDE.md +88 -0
  38. package/DOCS/WEBGPU_STATUS.md +121 -38
  39. package/DOCS/XR_BENCHMARKS.md +2 -0
  40. package/DOCS/archive/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md +1 -0
  41. package/DOCS/archive/DEV_TRACK_ANALYSIS.md +1 -0
  42. package/DOCS/archive/DEV_TRACK_PLAN_2026-01-07.md +1 -0
  43. package/DOCS/archive/SESSION_014_PLAN.md +1 -0
  44. package/DOCS/archive/SESSION_LOG_2026-01-07.md +1 -0
  45. package/DOCS/archive/STRATEGIC_BLUEPRINT_2026-01-07.md +1 -0
  46. package/DOCS/archive/SYSTEM_AUDIT_2026-01-30.md +1 -0
  47. package/DOCS/archive/WEBGPU_STATUS_2026-02-15_STALE.md +1 -0
  48. package/DOCS/{DEV_TRACK_SESSION_2026-01-31.md → dev-tracks/DEV_TRACK_SESSION_2026-01-31.md} +3 -1
  49. package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-06.md +233 -0
  50. package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-13.md +129 -0
  51. package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-15.md +144 -0
  52. package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-16.md +110 -0
  53. package/DOCS/dev-tracks/PERF_UPGRADE_2026-02-16.md +310 -0
  54. package/DOCS/dev-tracks/README.md +12 -0
  55. package/README.md +26 -13
  56. package/cpp/CMakeLists.txt +236 -0
  57. package/cpp/bindings/embind.cpp +269 -0
  58. package/cpp/build.sh +129 -0
  59. package/cpp/geometry/Crystal.cpp +103 -0
  60. package/cpp/geometry/Fractal.cpp +136 -0
  61. package/cpp/geometry/GeometryGenerator.cpp +262 -0
  62. package/cpp/geometry/KleinBottle.cpp +71 -0
  63. package/cpp/geometry/Sphere.cpp +134 -0
  64. package/cpp/geometry/Tesseract.cpp +94 -0
  65. package/cpp/geometry/Tetrahedron.cpp +83 -0
  66. package/cpp/geometry/Torus.cpp +65 -0
  67. package/cpp/geometry/WarpFunctions.cpp +238 -0
  68. package/cpp/geometry/Wave.cpp +85 -0
  69. package/cpp/include/vib3_ffi.h +238 -0
  70. package/cpp/math/Mat4x4.cpp +409 -0
  71. package/cpp/math/Mat4x4.hpp +209 -0
  72. package/cpp/math/Projection.cpp +142 -0
  73. package/cpp/math/Projection.hpp +148 -0
  74. package/cpp/math/Rotor4D.cpp +322 -0
  75. package/cpp/math/Rotor4D.hpp +204 -0
  76. package/cpp/math/Vec4.cpp +303 -0
  77. package/cpp/math/Vec4.hpp +225 -0
  78. package/cpp/src/vib3_ffi.cpp +607 -0
  79. package/cpp/tests/Geometry_test.cpp +213 -0
  80. package/cpp/tests/Mat4x4_test.cpp +494 -0
  81. package/cpp/tests/Projection_test.cpp +298 -0
  82. package/cpp/tests/Rotor4D_test.cpp +423 -0
  83. package/cpp/tests/Vec4_test.cpp +489 -0
  84. package/docs/webgpu-live.html +1 -1
  85. package/package.json +41 -30
  86. package/src/agent/index.js +1 -3
  87. package/src/agent/mcp/MCPServer.js +1220 -144
  88. package/src/agent/mcp/index.js +1 -1
  89. package/src/agent/mcp/stdio-server.js +264 -0
  90. package/src/agent/mcp/tools.js +498 -31
  91. package/src/cli/index.js +431 -47
  92. package/src/core/CanvasManager.js +97 -204
  93. package/src/core/ErrorReporter.js +1 -1
  94. package/src/core/Parameters.js +1 -1
  95. package/src/core/VIB3Engine.js +93 -4
  96. package/src/core/VitalitySystem.js +53 -0
  97. package/src/core/index.js +18 -0
  98. package/src/core/renderers/FacetedRendererAdapter.js +10 -9
  99. package/src/core/renderers/HolographicRendererAdapter.js +13 -9
  100. package/src/core/renderers/QuantumRendererAdapter.js +11 -7
  101. package/src/creative/AestheticMapper.js +628 -0
  102. package/src/creative/ChoreographyPlayer.js +481 -0
  103. package/src/creative/index.js +11 -0
  104. package/src/experimental/GameLoop.js +72 -0
  105. package/src/experimental/LatticePhysics.js +100 -0
  106. package/src/experimental/LiveDirector.js +143 -0
  107. package/src/experimental/PlayerController4D.js +154 -0
  108. package/src/experimental/VIB3Actor.js +138 -0
  109. package/src/experimental/VIB3Compositor.js +117 -0
  110. package/src/experimental/VIB3Link.js +122 -0
  111. package/src/experimental/VIB3Orchestrator.js +146 -0
  112. package/src/experimental/VIB3Universe.js +109 -0
  113. package/src/experimental/demos/CrystalLabyrinth.js +202 -0
  114. package/src/export/TradingCardManager.js +3 -4
  115. package/src/export/index.js +11 -1
  116. package/src/faceted/FacetedSystem.js +260 -394
  117. package/src/games/glyph-war/GlyphWarVisualizer.js +641 -0
  118. package/src/geometry/generators/Crystal.js +2 -2
  119. package/src/geometry/warp/HypersphereCore.js +53 -24
  120. package/src/holograms/HolographicVisualizer.js +84 -98
  121. package/src/holograms/RealHolographicSystem.js +194 -43
  122. package/src/math/Mat4x4.js +308 -105
  123. package/src/math/Rotor4D.js +124 -40
  124. package/src/math/Vec4.js +200 -103
  125. package/src/math/index.js +7 -7
  126. package/src/polychora/PolychoraSystem.js +77 -0
  127. package/src/quantum/QuantumEngine.js +103 -66
  128. package/src/quantum/QuantumVisualizer.js +31 -22
  129. package/src/reactivity/index.js +3 -5
  130. package/src/render/LayerPresetManager.js +372 -0
  131. package/src/render/LayerReactivityBridge.js +344 -0
  132. package/src/render/LayerRelationshipGraph.js +610 -0
  133. package/src/render/MultiCanvasBridge.js +148 -25
  134. package/src/render/ShaderLoader.js +38 -0
  135. package/src/render/ShaderProgram.js +4 -4
  136. package/src/render/UnifiedRenderBridge.js +4 -1
  137. package/src/render/backends/WebGPUBackend.js +8 -4
  138. package/src/render/index.js +27 -2
  139. package/src/scene/Node4D.js +74 -24
  140. package/src/scene/index.js +4 -4
  141. package/src/shaders/common/geometry24.glsl +65 -0
  142. package/src/shaders/common/geometry24.wgsl +54 -0
  143. package/src/shaders/common/rotation4d.glsl +4 -4
  144. package/src/shaders/common/rotation4d.wgsl +2 -2
  145. package/src/shaders/common/uniforms.wgsl +15 -8
  146. package/src/shaders/faceted/faceted.frag.glsl +220 -80
  147. package/src/shaders/faceted/faceted.frag.wgsl +144 -90
  148. package/src/shaders/holographic/holographic.frag.glsl +28 -9
  149. package/src/shaders/holographic/holographic.frag.wgsl +112 -41
  150. package/src/shaders/quantum/quantum.frag.glsl +1 -0
  151. package/src/shaders/quantum/quantum.frag.wgsl +6 -4
  152. package/src/testing/ParallelTestFramework.js +2 -2
  153. package/src/ui/adaptive/renderers/webgpu/WebGPURenderer.ts +2 -2
  154. package/src/viewer/GalleryUI.js +17 -0
  155. package/src/viewer/ViewerPortal.js +2 -2
  156. package/src/viewer/index.js +1 -1
  157. package/tools/headless-renderer.js +258 -0
  158. package/tools/shader-sync-verify.js +14 -8
  159. package/tools/site-analysis/all-reports.json +32 -0
  160. package/tools/site-analysis/combined-analysis.md +50 -0
  161. package/tools/site-analyzer.mjs +779 -0
  162. package/tools/visual-catalog/capture.js +276 -0
  163. package/tools/visual-catalog/composite.js +138 -0
  164. package/types/adaptive-sdk.d.ts +204 -5
  165. package/types/agent/cli.d.ts +78 -0
  166. package/types/agent/index.d.ts +18 -0
  167. package/types/agent/mcp.d.ts +87 -0
  168. package/types/agent/telemetry.d.ts +190 -0
  169. package/types/core/VIB3Engine.d.ts +26 -0
  170. package/types/core/index.d.ts +261 -0
  171. package/types/creative/AestheticMapper.d.ts +72 -0
  172. package/types/creative/ChoreographyPlayer.d.ts +96 -0
  173. package/types/creative/index.d.ts +17 -0
  174. package/types/export/index.d.ts +243 -0
  175. package/types/geometry/index.d.ts +164 -0
  176. package/types/math/index.d.ts +214 -0
  177. package/types/render/LayerPresetManager.d.ts +78 -0
  178. package/types/render/LayerReactivityBridge.d.ts +85 -0
  179. package/types/render/LayerRelationshipGraph.d.ts +174 -0
  180. package/types/render/index.d.ts +3 -0
  181. package/types/scene/index.d.ts +204 -0
  182. package/types/systems/index.d.ts +244 -0
  183. package/types/variations/index.d.ts +62 -0
  184. package/types/viewer/index.d.ts +225 -0
  185. package/DOCS/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md +0 -34
  186. package/DOCS/DEV_TRACK_ANALYSIS.md +0 -77
  187. package/DOCS/DEV_TRACK_PLAN_2026-01-07.md +0 -42
  188. package/DOCS/SESSION_014_PLAN.md +0 -195
  189. package/DOCS/SESSION_LOG_2026-01-07.md +0 -56
  190. package/DOCS/STRATEGIC_BLUEPRINT_2026-01-07.md +0 -72
  191. package/DOCS/SYSTEM_AUDIT_2026-01-30.md +0 -738
  192. /package/src/viewer/{ReactivityManager.js → ViewerInputHandler.js} +0 -0
@@ -0,0 +1,389 @@
1
+ Last reviewed: 2026-02-17
2
+
3
+ # VIB3+ Ultra — The Emergent Media Engine
4
+
5
+ **Purpose**: This document defines the **Ultra Tier** expansion for VIB3+. While the Premium Tier (`EXPANSION_DESIGN.md`) focuses on professional visualization tools, the Ultra Tier transforms the SDK into a **full-stack emergent media engine** capable of powering 4D video games, generative cartoons, and multi-user hallucinations.
6
+
7
+ **Status**: Vision Document / Technical Specification.
8
+ **Dependencies**: Requires `@vib3code/sdk` (core) and `@vib3code/premium` (for fine-grained control).
9
+
10
+ ---
11
+
12
+ ## I. Architecture: The VIB3 Universe
13
+
14
+ The core shift is from **Single Instance** to **Orchestrated Universe**.
15
+
16
+ ### The Concept
17
+ Instead of "a canvas on a page," we treat the browser window as a **Universe** containing multiple **Entities** (VIB3 instances). These entities share a clock, a physics lattice, and a narrative context.
18
+
19
+ ### The `VIB3Orchestrator`
20
+ A new singleton that manages the lifecycle and coordination of all VIB3 instances.
21
+
22
+ ```javascript
23
+ class VIB3Orchestrator {
24
+ constructor() {
25
+ this.entities = new Map(); // id -> VIB3Entity
26
+ this.clock = new MasterClock({ bpm: 120 }); // Shared beat sync
27
+ this.physics = new LatticePhysicsEngine(); // 4D collision detection
28
+ this.link = new VIB3Link(); // WebRTC multi-user sync
29
+ }
30
+
31
+ // Spawn a new entity (actor, prop, or environment)
32
+ spawn(type, config) { ... }
33
+
34
+ // Global tick loop
35
+ tick(deltaTime) {
36
+ this.physics.update(this.entities, deltaTime);
37
+ this.entities.forEach(e => e.update(deltaTime));
38
+ this.link.sync(this.entities);
39
+ }
40
+ }
41
+ ```
42
+
43
+ ---
44
+
45
+ ## II. HyperNarrative: Animating Stories & Cartoons
46
+
47
+ VIB3+ can tell stories. Characters are not mesh rigs but **VIB3 Actors** — distinct visualization instances with "souls" (parameter personalities) that express emotion through math.
48
+
49
+ ### 1. The `VIB3Actor`
50
+ Wraps a `VIB3Engine` instance with identity, role, and emotional state.
51
+
52
+ ```javascript
53
+ class VIB3Actor {
54
+ constructor(engine, personalityProfile) {
55
+ this.engine = engine;
56
+ this.profile = personalityProfile; // e.g., 'AnxiousGlitch', 'StoicCrystal'
57
+ this.emotion = { valence: 0, arousal: 0 }; // -1 to 1
58
+ this.voice = new AudioEmitter(); // Spatial audio source
59
+ }
60
+
61
+ // Express an emotion (modulates parameters based on profile)
62
+ emote(emotionName, intensity) {
63
+ const params = this.profile.mapEmotion(emotionName, intensity);
64
+ this.engine.transition(params, 500, 'easeOut');
65
+ }
66
+
67
+ // "Speak" with audio-reactive mouth modulation
68
+ speak(audioBuffer) {
69
+ this.voice.play(audioBuffer);
70
+ this.voice.onAnalysis((amplitude) => {
71
+ // Modulate geometry to simulate speech/expression
72
+ this.engine.setParameter('morphFactor', 0.5 + amplitude * 1.5);
73
+ this.engine.setParameter('intensity', 0.6 + amplitude * 0.4);
74
+ });
75
+ }
76
+ }
77
+ ```
78
+
79
+ ### 2. The Script Format (`.vib3script`)
80
+ A JSON-based screenplay format that controls actors, cameras, and environment.
81
+
82
+ ```json
83
+ {
84
+ "title": "The Geometric Encounter",
85
+ "bpm": 110,
86
+ "cast": {
87
+ "Hero": { "system": "faceted", "geometry": 0, "profile": "heroic" },
88
+ "Villain": { "system": "quantum", "geometry": 16, "profile": "chaotic" }
89
+ },
90
+ "sequence": [
91
+ {
92
+ "time": "0:00",
93
+ "action": "camera_cut",
94
+ "target": "Hero",
95
+ "shot": "close_up" // Adjusts zoom/projection
96
+ },
97
+ {
98
+ "time": "0:02",
99
+ "actor": "Hero",
100
+ "action": "speak",
101
+ "text": "Why do you disturb the lattice?",
102
+ "audio": "hero_line_1.mp3",
103
+ "emotion": "stern"
104
+ },
105
+ {
106
+ "time": "0:05",
107
+ "actor": "Villain",
108
+ "action": "emote",
109
+ "emotion": "rage",
110
+ "intensity": 0.8 // Triggers red hue, high chaos, spike geometry
111
+ }
112
+ ]
113
+ }
114
+ ```
115
+
116
+ ### 3. LipSync & Performance
117
+ Use `WebAudioAPI` analysis on dialogue tracks to drive `morphFactor` (mouth opening) and `intensity` (energy).
118
+ - **Consonants (High Freq)**: Trigger `chaos` spikes (sharp edges).
119
+ - **Vowels (Mid Freq)**: Trigger `morphFactor` swells (round shapes).
120
+ - **Volume**: Drives `gridDensity` (louder = larger/closer).
121
+
122
+ ---
123
+
124
+ ## III. HyperGame: FPV Gameplay Engine
125
+
126
+ Transform VIB3+ from a passive visualizer into an active **4D Game Engine**.
127
+
128
+ ### 1. 4D Player Controller (`FPVController`)
129
+ Maps WASD + Mouse to 6D motion, allowing navigation *through* the hyperspace lattice.
130
+
131
+ - **W/S**: Move forward/back in Z (depth).
132
+ - **A/D**: Strafe in X.
133
+ - **Space/Shift**: Move in Y (up/down).
134
+ - **Q/E**: Rotate in XW plane (portal strafe).
135
+ - **Mouse**: Rotate XY (look left/right) and YZ (look up/down).
136
+
137
+ ```javascript
138
+ // Inside game loop
139
+ if (input.forward) {
140
+ // Move "camera" through 4D noise space
141
+ // We don't move geometry; we offset the noise coordinate system!
142
+ uniforms.u_noiseOffset.z += speed * dt;
143
+ }
144
+ if (input.portalLeft) {
145
+ // Rotate the entire world in 4D
146
+ uniforms.u_rot4dXW += rotationSpeed * dt;
147
+ }
148
+ ```
149
+
150
+ ### 2. Lattice Physics (`LatticeCollider`)
151
+ Collision detection is not mesh-based (too expensive/abstract). It is **Function-Based**.
152
+ Since VIB3+ geometries are defined by math functions (SDFs or lattice grids), we check the player's coordinate against the active function.
153
+
154
+ ```javascript
155
+ function checkCollision(playerPos, activeGeometry) {
156
+ // Sample the density function at player position
157
+ const density = getDensityAt(playerPos, activeGeometry);
158
+ if (density > 0.8) {
159
+ // Hit a "solid" part of the fractal/lattice
160
+ return true;
161
+ }
162
+ return false;
163
+ }
164
+ ```
165
+
166
+ ### 3. Entity System
167
+ Game objects are lightweight VIB3 instances or simplified shader particles.
168
+ - **Projectiles**: Small `Quantum` instances (single particle geometry) moving in XYZW.
169
+ - **Pickups**: `Faceted` geometries (spinning crystals) that trigger events on collision.
170
+ - **Enemies**: `Holographic` instances that track player position.
171
+
172
+ ### 4. Game State Manager
173
+ Tracks score, health, and inventory.
174
+ - **Health**: Low health = high `chromaticAberration` + desaturation + `glitch` effect.
175
+ - **Powerup**: Ingesting a "hypercube" powerup transitions the player's view to `HyperMode` (geometry 17, max color).
176
+
177
+ ---
178
+
179
+ ## IV. Emergent Media: AI & Multi-User Sync
180
+
181
+ The final frontier: VIB3+ experiences that are alive, shared, and intelligent.
182
+
183
+ ### 1. VIB3Link (Multi-User Hallucination)
184
+ Uses WebRTC/WebSockets to synchronize the `VIB3Orchestrator` state across clients.
185
+ - **Shared Seed**: All clients start with same RNG seed.
186
+ - **Input Sync**: Player A's rotation is broadcast to Player B.
187
+ - **State Consensus**: "If Player A explodes the star, Player B sees it explode."
188
+
189
+ **Use Case**: A shared "VR" room (on flat screens) where users float in a 4D chatroom, represented by their `VIB3Actor` avatars.
190
+
191
+ ### 2. The Live Director (AI Agent)
192
+ An autonomous agent (MCP-connected) that watches the "audience" (user input, webcam, mic) and adjusts the show.
193
+
194
+ - **Sentiment Analysis**: If audience audio is loud/happy -> increase `speed` and `saturation`.
195
+ - **Attention Tracking**: If user stops interacting -> trigger `FocusLock` or `Explosion` to regain attention.
196
+ - **Generative Scripting**: The AI writes the `.vib3script` in real-time based on a prompt ("Make it scary", "Make it romantic").
197
+
198
+ ---
199
+
200
+ ## V. New MCP Tools for Ultra Tier
201
+
202
+ To empower agents to build these experiences, we add the following tools:
203
+
204
+ ### `spawn_actor`
205
+ Creates a `VIB3Actor` with a specific personality and role.
206
+ ```json
207
+ { "role": "protagonist", "personality": "glitch_witch", "system": "holographic" }
208
+ ```
209
+
210
+ ### `direct_scene`
211
+ Issues a high-level direction to the `LiveDirector`.
212
+ ```json
213
+ { "mood": "increasing_tension", "pacing": "frenetic", "focus_target": "villain" }
214
+ ```
215
+
216
+ ### `configure_game_rules`
217
+ Sets up the `HyperGame` mechanics.
218
+ ```json
219
+ { "physics": "lattice_heavy", "collision_damage": 10, "goal": "collect_shards" }
220
+ ```
221
+
222
+ ### `sync_session`
223
+ Initializes `VIB3Link` for a multi-user session.
224
+ ```json
225
+ { "room_id": "lobby_1", "max_users": 4, "sync_mode": "strict" }
226
+ ```
227
+
228
+ ---
229
+
230
+ ## VI. Deep Multilayer Architecture
231
+
232
+ To support `VIB3Universe`, we need a robust system for managing interactions between multiple VIB3 instances. This is not just visual layering; it's logic layering.
233
+
234
+ ### 1. Visual Compositing (`VIB3Compositor`)
235
+ Managing 10+ layers (e.g., 2 instances × 5 holographic layers) requires a dedicated compositor to avoid DOM explosion and Z-fighting.
236
+
237
+ * **Render Targets**: Instead of rendering directly to the DOM, each VIB3 instance renders to an offscreen canvas.
238
+ * **Unified Stage**: The Compositor draws these offscreen buffers onto a single `GlobalCanvas` using WebGL blending.
239
+ * **Depth Sorting**: Instances are sorted by their "World Z" coordinate.
240
+ * **Masking**: Instances can mask each other (e.g., a character standing behind a portal).
241
+
242
+ ```javascript
243
+ class VIB3Compositor {
244
+ registerInstance(instanceId, textureSource) { ... }
245
+ setLayerOrder(instanceIds) { ... }
246
+ render() {
247
+ // Draw background instances
248
+ // Draw foreground instances with blending
249
+ // Apply global post-processing (unifying the look)
250
+ }
251
+ }
252
+ ```
253
+
254
+ ### 2. Logic Layering (`LoopCoordinator`)
255
+ We have three distinct loops running at different frequencies:
256
+ 1. **Physics Loop (Fixed Step, 60hz)**: Collision detection, movement integration. Deterministic for multiplayer sync.
257
+ 2. **Narrative Loop (Event Driven)**: Script execution, state machine transitions.
258
+ 3. **Reactive Loop (Frame Rate)**: Audio analysis, visual parameter smoothing.
259
+
260
+ The `VIB3Orchestrator` must prioritize these:
261
+ * Physics updates *must* happen before Visual updates.
262
+ * Narrative events trigger Physics state changes.
263
+
264
+ ### 3. State Hydration (`UniverseSerializer`)
265
+ Saving a multi-instance universe is complex. We need a schema that captures the relationships, not just individual parameters.
266
+
267
+ ```json
268
+ {
269
+ "universe_id": "u_8823",
270
+ "timestamp": 12044,
271
+ "entities": [
272
+ { "id": "hero", "type": "actor", "pos": [0,0,0], "params": {...} },
273
+ { "id": "world", "type": "environment", "params": {...} }
274
+ ],
275
+ "global_state": {
276
+ "gravity": 9.8,
277
+ "tension": 0.4
278
+ }
279
+ }
280
+ ```
281
+
282
+ This allows "save games" for HyperGame and "bookmarks" for HyperNarrative.
283
+
284
+ ---
285
+
286
+ ## VII. VIB3Link Protocol
287
+
288
+ VIB3Link uses WebRTC DataChannels for low-latency state synchronization between clients in a `VIB3Universe`.
289
+
290
+ ### Protocol Message Format
291
+
292
+ Messages are JSON-encoded packets:
293
+ ```json
294
+ {
295
+ "t": "type", // 'update', 'event', 'sync'
296
+ "s": 1023, // sequence number (for ordering)
297
+ "p": { ... } // payload
298
+ }
299
+ ```
300
+
301
+ ### Core Message Types
302
+
303
+ 1. **Entity Update (`upd`)**: High-frequency (20Hz) updates of position/rotation.
304
+ ```json
305
+ { "t": "upd", "id": "actor_1", "pos": [x,y,z], "rot": [x,y,z,w] }
306
+ ```
307
+ 2. **Parameter Delta (`prm`)**: When a visual parameter changes.
308
+ ```json
309
+ { "t": "prm", "id": "actor_1", "k": "chaos", "v": 0.8 }
310
+ ```
311
+ 3. **Universe Event (`evt`)**: Narrative triggers or game events.
312
+ ```json
313
+ { "t": "evt", "n": "explosion", "loc": [10, 0, 5], "pow": 0.9 }
314
+ ```
315
+
316
+ ### Synchronization Strategy
317
+
318
+ * **Authority**: One client is the **Host** (orchestrator). Others are **Peers**.
319
+ * **Prediction**: Peers predict entity movement based on velocity.
320
+ * **Reconciliation**: If Peer state diverges > threshold from Host state, snap to Host.
321
+ * **Interpolation**: Visuals render at `t - buffer` to ensure smooth interpolation between network packets.
322
+
323
+ ---
324
+
325
+ ## VIII. HyperGame Engine
326
+
327
+ The VIB3+ Ultra HyperGame Engine enables 4D First-Person View (FPV) experiences. It decouples the physics simulation from the render loop and provides a 4D-native player controller.
328
+
329
+ ### 1. The Game Loop (`GameLoop`)
330
+ A fixed-timestep loop for physics and logic, separate from the variable-timestep render loop. This ensures deterministic physics and smooth rendering even under load.
331
+
332
+ ```javascript
333
+ class GameLoop {
334
+ constructor(updateFn, renderFn) {
335
+ this.accumulator = 0;
336
+ this.step = 1 / 60; // 60hz physics
337
+ }
338
+ // ... accumulates time and calls update() multiple times if needed
339
+ }
340
+ ```
341
+
342
+ ### 2. Lattice Physics (`LatticePhysics`)
343
+ Physics in VIB3+ is not about mesh-mesh intersection. It is about **Point-Field intersection**. We define the world as a scalar field (density) and check if the player's 4D point is inside a high-density region.
344
+
345
+ * **Collision**: `getDensity(pos) > threshold`
346
+ * **Gravity**: Constant force in -Y (or arbitrary 4D vector)
347
+ * **Friction**: Velocity decay
348
+
349
+ ### 3. Player Controller 4D (`PlayerController4D`)
350
+ Handles input mapping for 6-degree-of-freedom movement.
351
+
352
+ * **Input**: WASD (Translation), Mouse (Rotation), QE (Portal/4D Rotation).
353
+ * **State**: Position (Vec4), Rotation (Rotor4D/Quat).
354
+ * **Smoothing**: Inputs are smoothed to prevent motion sickness in 4D space.
355
+
356
+ ```javascript
357
+ update(dt) {
358
+ // Apply inputs to velocity
359
+ // Apply physics (gravity, friction)
360
+ // Integrate position: pos += vel * dt
361
+ // Resolve collisions: if (collision) pos -= normal * penetration
362
+ }
363
+ ```
364
+
365
+ ---
366
+
367
+ ## IX. Demo: The Crystal Labyrinth
368
+
369
+ A vertical slice demo showcasing all Ultra capabilities in one cohesive experience.
370
+
371
+ ### Story & Premise
372
+ The player is a **Lattice Runner** navigating a fractured 4D hyperspace maze. The goal is to collect **Resonance Crystals** (Facet engines) while avoiding **Void Shadows** (Holographic engines) that hunt based on noise (movement speed).
373
+
374
+ ### Gameplay Loop
375
+ 1. **Explore**: Navigate the 4D maze using WASD+Mouse+QE.
376
+ 2. **Collect**: Find blue crystals. Touching one triggers a `VIB3Actor` "Collection" animation (implosion + sound).
377
+ 3. **Evade**: Red "Shadows" drift towards you. If they touch you, the screen glitches (`chromaticAberration` spike) and health drops.
378
+ 4. **Win**: Collect 5 crystals to stabilize the universe (trigger "Victory" state).
379
+
380
+ ### Technical Integration
381
+ * **Universe**: One `VIB3Universe` managing the Player, 5 Crystal Actors, and 3 Shadow Actors.
382
+ * **Physics**: `LatticePhysics` handles wall collisions (fractal noise walls).
383
+ * **AI**: `LiveDirector` adjusts Shadow aggression based on player movement speed (stealth mechanic).
384
+ * **Networking**: (Optional) `VIB3Link` allows a spectator to watch the runner.
385
+
386
+ ---
387
+
388
+ *VIB3+ Ultra — The Future of Emergent Media*
389
+ *Draft v5.0 — Added Crystal Labyrinth Demo Design — Feb 16, 2026*
@@ -1,3 +1,5 @@
1
+ Last reviewed: 2026-02-17
2
+
1
3
  # Export formats
2
4
 
3
5
  This reference documents the target export formats supported by the agentic pipelines and how they are validated.
@@ -1,3 +1,5 @@
1
+ Last reviewed: 2026-02-17
2
+
1
3
  # GPU disposal patterns
2
4
 
3
5
  This guide documents safe GPU resource disposal patterns to prevent memory leaks across rendering backends.
@@ -0,0 +1,156 @@
1
+ Last reviewed: 2026-02-17
2
+
3
+ # VIB3+ Landing Page & Marketing Handoff Prompt
4
+
5
+ **Copy this entire document as the initial prompt when starting a new session focused on the landing page, marketing site, and forward-facing aspects.**
6
+
7
+ ---
8
+
9
+ ## Context
10
+
11
+ You are continuing development on the **VIB3+ landing page** — the marketing/showcase site for the `@vib3code/sdk` npm package (a 4D visualization SDK). The landing page demonstrates the SDK's three rendering systems (Quantum, Faceted, Holographic) through an immersive scroll-driven experience with GSAP choreography.
12
+
13
+ **Repository:** `Domusgpt/vib34d-xr-quaternion-sdk`
14
+ **Landing page location:** `site/` directory (separated from SDK code as of 2026-02-13)
15
+ **Live URL:** GitHub Pages deploy from `docs/` + root
16
+ **Owner:** Clear Seas Solutions LLC / Paul Phillips
17
+
18
+ ## Architecture
19
+
20
+ ```
21
+ site/
22
+ ├── index.html # Landing page (1977 lines, 9 scroll sections)
23
+ ├── styles/
24
+ │ ├── overlay-accents.css # CSS-only accent overlays (gradient washes, mirrors, particles)
25
+ │ └── reveal-layers.css # Multi-layer parallax reveal system (NEW)
26
+ └── js/
27
+ ├── main.js # Boot script — GPU context pool + section initialization
28
+ ├── config.js # Section parameter presets (hero, morph stages, etc.)
29
+ ├── adapters.js # SDK system adapters (Quantum/Holographic/Faceted + AmbientLattice)
30
+ ├── ContextPool.js # WebGL context budget manager (max 3 concurrent)
31
+ ├── CardTiltSystem.js # Mouse/touch → CSS 3D tilt + visualizer param mapping
32
+ ├── choreography.js # Main GSAP ScrollTrigger choreography (83KB, all sections)
33
+ ├── overlay-choreography.js # CSS accent overlays (gradient wash, mirror, glow, particles)
34
+ └── reveal-choreography.js # Multi-layer parallax reveal transitions (NEW)
35
+
36
+ Root SDK demo (separate):
37
+ ├── index.html # Clean SDK demo with toolbar (NOT the landing page)
38
+ ```
39
+
40
+ **CDN Dependencies:** Lenis smooth scroll, GSAP 3.12.5, ScrollTrigger 3.12.5 (loaded dynamically with 5s timeout fallback)
41
+
42
+ **SDK Imports:** `site/js/adapters.js` imports directly from `../src/` (Quantum, Holographic, Faceted engines). This is intentional since the site lives in the monorepo.
43
+
44
+ ## Current Page Sections (9 total, ~3050vh scroll)
45
+
46
+ | Section | Height | GPU Contexts | Systems | Key Feature |
47
+ |---------|--------|--------------|---------|-------------|
48
+ | Opening Cinematic | 800vh | 1 | Quantum | SVG text mask ("VIB3CODE") + lattice parallax |
49
+ | Hero | 100vh | 1 | Quantum | Title reveal + badge |
50
+ | Morph Experience | 1200vh | 1 (swaps) | Q→H→F | 6-stage card morphing with system swaps |
51
+ | Playground | static | 1 | User choice | Full parameter control (all 6D rotation planes) |
52
+ | Triptych | 200vh | 3 | Q+H+F | 3-system split-screen simultaneous render |
53
+ | Geometry Cascade | 400vh | 2+C2D | Q+H bg | Horizontal scroll cards with geometry showcase |
54
+ | Energy Transfer | 250vh | 2 | Q bg + F card | Interactive sweep demo |
55
+ | Agent Integration | static | 1 | Holographic | Download packs (MCP, Claude, OpenAI) |
56
+ | CTA | 100vh | 2 | Q+F diagonal | Installation code + links |
57
+
58
+ **Total GPU budget:** Max 3 concurrent WebGL contexts. ContextPool auto-evicts oldest.
59
+
60
+ ## What's Working
61
+
62
+ ### Choreography Engine (choreography.js — 83KB)
63
+ - **Depth Illusion Engine** — gridDensity = distance metaphor + CSS scale/blur/shadow
64
+ - **6 Coordination Modes** — opposition, convergence, call-response, heartbeat, energy-conservation, crossfade
65
+ - **Mathematical parameter curves** — Lissajous rotation, sine interference, exponential ramps
66
+ - **Section-specific timelines** — Each section has a pinned ScrollTrigger with multi-phase choreography
67
+ - **System swaps** — Morph section smoothly transitions Q→H→F with flash effects
68
+
69
+ ### Overlay System (overlay-choreography.js — 35KB)
70
+ - 5 accent systems: GradientWash, MirrorReflection, EdgeGlowRing, ParticleField, CrossfadeBridge
71
+ - Quaternion-to-CSS bridge (feeds 4D rotation to CSS custom properties)
72
+ - AccentChoreographer master controller
73
+
74
+ ### NEW: Reveal Layer System (reveal-choreography.js + reveal-layers.css)
75
+ - **Replaces ugly SVG section dividers** with dynamic transitions
76
+ - **8 transition patterns:** Iris aperture, diagonal bars, column split, glass panel retraction, bezel bar criss-cross, checkerboard dissolve
77
+ - **Persistent parallax field** — Subtle geometric depth texture at 0.3x scroll speed
78
+ - **Floating glassmorphic accent strips** — 3 colored lines at different parallax rates
79
+ - **Glow lines** — Luminous accent lines at section boundaries (replace SVG curves)
80
+ - **Section edge blending** — CSS gradient fades at section top/bottom (replace hard seams)
81
+
82
+ ## Known Issues & Priorities
83
+
84
+ ### HIGH PRIORITY — Visual Quality
85
+ 1. **Rectangular layout problem** — Despite excellent choreography math, everything is constrained to rectangular cards. Need organic shapes (SVG blob paths, fluid bezier boundaries, non-rectilinear clip-paths).
86
+ 2. **Predictable symmetry** — Triptych is perfect 33/33/33, CTA is 50/50 diagonal, energy is centered. Need asymmetry and visual tension.
87
+ 3. **Universal accent treatment** — Every card gets the same vignette+shadow+glow+chroma. Differentiate: some sections should get unique treatments while others stay minimal.
88
+ 4. **Mobile experience** — 3050vh total scroll on mobile is excessive. Canvas count should drop to 1 concurrent. Cascade horizontal scroll breaks at small viewports (6 cards at 88vw).
89
+
90
+ ### MEDIUM PRIORITY — Functionality
91
+ 5. **AmbientLattice anti-pattern** — 580-line Canvas2D renderer in adapters.js duplicates SDK geometry. Should use SDK's FacetedSystem with reduced GPU overhead instead.
92
+ 6. **No audio demo** — Audio reactivity is a key SDK feature but not demonstrated anywhere on the landing page. Add a toggle or auto-detect section.
93
+ 7. **No SpatialInput demo** — Device tilt/gyroscope is a selling point but not shown. Consider a "tilt your phone" section.
94
+ 8. **Agent section download links** — Point to `agent-config/` which may not exist in the site/ directory. Verify paths.
95
+
96
+ ### LOW PRIORITY — Polish
97
+ 9. **Performance profiling** — Mirror/MultiInstance overlays copy canvases via 2D context (CPU-bound). Profile on low-end devices.
98
+ 10. **Accessibility** — Many decorative elements lack `aria-hidden`. Heading hierarchy has duplicate `<h1>`. Keyboard navigation untested.
99
+ 11. **Cascade card clip-path morphing** — The 8-point polygon system (rect/hex/diamond/oct) is clever but all shapes share the same bounding box. More dramatic shape variation needed.
100
+
101
+ ## GSAP Pattern Reference (From Visual Codex)
102
+
103
+ These patterns were studied and should inform future development:
104
+
105
+ ### Stagger Patterns
106
+ - `from: "center"` with elastic easing for outward reveals
107
+ - Grid-based: `stagger: { grid: [rows, cols], from: "edges", amount: 1.2 }`
108
+ - Function-based: `each: (i) => i * 0.05 + Math.random() * 0.1`
109
+
110
+ ### 3D Transforms
111
+ - Z-depth emergence: `fromTo(el, { z: -500, scale: 0 }, { z: 0, scale: 1 })`
112
+ - Multi-axis spin: `{ rotationX: 720, rotationY: 540, rotationZ: 360 }` with elastic
113
+ - `perspective: 1000px` on body, `transform-style: preserve-3d` on containers
114
+
115
+ ### Filter/Blur
116
+ - Progressive blur reveal: `fromTo(el, { filter: "blur(20px)" }, { filter: "blur(0px)" })`
117
+ - Layered blur stack: 3 layers at different blur levels, stagger `"<0.2"` relative timing
118
+ - Glassmorphism: `backdrop-filter: blur(20px)` on panels
119
+
120
+ ### Multi-Visualizer Choreography
121
+ - 5-phase scroll modes: Intro→Grid→Carousel→Expand→Finale
122
+ - Impulse system: `targets.impulse = Math.min(targets.impulse + intensity, 1.5)`, decays at 92%/frame
123
+ - Scrub smoothing: `scrub: 0.3` (300ms delay)
124
+
125
+ ## Design Direction
126
+
127
+ The current page has **world-class mathematical choreography** trapped in a **rigid rectangular grid**. The goal is to break free with:
128
+
129
+ 1. **Multiple parallax layers** — Not just 2. Different areas should have different layer counts and behaviors (columns in one area, concentric iris in another, diagonal bars in a third).
130
+ 2. **Negative space** — Solid layers with cutouts that reveal visualizers. The visualizers shine THROUGH the design, not inside rectangular boxes.
131
+ 3. **Organic boundaries** — SVG blob paths, fluid beziers, non-rectangular clip-paths. Nothing should be a perfect rectangle.
132
+ 4. **Asymmetrical compositions** — Break the grid. Unequal column widths, off-center elements, visual tension.
133
+ 5. **Varied visual vocabulary** — Not every section needs every effect. Some should be minimal and clean, others dramatic and layered.
134
+ 6. **Glass morphism as a design language** — Frosted glass panels that slide, morph, and shatter to reveal content.
135
+
136
+ ## Commands
137
+
138
+ ```bash
139
+ # From project root:
140
+ pnpm dev # Opens dev server (default: docs gallery)
141
+ # Then navigate to /site/index.html for landing page
142
+ # Or / for SDK demo
143
+
144
+ # To verify no SDK regressions:
145
+ pnpm test
146
+ ```
147
+
148
+ ## Session Instructions
149
+
150
+ 1. Read `site/index.html` for the full HTML structure
151
+ 2. Read `site/js/choreography.js` for the existing scroll timeline (it's 83KB — skim the section-level functions)
152
+ 3. Read `site/js/reveal-choreography.js` for the new overlay layer system
153
+ 4. **Do not break existing choreography** — the new system layers ON TOP
154
+ 5. Test in browser after changes — the page relies on CDN-loaded GSAP
155
+ 6. Focus on the visual quality issues listed above
156
+ 7. Use the GSAP pattern reference for implementation guidance