@vib3code/sdk 2.0.1

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 (258) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/DOCS/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md +34 -0
  3. package/DOCS/CI_TESTING.md +38 -0
  4. package/DOCS/CLI_ONBOARDING.md +75 -0
  5. package/DOCS/CONTROL_REFERENCE.md +64 -0
  6. package/DOCS/DEV_TRACK_ANALYSIS.md +77 -0
  7. package/DOCS/DEV_TRACK_PLAN_2026-01-07.md +42 -0
  8. package/DOCS/DEV_TRACK_SESSION_2026-01-31.md +220 -0
  9. package/DOCS/ENV_SETUP.md +189 -0
  10. package/DOCS/EXPORT_FORMATS.md +417 -0
  11. package/DOCS/GPU_DISPOSAL_GUIDE.md +21 -0
  12. package/DOCS/LICENSING_TIERS.md +275 -0
  13. package/DOCS/MASTER_PLAN_2026-01-31.md +570 -0
  14. package/DOCS/OBS_SETUP_GUIDE.md +98 -0
  15. package/DOCS/PROJECT_SETUP.md +66 -0
  16. package/DOCS/RENDERER_LIFECYCLE.md +40 -0
  17. package/DOCS/REPO_MANIFEST.md +121 -0
  18. package/DOCS/SESSION_014_PLAN.md +195 -0
  19. package/DOCS/SESSION_LOG_2026-01-07.md +56 -0
  20. package/DOCS/STRATEGIC_BLUEPRINT_2026-01-07.md +72 -0
  21. package/DOCS/SYSTEM_AUDIT_2026-01-30.md +738 -0
  22. package/DOCS/SYSTEM_INVENTORY.md +520 -0
  23. package/DOCS/TELEMETRY_EXPORTS.md +34 -0
  24. package/DOCS/WEBGPU_STATUS.md +38 -0
  25. package/DOCS/XR_BENCHMARKS.md +608 -0
  26. package/LICENSE +21 -0
  27. package/README.md +426 -0
  28. package/docs/.nojekyll +0 -0
  29. package/docs/01-dissolution_of_euclidean_hegemony.html +346 -0
  30. package/docs/02-hyperspatial_ego_death.html +346 -0
  31. package/docs/03-post_cartesian_sublime.html +346 -0
  32. package/docs/04-crystalline_void_meditation.html +346 -0
  33. package/docs/05-quantum_decoherence_ballet.html +346 -0
  34. package/docs/06-dissolution_of_euclidean_hegemony.html +346 -0
  35. package/docs/07-hyperspatial_ego_death.html +346 -0
  36. package/docs/08-post_cartesian_sublime.html +346 -0
  37. package/docs/09-crystalline_void_meditation.html +346 -0
  38. package/docs/10-quantum_decoherence_ballet.html +346 -0
  39. package/docs/11-dissolution_of_euclidean_hegemony.html +346 -0
  40. package/docs/12-hyperspatial_ego_death.html +346 -0
  41. package/docs/13-post_cartesian_sublime.html +346 -0
  42. package/docs/index.html +794 -0
  43. package/docs/test-hub.html +441 -0
  44. package/docs/url-state.js +102 -0
  45. package/docs/vib3-exports/01-quantum-quantum-tetrahedron-lattice.html +489 -0
  46. package/docs/vib3-exports/02-quantum-quantum-hypersphere-matrix.html +489 -0
  47. package/docs/vib3-exports/03-quantum-quantum-hypertetra-fractal.html +489 -0
  48. package/docs/vib3-exports/04-faceted-faceted-crystal-structure.html +407 -0
  49. package/docs/vib3-exports/05-faceted-faceted-klein-bottle.html +407 -0
  50. package/docs/vib3-exports/06-faceted-faceted-hypertetra-torus.html +407 -0
  51. package/docs/vib3-exports/07-holographic-holographic-wave-field.html +457 -0
  52. package/docs/vib3-exports/08-holographic-holographic-hypersphere-sphere.html +457 -0
  53. package/docs/vib3-exports/09-holographic-holographic-hypertetra-crystal.html +457 -0
  54. package/docs/vib3-exports/index.html +238 -0
  55. package/docs/webgpu-live.html +702 -0
  56. package/package.json +367 -0
  57. package/src/advanced/AIPresetGenerator.js +777 -0
  58. package/src/advanced/MIDIController.js +703 -0
  59. package/src/advanced/OffscreenWorker.js +1051 -0
  60. package/src/advanced/WebGPUCompute.js +1051 -0
  61. package/src/advanced/WebXRRenderer.js +680 -0
  62. package/src/agent/cli/AgentCLI.js +615 -0
  63. package/src/agent/cli/index.js +14 -0
  64. package/src/agent/index.js +73 -0
  65. package/src/agent/mcp/MCPServer.js +950 -0
  66. package/src/agent/mcp/index.js +9 -0
  67. package/src/agent/mcp/tools.js +548 -0
  68. package/src/agent/telemetry/EventStream.js +669 -0
  69. package/src/agent/telemetry/Instrumentation.js +618 -0
  70. package/src/agent/telemetry/TelemetryExporters.js +427 -0
  71. package/src/agent/telemetry/TelemetryService.js +464 -0
  72. package/src/agent/telemetry/index.js +52 -0
  73. package/src/benchmarks/BenchmarkRunner.js +381 -0
  74. package/src/benchmarks/MetricsCollector.js +299 -0
  75. package/src/benchmarks/index.js +9 -0
  76. package/src/benchmarks/scenes.js +259 -0
  77. package/src/cli/index.js +675 -0
  78. package/src/config/ApiConfig.js +88 -0
  79. package/src/core/CanvasManager.js +217 -0
  80. package/src/core/ErrorReporter.js +117 -0
  81. package/src/core/ParameterMapper.js +333 -0
  82. package/src/core/Parameters.js +396 -0
  83. package/src/core/RendererContracts.js +200 -0
  84. package/src/core/UnifiedResourceManager.js +370 -0
  85. package/src/core/VIB3Engine.js +636 -0
  86. package/src/core/renderers/FacetedRendererAdapter.js +32 -0
  87. package/src/core/renderers/HolographicRendererAdapter.js +29 -0
  88. package/src/core/renderers/QuantumRendererAdapter.js +29 -0
  89. package/src/core/renderers/RendererLifecycleManager.js +63 -0
  90. package/src/creative/ColorPresetsSystem.js +980 -0
  91. package/src/creative/ParameterTimeline.js +1061 -0
  92. package/src/creative/PostProcessingPipeline.js +1113 -0
  93. package/src/creative/TransitionAnimator.js +683 -0
  94. package/src/export/CSSExporter.js +226 -0
  95. package/src/export/CardGeneratorBase.js +279 -0
  96. package/src/export/ExportManager.js +580 -0
  97. package/src/export/FacetedCardGenerator.js +279 -0
  98. package/src/export/HolographicCardGenerator.js +543 -0
  99. package/src/export/LottieExporter.js +552 -0
  100. package/src/export/QuantumCardGenerator.js +315 -0
  101. package/src/export/SVGExporter.js +519 -0
  102. package/src/export/ShaderExporter.js +903 -0
  103. package/src/export/TradingCardGenerator.js +3055 -0
  104. package/src/export/TradingCardManager.js +181 -0
  105. package/src/export/VIB3PackageExporter.js +559 -0
  106. package/src/export/index.js +14 -0
  107. package/src/export/systems/TradingCardSystemFaceted.js +494 -0
  108. package/src/export/systems/TradingCardSystemHolographic.js +452 -0
  109. package/src/export/systems/TradingCardSystemQuantum.js +411 -0
  110. package/src/faceted/FacetedSystem.js +963 -0
  111. package/src/features/CollectionManager.js +433 -0
  112. package/src/gallery/CollectionManager.js +240 -0
  113. package/src/gallery/GallerySystem.js +485 -0
  114. package/src/geometry/GeometryFactory.js +314 -0
  115. package/src/geometry/GeometryLibrary.js +72 -0
  116. package/src/geometry/buffers/BufferBuilder.js +338 -0
  117. package/src/geometry/buffers/index.js +18 -0
  118. package/src/geometry/generators/Crystal.js +420 -0
  119. package/src/geometry/generators/Fractal.js +298 -0
  120. package/src/geometry/generators/KleinBottle.js +197 -0
  121. package/src/geometry/generators/Sphere.js +192 -0
  122. package/src/geometry/generators/Tesseract.js +160 -0
  123. package/src/geometry/generators/Tetrahedron.js +225 -0
  124. package/src/geometry/generators/Torus.js +304 -0
  125. package/src/geometry/generators/Wave.js +341 -0
  126. package/src/geometry/index.js +142 -0
  127. package/src/geometry/warp/HypersphereCore.js +211 -0
  128. package/src/geometry/warp/HypertetraCore.js +386 -0
  129. package/src/geometry/warp/index.js +57 -0
  130. package/src/holograms/HolographicVisualizer.js +1073 -0
  131. package/src/holograms/RealHolographicSystem.js +966 -0
  132. package/src/holograms/variantRegistry.js +69 -0
  133. package/src/integrations/FigmaPlugin.js +854 -0
  134. package/src/integrations/OBSMode.js +754 -0
  135. package/src/integrations/ThreeJsPackage.js +660 -0
  136. package/src/integrations/TouchDesignerExport.js +552 -0
  137. package/src/integrations/frameworks/Vib3React.js +591 -0
  138. package/src/integrations/frameworks/Vib3Svelte.js +654 -0
  139. package/src/integrations/frameworks/Vib3Vue.js +628 -0
  140. package/src/llm/LLMParameterInterface.js +240 -0
  141. package/src/llm/LLMParameterUI.js +577 -0
  142. package/src/math/Mat4x4.js +708 -0
  143. package/src/math/Projection.js +341 -0
  144. package/src/math/Rotor4D.js +637 -0
  145. package/src/math/Vec4.js +476 -0
  146. package/src/math/constants.js +164 -0
  147. package/src/math/index.js +68 -0
  148. package/src/math/projections.js +54 -0
  149. package/src/math/rotations.js +196 -0
  150. package/src/quantum/QuantumEngine.js +906 -0
  151. package/src/quantum/QuantumVisualizer.js +1103 -0
  152. package/src/reactivity/ReactivityConfig.js +499 -0
  153. package/src/reactivity/ReactivityManager.js +586 -0
  154. package/src/reactivity/SpatialInputSystem.js +1783 -0
  155. package/src/reactivity/index.js +93 -0
  156. package/src/render/CommandBuffer.js +465 -0
  157. package/src/render/MultiCanvasBridge.js +340 -0
  158. package/src/render/RenderCommand.js +514 -0
  159. package/src/render/RenderResourceRegistry.js +523 -0
  160. package/src/render/RenderState.js +552 -0
  161. package/src/render/RenderTarget.js +512 -0
  162. package/src/render/ShaderLoader.js +253 -0
  163. package/src/render/ShaderProgram.js +599 -0
  164. package/src/render/UnifiedRenderBridge.js +496 -0
  165. package/src/render/backends/WebGLBackend.js +1108 -0
  166. package/src/render/backends/WebGPUBackend.js +1409 -0
  167. package/src/render/commands/CommandBufferExecutor.js +607 -0
  168. package/src/render/commands/RenderCommandBuffer.js +661 -0
  169. package/src/render/commands/index.js +17 -0
  170. package/src/render/index.js +367 -0
  171. package/src/scene/Disposable.js +498 -0
  172. package/src/scene/MemoryPool.js +618 -0
  173. package/src/scene/Node4D.js +697 -0
  174. package/src/scene/ResourceManager.js +599 -0
  175. package/src/scene/Scene4D.js +540 -0
  176. package/src/scene/index.js +98 -0
  177. package/src/schemas/error.schema.json +84 -0
  178. package/src/schemas/extension.schema.json +88 -0
  179. package/src/schemas/index.js +214 -0
  180. package/src/schemas/parameters.schema.json +142 -0
  181. package/src/schemas/tool-pack.schema.json +44 -0
  182. package/src/schemas/tool-response.schema.json +127 -0
  183. package/src/shaders/common/fullscreen.vert.glsl +5 -0
  184. package/src/shaders/common/fullscreen.vert.wgsl +17 -0
  185. package/src/shaders/common/geometry24.glsl +65 -0
  186. package/src/shaders/common/geometry24.wgsl +54 -0
  187. package/src/shaders/common/rotation4d.glsl +85 -0
  188. package/src/shaders/common/rotation4d.wgsl +86 -0
  189. package/src/shaders/common/uniforms.glsl +44 -0
  190. package/src/shaders/common/uniforms.wgsl +48 -0
  191. package/src/shaders/faceted/faceted.frag.glsl +129 -0
  192. package/src/shaders/faceted/faceted.frag.wgsl +164 -0
  193. package/src/shaders/holographic/holographic.frag.glsl +406 -0
  194. package/src/shaders/holographic/holographic.frag.wgsl +185 -0
  195. package/src/shaders/quantum/quantum.frag.glsl +513 -0
  196. package/src/shaders/quantum/quantum.frag.wgsl +361 -0
  197. package/src/testing/ParallelTestFramework.js +519 -0
  198. package/src/testing/__snapshots__/exportFormats.test.js.snap +24 -0
  199. package/src/testing/exportFormats.test.js +8 -0
  200. package/src/testing/projections.test.js +14 -0
  201. package/src/testing/rotations.test.js +37 -0
  202. package/src/ui/InteractivityMenu.js +516 -0
  203. package/src/ui/StatusManager.js +96 -0
  204. package/src/ui/adaptive/renderers/webgpu/BufferLayout.ts +252 -0
  205. package/src/ui/adaptive/renderers/webgpu/PolytopeInstanceBuffer.ts +144 -0
  206. package/src/ui/adaptive/renderers/webgpu/TripleBufferedUniform.ts +170 -0
  207. package/src/ui/adaptive/renderers/webgpu/WebGPURenderer.ts +735 -0
  208. package/src/ui/adaptive/renderers/webgpu/index.ts +112 -0
  209. package/src/variations/VariationManager.js +431 -0
  210. package/src/viewer/AudioReactivity.js +505 -0
  211. package/src/viewer/CardBending.js +481 -0
  212. package/src/viewer/GalleryUI.js +832 -0
  213. package/src/viewer/ReactivityManager.js +590 -0
  214. package/src/viewer/TradingCardExporter.js +600 -0
  215. package/src/viewer/ViewerPortal.js +374 -0
  216. package/src/viewer/index.js +12 -0
  217. package/src/wasm/WasmLoader.js +296 -0
  218. package/src/wasm/index.js +132 -0
  219. package/tools/agentic/mcpTools.js +88 -0
  220. package/tools/cli/agent-cli.js +92 -0
  221. package/tools/export/formats.js +24 -0
  222. package/tools/math/rotation-baseline.mjs +64 -0
  223. package/tools/shader-sync-verify.js +937 -0
  224. package/tools/telemetry/manifestPipeline.js +141 -0
  225. package/tools/telemetry/telemetryEvents.js +35 -0
  226. package/types/adaptive-sdk.d.ts +185 -0
  227. package/types/advanced/AIPresetGenerator.d.ts +81 -0
  228. package/types/advanced/MIDIController.d.ts +100 -0
  229. package/types/advanced/OffscreenWorker.d.ts +82 -0
  230. package/types/advanced/WebGPUCompute.d.ts +52 -0
  231. package/types/advanced/WebXRRenderer.d.ts +77 -0
  232. package/types/advanced/index.d.ts +46 -0
  233. package/types/core/ErrorReporter.d.ts +50 -0
  234. package/types/core/VIB3Engine.d.ts +204 -0
  235. package/types/creative/ColorPresetsSystem.d.ts +91 -0
  236. package/types/creative/ParameterTimeline.d.ts +74 -0
  237. package/types/creative/PostProcessingPipeline.d.ts +109 -0
  238. package/types/creative/TransitionAnimator.d.ts +71 -0
  239. package/types/creative/index.d.ts +35 -0
  240. package/types/integrations/FigmaPlugin.d.ts +46 -0
  241. package/types/integrations/OBSMode.d.ts +74 -0
  242. package/types/integrations/ThreeJsPackage.d.ts +62 -0
  243. package/types/integrations/TouchDesignerExport.d.ts +36 -0
  244. package/types/integrations/Vib3React.d.ts +74 -0
  245. package/types/integrations/Vib3Svelte.d.ts +63 -0
  246. package/types/integrations/Vib3Vue.d.ts +55 -0
  247. package/types/integrations/index.d.ts +52 -0
  248. package/types/reactivity/SpatialInputSystem.d.ts +173 -0
  249. package/types/reactivity/index.d.ts +394 -0
  250. package/types/render/CommandBuffer.d.ts +169 -0
  251. package/types/render/RenderCommand.d.ts +312 -0
  252. package/types/render/RenderState.d.ts +279 -0
  253. package/types/render/RenderTarget.d.ts +254 -0
  254. package/types/render/ShaderProgram.d.ts +277 -0
  255. package/types/render/UnifiedRenderBridge.d.ts +143 -0
  256. package/types/render/WebGLBackend.d.ts +168 -0
  257. package/types/render/WebGPUBackend.d.ts +186 -0
  258. package/types/render/index.d.ts +141 -0
@@ -0,0 +1,396 @@
1
+ /**
2
+ * VIB34D Parameter Management System
3
+ * Unified parameter control for both holographic and polytopal systems
4
+ */
5
+
6
+ export class ParameterManager {
7
+ constructor() {
8
+ // Default parameter set combining both systems
9
+ this.params = {
10
+ // Current variation
11
+ variation: 0,
12
+
13
+ // 6D Rotation - 3D space rotations
14
+ rot4dXY: 0.0, // X-Y plane rotation (-6.28 to 6.28)
15
+ rot4dXZ: 0.0, // X-Z plane rotation (-6.28 to 6.28)
16
+ rot4dYZ: 0.0, // Y-Z plane rotation (-6.28 to 6.28)
17
+ // 4D hyperspace rotations
18
+ rot4dXW: 0.0, // X-W plane rotation (-6.28 to 6.28)
19
+ rot4dYW: 0.0, // Y-W plane rotation (-6.28 to 6.28)
20
+ rot4dZW: 0.0, // Z-W plane rotation (-6.28 to 6.28)
21
+ dimension: 3.5, // Dimensional level (3.0 to 4.5)
22
+
23
+ // Holographic Visualization
24
+ gridDensity: 15, // Geometric detail (4 to 30)
25
+ morphFactor: 1.0, // Shape transformation (0 to 2)
26
+ chaos: 0.2, // Randomization level (0 to 1)
27
+ speed: 1.0, // Animation speed (0.1 to 3)
28
+ hue: 200, // Color rotation (0 to 360)
29
+ intensity: 0.5, // Visual intensity (0 to 1)
30
+ saturation: 0.8, // Color saturation (0 to 1)
31
+
32
+ // Geometry selection
33
+ geometry: 0 // Current geometry type (0-7)
34
+ };
35
+
36
+ // Parameter definitions for validation and UI
37
+ this.parameterDefs = {
38
+ variation: { min: 0, max: 99, step: 1, type: 'int' },
39
+ // 3D Space Rotations
40
+ rot4dXY: { min: -6.28, max: 6.28, step: 0.01, type: 'float' },
41
+ rot4dXZ: { min: -6.28, max: 6.28, step: 0.01, type: 'float' },
42
+ rot4dYZ: { min: -6.28, max: 6.28, step: 0.01, type: 'float' },
43
+ // 4D Hyperspace Rotations
44
+ rot4dXW: { min: -2, max: 2, step: 0.01, type: 'float' },
45
+ rot4dYW: { min: -2, max: 2, step: 0.01, type: 'float' },
46
+ rot4dZW: { min: -2, max: 2, step: 0.01, type: 'float' },
47
+ dimension: { min: 3.0, max: 4.5, step: 0.01, type: 'float' },
48
+ gridDensity: { min: 4, max: 100, step: 0.1, type: 'float' },
49
+ morphFactor: { min: 0, max: 2, step: 0.01, type: 'float' },
50
+ chaos: { min: 0, max: 1, step: 0.01, type: 'float' },
51
+ speed: { min: 0.1, max: 3, step: 0.01, type: 'float' },
52
+ hue: { min: 0, max: 360, step: 1, type: 'int' },
53
+ intensity: { min: 0, max: 1, step: 0.01, type: 'float' },
54
+ saturation: { min: 0, max: 1, step: 0.01, type: 'float' },
55
+ geometry: { min: 0, max: 23, step: 1, type: 'int' }
56
+ };
57
+
58
+ // Default parameter backup for reset
59
+ this.defaults = { ...this.params };
60
+ }
61
+
62
+ /**
63
+ * Get all current parameters
64
+ */
65
+ getAllParameters() {
66
+ return { ...this.params };
67
+ }
68
+
69
+ /**
70
+ * Set a specific parameter with validation
71
+ */
72
+ setParameter(name, value) {
73
+ if (this.parameterDefs[name]) {
74
+ const def = this.parameterDefs[name];
75
+
76
+ // Coerce to number and reject NaN/Infinity
77
+ value = Number(value);
78
+ if (!Number.isFinite(value)) {
79
+ console.warn(`Parameter "${name}" received non-finite value, ignoring`);
80
+ return false;
81
+ }
82
+
83
+ // Clamp value to valid range
84
+ value = Math.max(def.min, Math.min(def.max, value));
85
+
86
+ // Apply type conversion
87
+ if (def.type === 'int') {
88
+ value = Math.round(value);
89
+ }
90
+
91
+ this.params[name] = value;
92
+ return true;
93
+ }
94
+
95
+ console.warn(`Unknown parameter: ${name}`);
96
+ return false;
97
+ }
98
+
99
+ /**
100
+ * Set multiple parameters at once
101
+ */
102
+ setParameters(paramObj) {
103
+ for (const [name, value] of Object.entries(paramObj)) {
104
+ this.setParameter(name, value);
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Get a specific parameter value
110
+ */
111
+ getParameter(name) {
112
+ return this.params[name];
113
+ }
114
+
115
+ /**
116
+ * Set geometry type with validation
117
+ */
118
+ setGeometry(geometryType) {
119
+ this.setParameter('geometry', geometryType);
120
+ }
121
+
122
+ /**
123
+ * Update parameters from UI controls
124
+ */
125
+ updateFromControls() {
126
+ const controlIds = [
127
+ 'variationSlider', 'rot4dXW', 'rot4dYW', 'rot4dZW', 'dimension',
128
+ 'gridDensity', 'morphFactor', 'chaos', 'speed', 'hue'
129
+ ];
130
+
131
+ controlIds.forEach(id => {
132
+ const element = document.getElementById(id);
133
+ if (element) {
134
+ const value = parseFloat(element.value);
135
+ if (!Number.isFinite(value)) return;
136
+
137
+ // Map slider IDs to parameter names
138
+ let paramName = id;
139
+ if (id === 'variationSlider') {
140
+ paramName = 'variation';
141
+ }
142
+
143
+ this.setParameter(paramName, value);
144
+ }
145
+ });
146
+ }
147
+
148
+ /**
149
+ * Update UI display values from current parameters
150
+ */
151
+ updateDisplayValues() {
152
+ // Update slider values
153
+ this.updateSliderValue('variationSlider', this.params.variation);
154
+ this.updateSliderValue('rot4dXW', this.params.rot4dXW);
155
+ this.updateSliderValue('rot4dYW', this.params.rot4dYW);
156
+ this.updateSliderValue('rot4dZW', this.params.rot4dZW);
157
+ this.updateSliderValue('dimension', this.params.dimension);
158
+ this.updateSliderValue('gridDensity', this.params.gridDensity);
159
+ this.updateSliderValue('morphFactor', this.params.morphFactor);
160
+ this.updateSliderValue('chaos', this.params.chaos);
161
+ this.updateSliderValue('speed', this.params.speed);
162
+ this.updateSliderValue('hue', this.params.hue);
163
+
164
+ // Update display texts
165
+ this.updateDisplayText('rot4dXWDisplay', this.params.rot4dXW.toFixed(2));
166
+ this.updateDisplayText('rot4dYWDisplay', this.params.rot4dYW.toFixed(2));
167
+ this.updateDisplayText('rot4dZWDisplay', this.params.rot4dZW.toFixed(2));
168
+ this.updateDisplayText('dimensionDisplay', this.params.dimension.toFixed(2));
169
+ this.updateDisplayText('gridDensityDisplay', this.params.gridDensity.toFixed(1));
170
+ this.updateDisplayText('morphFactorDisplay', this.params.morphFactor.toFixed(2));
171
+ this.updateDisplayText('chaosDisplay', this.params.chaos.toFixed(2));
172
+ this.updateDisplayText('speedDisplay', this.params.speed.toFixed(2));
173
+ this.updateDisplayText('hueDisplay', this.params.hue + '°');
174
+
175
+ // Update variation info
176
+ this.updateVariationInfo();
177
+
178
+ // Update geometry preset buttons
179
+ this.updateGeometryButtons();
180
+ }
181
+
182
+ updateSliderValue(id, value) {
183
+ const element = document.getElementById(id);
184
+ if (element) {
185
+ element.value = value;
186
+ }
187
+ }
188
+
189
+ updateDisplayText(id, text) {
190
+ const element = document.getElementById(id);
191
+ if (element) {
192
+ element.textContent = text;
193
+ }
194
+ }
195
+
196
+ updateVariationInfo() {
197
+ const variationDisplay = document.getElementById('currentVariationDisplay');
198
+ if (variationDisplay) {
199
+ const geometryNames = [
200
+ 'TETRAHEDRON LATTICE', 'HYPERCUBE LATTICE', 'SPHERE LATTICE', 'TORUS LATTICE',
201
+ 'KLEIN BOTTLE LATTICE', 'FRACTAL LATTICE', 'WAVE LATTICE', 'CRYSTAL LATTICE'
202
+ ];
203
+
204
+ const geometryType = Math.floor(this.params.variation / 4);
205
+ const geometryLevel = (this.params.variation % 4) + 1;
206
+ const geometryName = geometryNames[geometryType] || 'CUSTOM VARIATION';
207
+
208
+ variationDisplay.textContent = `${this.params.variation + 1} - ${geometryName}`;
209
+
210
+ if (this.params.variation < 30) {
211
+ variationDisplay.textContent += ` ${geometryLevel}`;
212
+ }
213
+ }
214
+ }
215
+
216
+ updateGeometryButtons() {
217
+ document.querySelectorAll('[data-geometry]').forEach(btn => {
218
+ btn.classList.toggle('active', parseInt(btn.dataset.geometry) === this.params.geometry);
219
+ });
220
+ }
221
+
222
+ /**
223
+ * Randomize all parameters
224
+ */
225
+ randomizeAll() {
226
+ // 3D Space Rotations
227
+ this.params.rot4dXY = Math.random() * 12.56 - 6.28;
228
+ this.params.rot4dXZ = Math.random() * 12.56 - 6.28;
229
+ this.params.rot4dYZ = Math.random() * 12.56 - 6.28;
230
+ // 4D Hyperspace Rotations
231
+ this.params.rot4dXW = Math.random() * 4 - 2;
232
+ this.params.rot4dYW = Math.random() * 4 - 2;
233
+ this.params.rot4dZW = Math.random() * 4 - 2;
234
+ // Visual Parameters
235
+ this.params.dimension = 3.0 + Math.random() * 1.5;
236
+ this.params.gridDensity = 4 + Math.random() * 26;
237
+ this.params.morphFactor = Math.random() * 2;
238
+ this.params.chaos = Math.random();
239
+ this.params.speed = 0.1 + Math.random() * 2.9;
240
+ this.params.hue = Math.random() * 360;
241
+ this.params.geometry = Math.floor(Math.random() * 24);
242
+ }
243
+
244
+ /**
245
+ * Reset to default parameters
246
+ */
247
+ resetToDefaults() {
248
+ this.params = { ...this.defaults };
249
+ }
250
+
251
+ /**
252
+ * Load parameter configuration
253
+ */
254
+ loadConfiguration(config) {
255
+ if (!config || typeof config !== 'object') return false;
256
+
257
+ // If it has a parameters sub-object, use that (export format)
258
+ const params = config.parameters || config;
259
+ if (typeof params !== 'object') return false;
260
+
261
+ for (const [key, value] of Object.entries(params)) {
262
+ if (this.parameterDefs[key]) {
263
+ this.setParameter(key, value);
264
+ }
265
+ }
266
+ return true;
267
+ }
268
+
269
+ /**
270
+ * Export current configuration
271
+ */
272
+ exportConfiguration() {
273
+ return {
274
+ type: 'vib34d-integrated-config',
275
+ version: '1.0.0',
276
+ timestamp: new Date().toISOString(),
277
+ name: `VIB34D Config ${new Date().toLocaleDateString()}`,
278
+ parameters: { ...this.params }
279
+ };
280
+ }
281
+
282
+ /**
283
+ * Generate variation-specific parameters
284
+ */
285
+ generateVariationParameters(variationIndex) {
286
+ if (variationIndex < 30) {
287
+ // Default variations with consistent patterns
288
+ const geometryType = Math.floor(variationIndex / 4);
289
+ const level = variationIndex % 4;
290
+
291
+ return {
292
+ geometry: geometryType,
293
+ gridDensity: 8 + (level * 4),
294
+ morphFactor: 0.5 + (level * 0.3),
295
+ chaos: level * 0.15,
296
+ speed: 0.8 + (level * 0.2),
297
+ hue: (geometryType * 45 + level * 15) % 360,
298
+ rot4dXW: (level - 1.5) * 0.5,
299
+ rot4dYW: (geometryType % 2) * 0.3,
300
+ rot4dZW: ((geometryType + level) % 3) * 0.2,
301
+ dimension: 3.2 + (level * 0.2)
302
+ };
303
+ } else {
304
+ // Custom variations - return current parameters
305
+ return { ...this.params };
306
+ }
307
+ }
308
+
309
+ /**
310
+ * Apply variation to current parameters
311
+ */
312
+ applyVariation(variationIndex) {
313
+ const variationParams = this.generateVariationParameters(variationIndex);
314
+ this.setParameters(variationParams);
315
+ this.params.variation = variationIndex;
316
+ }
317
+
318
+ /**
319
+ * Get HSV color values for current hue
320
+ */
321
+ getColorHSV() {
322
+ return {
323
+ h: this.params.hue,
324
+ s: 0.8, // Fixed saturation
325
+ v: 0.9 // Fixed value
326
+ };
327
+ }
328
+
329
+ /**
330
+ * Get RGB color values for current hue
331
+ */
332
+ getColorRGB() {
333
+ const hsv = this.getColorHSV();
334
+ return this.hsvToRgb(hsv.h, hsv.s, hsv.v);
335
+ }
336
+
337
+ /**
338
+ * Convert HSV to RGB
339
+ */
340
+ hsvToRgb(h, s, v) {
341
+ h = h / 60;
342
+ const c = v * s;
343
+ const x = c * (1 - Math.abs((h % 2) - 1));
344
+ const m = v - c;
345
+
346
+ let r, g, b;
347
+ if (h < 1) {
348
+ [r, g, b] = [c, x, 0];
349
+ } else if (h < 2) {
350
+ [r, g, b] = [x, c, 0];
351
+ } else if (h < 3) {
352
+ [r, g, b] = [0, c, x];
353
+ } else if (h < 4) {
354
+ [r, g, b] = [0, x, c];
355
+ } else if (h < 5) {
356
+ [r, g, b] = [x, 0, c];
357
+ } else {
358
+ [r, g, b] = [c, 0, x];
359
+ }
360
+
361
+ return {
362
+ r: Math.round((r + m) * 255),
363
+ g: Math.round((g + m) * 255),
364
+ b: Math.round((b + m) * 255)
365
+ };
366
+ }
367
+
368
+ /**
369
+ * Validate parameter configuration
370
+ */
371
+ validateConfiguration(config) {
372
+ if (!config || typeof config !== 'object') {
373
+ return { valid: false, error: 'Configuration must be an object' };
374
+ }
375
+
376
+ if (config.type !== 'vib34d-integrated-config') {
377
+ return { valid: false, error: 'Invalid configuration type' };
378
+ }
379
+
380
+ if (!config.parameters) {
381
+ return { valid: false, error: 'Missing parameters object' };
382
+ }
383
+
384
+ // Validate individual parameters
385
+ for (const [key, value] of Object.entries(config.parameters)) {
386
+ if (this.parameterDefs[key]) {
387
+ const def = this.parameterDefs[key];
388
+ if (typeof value !== 'number' || value < def.min || value > def.max) {
389
+ return { valid: false, error: `Invalid value for parameter ${key}: ${value}` };
390
+ }
391
+ }
392
+ }
393
+
394
+ return { valid: true };
395
+ }
396
+ }
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Renderer and resource manager contracts for unified engine integrations.
3
+ * These contracts provide a minimal API surface so renderers and resource managers
4
+ * can be swapped without rewriting orchestration layers.
5
+ *
6
+ * @fileoverview VIB3+ SDK Renderer Contract System
7
+ *
8
+ * Contract Methods:
9
+ * - init(context) Initialize renderer with optional context
10
+ * - resize(width, height, dpr) Handle canvas resize
11
+ * - render(frameState) Render a single frame
12
+ * - setActive(active) Activate/deactivate renderer
13
+ * - dispose() Clean up all resources
14
+ *
15
+ * Systems implementing this contract:
16
+ * - QuantumEngine (src/quantum/QuantumEngine.js)
17
+ * - FacetedSystem (src/faceted/FacetedSystem.js)
18
+ * - RealHolographicSystem (src/holograms/RealHolographicSystem.js)
19
+ */
20
+
21
+ /**
22
+ * Abstract renderer contract - base class for all visualization systems
23
+ * @abstract
24
+ */
25
+ export class RendererContract {
26
+ /**
27
+ * Initialize the renderer
28
+ * @param {Object} context - Initialization context (canvas, options, etc.)
29
+ * @returns {boolean|Promise<boolean>} Success status
30
+ */
31
+ init(context) {
32
+ throw new Error('RendererContract.init() must be implemented.');
33
+ }
34
+
35
+ /**
36
+ * Handle canvas resize
37
+ * @param {number} width - New width in pixels
38
+ * @param {number} height - New height in pixels
39
+ * @param {number} [pixelRatio=1] - Device pixel ratio
40
+ */
41
+ resize(width, height, pixelRatio = 1) {
42
+ throw new Error('RendererContract.resize() must be implemented.');
43
+ }
44
+
45
+ /**
46
+ * Render a single frame
47
+ * @param {Object} [frameState] - Frame state with time, parameters, audio data
48
+ * @param {number} [frameState.time] - Current time in seconds
49
+ * @param {Object} [frameState.params] - Visualization parameters
50
+ * @param {Object} [frameState.audio] - Audio reactivity data
51
+ */
52
+ render(frameState) {
53
+ throw new Error('RendererContract.render() must be implemented.');
54
+ }
55
+
56
+ /**
57
+ * Set active/inactive state
58
+ * @param {boolean} active - Whether the renderer should be active
59
+ */
60
+ setActive(active) {
61
+ throw new Error('RendererContract.setActive() must be implemented.');
62
+ }
63
+
64
+ /**
65
+ * Clean up all resources (WebGL contexts, audio, event listeners)
66
+ */
67
+ dispose() {
68
+ throw new Error('RendererContract.dispose() must be implemented.');
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Adapter base class that provides default implementations
74
+ * Systems can extend this instead of RendererContract for easier compliance
75
+ */
76
+ export class RendererContractAdapter extends RendererContract {
77
+ constructor() {
78
+ super();
79
+ this._initialized = false;
80
+ this._active = false;
81
+ this._width = 0;
82
+ this._height = 0;
83
+ this._pixelRatio = 1;
84
+ }
85
+
86
+ /**
87
+ * Check if renderer is initialized
88
+ * @returns {boolean}
89
+ */
90
+ get initialized() {
91
+ return this._initialized;
92
+ }
93
+
94
+ /**
95
+ * Check if renderer is active
96
+ * @returns {boolean}
97
+ */
98
+ get isActive() {
99
+ return this._active;
100
+ }
101
+
102
+ /**
103
+ * Default init - override in subclass
104
+ * @param {Object} context
105
+ * @returns {boolean}
106
+ */
107
+ init(context) {
108
+ this._initialized = true;
109
+ return true;
110
+ }
111
+
112
+ /**
113
+ * Default resize - stores dimensions, override to apply to canvases
114
+ * @param {number} width
115
+ * @param {number} height
116
+ * @param {number} pixelRatio
117
+ */
118
+ resize(width, height, pixelRatio = 1) {
119
+ this._width = width;
120
+ this._height = height;
121
+ this._pixelRatio = pixelRatio;
122
+ }
123
+
124
+ /**
125
+ * Default render - no-op, override in subclass
126
+ * @param {Object} frameState
127
+ */
128
+ render(frameState) {
129
+ // Override in subclass
130
+ }
131
+
132
+ /**
133
+ * Default setActive - stores state
134
+ * @param {boolean} active
135
+ */
136
+ setActive(active) {
137
+ this._active = active;
138
+ }
139
+
140
+ /**
141
+ * Default dispose - resets state
142
+ */
143
+ dispose() {
144
+ this._initialized = false;
145
+ this._active = false;
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Verify that a system implements the RendererContract
151
+ * @param {Object} system - System instance to verify
152
+ * @returns {{compliant: boolean, missing: string[], warnings: string[]}}
153
+ */
154
+ export function verifyRendererContract(system) {
155
+ const required = ['init', 'resize', 'render', 'setActive', 'dispose'];
156
+ const missing = [];
157
+ const warnings = [];
158
+
159
+ for (const method of required) {
160
+ if (typeof system[method] !== 'function') {
161
+ // Check for common aliases
162
+ const aliases = {
163
+ init: ['initialize'],
164
+ dispose: ['destroy', 'cleanup'],
165
+ render: ['renderFrame', 'draw']
166
+ };
167
+
168
+ const hasAlias = aliases[method]?.some(alias => typeof system[alias] === 'function');
169
+ if (hasAlias) {
170
+ warnings.push(`${method}() missing but alias exists - consider adding standard method`);
171
+ } else {
172
+ missing.push(method);
173
+ }
174
+ }
175
+ }
176
+
177
+ return {
178
+ compliant: missing.length === 0,
179
+ missing,
180
+ warnings
181
+ };
182
+ }
183
+
184
+ export class ResourceManagerContract {
185
+ registerResource(type, id, resource, bytes = 0) {
186
+ throw new Error('ResourceManagerContract.registerResource() must be implemented.');
187
+ }
188
+
189
+ releaseResource(type, id) {
190
+ throw new Error('ResourceManagerContract.releaseResource() must be implemented.');
191
+ }
192
+
193
+ disposeAll() {
194
+ throw new Error('ResourceManagerContract.disposeAll() must be implemented.');
195
+ }
196
+
197
+ getStats() {
198
+ throw new Error('ResourceManagerContract.getStats() must be implemented.');
199
+ }
200
+ }