@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.
- package/DOCS/AGENT_HARNESS_ARCHITECTURE.md +2 -0
- package/DOCS/ANDROID_DEPLOYMENT.md +59 -0
- package/DOCS/ARCHITECTURE.md +1 -0
- package/DOCS/CI_TESTING.md +2 -0
- package/DOCS/CLI_ONBOARDING.md +2 -0
- package/DOCS/CONTROL_REFERENCE.md +2 -0
- package/DOCS/CROSS_SITE_DESIGN_PATTERNS.md +2 -0
- package/DOCS/ENV_SETUP.md +2 -0
- package/DOCS/EPIC_SCROLL_EVENTS.md +2 -0
- package/DOCS/EXPANSION_DESIGN.md +979 -0
- package/DOCS/EXPANSION_DESIGN_ULTRA.md +389 -0
- package/DOCS/EXPORT_FORMATS.md +2 -0
- package/DOCS/GPU_DISPOSAL_GUIDE.md +2 -0
- package/DOCS/HANDOFF_LANDING_PAGE.md +2 -0
- package/DOCS/HANDOFF_SDK_DEVELOPMENT.md +2 -0
- package/DOCS/LICENSING_TIERS.md +2 -0
- package/DOCS/MASTER_PLAN_2026-01-31.md +4 -2
- package/DOCS/MULTIVIZ_CHOREOGRAPHY_PATTERNS.md +3 -1
- package/DOCS/OBS_SETUP_GUIDE.md +2 -0
- package/DOCS/OPTIMIZATION_PLAN_MATH.md +119 -0
- package/DOCS/PRODUCT_STRATEGY.md +2 -0
- package/DOCS/PROJECT_SETUP.md +2 -0
- package/DOCS/README.md +5 -3
- package/DOCS/REFERENCE_SCROLL_ANALYSIS.md +2 -0
- package/DOCS/RENDERER_LIFECYCLE.md +2 -0
- package/DOCS/REPO_MANIFEST.md +2 -0
- package/DOCS/ROADMAP.md +2 -0
- package/DOCS/SCROLL_TIMELINE_v3.md +2 -0
- package/DOCS/SITE_REFACTOR_PLAN.md +2 -0
- package/DOCS/STATUS.md +2 -0
- package/DOCS/SYSTEM_INVENTORY.md +4 -2
- package/DOCS/TELEMETRY_EXPORTS.md +2 -0
- package/DOCS/VISUAL_ANALYSIS_CLICKERSS.md +2 -0
- package/DOCS/VISUAL_ANALYSIS_FACETAD.md +2 -0
- package/DOCS/VISUAL_ANALYSIS_SIMONE.md +2 -0
- package/DOCS/VISUAL_ANALYSIS_TABLESIDE.md +2 -0
- package/DOCS/WEBGPU_STATUS.md +121 -38
- package/DOCS/XR_BENCHMARKS.md +2 -0
- package/DOCS/archive/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md +1 -34
- package/DOCS/archive/DEV_TRACK_ANALYSIS.md +1 -80
- package/DOCS/archive/DEV_TRACK_PLAN_2026-01-07.md +1 -42
- package/DOCS/archive/SESSION_014_PLAN.md +1 -195
- package/DOCS/archive/SESSION_LOG_2026-01-07.md +1 -56
- package/DOCS/archive/STRATEGIC_BLUEPRINT_2026-01-07.md +1 -72
- package/DOCS/archive/SYSTEM_AUDIT_2026-01-30.md +1 -741
- package/DOCS/archive/WEBGPU_STATUS_2026-02-15_STALE.md +1 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-01-31.md +2 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-06.md +2 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-13.md +2 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-15.md +2 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-16.md +110 -0
- package/DOCS/dev-tracks/PERF_UPGRADE_2026-02-16.md +310 -0
- package/DOCS/dev-tracks/README.md +2 -0
- package/docs/webgpu-live.html +1 -1
- package/package.json +1 -1
- package/src/agent/mcp/MCPServer.js +195 -136
- package/src/agent/mcp/tools.js +45 -32
- package/src/experimental/GameLoop.js +72 -0
- package/src/experimental/LatticePhysics.js +100 -0
- package/src/experimental/LiveDirector.js +143 -0
- package/src/experimental/PlayerController4D.js +154 -0
- package/src/experimental/VIB3Actor.js +138 -0
- package/src/experimental/VIB3Compositor.js +117 -0
- package/src/experimental/VIB3Link.js +122 -0
- package/src/experimental/VIB3Orchestrator.js +146 -0
- package/src/experimental/VIB3Universe.js +109 -0
- package/src/experimental/demos/CrystalLabyrinth.js +202 -0
- package/src/faceted/FacetedSystem.js +19 -6
- package/src/geometry/generators/Crystal.js +2 -2
- package/src/holograms/HolographicVisualizer.js +58 -89
- package/src/math/Mat4x4.js +155 -23
- package/src/math/Rotor4D.js +69 -46
- package/src/math/Vec4.js +200 -103
- package/src/quantum/QuantumVisualizer.js +24 -20
- package/src/render/ShaderLoader.js +38 -0
- package/src/render/ShaderProgram.js +4 -4
- package/src/render/UnifiedRenderBridge.js +1 -1
- package/src/render/backends/WebGPUBackend.js +8 -4
- package/src/scene/Node4D.js +74 -24
- package/src/shaders/common/geometry24.glsl +65 -0
- package/src/shaders/common/geometry24.wgsl +54 -0
- package/src/shaders/common/rotation4d.glsl +4 -4
- package/src/shaders/common/rotation4d.wgsl +2 -2
- package/src/shaders/common/uniforms.wgsl +15 -8
- package/src/shaders/faceted/faceted.frag.wgsl +19 -6
- package/src/shaders/holographic/holographic.frag.wgsl +7 -5
- package/src/shaders/quantum/quantum.frag.wgsl +7 -5
- package/src/ui/adaptive/renderers/webgpu/WebGPURenderer.ts +2 -2
- package/tools/shader-sync-verify.js +6 -4
|
@@ -6,6 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
import { GeometryLibrary } from '../geometry/GeometryLibrary.js';
|
|
8
8
|
|
|
9
|
+
// Role-specific intensity values for 5-layer canvas architecture.
|
|
10
|
+
// IMPORTANT: Must stay in sync with shader epsilon comparisons in the fragment shader
|
|
11
|
+
// at the "LAYER-BY-LAYER COLOR SYSTEM" section (search for layerIndex).
|
|
12
|
+
const ROLE_INTENSITIES = {
|
|
13
|
+
'background': 0.4,
|
|
14
|
+
'shadow': 0.6,
|
|
15
|
+
'content': 1.0,
|
|
16
|
+
'highlight': 1.3,
|
|
17
|
+
'accent': 1.6
|
|
18
|
+
};
|
|
19
|
+
|
|
9
20
|
export class QuantumHolographicVisualizer {
|
|
10
21
|
constructor(canvasIdOrElement, role, reactivity, variant) {
|
|
11
22
|
this.canvas = (canvasIdOrElement instanceof HTMLCanvasElement)
|
|
@@ -14,6 +25,7 @@ export class QuantumHolographicVisualizer {
|
|
|
14
25
|
this.role = role;
|
|
15
26
|
this.reactivity = reactivity;
|
|
16
27
|
this.variant = variant;
|
|
28
|
+
this._canvasLabel = typeof canvasIdOrElement === 'string' ? canvasIdOrElement : canvasIdOrElement?.id || 'unknown';
|
|
17
29
|
|
|
18
30
|
// CRITICAL FIX: Define contextOptions as instance property to match SmartCanvasPool
|
|
19
31
|
this.contextOptions = {
|
|
@@ -34,9 +46,9 @@ export class QuantumHolographicVisualizer {
|
|
|
34
46
|
this.canvas.getContext('experimental-webgl', this.contextOptions);
|
|
35
47
|
|
|
36
48
|
if (!this.gl) {
|
|
37
|
-
console.error(`WebGL not supported for ${
|
|
49
|
+
console.error(`WebGL not supported for ${this._canvasLabel}`);
|
|
38
50
|
if (window.mobileDebug) {
|
|
39
|
-
window.mobileDebug.log(`❌ ${
|
|
51
|
+
window.mobileDebug.log(`❌ ${this._canvasLabel}: WebGL context creation failed`);
|
|
40
52
|
}
|
|
41
53
|
// Show user-friendly error instead of white screen
|
|
42
54
|
this.showWebGLError();
|
|
@@ -44,7 +56,7 @@ export class QuantumHolographicVisualizer {
|
|
|
44
56
|
} else {
|
|
45
57
|
if (window.mobileDebug) {
|
|
46
58
|
const version = this.gl.getParameter(this.gl.VERSION);
|
|
47
|
-
window.mobileDebug.log(`✅ ${
|
|
59
|
+
window.mobileDebug.log(`✅ ${this._canvasLabel}: WebGL context created - ${version}`);
|
|
48
60
|
}
|
|
49
61
|
}
|
|
50
62
|
|
|
@@ -59,15 +71,15 @@ export class QuantumHolographicVisualizer {
|
|
|
59
71
|
this._onContextLost = (e) => {
|
|
60
72
|
e.preventDefault();
|
|
61
73
|
this._contextLost = true;
|
|
62
|
-
console.warn(`WebGL context lost for ${
|
|
74
|
+
console.warn(`WebGL context lost for ${this._canvasLabel}`);
|
|
63
75
|
};
|
|
64
76
|
this._onContextRestored = () => {
|
|
65
|
-
console.log(`WebGL context restored for ${
|
|
77
|
+
console.log(`WebGL context restored for ${this._canvasLabel}`);
|
|
66
78
|
this._contextLost = false;
|
|
67
79
|
try {
|
|
68
80
|
this.init();
|
|
69
81
|
} catch (err) {
|
|
70
|
-
console.error(`Failed to reinit after context restore for ${
|
|
82
|
+
console.error(`Failed to reinit after context restore for ${this._canvasLabel}:`, err);
|
|
71
83
|
}
|
|
72
84
|
};
|
|
73
85
|
this.canvas.addEventListener('webglcontextlost', this._onContextLost);
|
|
@@ -688,11 +700,12 @@ void main() {
|
|
|
688
700
|
|
|
689
701
|
// LAYER-BY-LAYER COLOR SYSTEM with user hue/saturation/intensity controls
|
|
690
702
|
// Determine canvas layer from role/variant (0=background, 1=shadow, 2=content, 3=highlight, 4=accent)
|
|
703
|
+
// Values must match ROLE_INTENSITIES in JS: bg=0.4, shadow=0.6, content=1.0, highlight=1.3, accent=1.6
|
|
691
704
|
int layerIndex = 0;
|
|
692
|
-
if (u_roleIntensity
|
|
693
|
-
else if (u_roleIntensity
|
|
694
|
-
else if (u_roleIntensity
|
|
695
|
-
else if (u_roleIntensity
|
|
705
|
+
if (abs(u_roleIntensity - 0.6) < 0.05) layerIndex = 1; // shadow layer
|
|
706
|
+
else if (abs(u_roleIntensity - 1.0) < 0.05) layerIndex = 2; // content layer
|
|
707
|
+
else if (abs(u_roleIntensity - 1.3) < 0.05) layerIndex = 3; // highlight layer
|
|
708
|
+
else if (abs(u_roleIntensity - 1.6) < 0.05) layerIndex = 4; // accent layer
|
|
696
709
|
|
|
697
710
|
// Get layer-specific base color using user hue/saturation controls
|
|
698
711
|
float colorTime = timeSpeed * 2.0 + value * 3.0;
|
|
@@ -1016,15 +1029,6 @@ void main() {
|
|
|
1016
1029
|
this._renderParamsLogged = true;
|
|
1017
1030
|
}
|
|
1018
1031
|
|
|
1019
|
-
// Role-specific intensity for quantum effects
|
|
1020
|
-
const roleIntensities = {
|
|
1021
|
-
'background': 0.4,
|
|
1022
|
-
'shadow': 0.6,
|
|
1023
|
-
'content': 1.0,
|
|
1024
|
-
'highlight': 1.3,
|
|
1025
|
-
'accent': 1.6
|
|
1026
|
-
};
|
|
1027
|
-
|
|
1028
1032
|
const time = Date.now() - this.startTime;
|
|
1029
1033
|
|
|
1030
1034
|
// Set uniforms
|
|
@@ -1068,7 +1072,7 @@ void main() {
|
|
|
1068
1072
|
this.gl.uniform1f(this.uniforms.rot4dZW, this.params.rot4dZW || 0.0);
|
|
1069
1073
|
this.gl.uniform1f(this.uniforms.mouseIntensity, this.mouseIntensity);
|
|
1070
1074
|
this.gl.uniform1f(this.uniforms.clickIntensity, this.clickIntensity);
|
|
1071
|
-
this.gl.uniform1f(this.uniforms.roleIntensity,
|
|
1075
|
+
this.gl.uniform1f(this.uniforms.roleIntensity, ROLE_INTENSITIES[this.role] || 1.0);
|
|
1072
1076
|
this.gl.uniform1f(this.uniforms.breath, this.params.breath || 0.0);
|
|
1073
1077
|
|
|
1074
1078
|
this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4);
|
|
@@ -199,6 +199,44 @@ export class ShaderLoader {
|
|
|
199
199
|
return results;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Resolve #include directives in shader source.
|
|
204
|
+
* GLSL: #include "common/rotation4d.glsl"
|
|
205
|
+
* WGSL: // @include "common/rotation4d.wgsl"
|
|
206
|
+
*
|
|
207
|
+
* Includes are resolved from the loader's cache (call loadCommonLibrary() first).
|
|
208
|
+
* Non-recursive — only resolves one level of includes.
|
|
209
|
+
*
|
|
210
|
+
* @param {string} source - Shader source with include directives
|
|
211
|
+
* @returns {string} Resolved shader source
|
|
212
|
+
*/
|
|
213
|
+
resolveIncludes(source) {
|
|
214
|
+
if (!source) return source;
|
|
215
|
+
|
|
216
|
+
// GLSL: #include "path"
|
|
217
|
+
// WGSL: // @include "path"
|
|
218
|
+
const includeRegex = /(?:^|\n)\s*(?:#include|\/\/\s*@include)\s+"([^"]+)"\s*(?:\n|$)/g;
|
|
219
|
+
|
|
220
|
+
return source.replace(includeRegex, (match, path) => {
|
|
221
|
+
const cached = this._cache.get(path);
|
|
222
|
+
if (cached) {
|
|
223
|
+
return '\n// --- included from ' + path + ' ---\n' + cached + '\n// --- end ' + path + ' ---\n';
|
|
224
|
+
}
|
|
225
|
+
console.warn(`ShaderLoader: Include not found in cache: "${path}" — load it first via loadCommonLibrary()`);
|
|
226
|
+
return match; // Leave directive in place if not found
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Load a shader file and resolve includes.
|
|
232
|
+
* @param {string} relativePath
|
|
233
|
+
* @returns {Promise<string|null>}
|
|
234
|
+
*/
|
|
235
|
+
async loadAndResolve(relativePath) {
|
|
236
|
+
const source = await this.load(relativePath);
|
|
237
|
+
return source ? this.resolveIncludes(source) : null;
|
|
238
|
+
}
|
|
239
|
+
|
|
202
240
|
/**
|
|
203
241
|
* Clear all cached shaders.
|
|
204
242
|
*/
|
|
@@ -384,10 +384,10 @@ export const ShaderLib = {
|
|
|
384
384
|
mat4 rotateXZ(float angle) {
|
|
385
385
|
float c = cos(angle), s = sin(angle);
|
|
386
386
|
return mat4(
|
|
387
|
-
c, 0,
|
|
388
|
-
0, 1,
|
|
389
|
-
|
|
390
|
-
0, 0,
|
|
387
|
+
c, 0, s, 0,
|
|
388
|
+
0, 1, 0, 0,
|
|
389
|
+
-s, 0, c, 0,
|
|
390
|
+
0, 0, 0, 1
|
|
391
391
|
);
|
|
392
392
|
}
|
|
393
393
|
|
|
@@ -25,7 +25,7 @@ import { createWebGPUBackend, isWebGPUSupported, WGSLShaderLib } from './backend
|
|
|
25
25
|
* @returns {Float32Array}
|
|
26
26
|
*/
|
|
27
27
|
function packVIB3Uniforms(uniforms) {
|
|
28
|
-
// Total:
|
|
28
|
+
// Total: 33 floats (indices 0-32) = 132 bytes → padded to 256 bytes in buffer
|
|
29
29
|
const data = new Float32Array(64); // 256 bytes
|
|
30
30
|
|
|
31
31
|
data[0] = uniforms.u_time || 0;
|
|
@@ -152,10 +152,14 @@ struct VIB3Uniforms {
|
|
|
152
152
|
layerScale: f32,
|
|
153
153
|
layerOpacity: f32,
|
|
154
154
|
_pad1: f32,
|
|
155
|
-
|
|
155
|
+
layerColorR: f32,
|
|
156
|
+
layerColorG: f32,
|
|
157
|
+
layerColorB: f32,
|
|
156
158
|
densityMult: f32,
|
|
157
159
|
speedMult: f32,
|
|
158
|
-
|
|
160
|
+
|
|
161
|
+
// Vitality
|
|
162
|
+
breath: f32,
|
|
159
163
|
};
|
|
160
164
|
`;
|
|
161
165
|
|
|
@@ -178,9 +182,9 @@ fn rotateXZ(angle: f32) -> mat4x4<f32> {
|
|
|
178
182
|
let c = cos(angle);
|
|
179
183
|
let s = sin(angle);
|
|
180
184
|
return mat4x4<f32>(
|
|
181
|
-
vec4<f32>(c, 0.0,
|
|
185
|
+
vec4<f32>( c, 0.0, s, 0.0),
|
|
182
186
|
vec4<f32>(0.0, 1.0, 0.0, 0.0),
|
|
183
|
-
vec4<f32>(s, 0.0, c, 0.0),
|
|
187
|
+
vec4<f32>(-s, 0.0, c, 0.0),
|
|
184
188
|
vec4<f32>(0.0, 0.0, 0.0, 1.0)
|
|
185
189
|
);
|
|
186
190
|
}
|
package/src/scene/Node4D.js
CHANGED
|
@@ -500,29 +500,74 @@ export class Node4D {
|
|
|
500
500
|
* @private
|
|
501
501
|
*/
|
|
502
502
|
_updateLocalMatrix() {
|
|
503
|
-
//
|
|
504
|
-
this._localMatrix
|
|
503
|
+
// Ensure matrix exists
|
|
504
|
+
if (!this._localMatrix) {
|
|
505
|
+
this._localMatrix = new Mat4x4();
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
const m = this._localMatrix.data;
|
|
509
|
+
const s = this._scale;
|
|
510
|
+
const p = this._position;
|
|
511
|
+
|
|
512
|
+
// 1. Write rotation directly to local matrix (No allocation)
|
|
513
|
+
this._rotation.toMatrix(m);
|
|
514
|
+
|
|
515
|
+
// 2. Apply scale (Diagonal matrix multiplication on the right)
|
|
516
|
+
// M = M * S
|
|
517
|
+
// Columns of M are scaled by s.x, s.y, s.z, s.w
|
|
518
|
+
|
|
519
|
+
// Col 0
|
|
520
|
+
m[0] *= s.x; m[1] *= s.x; m[2] *= s.x; m[3] *= s.x;
|
|
521
|
+
// Col 1
|
|
522
|
+
m[4] *= s.y; m[5] *= s.y; m[6] *= s.y; m[7] *= s.y;
|
|
523
|
+
// Col 2
|
|
524
|
+
m[8] *= s.z; m[9] *= s.z; m[10] *= s.z; m[11] *= s.z;
|
|
525
|
+
// Col 3
|
|
526
|
+
m[12] *= s.w; m[13] *= s.w; m[14] *= s.w; m[15] *= s.w;
|
|
527
|
+
|
|
528
|
+
// 3. Apply translation (Matrix multiplication on the left)
|
|
529
|
+
// M = T * M
|
|
530
|
+
// T is standard 3D translation:
|
|
531
|
+
// [ 1 0 0 px ]
|
|
532
|
+
// [ 0 1 0 py ]
|
|
533
|
+
// [ 0 0 1 pz ]
|
|
534
|
+
// [ 0 0 0 1 ]
|
|
535
|
+
//
|
|
536
|
+
// Row 0 += px * Row 3
|
|
537
|
+
// Row 1 += py * Row 3
|
|
538
|
+
// Row 2 += pz * Row 3
|
|
539
|
+
|
|
540
|
+
const px = p.x;
|
|
541
|
+
const py = p.y;
|
|
542
|
+
const pz = p.z;
|
|
543
|
+
|
|
544
|
+
// Row 3 elements of M (which are used in the calculation)
|
|
545
|
+
const m3 = m[3];
|
|
546
|
+
const m7 = m[7];
|
|
547
|
+
const m11 = m[11];
|
|
548
|
+
const m15 = m[15];
|
|
549
|
+
|
|
550
|
+
if (px !== 0) {
|
|
551
|
+
m[0] += px * m3;
|
|
552
|
+
m[4] += px * m7;
|
|
553
|
+
m[8] += px * m11;
|
|
554
|
+
m[12] += px * m15;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
if (py !== 0) {
|
|
558
|
+
m[1] += py * m3;
|
|
559
|
+
m[5] += py * m7;
|
|
560
|
+
m[9] += py * m11;
|
|
561
|
+
m[13] += py * m15;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (pz !== 0) {
|
|
565
|
+
m[2] += pz * m3;
|
|
566
|
+
m[6] += pz * m7;
|
|
567
|
+
m[10] += pz * m11;
|
|
568
|
+
m[14] += pz * m15;
|
|
569
|
+
}
|
|
505
570
|
|
|
506
|
-
// Apply scale
|
|
507
|
-
const scaleMatrix = Mat4x4.identity();
|
|
508
|
-
scaleMatrix.set(0, 0, this._scale.x);
|
|
509
|
-
scaleMatrix.set(1, 1, this._scale.y);
|
|
510
|
-
scaleMatrix.set(2, 2, this._scale.z);
|
|
511
|
-
scaleMatrix.set(3, 3, this._scale.w);
|
|
512
|
-
|
|
513
|
-
// Apply rotation (toMatrix returns Float32Array, wrap in Mat4x4)
|
|
514
|
-
const rotationMatrix = new Mat4x4(this._rotation.toMatrix());
|
|
515
|
-
|
|
516
|
-
// Apply translation (in 4D, translation is stored in last column, keep [3,3]=1)
|
|
517
|
-
const translationMatrix = Mat4x4.identity();
|
|
518
|
-
translationMatrix.set(0, 3, this._position.x);
|
|
519
|
-
translationMatrix.set(1, 3, this._position.y);
|
|
520
|
-
translationMatrix.set(2, 3, this._position.z);
|
|
521
|
-
// Note: position.w is the 4th spatial coordinate, handled separately
|
|
522
|
-
// Matrix[3,3] must remain 1 for proper transformation
|
|
523
|
-
|
|
524
|
-
// Compose: T * R * S
|
|
525
|
-
this._localMatrix = translationMatrix.multiply(rotationMatrix).multiply(scaleMatrix);
|
|
526
571
|
this._localDirty = false;
|
|
527
572
|
}
|
|
528
573
|
|
|
@@ -535,10 +580,15 @@ export class Node4D {
|
|
|
535
580
|
this._updateLocalMatrix();
|
|
536
581
|
}
|
|
537
582
|
|
|
583
|
+
// Ensure matrix exists
|
|
584
|
+
if (!this._worldMatrix) {
|
|
585
|
+
this._worldMatrix = new Mat4x4();
|
|
586
|
+
}
|
|
587
|
+
|
|
538
588
|
if (this._parent) {
|
|
539
|
-
this.
|
|
589
|
+
this._parent.worldMatrix.multiply(this._localMatrix, this._worldMatrix);
|
|
540
590
|
} else {
|
|
541
|
-
this._worldMatrix
|
|
591
|
+
this._worldMatrix.copy(this._localMatrix);
|
|
542
592
|
}
|
|
543
593
|
|
|
544
594
|
this._worldDirty = false;
|
|
@@ -53,6 +53,71 @@ float hypertetrahedronCore(vec4 p, float baseType) {
|
|
|
53
53
|
return max(baseShape, tetraField);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
// ── Polytope Core Warp Functions ──
|
|
57
|
+
// Requires: rotation matrices from rotation4d.glsl, project4Dto3D, and u_* uniforms
|
|
58
|
+
|
|
59
|
+
vec3 warpHypersphereCore(vec3 p, int geometryIndex, vec2 mouseDelta) {
|
|
60
|
+
float radius = length(p);
|
|
61
|
+
float morphBlend = clamp(u_morphFactor * 0.6 + (u_dimension - 3.0) * 0.25, 0.0, 2.0);
|
|
62
|
+
float w = sin(radius * (1.3 + float(geometryIndex) * 0.12) + u_time * 0.0008 * u_speed);
|
|
63
|
+
w *= (0.4 + morphBlend * 0.45);
|
|
64
|
+
|
|
65
|
+
vec4 p4d = vec4(p * (1.0 + morphBlend * 0.2), w);
|
|
66
|
+
p4d = rotateXY(u_rot4dXY) * p4d;
|
|
67
|
+
p4d = rotateXZ(u_rot4dXZ) * p4d;
|
|
68
|
+
p4d = rotateYZ(u_rot4dYZ) * p4d;
|
|
69
|
+
p4d = rotateXW(u_rot4dXW) * p4d;
|
|
70
|
+
p4d = rotateYW(u_rot4dYW) * p4d;
|
|
71
|
+
p4d = rotateZW(u_rot4dZW) * p4d;
|
|
72
|
+
|
|
73
|
+
vec3 projected = project4Dto3D(p4d);
|
|
74
|
+
return mix(p, projected, clamp(0.45 + morphBlend * 0.35, 0.0, 1.0));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
vec3 warpHypertetraCore(vec3 p, int geometryIndex, vec2 mouseDelta) {
|
|
78
|
+
vec3 c1 = normalize(vec3(1.0, 1.0, 1.0));
|
|
79
|
+
vec3 c2 = normalize(vec3(-1.0, -1.0, 1.0));
|
|
80
|
+
vec3 c3 = normalize(vec3(-1.0, 1.0, -1.0));
|
|
81
|
+
vec3 c4 = normalize(vec3(1.0, -1.0, -1.0));
|
|
82
|
+
|
|
83
|
+
float morphBlend = clamp(u_morphFactor * 0.8 + (u_dimension - 3.0) * 0.2, 0.0, 2.0);
|
|
84
|
+
float basisMix = dot(p, c1) * 0.14 + dot(p, c2) * 0.1 + dot(p, c3) * 0.08;
|
|
85
|
+
float w = sin(basisMix * 5.5 + u_time * 0.0009 * u_speed);
|
|
86
|
+
w *= cos(dot(p, c4) * 4.2 - u_time * 0.0007 * u_speed);
|
|
87
|
+
w *= (0.5 + morphBlend * 0.4);
|
|
88
|
+
|
|
89
|
+
vec3 offset = vec3(dot(p, c1), dot(p, c2), dot(p, c3)) * 0.1 * morphBlend;
|
|
90
|
+
vec4 p4d = vec4(p + offset, w);
|
|
91
|
+
p4d = rotateXY(u_rot4dXY) * p4d;
|
|
92
|
+
p4d = rotateXZ(u_rot4dXZ) * p4d;
|
|
93
|
+
p4d = rotateYZ(u_rot4dYZ) * p4d;
|
|
94
|
+
p4d = rotateXW(u_rot4dXW) * p4d;
|
|
95
|
+
p4d = rotateYW(u_rot4dYW) * p4d;
|
|
96
|
+
p4d = rotateZW(u_rot4dZW) * p4d;
|
|
97
|
+
|
|
98
|
+
vec3 projected = project4Dto3D(p4d);
|
|
99
|
+
float planeInfluence = min(min(abs(dot(p, c1)), abs(dot(p, c2))),
|
|
100
|
+
min(abs(dot(p, c3)), abs(dot(p, c4))));
|
|
101
|
+
vec3 blended = mix(p, projected, clamp(0.45 + morphBlend * 0.35, 0.0, 1.0));
|
|
102
|
+
return mix(blended, blended * (1.0 - planeInfluence * 0.55), 0.2 + morphBlend * 0.2);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
vec3 applyCoreWarp(vec3 p, float geometryType, vec2 mouseDelta) {
|
|
106
|
+
float totalBase = 8.0;
|
|
107
|
+
float coreFloat = floor(geometryType / totalBase);
|
|
108
|
+
int coreIndex = int(clamp(coreFloat, 0.0, 2.0));
|
|
109
|
+
float baseGeomFloat = geometryType - floor(geometryType / totalBase) * totalBase;
|
|
110
|
+
int geometryIndex = int(clamp(floor(baseGeomFloat + 0.5), 0.0, totalBase - 1.0));
|
|
111
|
+
|
|
112
|
+
if (coreIndex == 1) {
|
|
113
|
+
return warpHypersphereCore(p, geometryIndex, mouseDelta);
|
|
114
|
+
}
|
|
115
|
+
if (coreIndex == 2) {
|
|
116
|
+
return warpHypertetraCore(p, geometryIndex, mouseDelta);
|
|
117
|
+
}
|
|
118
|
+
return p;
|
|
119
|
+
}
|
|
120
|
+
|
|
56
121
|
// Main geometry dispatcher (0-23)
|
|
57
122
|
float geometry(vec4 p, float type) {
|
|
58
123
|
if (type < 8.0) {
|
|
@@ -47,6 +47,60 @@ fn hypertetrahedronCore(p: vec4<f32>, baseType: f32) -> f32 {
|
|
|
47
47
|
return max(baseGeometry(p, baseType), tf);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
// ── Polytope Core Warp Functions ──
|
|
51
|
+
// Requires: rotation functions from rotation4d.wgsl and u: VIB3Uniforms
|
|
52
|
+
|
|
53
|
+
fn warpHypersphereCore_common(p: vec3<f32>, geomIdx: i32) -> vec3<f32> {
|
|
54
|
+
let radius = length(p);
|
|
55
|
+
let morphBlend = clamp(u.morphFactor * 0.6 + (u.dimension - 3.0) * 0.25, 0.0, 2.0);
|
|
56
|
+
let w = sin(radius * (1.3 + f32(geomIdx) * 0.12) + u.time * 0.0008 * u.speed)
|
|
57
|
+
* (0.4 + morphBlend * 0.45);
|
|
58
|
+
var p4d = vec4<f32>(p * (1.0 + morphBlend * 0.2), w);
|
|
59
|
+
p4d = rotateXY(u.rot4dXY) * p4d;
|
|
60
|
+
p4d = rotateXZ(u.rot4dXZ) * p4d;
|
|
61
|
+
p4d = rotateYZ(u.rot4dYZ) * p4d;
|
|
62
|
+
p4d = rotateXW(u.rot4dXW) * p4d;
|
|
63
|
+
p4d = rotateYW(u.rot4dYW) * p4d;
|
|
64
|
+
p4d = rotateZW(u.rot4dZW) * p4d;
|
|
65
|
+
let proj = project4Dto3D(p4d);
|
|
66
|
+
return mix(p, proj, clamp(0.45 + morphBlend * 0.35, 0.0, 1.0));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
fn warpHypertetraCore_common(p: vec3<f32>, geomIdx: i32) -> vec3<f32> {
|
|
70
|
+
let c1 = normalize(vec3<f32>(1.0, 1.0, 1.0));
|
|
71
|
+
let c2 = normalize(vec3<f32>(-1.0, -1.0, 1.0));
|
|
72
|
+
let c3 = normalize(vec3<f32>(-1.0, 1.0, -1.0));
|
|
73
|
+
let c4 = normalize(vec3<f32>(1.0, -1.0, -1.0));
|
|
74
|
+
let morphBlend = clamp(u.morphFactor * 0.8 + (u.dimension - 3.0) * 0.2, 0.0, 2.0);
|
|
75
|
+
let basisMix = dot(p, c1) * 0.14 + dot(p, c2) * 0.1 + dot(p, c3) * 0.08;
|
|
76
|
+
let w = sin(basisMix * 5.5 + u.time * 0.0009 * u.speed)
|
|
77
|
+
* cos(dot(p, c4) * 4.2 - u.time * 0.0007 * u.speed)
|
|
78
|
+
* (0.5 + morphBlend * 0.4);
|
|
79
|
+
let offset = vec3<f32>(dot(p, c1), dot(p, c2), dot(p, c3)) * 0.1 * morphBlend;
|
|
80
|
+
var p4d = vec4<f32>(p + offset, w);
|
|
81
|
+
p4d = rotateXY(u.rot4dXY) * p4d;
|
|
82
|
+
p4d = rotateXZ(u.rot4dXZ) * p4d;
|
|
83
|
+
p4d = rotateYZ(u.rot4dYZ) * p4d;
|
|
84
|
+
p4d = rotateXW(u.rot4dXW) * p4d;
|
|
85
|
+
p4d = rotateYW(u.rot4dYW) * p4d;
|
|
86
|
+
p4d = rotateZW(u.rot4dZW) * p4d;
|
|
87
|
+
let proj = project4Dto3D(p4d);
|
|
88
|
+
let planeInf = min(min(abs(dot(p, c1)), abs(dot(p, c2))),
|
|
89
|
+
min(abs(dot(p, c3)), abs(dot(p, c4))));
|
|
90
|
+
let blended = mix(p, proj, clamp(0.45 + morphBlend * 0.35, 0.0, 1.0));
|
|
91
|
+
return mix(blended, blended * (1.0 - planeInf * 0.55), 0.2 + morphBlend * 0.2);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
fn applyCoreWarp_common(p: vec3<f32>, geomType: f32) -> vec3<f32> {
|
|
95
|
+
let coreFloat = floor(geomType / 8.0);
|
|
96
|
+
let coreIndex = i32(clamp(coreFloat, 0.0, 2.0));
|
|
97
|
+
let baseFloat = geomType - floor(geomType / 8.0) * 8.0;
|
|
98
|
+
let geomIdx = i32(clamp(floor(baseFloat + 0.5), 0.0, 7.0));
|
|
99
|
+
if (coreIndex == 1) { return warpHypersphereCore_common(p, geomIdx); }
|
|
100
|
+
if (coreIndex == 2) { return warpHypertetraCore_common(p, geomIdx); }
|
|
101
|
+
return p;
|
|
102
|
+
}
|
|
103
|
+
|
|
50
104
|
fn geometry(p: vec4<f32>, t: f32) -> f32 {
|
|
51
105
|
if (t < 8.0) { return baseGeometry(p, t); }
|
|
52
106
|
else if (t < 16.0) { return hypersphereCore(p, t - 8.0); }
|
|
@@ -16,9 +16,9 @@ fn rotateXZ(angle: f32) -> mat4x4<f32> {
|
|
|
16
16
|
let c = cos(angle);
|
|
17
17
|
let s = sin(angle);
|
|
18
18
|
return mat4x4<f32>(
|
|
19
|
-
vec4<f32>(c, 0.0,
|
|
19
|
+
vec4<f32>( c, 0.0, s, 0.0),
|
|
20
20
|
vec4<f32>(0.0, 1.0, 0.0, 0.0),
|
|
21
|
-
vec4<f32>(s, 0.0,
|
|
21
|
+
vec4<f32>(-s, 0.0, c, 0.0),
|
|
22
22
|
vec4<f32>(0.0, 0.0, 0.0, 1.0)
|
|
23
23
|
);
|
|
24
24
|
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
// VIB3+ Common Uniform Struct (WGSL)
|
|
2
2
|
// Shared across all visualization systems
|
|
3
|
+
// Canonical layout — must match packVIB3Uniforms() in UnifiedRenderBridge.js
|
|
4
|
+
// All fields are f32 (except resolution vec2) to avoid alignment surprises.
|
|
5
|
+
// Total: 33 floats (132 bytes), buffer padded to 256 bytes.
|
|
3
6
|
|
|
4
7
|
struct VIB3Uniforms {
|
|
5
|
-
// Time and resolution
|
|
8
|
+
// Time and resolution (indices 0-3)
|
|
6
9
|
time: f32,
|
|
7
10
|
_pad0: f32,
|
|
8
11
|
resolution: vec2<f32>,
|
|
9
12
|
|
|
10
|
-
// Geometry selection
|
|
13
|
+
// Geometry selection 0-23 (index 4)
|
|
11
14
|
geometry: f32,
|
|
12
15
|
|
|
13
|
-
// 6D Rotation (
|
|
16
|
+
// 6D Rotation in radians (indices 5-10)
|
|
14
17
|
rot4dXY: f32,
|
|
15
18
|
rot4dXZ: f32,
|
|
16
19
|
rot4dYZ: f32,
|
|
@@ -18,7 +21,7 @@ struct VIB3Uniforms {
|
|
|
18
21
|
rot4dYW: f32,
|
|
19
22
|
rot4dZW: f32,
|
|
20
23
|
|
|
21
|
-
// Visual parameters
|
|
24
|
+
// Visual parameters (indices 11-18)
|
|
22
25
|
dimension: f32,
|
|
23
26
|
gridDensity: f32,
|
|
24
27
|
morphFactor: f32,
|
|
@@ -28,21 +31,25 @@ struct VIB3Uniforms {
|
|
|
28
31
|
intensity: f32,
|
|
29
32
|
saturation: f32,
|
|
30
33
|
|
|
31
|
-
// Reactivity
|
|
34
|
+
// Reactivity (indices 19-23)
|
|
32
35
|
mouseIntensity: f32,
|
|
33
36
|
clickIntensity: f32,
|
|
34
37
|
bass: f32,
|
|
35
38
|
mid: f32,
|
|
36
39
|
high: f32,
|
|
37
40
|
|
|
38
|
-
// Layer parameters (
|
|
41
|
+
// Layer parameters (indices 24-31)
|
|
39
42
|
layerScale: f32,
|
|
40
43
|
layerOpacity: f32,
|
|
41
44
|
_pad1: f32,
|
|
42
|
-
|
|
45
|
+
layerColorR: f32,
|
|
46
|
+
layerColorG: f32,
|
|
47
|
+
layerColorB: f32,
|
|
43
48
|
densityMult: f32,
|
|
44
49
|
speedMult: f32,
|
|
45
|
-
|
|
50
|
+
|
|
51
|
+
// Vitality (index 32)
|
|
52
|
+
breath: f32,
|
|
46
53
|
};
|
|
47
54
|
|
|
48
55
|
@group(0) @binding(0) var<uniform> u: VIB3Uniforms;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
struct VIB3Uniforms {
|
|
6
6
|
time: f32,
|
|
7
|
-
|
|
7
|
+
_pad0: f32,
|
|
8
8
|
resolution: vec2<f32>,
|
|
9
9
|
geometry: f32,
|
|
10
10
|
rot4dXY: f32,
|
|
@@ -17,18 +17,24 @@ struct VIB3Uniforms {
|
|
|
17
17
|
gridDensity: f32,
|
|
18
18
|
morphFactor: f32,
|
|
19
19
|
chaos: f32,
|
|
20
|
+
speed: f32,
|
|
20
21
|
hue: f32,
|
|
21
22
|
intensity: f32,
|
|
22
23
|
saturation: f32,
|
|
23
24
|
mouseIntensity: f32,
|
|
24
25
|
clickIntensity: f32,
|
|
25
|
-
roleIntensity: f32,
|
|
26
26
|
bass: f32,
|
|
27
27
|
mid: f32,
|
|
28
28
|
high: f32,
|
|
29
|
+
layerScale: f32,
|
|
30
|
+
layerOpacity: f32,
|
|
31
|
+
_pad1: f32,
|
|
32
|
+
layerColorR: f32,
|
|
33
|
+
layerColorG: f32,
|
|
34
|
+
layerColorB: f32,
|
|
35
|
+
densityMult: f32,
|
|
36
|
+
speedMult: f32,
|
|
29
37
|
breath: f32,
|
|
30
|
-
mouse: vec2<f32>,
|
|
31
|
-
_pad1: vec2<f32>,
|
|
32
38
|
};
|
|
33
39
|
|
|
34
40
|
@group(0) @binding(0) var<uniform> u: VIB3Uniforms;
|
|
@@ -131,8 +137,15 @@ fn geometryFunction_w(p: vec4<f32>) -> f32 {
|
|
|
131
137
|
let gt = i32(clamp(floor(baseFloat + 0.5), 0.0, 7.0));
|
|
132
138
|
let d = u.gridDensity * 0.08;
|
|
133
139
|
if (gt == 0) {
|
|
134
|
-
|
|
135
|
-
|
|
140
|
+
// Tetrahedron — tetrahedral symmetry planes
|
|
141
|
+
let c1 = normalize(vec3<f32>(1.0, 1.0, 1.0));
|
|
142
|
+
let c2 = normalize(vec3<f32>(-1.0, -1.0, 1.0));
|
|
143
|
+
let c3 = normalize(vec3<f32>(-1.0, 1.0, -1.0));
|
|
144
|
+
let c4 = normalize(vec3<f32>(1.0, -1.0, -1.0));
|
|
145
|
+
let q = fract(p.xyz * d + 0.5) - 0.5;
|
|
146
|
+
let minPlane = min(min(abs(dot(q, c1)), abs(dot(q, c2))),
|
|
147
|
+
min(abs(dot(q, c3)), abs(dot(q, c4))));
|
|
148
|
+
return (1.0 - smoothstep(0.0, 0.05, minPlane)) * u.morphFactor;
|
|
136
149
|
} else if (gt == 1) {
|
|
137
150
|
let pos = fract(p * d); let dist = min(pos, 1.0 - pos);
|
|
138
151
|
return min(min(dist.x, dist.y), min(dist.z, dist.w)) * u.morphFactor;
|
|
@@ -28,11 +28,13 @@ struct VIB3Uniforms {
|
|
|
28
28
|
high: f32,
|
|
29
29
|
layerScale: f32,
|
|
30
30
|
layerOpacity: f32,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
_pad1: f32,
|
|
32
|
+
layerColorR: f32,
|
|
33
|
+
layerColorG: f32,
|
|
34
|
+
layerColorB: f32,
|
|
33
35
|
densityMult: f32,
|
|
34
36
|
speedMult: f32,
|
|
35
|
-
|
|
37
|
+
breath: f32,
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
@group(0) @binding(0) var<uniform> u: VIB3Uniforms;
|
|
@@ -52,8 +54,8 @@ fn rotateXY(angle: f32) -> mat4x4<f32> {
|
|
|
52
54
|
fn rotateXZ(angle: f32) -> mat4x4<f32> {
|
|
53
55
|
let c = cos(angle); let s = sin(angle);
|
|
54
56
|
return mat4x4<f32>(
|
|
55
|
-
vec4<f32>(c, 0.0,
|
|
56
|
-
vec4<f32>(s, 0.0, c, 0.0), vec4<f32>(0.0, 0.0, 0.0, 1.0));
|
|
57
|
+
vec4<f32>(c, 0.0, s, 0.0), vec4<f32>(0.0, 1.0, 0.0, 0.0),
|
|
58
|
+
vec4<f32>(-s, 0.0, c, 0.0), vec4<f32>(0.0, 0.0, 0.0, 1.0));
|
|
57
59
|
}
|
|
58
60
|
fn rotateYZ(angle: f32) -> mat4x4<f32> {
|
|
59
61
|
let c = cos(angle); let s = sin(angle);
|
|
@@ -28,11 +28,13 @@ struct VIB3Uniforms {
|
|
|
28
28
|
high: f32,
|
|
29
29
|
layerScale: f32,
|
|
30
30
|
layerOpacity: f32,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
_pad1: f32,
|
|
32
|
+
layerColorR: f32,
|
|
33
|
+
layerColorG: f32,
|
|
34
|
+
layerColorB: f32,
|
|
33
35
|
densityMult: f32,
|
|
34
36
|
speedMult: f32,
|
|
35
|
-
|
|
37
|
+
breath: f32,
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
@group(0) @binding(0) var<uniform> u: VIB3Uniforms;
|
|
@@ -52,8 +54,8 @@ fn rotateXY(angle: f32) -> mat4x4<f32> {
|
|
|
52
54
|
fn rotateXZ(angle: f32) -> mat4x4<f32> {
|
|
53
55
|
let c = cos(angle); let s = sin(angle);
|
|
54
56
|
return mat4x4<f32>(
|
|
55
|
-
vec4<f32>(c, 0.0,
|
|
56
|
-
vec4<f32>(s, 0.0, c, 0.0), vec4<f32>(0.0, 0.0, 0.0, 1.0));
|
|
57
|
+
vec4<f32>(c, 0.0, s, 0.0), vec4<f32>(0.0, 1.0, 0.0, 0.0),
|
|
58
|
+
vec4<f32>(-s, 0.0, c, 0.0), vec4<f32>(0.0, 0.0, 0.0, 1.0));
|
|
57
59
|
}
|
|
58
60
|
fn rotateYZ(angle: f32) -> mat4x4<f32> {
|
|
59
61
|
let c = cos(angle); let s = sin(angle);
|
|
@@ -546,9 +546,9 @@ fn rotateXZ(angle: f32) -> mat4x4<f32> {
|
|
|
546
546
|
let c = cos(angle);
|
|
547
547
|
let s = sin(angle);
|
|
548
548
|
return mat4x4<f32>(
|
|
549
|
-
vec4<f32>(c, 0.0,
|
|
549
|
+
vec4<f32>( c, 0.0, s, 0.0),
|
|
550
550
|
vec4<f32>(0.0, 1.0, 0.0, 0.0),
|
|
551
|
-
vec4<f32>(s, 0.0, c, 0.0),
|
|
551
|
+
vec4<f32>(-s, 0.0, c, 0.0),
|
|
552
552
|
vec4<f32>(0.0, 0.0, 0.0, 1.0)
|
|
553
553
|
);
|
|
554
554
|
}
|