@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
@@ -16,13 +16,14 @@ import { Vec4 } from '../../math/Vec4.js';
16
16
  * @param {number} radius - Hypersphere radius
17
17
  * @returns {Vec4} Point on hypersphere
18
18
  */
19
- export function projectToHypersphere(point, radius = 1) {
19
+ export function projectToHypersphere(point, radius = 1, target = null) {
20
20
  const len = point.length();
21
21
  if (len < 0.0001) {
22
22
  // Handle origin - project to north pole
23
+ if (target) return target.set(0, 0, 0, radius);
23
24
  return new Vec4(0, 0, 0, radius);
24
25
  }
25
- return point.scale(radius / len);
26
+ return point.scale(radius / len, target);
26
27
  }
27
28
 
28
29
  /**
@@ -30,9 +31,10 @@ export function projectToHypersphere(point, radius = 1) {
30
31
  * Maps all of 3D space onto the 4D hypersphere
31
32
  * @param {Vec4} point - Input point (uses x, y, z)
32
33
  * @param {number} radius - Hypersphere radius
34
+ * @param {Vec4} [target=null] - Optional target vector
33
35
  * @returns {Vec4} Point on hypersphere
34
36
  */
35
- export function stereographicToHypersphere(point, radius = 1) {
37
+ export function stereographicToHypersphere(point, radius = 1, target = null) {
36
38
  const x = point.x;
37
39
  const y = point.y;
38
40
  const z = point.z;
@@ -40,6 +42,15 @@ export function stereographicToHypersphere(point, radius = 1) {
40
42
  const sumSq = x * x + y * y + z * z;
41
43
  const denom = sumSq + 1;
42
44
 
45
+ if (target) {
46
+ return target.set(
47
+ (2 * x) / denom * radius,
48
+ (2 * y) / denom * radius,
49
+ (2 * z) / denom * radius,
50
+ (sumSq - 1) / denom * radius
51
+ );
52
+ }
53
+
43
54
  return new Vec4(
44
55
  (2 * x) / denom * radius,
45
56
  (2 * y) / denom * radius,
@@ -56,12 +67,22 @@ export function stereographicToHypersphere(point, radius = 1) {
56
67
  * @param {number} phi - Azimuth on base S² (0 to 2π)
57
68
  * @param {number} psi - Fiber angle (0 to 2π)
58
69
  * @param {number} radius - Hypersphere radius
70
+ * @param {Vec4} [target=null] - Optional target vector
59
71
  * @returns {Vec4} Point on hypersphere
60
72
  */
61
- export function hopfFibration(theta, phi, psi, radius = 1) {
73
+ export function hopfFibration(theta, phi, psi, radius = 1, target = null) {
62
74
  const cosTheta2 = Math.cos(theta / 2);
63
75
  const sinTheta2 = Math.sin(theta / 2);
64
76
 
77
+ if (target) {
78
+ return target.set(
79
+ cosTheta2 * Math.cos((phi + psi) / 2) * radius,
80
+ cosTheta2 * Math.sin((phi + psi) / 2) * radius,
81
+ sinTheta2 * Math.cos((phi - psi) / 2) * radius,
82
+ sinTheta2 * Math.sin((phi - psi) / 2) * radius
83
+ );
84
+ }
85
+
65
86
  return new Vec4(
66
87
  cosTheta2 * Math.cos((phi + psi) / 2) * radius,
67
88
  cosTheta2 * Math.sin((phi + psi) / 2) * radius,
@@ -78,8 +99,9 @@ export function hopfFibration(theta, phi, psi, radius = 1) {
78
99
  * @returns {Vec4[]} Warped vertices
79
100
  */
80
101
  export function warpRadial(vertices, radius = 1, blendFactor = 1) {
102
+ const onSphere = new Vec4();
81
103
  return vertices.map(v => {
82
- const onSphere = projectToHypersphere(v, radius);
104
+ projectToHypersphere(v, radius, onSphere);
83
105
  return v.lerp(onSphere, blendFactor);
84
106
  });
85
107
  }
@@ -93,8 +115,9 @@ export function warpRadial(vertices, radius = 1, blendFactor = 1) {
93
115
  * @returns {Vec4[]} Warped vertices
94
116
  */
95
117
  export function warpStereographic(vertices, radius = 1, scale = 1) {
118
+ const scaled = new Vec4();
96
119
  return vertices.map(v => {
97
- const scaled = v.scale(scale);
120
+ v.scale(scale, scaled);
98
121
  return stereographicToHypersphere(scaled, radius);
99
122
  });
100
123
  }
@@ -146,25 +169,31 @@ export function warpHypersphereCore(geometry, options = {}) {
146
169
  twist = 1
147
170
  } = options;
148
171
 
149
- let warpedVertices;
150
-
151
- // Pre-scale vertices
152
- const scaledVertices = geometry.vertices.map(v => v.scale(scale));
153
-
154
- switch (method) {
155
- case 'stereographic':
156
- warpedVertices = warpStereographic(scaledVertices, radius, 1);
157
- break;
158
-
159
- case 'hopf':
160
- warpedVertices = warpHopf(scaledVertices, radius, twist);
161
- break;
172
+ const temp = new Vec4();
173
+ const warpedVertices = geometry.vertices.map(v => {
174
+ // Combined scaling and warping to minimize allocations
175
+ const result = v.scale(scale);
176
+
177
+ if (method === 'stereographic') {
178
+ stereographicToHypersphere(result, radius, result);
179
+ } else if (method === 'hopf') {
180
+ const r = result.length();
181
+ if (r < 0.0001) {
182
+ result.set(0, 0, 0, radius);
183
+ } else {
184
+ const theta = Math.acos(result.z / r);
185
+ const phi = Math.atan2(result.y, result.x);
186
+ const psi = result.w * twist + phi * 0.5;
187
+ hopfFibration(theta, phi, psi, radius, result);
188
+ }
189
+ } else {
190
+ // Radial (default)
191
+ projectToHypersphere(result, radius, temp);
192
+ result.lerp(temp, blend, result);
193
+ }
162
194
 
163
- case 'radial':
164
- default:
165
- warpedVertices = warpRadial(scaledVertices, radius, blend);
166
- break;
167
- }
195
+ return result;
196
+ });
168
197
 
169
198
  return {
170
199
  ...geometry,
@@ -29,7 +29,7 @@ export class HolographicVisualizer {
29
29
  this.canvas.getContext('experimental-webgl');
30
30
 
31
31
  if (existingContext && !existingContext.isContextLost()) {
32
- console.log(`🔄 Reusing existing WebGL context for ${canvasId}`);
32
+ console.log(`🔄 Reusing existing WebGL context for ${canvasIdOrElement instanceof HTMLCanvasElement ? canvasIdOrElement.id : canvasIdOrElement}`);
33
33
  this.gl = existingContext;
34
34
  } else {
35
35
  // Try WebGL2 first (better mobile support), then WebGL1
@@ -39,9 +39,9 @@ export class HolographicVisualizer {
39
39
  }
40
40
 
41
41
  if (!this.gl) {
42
- console.error(`WebGL not supported for ${canvasId}`);
42
+ console.error(`WebGL not supported for ${canvasIdOrElement}`);
43
43
  this.showWebGLError();
44
- throw new Error(`WebGL not supported for ${canvasId}`);
44
+ throw new Error(`WebGL not supported for ${canvasIdOrElement}`);
45
45
  }
46
46
 
47
47
  this.variantParams = this.generateVariantParams(variant);
@@ -86,17 +86,17 @@ export class HolographicVisualizer {
86
86
  this._onContextLost = (e) => {
87
87
  e.preventDefault();
88
88
  this._contextLost = true;
89
- console.warn(`WebGL context lost for ${canvasId}`);
89
+ console.warn(`WebGL context lost for ${canvasIdOrElement}`);
90
90
  };
91
91
  this._onContextRestored = () => {
92
- console.log(`WebGL context restored for ${canvasId}`);
92
+ console.log(`WebGL context restored for ${canvasIdOrElement}`);
93
93
  this._contextLost = false;
94
94
  try {
95
95
  this.initShaders();
96
96
  this.initBuffers();
97
97
  this.resize();
98
98
  } catch (err) {
99
- console.error(`Failed to reinit after context restore for ${canvasId}:`, err);
99
+ console.error(`Failed to reinit after context restore for ${canvasIdOrElement}:`, err);
100
100
  }
101
101
  };
102
102
  this.canvas.addEventListener('webglcontextlost', this._onContextLost);
@@ -132,28 +132,28 @@ export class HolographicVisualizer {
132
132
  const finalName = geometryName + suffixes[variationLevel];
133
133
 
134
134
  const geometryConfigs = {
135
- 0: { density: 0.8 + variationLevel * 0.2, speed: 0.3 + variationLevel * 0.1, chaos: variationLevel * 0.1, morph: 0.0 + variationLevel * 0.2 },
136
- 1: { density: 1.0 + variationLevel * 0.3, speed: 0.5 + variationLevel * 0.1, chaos: variationLevel * 0.15, morph: variationLevel * 0.2 },
137
- 2: { density: 1.2 + variationLevel * 0.4, speed: 0.4 + variationLevel * 0.2, chaos: 0.1 + variationLevel * 0.1, morph: 0.3 + variationLevel * 0.2 },
138
- 3: { density: 0.9 + variationLevel * 0.3, speed: 0.6 + variationLevel * 0.2, chaos: 0.2 + variationLevel * 0.2, morph: 0.5 + variationLevel * 0.1 },
139
- 4: { density: 1.4 + variationLevel * 0.5, speed: 0.7 + variationLevel * 0.1, chaos: 0.3 + variationLevel * 0.2, morph: 0.7 + variationLevel * 0.1 },
140
- 5: { density: 1.8 + variationLevel * 0.3, speed: 0.5 + variationLevel * 0.3, chaos: 0.5 + variationLevel * 0.2, morph: 0.8 + variationLevel * 0.05 },
141
- 6: { density: 0.6 + variationLevel * 0.4, speed: 0.8 + variationLevel * 0.4, chaos: 0.4 + variationLevel * 0.3, morph: 0.6 + variationLevel * 0.2 },
142
- 7: { density: 1.6 + variationLevel * 0.2, speed: 0.2 + variationLevel * 0.1, chaos: 0.1 + variationLevel * 0.1, morph: 0.2 + variationLevel * 0.2 }
135
+ 0: { gridDensity: 0.8 + variationLevel * 0.2, speed: 0.3 + variationLevel * 0.1, chaos: variationLevel * 0.1, morphFactor: 0.0 + variationLevel * 0.2 },
136
+ 1: { gridDensity: 1.0 + variationLevel * 0.3, speed: 0.5 + variationLevel * 0.1, chaos: variationLevel * 0.15, morphFactor: variationLevel * 0.2 },
137
+ 2: { gridDensity: 1.2 + variationLevel * 0.4, speed: 0.4 + variationLevel * 0.2, chaos: 0.1 + variationLevel * 0.1, morphFactor: 0.3 + variationLevel * 0.2 },
138
+ 3: { gridDensity: 0.9 + variationLevel * 0.3, speed: 0.6 + variationLevel * 0.2, chaos: 0.2 + variationLevel * 0.2, morphFactor: 0.5 + variationLevel * 0.1 },
139
+ 4: { gridDensity: 1.4 + variationLevel * 0.5, speed: 0.7 + variationLevel * 0.1, chaos: 0.3 + variationLevel * 0.2, morphFactor: 0.7 + variationLevel * 0.1 },
140
+ 5: { gridDensity: 1.8 + variationLevel * 0.3, speed: 0.5 + variationLevel * 0.3, chaos: 0.5 + variationLevel * 0.2, morphFactor: 0.8 + variationLevel * 0.05 },
141
+ 6: { gridDensity: 0.6 + variationLevel * 0.4, speed: 0.8 + variationLevel * 0.4, chaos: 0.4 + variationLevel * 0.3, morphFactor: 0.6 + variationLevel * 0.2 },
142
+ 7: { gridDensity: 1.6 + variationLevel * 0.2, speed: 0.2 + variationLevel * 0.1, chaos: 0.1 + variationLevel * 0.1, morphFactor: 0.2 + variationLevel * 0.2 }
143
143
  };
144
-
144
+
145
145
  const config = geometryConfigs[baseGeometry];
146
-
146
+
147
147
  return {
148
- geometryType: baseGeometry,
148
+ geometry: baseGeometry,
149
149
  name: finalName,
150
- density: config.density,
150
+ gridDensity: config.gridDensity,
151
151
  speed: config.speed,
152
152
  hue: (variant * 12.27) % 360,
153
- saturation: 0.8 + (variationLevel * 0.05), // Add saturation parameter
153
+ saturation: 0.8 + (variationLevel * 0.05),
154
154
  intensity: 0.5 + (variationLevel * 0.1),
155
155
  chaos: config.chaos,
156
- morph: config.morph
156
+ morphFactor: config.morphFactor
157
157
  };
158
158
  }
159
159
 
@@ -169,20 +169,20 @@ export class HolographicVisualizer {
169
169
  densityMult: 0.8, speedMult: 0.3, colorShift: 180.0, intensity: 0.4,
170
170
  mouseReactivity: 0.5, clickReactivity: 0.3
171
171
  },
172
- 'content': {
173
- densityMult: vp.density, speedMult: vp.speed,
172
+ 'content': {
173
+ densityMult: vp.gridDensity, speedMult: vp.speed,
174
174
  colorShift: vp.hue, intensity: vp.intensity,
175
- mouseReactivity: 1.0, clickReactivity: 0.8
175
+ mouseReactivity: 1.0, clickReactivity: 0.8
176
176
  },
177
- 'highlight': {
178
- densityMult: 1.5 + (vp.density * 0.3), speedMult: 0.8 + (vp.speed * 0.2),
177
+ 'highlight': {
178
+ densityMult: 1.5 + (vp.gridDensity * 0.3), speedMult: 0.8 + (vp.speed * 0.2),
179
179
  colorShift: vp.hue + 60.0, intensity: 0.6 + (vp.intensity * 0.2),
180
- mouseReactivity: 1.2, clickReactivity: 1.0
180
+ mouseReactivity: 1.2, clickReactivity: 1.0
181
181
  },
182
- 'accent': {
183
- densityMult: 2.5 + (vp.density * 0.5), speedMult: 0.4 + (vp.speed * 0.1),
182
+ 'accent': {
183
+ densityMult: 2.5 + (vp.gridDensity * 0.5), speedMult: 0.4 + (vp.speed * 0.1),
184
184
  colorShift: vp.hue + 300.0, intensity: 0.3 + (vp.intensity * 0.1),
185
- mouseReactivity: 1.5, clickReactivity: 1.2
185
+ mouseReactivity: 1.5, clickReactivity: 1.2
186
186
  }
187
187
  };
188
188
 
@@ -207,7 +207,7 @@ export class HolographicVisualizer {
207
207
  uniform float u_time;
208
208
  uniform vec2 u_mouse;
209
209
  uniform float u_geometry;
210
- uniform float u_density;
210
+ uniform float u_gridDensity;
211
211
  uniform float u_speed;
212
212
  uniform vec3 u_color;
213
213
  uniform float u_intensity;
@@ -218,9 +218,8 @@ export class HolographicVisualizer {
218
218
  uniform float u_mouseIntensity;
219
219
  uniform float u_clickIntensity;
220
220
  uniform float u_densityVariation;
221
- uniform float u_geometryType;
222
221
  uniform float u_chaos;
223
- uniform float u_morph;
222
+ uniform float u_morphFactor;
224
223
  uniform float u_touchMorph;
225
224
  uniform float u_touchChaos;
226
225
  uniform float u_scrollParallax;
@@ -238,6 +237,9 @@ export class HolographicVisualizer {
238
237
  uniform float u_rot4dYW;
239
238
  uniform float u_rot4dZW;
240
239
 
240
+ // EXHALE FEATURE: Breathing uniform
241
+ uniform float u_breath;
242
+
241
243
  // 6D rotation matrices - 3D space rotations (XY, XZ, YZ)
242
244
  mat4 rotateXY(float theta) {
243
245
  float c = cos(theta);
@@ -276,9 +278,12 @@ export class HolographicVisualizer {
276
278
  return mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, c, -s, 0, 0, s, c);
277
279
  }
278
280
 
279
- // 4D to 3D projection
281
+ // 4D to 3D projection - BREATHING EFFECT
280
282
  vec3 project4Dto3D(vec4 p) {
281
- float w = 2.5 / (2.5 + p.w);
283
+ // Modulate projection distance with breath for "exhale" effect (expansion/contraction)
284
+ float baseDim = 2.5;
285
+ float dim = baseDim + u_breath * 0.5; // Expands on exhale
286
+ float w = dim / (dim + p.w);
282
287
  return vec3(p.x * w, p.y * w, p.z * w);
283
288
  }
284
289
 
@@ -287,7 +292,7 @@ export class HolographicVisualizer {
287
292
  // ========================================
288
293
  vec3 warpHypersphereCore(vec3 p, int geometryIndex, vec2 mouseDelta) {
289
294
  float radius = length(p);
290
- float morphBlend = clamp(u_morph * 0.6 + 0.3, 0.0, 2.0);
295
+ float morphBlend = clamp(u_morphFactor * 0.6 + 0.3, 0.0, 2.0);
291
296
  float w = sin(radius * (1.3 + float(geometryIndex) * 0.12) + u_time * 0.0008 * u_speed);
292
297
  w *= (0.4 + morphBlend * 0.45);
293
298
 
@@ -309,7 +314,7 @@ export class HolographicVisualizer {
309
314
  vec3 c3 = normalize(vec3(-1.0, 1.0, -1.0));
310
315
  vec3 c4 = normalize(vec3(1.0, -1.0, -1.0));
311
316
 
312
- float morphBlend = clamp(u_morph * 0.8 + 0.2, 0.0, 2.0);
317
+ float morphBlend = clamp(u_morphFactor * 0.8 + 0.2, 0.0, 2.0);
313
318
  float basisMix = dot(p, c1) * 0.14 + dot(p, c2) * 0.1 + dot(p, c3) * 0.08;
314
319
  float w = sin(basisMix * 5.5 + u_time * 0.0009 * u_speed);
315
320
  w *= cos(dot(p, c4) * 4.2 - u_time * 0.0007 * u_speed);
@@ -543,18 +548,23 @@ export class HolographicVisualizer {
543
548
 
544
549
  float scrollDensityMod = 1.0 + u_gridDensityShift * 0.3;
545
550
  float audioDensityMod = 1.0 + u_audioDensityBoost * 0.5;
546
- // FIX: Prevent density doubling by using base density with controlled variations
547
- float baseDensity = u_density * u_roleDensity;
551
+ // Controlled density calculation - breathing modulation added
552
+ float breathDensityMod = 1.0 + u_breath * 0.1;
553
+ float baseDensity = u_gridDensity * u_roleDensity * breathDensityMod;
554
+
548
555
  float densityVariations = (u_densityVariation * 0.3 + (scrollDensityMod - 1.0) * 0.4 + (audioDensityMod - 1.0) * 0.2);
549
556
  float roleDensity = baseDensity + densityVariations;
550
557
 
551
- float morphedGeometry = u_geometryType + u_morph * 3.0 + u_touchMorph * 2.0 + u_audioMorphBoost * 1.5;
558
+ float morphedGeometry = u_geometry + u_morphFactor * 3.0 + u_touchMorph * 2.0 + u_audioMorphBoost * 1.5;
552
559
  float lattice = getDynamicGeometry(p, roleDensity, morphedGeometry);
553
560
 
554
561
  // Enhanced holographic color processing
555
562
  vec3 baseColor = u_color;
556
563
  float latticeIntensity = lattice * u_intensity;
557
564
 
565
+ // Breathing glow effect
566
+ latticeIntensity *= (1.0 + u_breath * 0.4);
567
+
558
568
  // Multi-layer color composition for higher fidelity
559
569
  vec3 color = baseColor * (0.2 + latticeIntensity * 0.8);
560
570
 
@@ -579,9 +589,9 @@ export class HolographicVisualizer {
579
589
  color = rgbGlitch(color, uv, enhancedChaos);
580
590
 
581
591
  // Apply morph distortion to position
582
- vec2 morphDistortion = vec2(sin(uv.y * 10.0 + u_time * 0.001) * u_morph * 0.1,
583
- cos(uv.x * 10.0 + u_time * 0.001) * u_morph * 0.1);
584
- color = mix(color, color * (1.0 + length(morphDistortion)), u_morph * 0.5);
592
+ vec2 morphDistortion = vec2(sin(uv.y * 10.0 + u_time * 0.001) * u_morphFactor * 0.1,
593
+ cos(uv.x * 10.0 + u_time * 0.001) * u_morphFactor * 0.1);
594
+ color = mix(color, color * (1.0 + length(morphDistortion)), u_morphFactor * 0.5);
585
595
 
586
596
  // Enhanced holographic interaction effects
587
597
  float mouseDist = length(uv - (u_mouse - 0.5) * vec2(aspectRatio, 1.0));
@@ -610,7 +620,7 @@ export class HolographicVisualizer {
610
620
  time: this.gl.getUniformLocation(this.program, 'u_time'),
611
621
  mouse: this.gl.getUniformLocation(this.program, 'u_mouse'),
612
622
  geometry: this.gl.getUniformLocation(this.program, 'u_geometry'),
613
- density: this.gl.getUniformLocation(this.program, 'u_density'),
623
+ gridDensity: this.gl.getUniformLocation(this.program, 'u_gridDensity'),
614
624
  speed: this.gl.getUniformLocation(this.program, 'u_speed'),
615
625
  color: this.gl.getUniformLocation(this.program, 'u_color'),
616
626
  intensity: this.gl.getUniformLocation(this.program, 'u_intensity'),
@@ -621,9 +631,8 @@ export class HolographicVisualizer {
621
631
  mouseIntensity: this.gl.getUniformLocation(this.program, 'u_mouseIntensity'),
622
632
  clickIntensity: this.gl.getUniformLocation(this.program, 'u_clickIntensity'),
623
633
  densityVariation: this.gl.getUniformLocation(this.program, 'u_densityVariation'),
624
- geometryType: this.gl.getUniformLocation(this.program, 'u_geometryType'),
625
634
  chaos: this.gl.getUniformLocation(this.program, 'u_chaos'),
626
- morph: this.gl.getUniformLocation(this.program, 'u_morph'),
635
+ morphFactor: this.gl.getUniformLocation(this.program, 'u_morphFactor'),
627
636
  touchMorph: this.gl.getUniformLocation(this.program, 'u_touchMorph'),
628
637
  touchChaos: this.gl.getUniformLocation(this.program, 'u_touchChaos'),
629
638
  scrollParallax: this.gl.getUniformLocation(this.program, 'u_scrollParallax'),
@@ -639,7 +648,8 @@ export class HolographicVisualizer {
639
648
  rot4dYZ: this.gl.getUniformLocation(this.program, 'u_rot4dYZ'),
640
649
  rot4dXW: this.gl.getUniformLocation(this.program, 'u_rot4dXW'),
641
650
  rot4dYW: this.gl.getUniformLocation(this.program, 'u_rot4dYW'),
642
- rot4dZW: this.gl.getUniformLocation(this.program, 'u_rot4dZW')
651
+ rot4dZW: this.gl.getUniformLocation(this.program, 'u_rot4dZW'),
652
+ breath: this.gl.getUniformLocation(this.program, 'u_breath')
643
653
  };
644
654
  }
645
655
 
@@ -882,11 +892,11 @@ export class HolographicVisualizer {
882
892
  this.gl.uniform2f(this.uniforms.resolution, this.canvas.width, this.canvas.height);
883
893
  this.gl.uniform1f(this.uniforms.time, time);
884
894
  this.gl.uniform2f(this.uniforms.mouse, this.mouseX, this.mouseY);
885
- this.gl.uniform1f(this.uniforms.geometryType, this.variantParams.geometryType || 0);
886
- this.gl.uniform1f(this.uniforms.density, this.variantParams.density || 1.0);
887
- // FIX: Controlled speed calculation - base speed controls main movement, audio provides subtle boost
888
- const baseSpeed = (this.variantParams.speed || 0.5) * 0.2; // Much slower base speed
889
- const audioBoost = (this.audioSpeedBoost || 0.0) * 0.1; // Subtle audio boost only
895
+ this.gl.uniform1f(this.uniforms.geometry, this.variantParams.geometry !== undefined ? this.variantParams.geometry : this.variant || 0);
896
+ this.gl.uniform1f(this.uniforms.gridDensity, this.variantParams.gridDensity || 1.0);
897
+ // Controlled speed calculation - base speed controls main movement, audio provides subtle boost
898
+ const baseSpeed = (this.variantParams.speed || 0.5) * 0.2;
899
+ const audioBoost = (this.audioSpeedBoost || 0.0) * 0.1;
890
900
  this.gl.uniform1f(this.uniforms.speed, baseSpeed + audioBoost);
891
901
  this.gl.uniform3fv(this.uniforms.color, new Float32Array(rgbColor));
892
902
  this.gl.uniform1f(this.uniforms.intensity, (this.variantParams.intensity || 0.5) * this.roleParams.intensity);
@@ -897,9 +907,8 @@ export class HolographicVisualizer {
897
907
  this.gl.uniform1f(this.uniforms.mouseIntensity, this.mouseIntensity);
898
908
  this.gl.uniform1f(this.uniforms.clickIntensity, this.clickIntensity);
899
909
  this.gl.uniform1f(this.uniforms.densityVariation, this.densityVariation);
900
- this.gl.uniform1f(this.uniforms.geometryType, this.variantParams.geometryType !== undefined ? this.variantParams.geometryType : this.variant || 0);
901
910
  this.gl.uniform1f(this.uniforms.chaos, this.variantParams.chaos || 0.0);
902
- this.gl.uniform1f(this.uniforms.morph, this.variantParams.morph || 0.0);
911
+ this.gl.uniform1f(this.uniforms.morphFactor, this.variantParams.morphFactor || 0.0);
903
912
 
904
913
  // Touch and scroll uniforms
905
914
  this.gl.uniform1f(this.uniforms.touchMorph, this.touchMorph);
@@ -939,6 +948,10 @@ export class HolographicVisualizer {
939
948
  this.gl.uniform1f(this.uniforms.rot4dYW, this.variantParams.rot4dYW || 0.0);
940
949
  this.gl.uniform1f(this.uniforms.rot4dZW, this.variantParams.rot4dZW || 0.0);
941
950
 
951
+ // Exhale feature: Use centralized breath from VitalitySystem (0.0 = inhale, 1.0 = exhale)
952
+ const breathCycle = this.variantParams.breath || 0.0;
953
+ this.gl.uniform1f(this.uniforms.breath, breathCycle);
954
+
942
955
  this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4);
943
956
  }
944
957
 
@@ -985,61 +998,34 @@ export class HolographicVisualizer {
985
998
  }
986
999
 
987
1000
  /**
988
- * CRITICAL FIX: Update visualization parameters with immediate re-render
989
- * This method was missing and causing parameter sliders to not work in holographic system
1001
+ * Update visualization parameters from SDK global parameter names.
1002
+ * Parameters are written directly to variantParams no name mapping needed
1003
+ * since shader uniforms now use SDK-standard names.
990
1004
  */
991
1005
  updateParameters(params) {
992
1006
  if (!params || typeof params !== 'object') return;
993
- // Update variant parameters with proper mapping and scaling
994
1007
  if (this.variantParams) {
995
1008
  Object.keys(params).forEach(param => {
996
- const mappedParam = this.mapParameterName(param);
997
- if (mappedParam !== null) {
998
- let scaledValue = params[param];
999
- // Guard against NaN/Infinity reaching GPU uniforms
1000
- if (typeof scaledValue !== 'number' || !Number.isFinite(scaledValue)) return;
1001
-
1002
- // FIX: Scale gridDensity to reasonable holographic density range (back to normal levels)
1003
- if (param === 'gridDensity') {
1004
- // Convert gridDensity (5-100) to holographic density (0.3-2.5) - reasonable range
1005
- // Formula: density = 0.3 + (gridDensity - 5) / (100 - 5) * (2.5 - 0.3)
1006
- scaledValue = 0.3 + (parseFloat(params[param]) - 5) / 95 * 2.2;
1007
- console.log(`🔧 Density scaling: gridDensity=${params[param]} density=${scaledValue.toFixed(3)} (normal range)`);
1008
- }
1009
-
1010
- this.variantParams[mappedParam] = scaledValue;
1011
-
1012
- // Handle special parameter types
1013
- if (mappedParam === 'geometryType') {
1014
- // Regenerate role params with new geometry
1015
- this.roleParams = this.generateRoleParams(this.role);
1016
- }
1009
+ let scaledValue = params[param];
1010
+ // Guard against NaN/Infinity reaching GPU uniforms
1011
+ if (typeof scaledValue !== 'number' || !Number.isFinite(scaledValue)) return;
1012
+
1013
+ // Scale gridDensity (5-100) to holographic density range (0.3-2.5)
1014
+ if (param === 'gridDensity') {
1015
+ scaledValue = 0.3 + (parseFloat(params[param]) - 5) / 95 * 2.2;
1016
+ }
1017
+
1018
+ this.variantParams[param] = scaledValue;
1019
+
1020
+ // Regenerate role params when geometry changes
1021
+ if (param === 'geometry') {
1022
+ this.roleParams = this.generateRoleParams(this.role);
1017
1023
  }
1018
1024
  });
1019
1025
  }
1020
-
1026
+
1021
1027
  // Don't call render() here - engine will call it to prevent infinite loop
1022
1028
  }
1023
-
1024
- /**
1025
- * Map global parameter names to holographic system parameter names
1026
- */
1027
- mapParameterName(globalParam) {
1028
- const paramMap = {
1029
- 'gridDensity': 'density',
1030
- 'morphFactor': 'morph',
1031
- 'rot4dXW': 'rot4dXW',
1032
- 'rot4dYW': 'rot4dYW',
1033
- 'rot4dZW': 'rot4dZW',
1034
- 'hue': 'hue',
1035
- 'intensity': 'intensity',
1036
- 'saturation': 'saturation',
1037
- 'chaos': 'chaos',
1038
- 'speed': 'speed',
1039
- 'geometry': 'geometryType'
1040
- };
1041
- return paramMap[globalParam] || globalParam;
1042
- }
1043
1029
 
1044
1030
  /**
1045
1031
  * Clean up all WebGL resources and event listeners