@vib3code/sdk 2.0.3-canary.0c55e5a → 2.0.3-canary.183c93e

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 (89) hide show
  1. package/DOCS/AGENT_HARNESS_ARCHITECTURE.md +2 -0
  2. package/DOCS/ANDROID_DEPLOYMENT.md +59 -0
  3. package/DOCS/ARCHITECTURE.md +1 -0
  4. package/DOCS/CI_TESTING.md +2 -0
  5. package/DOCS/CLI_ONBOARDING.md +2 -0
  6. package/DOCS/CONTROL_REFERENCE.md +2 -0
  7. package/DOCS/CROSS_SITE_DESIGN_PATTERNS.md +2 -0
  8. package/DOCS/ENV_SETUP.md +2 -0
  9. package/DOCS/EPIC_SCROLL_EVENTS.md +2 -0
  10. package/DOCS/EXPANSION_DESIGN.md +979 -0
  11. package/DOCS/EXPANSION_DESIGN_ULTRA.md +389 -0
  12. package/DOCS/EXPORT_FORMATS.md +2 -0
  13. package/DOCS/GPU_DISPOSAL_GUIDE.md +2 -0
  14. package/DOCS/HANDOFF_LANDING_PAGE.md +2 -0
  15. package/DOCS/HANDOFF_SDK_DEVELOPMENT.md +2 -0
  16. package/DOCS/LICENSING_TIERS.md +2 -0
  17. package/DOCS/MASTER_PLAN_2026-01-31.md +4 -2
  18. package/DOCS/MULTIVIZ_CHOREOGRAPHY_PATTERNS.md +3 -1
  19. package/DOCS/OBS_SETUP_GUIDE.md +2 -0
  20. package/DOCS/OPTIMIZATION_PLAN_MATH.md +119 -0
  21. package/DOCS/PRODUCT_STRATEGY.md +2 -0
  22. package/DOCS/PROJECT_SETUP.md +2 -0
  23. package/DOCS/README.md +5 -3
  24. package/DOCS/REFERENCE_SCROLL_ANALYSIS.md +2 -0
  25. package/DOCS/RENDERER_LIFECYCLE.md +2 -0
  26. package/DOCS/REPO_MANIFEST.md +2 -0
  27. package/DOCS/ROADMAP.md +2 -0
  28. package/DOCS/SCROLL_TIMELINE_v3.md +2 -0
  29. package/DOCS/SITE_REFACTOR_PLAN.md +2 -0
  30. package/DOCS/STATUS.md +2 -0
  31. package/DOCS/SYSTEM_INVENTORY.md +4 -2
  32. package/DOCS/TELEMETRY_EXPORTS.md +2 -0
  33. package/DOCS/VISUAL_ANALYSIS_CLICKERSS.md +2 -0
  34. package/DOCS/VISUAL_ANALYSIS_FACETAD.md +2 -0
  35. package/DOCS/VISUAL_ANALYSIS_SIMONE.md +2 -0
  36. package/DOCS/VISUAL_ANALYSIS_TABLESIDE.md +2 -0
  37. package/DOCS/WEBGPU_STATUS.md +121 -38
  38. package/DOCS/XR_BENCHMARKS.md +2 -0
  39. package/DOCS/archive/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md +1 -34
  40. package/DOCS/archive/DEV_TRACK_ANALYSIS.md +1 -80
  41. package/DOCS/archive/DEV_TRACK_PLAN_2026-01-07.md +1 -42
  42. package/DOCS/archive/SESSION_014_PLAN.md +1 -195
  43. package/DOCS/archive/SESSION_LOG_2026-01-07.md +1 -56
  44. package/DOCS/archive/STRATEGIC_BLUEPRINT_2026-01-07.md +1 -72
  45. package/DOCS/archive/SYSTEM_AUDIT_2026-01-30.md +1 -741
  46. package/DOCS/archive/WEBGPU_STATUS_2026-02-15_STALE.md +1 -0
  47. package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-01-31.md +2 -0
  48. package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-06.md +2 -0
  49. package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-13.md +2 -0
  50. package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-15.md +2 -0
  51. package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-16.md +110 -0
  52. package/DOCS/dev-tracks/PERF_UPGRADE_2026-02-16.md +310 -0
  53. package/DOCS/dev-tracks/README.md +2 -0
  54. package/docs/webgpu-live.html +1 -1
  55. package/package.json +1 -1
  56. package/src/agent/mcp/MCPServer.js +195 -136
  57. package/src/agent/mcp/tools.js +45 -32
  58. package/src/experimental/GameLoop.js +72 -0
  59. package/src/experimental/LatticePhysics.js +100 -0
  60. package/src/experimental/LiveDirector.js +143 -0
  61. package/src/experimental/PlayerController4D.js +154 -0
  62. package/src/experimental/VIB3Actor.js +138 -0
  63. package/src/experimental/VIB3Compositor.js +117 -0
  64. package/src/experimental/VIB3Link.js +122 -0
  65. package/src/experimental/VIB3Orchestrator.js +146 -0
  66. package/src/experimental/VIB3Universe.js +109 -0
  67. package/src/experimental/demos/CrystalLabyrinth.js +202 -0
  68. package/src/faceted/FacetedSystem.js +19 -6
  69. package/src/geometry/generators/Crystal.js +2 -2
  70. package/src/holograms/HolographicVisualizer.js +58 -89
  71. package/src/math/Mat4x4.js +155 -23
  72. package/src/math/Rotor4D.js +69 -46
  73. package/src/math/Vec4.js +200 -103
  74. package/src/quantum/QuantumVisualizer.js +24 -20
  75. package/src/render/ShaderLoader.js +38 -0
  76. package/src/render/ShaderProgram.js +4 -4
  77. package/src/render/UnifiedRenderBridge.js +1 -1
  78. package/src/render/backends/WebGPUBackend.js +8 -4
  79. package/src/scene/Node4D.js +74 -24
  80. package/src/shaders/common/geometry24.glsl +65 -0
  81. package/src/shaders/common/geometry24.wgsl +54 -0
  82. package/src/shaders/common/rotation4d.glsl +4 -4
  83. package/src/shaders/common/rotation4d.wgsl +2 -2
  84. package/src/shaders/common/uniforms.wgsl +15 -8
  85. package/src/shaders/faceted/faceted.frag.wgsl +19 -6
  86. package/src/shaders/holographic/holographic.frag.wgsl +7 -5
  87. package/src/shaders/quantum/quantum.frag.wgsl +7 -5
  88. package/src/ui/adaptive/renderers/webgpu/WebGPURenderer.ts +2 -2
  89. package/tools/shader-sync-verify.js +6 -4
@@ -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;
@@ -293,7 +292,7 @@ export class HolographicVisualizer {
293
292
  // ========================================
294
293
  vec3 warpHypersphereCore(vec3 p, int geometryIndex, vec2 mouseDelta) {
295
294
  float radius = length(p);
296
- 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);
297
296
  float w = sin(radius * (1.3 + float(geometryIndex) * 0.12) + u_time * 0.0008 * u_speed);
298
297
  w *= (0.4 + morphBlend * 0.45);
299
298
 
@@ -315,7 +314,7 @@ export class HolographicVisualizer {
315
314
  vec3 c3 = normalize(vec3(-1.0, 1.0, -1.0));
316
315
  vec3 c4 = normalize(vec3(1.0, -1.0, -1.0));
317
316
 
318
- 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);
319
318
  float basisMix = dot(p, c1) * 0.14 + dot(p, c2) * 0.1 + dot(p, c3) * 0.08;
320
319
  float w = sin(basisMix * 5.5 + u_time * 0.0009 * u_speed);
321
320
  w *= cos(dot(p, c4) * 4.2 - u_time * 0.0007 * u_speed);
@@ -551,12 +550,12 @@ export class HolographicVisualizer {
551
550
  float audioDensityMod = 1.0 + u_audioDensityBoost * 0.5;
552
551
  // Controlled density calculation - breathing modulation added
553
552
  float breathDensityMod = 1.0 + u_breath * 0.1;
554
- float baseDensity = u_density * u_roleDensity * breathDensityMod;
553
+ float baseDensity = u_gridDensity * u_roleDensity * breathDensityMod;
555
554
 
556
555
  float densityVariations = (u_densityVariation * 0.3 + (scrollDensityMod - 1.0) * 0.4 + (audioDensityMod - 1.0) * 0.2);
557
556
  float roleDensity = baseDensity + densityVariations;
558
557
 
559
- 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;
560
559
  float lattice = getDynamicGeometry(p, roleDensity, morphedGeometry);
561
560
 
562
561
  // Enhanced holographic color processing
@@ -590,9 +589,9 @@ export class HolographicVisualizer {
590
589
  color = rgbGlitch(color, uv, enhancedChaos);
591
590
 
592
591
  // Apply morph distortion to position
593
- vec2 morphDistortion = vec2(sin(uv.y * 10.0 + u_time * 0.001) * u_morph * 0.1,
594
- cos(uv.x * 10.0 + u_time * 0.001) * u_morph * 0.1);
595
- 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);
596
595
 
597
596
  // Enhanced holographic interaction effects
598
597
  float mouseDist = length(uv - (u_mouse - 0.5) * vec2(aspectRatio, 1.0));
@@ -621,7 +620,7 @@ export class HolographicVisualizer {
621
620
  time: this.gl.getUniformLocation(this.program, 'u_time'),
622
621
  mouse: this.gl.getUniformLocation(this.program, 'u_mouse'),
623
622
  geometry: this.gl.getUniformLocation(this.program, 'u_geometry'),
624
- density: this.gl.getUniformLocation(this.program, 'u_density'),
623
+ gridDensity: this.gl.getUniformLocation(this.program, 'u_gridDensity'),
625
624
  speed: this.gl.getUniformLocation(this.program, 'u_speed'),
626
625
  color: this.gl.getUniformLocation(this.program, 'u_color'),
627
626
  intensity: this.gl.getUniformLocation(this.program, 'u_intensity'),
@@ -632,9 +631,8 @@ export class HolographicVisualizer {
632
631
  mouseIntensity: this.gl.getUniformLocation(this.program, 'u_mouseIntensity'),
633
632
  clickIntensity: this.gl.getUniformLocation(this.program, 'u_clickIntensity'),
634
633
  densityVariation: this.gl.getUniformLocation(this.program, 'u_densityVariation'),
635
- geometryType: this.gl.getUniformLocation(this.program, 'u_geometryType'),
636
634
  chaos: this.gl.getUniformLocation(this.program, 'u_chaos'),
637
- morph: this.gl.getUniformLocation(this.program, 'u_morph'),
635
+ morphFactor: this.gl.getUniformLocation(this.program, 'u_morphFactor'),
638
636
  touchMorph: this.gl.getUniformLocation(this.program, 'u_touchMorph'),
639
637
  touchChaos: this.gl.getUniformLocation(this.program, 'u_touchChaos'),
640
638
  scrollParallax: this.gl.getUniformLocation(this.program, 'u_scrollParallax'),
@@ -894,11 +892,11 @@ export class HolographicVisualizer {
894
892
  this.gl.uniform2f(this.uniforms.resolution, this.canvas.width, this.canvas.height);
895
893
  this.gl.uniform1f(this.uniforms.time, time);
896
894
  this.gl.uniform2f(this.uniforms.mouse, this.mouseX, this.mouseY);
897
- this.gl.uniform1f(this.uniforms.geometryType, this.variantParams.geometryType || 0);
898
- this.gl.uniform1f(this.uniforms.density, this.variantParams.density || 1.0);
899
- // FIX: Controlled speed calculation - base speed controls main movement, audio provides subtle boost
900
- const baseSpeed = (this.variantParams.speed || 0.5) * 0.2; // Much slower base speed
901
- 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;
902
900
  this.gl.uniform1f(this.uniforms.speed, baseSpeed + audioBoost);
903
901
  this.gl.uniform3fv(this.uniforms.color, new Float32Array(rgbColor));
904
902
  this.gl.uniform1f(this.uniforms.intensity, (this.variantParams.intensity || 0.5) * this.roleParams.intensity);
@@ -909,9 +907,8 @@ export class HolographicVisualizer {
909
907
  this.gl.uniform1f(this.uniforms.mouseIntensity, this.mouseIntensity);
910
908
  this.gl.uniform1f(this.uniforms.clickIntensity, this.clickIntensity);
911
909
  this.gl.uniform1f(this.uniforms.densityVariation, this.densityVariation);
912
- this.gl.uniform1f(this.uniforms.geometryType, this.variantParams.geometryType !== undefined ? this.variantParams.geometryType : this.variant || 0);
913
910
  this.gl.uniform1f(this.uniforms.chaos, this.variantParams.chaos || 0.0);
914
- this.gl.uniform1f(this.uniforms.morph, this.variantParams.morph || 0.0);
911
+ this.gl.uniform1f(this.uniforms.morphFactor, this.variantParams.morphFactor || 0.0);
915
912
 
916
913
  // Touch and scroll uniforms
917
914
  this.gl.uniform1f(this.uniforms.touchMorph, this.touchMorph);
@@ -1001,62 +998,34 @@ export class HolographicVisualizer {
1001
998
  }
1002
999
 
1003
1000
  /**
1004
- * CRITICAL FIX: Update visualization parameters with immediate re-render
1005
- * 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.
1006
1004
  */
1007
1005
  updateParameters(params) {
1008
1006
  if (!params || typeof params !== 'object') return;
1009
- // Update variant parameters with proper mapping and scaling
1010
1007
  if (this.variantParams) {
1011
1008
  Object.keys(params).forEach(param => {
1012
- const mappedParam = this.mapParameterName(param);
1013
- if (mappedParam !== null) {
1014
- let scaledValue = params[param];
1015
- // Guard against NaN/Infinity reaching GPU uniforms
1016
- if (typeof scaledValue !== 'number' || !Number.isFinite(scaledValue)) return;
1017
-
1018
- // FIX: Scale gridDensity to reasonable holographic density range (back to normal levels)
1019
- if (param === 'gridDensity') {
1020
- // Convert gridDensity (5-100) to holographic density (0.3-2.5) - reasonable range
1021
- // Formula: density = 0.3 + (gridDensity - 5) / (100 - 5) * (2.5 - 0.3)
1022
- scaledValue = 0.3 + (parseFloat(params[param]) - 5) / 95 * 2.2;
1023
- console.log(`🔧 Density scaling: gridDensity=${params[param]} density=${scaledValue.toFixed(3)} (normal range)`);
1024
- }
1025
-
1026
- this.variantParams[mappedParam] = scaledValue;
1027
-
1028
- // Handle special parameter types
1029
- if (mappedParam === 'geometryType') {
1030
- // Regenerate role params with new geometry
1031
- this.roleParams = this.generateRoleParams(this.role);
1032
- }
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);
1033
1023
  }
1034
1024
  });
1035
1025
  }
1036
-
1026
+
1037
1027
  // Don't call render() here - engine will call it to prevent infinite loop
1038
1028
  }
1039
-
1040
- /**
1041
- * Map global parameter names to holographic system parameter names
1042
- */
1043
- mapParameterName(globalParam) {
1044
- const paramMap = {
1045
- 'gridDensity': 'density',
1046
- 'morphFactor': 'morph',
1047
- 'rot4dXW': 'rot4dXW',
1048
- 'rot4dYW': 'rot4dYW',
1049
- 'rot4dZW': 'rot4dZW',
1050
- 'hue': 'hue',
1051
- 'intensity': 'intensity',
1052
- 'saturation': 'saturation',
1053
- 'chaos': 'chaos',
1054
- 'speed': 'speed',
1055
- 'geometry': 'geometryType',
1056
- 'breath': 'breath'
1057
- };
1058
- return paramMap[globalParam] || globalParam;
1059
- }
1060
1029
 
1061
1030
  /**
1062
1031
  * Clean up all WebGL resources and event listeners
@@ -157,10 +157,11 @@ export class Mat4x4 {
157
157
  /**
158
158
  * Multiply two matrices
159
159
  * @param {Mat4x4} m - Right operand
160
+ * @param {Mat4x4} [target=null] - Optional target matrix to store result
160
161
  * @returns {Mat4x4} New matrix = this * m
161
162
  */
162
- multiply(m) {
163
- const out = new Mat4x4();
163
+ multiply(m, target = null) {
164
+ const out = target || new Mat4x4();
164
165
  const r = out.data;
165
166
  const a = this.data;
166
167
  const b = m.data;
@@ -259,16 +260,22 @@ export class Mat4x4 {
259
260
  /**
260
261
  * Transform a Vec4 by this matrix
261
262
  * @param {Vec4} v
263
+ * @param {Vec4} [target=null] - Optional target vector to store result
262
264
  * @returns {Vec4} Transformed vector
263
265
  */
264
- multiplyVec4(v) {
266
+ multiplyVec4(v, target = null) {
265
267
  const m = this.data;
266
- return new Vec4(
267
- m[0] * v.x + m[4] * v.y + m[8] * v.z + m[12] * v.w,
268
- m[1] * v.x + m[5] * v.y + m[9] * v.z + m[13] * v.w,
269
- m[2] * v.x + m[6] * v.y + m[10] * v.z + m[14] * v.w,
270
- m[3] * v.x + m[7] * v.y + m[11] * v.z + m[15] * v.w
271
- );
268
+ const out = target || new Vec4();
269
+
270
+ // Cache components to support aliasing (target === v)
271
+ const x = v.x, y = v.y, z = v.z, w = v.w;
272
+
273
+ out.x = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
274
+ out.y = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
275
+ out.z = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
276
+ out.w = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
277
+
278
+ return out;
272
279
  }
273
280
 
274
281
  /**
@@ -310,27 +317,36 @@ export class Mat4x4 {
310
317
  /**
311
318
  * Add another matrix
312
319
  * @param {Mat4x4} m
320
+ * @param {Mat4x4} [target=null] - Optional target matrix
313
321
  * @returns {Mat4x4} New matrix
314
322
  */
315
- add(m) {
316
- const result = new Float32Array(16);
323
+ add(m, target = null) {
324
+ const out = target || new Mat4x4();
325
+ const r = out.data;
326
+ const a = this.data;
327
+ const b = m.data;
328
+
317
329
  for (let i = 0; i < 16; i++) {
318
- result[i] = this.data[i] + m.data[i];
330
+ r[i] = a[i] + b[i];
319
331
  }
320
- return new Mat4x4(result);
332
+ return out;
321
333
  }
322
334
 
323
335
  /**
324
336
  * Multiply by scalar
325
337
  * @param {number} s
338
+ * @param {Mat4x4} [target=null] - Optional target matrix
326
339
  * @returns {Mat4x4} New matrix
327
340
  */
328
- scale(s) {
329
- const result = new Float32Array(16);
341
+ scale(s, target = null) {
342
+ const out = target || new Mat4x4();
343
+ const r = out.data;
344
+ const a = this.data;
345
+
330
346
  for (let i = 0; i < 16; i++) {
331
- result[i] = this.data[i] * s;
347
+ r[i] = a[i] * s;
332
348
  }
333
- return new Mat4x4(result);
349
+ return out;
334
350
  }
335
351
 
336
352
  /**
@@ -547,6 +563,122 @@ export class Mat4x4 {
547
563
  return new Mat4x4(json.data);
548
564
  }
549
565
 
566
+ // ========== IN-PLACE ROTATIONS ==========
567
+
568
+ /**
569
+ * Rotate in XY plane in place
570
+ * @param {number} angle
571
+ * @returns {Mat4x4} this
572
+ */
573
+ rotateXY(angle) {
574
+ const c = Math.cos(angle);
575
+ const s = Math.sin(angle);
576
+ const m = this.data;
577
+
578
+ for (let i = 0; i < 4; i++) {
579
+ const a0 = m[i]; // Col 0
580
+ const a1 = m[i + 4]; // Col 1
581
+ m[i] = a0 * c + a1 * s;
582
+ m[i + 4] = -a0 * s + a1 * c;
583
+ }
584
+ return this;
585
+ }
586
+
587
+ /**
588
+ * Rotate in XZ plane in place
589
+ * @param {number} angle
590
+ * @returns {Mat4x4} this
591
+ */
592
+ rotateXZ(angle) {
593
+ const c = Math.cos(angle);
594
+ const s = Math.sin(angle);
595
+ const m = this.data;
596
+
597
+ for (let i = 0; i < 4; i++) {
598
+ const a0 = m[i]; // Col 0
599
+ const a2 = m[i + 8]; // Col 2
600
+ m[i] = a0 * c - a2 * s;
601
+ m[i + 8] = a0 * s + a2 * c;
602
+ }
603
+ return this;
604
+ }
605
+
606
+ /**
607
+ * Rotate in YZ plane in place
608
+ * @param {number} angle
609
+ * @returns {Mat4x4} this
610
+ */
611
+ rotateYZ(angle) {
612
+ const c = Math.cos(angle);
613
+ const s = Math.sin(angle);
614
+ const m = this.data;
615
+
616
+ for (let i = 0; i < 4; i++) {
617
+ const a1 = m[i + 4]; // Col 1
618
+ const a2 = m[i + 8]; // Col 2
619
+ m[i + 4] = a1 * c + a2 * s;
620
+ m[i + 8] = -a1 * s + a2 * c;
621
+ }
622
+ return this;
623
+ }
624
+
625
+ /**
626
+ * Rotate in XW plane in place
627
+ * @param {number} angle
628
+ * @returns {Mat4x4} this
629
+ */
630
+ rotateXW(angle) {
631
+ const c = Math.cos(angle);
632
+ const s = Math.sin(angle);
633
+ const m = this.data;
634
+
635
+ for (let i = 0; i < 4; i++) {
636
+ const a0 = m[i]; // Col 0
637
+ const a3 = m[i + 12]; // Col 3
638
+ m[i] = a0 * c + a3 * s;
639
+ m[i + 12] = -a0 * s + a3 * c;
640
+ }
641
+ return this;
642
+ }
643
+
644
+ /**
645
+ * Rotate in YW plane in place
646
+ * @param {number} angle
647
+ * @returns {Mat4x4} this
648
+ */
649
+ rotateYW(angle) {
650
+ const c = Math.cos(angle);
651
+ const s = Math.sin(angle);
652
+ const m = this.data;
653
+
654
+ for (let i = 0; i < 4; i++) {
655
+ const a1 = m[i + 4]; // Col 1
656
+ const a3 = m[i + 12]; // Col 3
657
+ m[i + 4] = a1 * c + a3 * s;
658
+ m[i + 12] = -a1 * s + a3 * c;
659
+ }
660
+ return this;
661
+ }
662
+
663
+ /**
664
+ * Rotate in ZW plane in place
665
+ * @param {number} angle
666
+ * @returns {Mat4x4} this
667
+ */
668
+ rotateZW(angle) {
669
+ const c = Math.cos(angle);
670
+ const s = Math.sin(angle);
671
+ const m = this.data;
672
+
673
+ for (let i = 0; i < 4; i++) {
674
+ const a2 = m[i + 8]; // Col 2
675
+ const a3 = m[i + 12]; // Col 3
676
+ m[i + 8] = a2 * c + a3 * s;
677
+ m[i + 12] = -a2 * s + a3 * c;
678
+ }
679
+ return this;
680
+ }
681
+
550
682
  // ========== ROTATION MATRICES FOR ALL 6 PLANES ==========
551
683
 
552
684
  /**
@@ -681,12 +813,12 @@ export class Mat4x4 {
681
813
  static rotationFromAngles(angles) {
682
814
  let result = Mat4x4.identity();
683
815
 
684
- if (angles.xy) result = result.multiply(Mat4x4.rotationXY(angles.xy));
685
- if (angles.xz) result = result.multiply(Mat4x4.rotationXZ(angles.xz));
686
- if (angles.yz) result = result.multiply(Mat4x4.rotationYZ(angles.yz));
687
- if (angles.xw) result = result.multiply(Mat4x4.rotationXW(angles.xw));
688
- if (angles.yw) result = result.multiply(Mat4x4.rotationYW(angles.yw));
689
- if (angles.zw) result = result.multiply(Mat4x4.rotationZW(angles.zw));
816
+ if (angles.xy) result.rotateXY(angles.xy);
817
+ if (angles.xz) result.rotateXZ(angles.xz);
818
+ if (angles.yz) result.rotateYZ(angles.yz);
819
+ if (angles.xw) result.rotateXW(angles.xw);
820
+ if (angles.yw) result.rotateYW(angles.yw);
821
+ if (angles.zw) result.rotateZW(angles.zw);
690
822
 
691
823
  return result;
692
824
  }