@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.
- package/CHANGELOG.md +118 -0
- package/DOCS/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md +34 -0
- package/DOCS/CI_TESTING.md +38 -0
- package/DOCS/CLI_ONBOARDING.md +75 -0
- package/DOCS/CONTROL_REFERENCE.md +64 -0
- package/DOCS/DEV_TRACK_ANALYSIS.md +77 -0
- package/DOCS/DEV_TRACK_PLAN_2026-01-07.md +42 -0
- package/DOCS/DEV_TRACK_SESSION_2026-01-31.md +220 -0
- package/DOCS/ENV_SETUP.md +189 -0
- package/DOCS/EXPORT_FORMATS.md +417 -0
- package/DOCS/GPU_DISPOSAL_GUIDE.md +21 -0
- package/DOCS/LICENSING_TIERS.md +275 -0
- package/DOCS/MASTER_PLAN_2026-01-31.md +570 -0
- package/DOCS/OBS_SETUP_GUIDE.md +98 -0
- package/DOCS/PROJECT_SETUP.md +66 -0
- package/DOCS/RENDERER_LIFECYCLE.md +40 -0
- package/DOCS/REPO_MANIFEST.md +121 -0
- package/DOCS/SESSION_014_PLAN.md +195 -0
- package/DOCS/SESSION_LOG_2026-01-07.md +56 -0
- package/DOCS/STRATEGIC_BLUEPRINT_2026-01-07.md +72 -0
- package/DOCS/SYSTEM_AUDIT_2026-01-30.md +738 -0
- package/DOCS/SYSTEM_INVENTORY.md +520 -0
- package/DOCS/TELEMETRY_EXPORTS.md +34 -0
- package/DOCS/WEBGPU_STATUS.md +38 -0
- package/DOCS/XR_BENCHMARKS.md +608 -0
- package/LICENSE +21 -0
- package/README.md +426 -0
- package/docs/.nojekyll +0 -0
- package/docs/01-dissolution_of_euclidean_hegemony.html +346 -0
- package/docs/02-hyperspatial_ego_death.html +346 -0
- package/docs/03-post_cartesian_sublime.html +346 -0
- package/docs/04-crystalline_void_meditation.html +346 -0
- package/docs/05-quantum_decoherence_ballet.html +346 -0
- package/docs/06-dissolution_of_euclidean_hegemony.html +346 -0
- package/docs/07-hyperspatial_ego_death.html +346 -0
- package/docs/08-post_cartesian_sublime.html +346 -0
- package/docs/09-crystalline_void_meditation.html +346 -0
- package/docs/10-quantum_decoherence_ballet.html +346 -0
- package/docs/11-dissolution_of_euclidean_hegemony.html +346 -0
- package/docs/12-hyperspatial_ego_death.html +346 -0
- package/docs/13-post_cartesian_sublime.html +346 -0
- package/docs/index.html +794 -0
- package/docs/test-hub.html +441 -0
- package/docs/url-state.js +102 -0
- package/docs/vib3-exports/01-quantum-quantum-tetrahedron-lattice.html +489 -0
- package/docs/vib3-exports/02-quantum-quantum-hypersphere-matrix.html +489 -0
- package/docs/vib3-exports/03-quantum-quantum-hypertetra-fractal.html +489 -0
- package/docs/vib3-exports/04-faceted-faceted-crystal-structure.html +407 -0
- package/docs/vib3-exports/05-faceted-faceted-klein-bottle.html +407 -0
- package/docs/vib3-exports/06-faceted-faceted-hypertetra-torus.html +407 -0
- package/docs/vib3-exports/07-holographic-holographic-wave-field.html +457 -0
- package/docs/vib3-exports/08-holographic-holographic-hypersphere-sphere.html +457 -0
- package/docs/vib3-exports/09-holographic-holographic-hypertetra-crystal.html +457 -0
- package/docs/vib3-exports/index.html +238 -0
- package/docs/webgpu-live.html +702 -0
- package/package.json +367 -0
- package/src/advanced/AIPresetGenerator.js +777 -0
- package/src/advanced/MIDIController.js +703 -0
- package/src/advanced/OffscreenWorker.js +1051 -0
- package/src/advanced/WebGPUCompute.js +1051 -0
- package/src/advanced/WebXRRenderer.js +680 -0
- package/src/agent/cli/AgentCLI.js +615 -0
- package/src/agent/cli/index.js +14 -0
- package/src/agent/index.js +73 -0
- package/src/agent/mcp/MCPServer.js +950 -0
- package/src/agent/mcp/index.js +9 -0
- package/src/agent/mcp/tools.js +548 -0
- package/src/agent/telemetry/EventStream.js +669 -0
- package/src/agent/telemetry/Instrumentation.js +618 -0
- package/src/agent/telemetry/TelemetryExporters.js +427 -0
- package/src/agent/telemetry/TelemetryService.js +464 -0
- package/src/agent/telemetry/index.js +52 -0
- package/src/benchmarks/BenchmarkRunner.js +381 -0
- package/src/benchmarks/MetricsCollector.js +299 -0
- package/src/benchmarks/index.js +9 -0
- package/src/benchmarks/scenes.js +259 -0
- package/src/cli/index.js +675 -0
- package/src/config/ApiConfig.js +88 -0
- package/src/core/CanvasManager.js +217 -0
- package/src/core/ErrorReporter.js +117 -0
- package/src/core/ParameterMapper.js +333 -0
- package/src/core/Parameters.js +396 -0
- package/src/core/RendererContracts.js +200 -0
- package/src/core/UnifiedResourceManager.js +370 -0
- package/src/core/VIB3Engine.js +636 -0
- package/src/core/renderers/FacetedRendererAdapter.js +32 -0
- package/src/core/renderers/HolographicRendererAdapter.js +29 -0
- package/src/core/renderers/QuantumRendererAdapter.js +29 -0
- package/src/core/renderers/RendererLifecycleManager.js +63 -0
- package/src/creative/ColorPresetsSystem.js +980 -0
- package/src/creative/ParameterTimeline.js +1061 -0
- package/src/creative/PostProcessingPipeline.js +1113 -0
- package/src/creative/TransitionAnimator.js +683 -0
- package/src/export/CSSExporter.js +226 -0
- package/src/export/CardGeneratorBase.js +279 -0
- package/src/export/ExportManager.js +580 -0
- package/src/export/FacetedCardGenerator.js +279 -0
- package/src/export/HolographicCardGenerator.js +543 -0
- package/src/export/LottieExporter.js +552 -0
- package/src/export/QuantumCardGenerator.js +315 -0
- package/src/export/SVGExporter.js +519 -0
- package/src/export/ShaderExporter.js +903 -0
- package/src/export/TradingCardGenerator.js +3055 -0
- package/src/export/TradingCardManager.js +181 -0
- package/src/export/VIB3PackageExporter.js +559 -0
- package/src/export/index.js +14 -0
- package/src/export/systems/TradingCardSystemFaceted.js +494 -0
- package/src/export/systems/TradingCardSystemHolographic.js +452 -0
- package/src/export/systems/TradingCardSystemQuantum.js +411 -0
- package/src/faceted/FacetedSystem.js +963 -0
- package/src/features/CollectionManager.js +433 -0
- package/src/gallery/CollectionManager.js +240 -0
- package/src/gallery/GallerySystem.js +485 -0
- package/src/geometry/GeometryFactory.js +314 -0
- package/src/geometry/GeometryLibrary.js +72 -0
- package/src/geometry/buffers/BufferBuilder.js +338 -0
- package/src/geometry/buffers/index.js +18 -0
- package/src/geometry/generators/Crystal.js +420 -0
- package/src/geometry/generators/Fractal.js +298 -0
- package/src/geometry/generators/KleinBottle.js +197 -0
- package/src/geometry/generators/Sphere.js +192 -0
- package/src/geometry/generators/Tesseract.js +160 -0
- package/src/geometry/generators/Tetrahedron.js +225 -0
- package/src/geometry/generators/Torus.js +304 -0
- package/src/geometry/generators/Wave.js +341 -0
- package/src/geometry/index.js +142 -0
- package/src/geometry/warp/HypersphereCore.js +211 -0
- package/src/geometry/warp/HypertetraCore.js +386 -0
- package/src/geometry/warp/index.js +57 -0
- package/src/holograms/HolographicVisualizer.js +1073 -0
- package/src/holograms/RealHolographicSystem.js +966 -0
- package/src/holograms/variantRegistry.js +69 -0
- package/src/integrations/FigmaPlugin.js +854 -0
- package/src/integrations/OBSMode.js +754 -0
- package/src/integrations/ThreeJsPackage.js +660 -0
- package/src/integrations/TouchDesignerExport.js +552 -0
- package/src/integrations/frameworks/Vib3React.js +591 -0
- package/src/integrations/frameworks/Vib3Svelte.js +654 -0
- package/src/integrations/frameworks/Vib3Vue.js +628 -0
- package/src/llm/LLMParameterInterface.js +240 -0
- package/src/llm/LLMParameterUI.js +577 -0
- package/src/math/Mat4x4.js +708 -0
- package/src/math/Projection.js +341 -0
- package/src/math/Rotor4D.js +637 -0
- package/src/math/Vec4.js +476 -0
- package/src/math/constants.js +164 -0
- package/src/math/index.js +68 -0
- package/src/math/projections.js +54 -0
- package/src/math/rotations.js +196 -0
- package/src/quantum/QuantumEngine.js +906 -0
- package/src/quantum/QuantumVisualizer.js +1103 -0
- package/src/reactivity/ReactivityConfig.js +499 -0
- package/src/reactivity/ReactivityManager.js +586 -0
- package/src/reactivity/SpatialInputSystem.js +1783 -0
- package/src/reactivity/index.js +93 -0
- package/src/render/CommandBuffer.js +465 -0
- package/src/render/MultiCanvasBridge.js +340 -0
- package/src/render/RenderCommand.js +514 -0
- package/src/render/RenderResourceRegistry.js +523 -0
- package/src/render/RenderState.js +552 -0
- package/src/render/RenderTarget.js +512 -0
- package/src/render/ShaderLoader.js +253 -0
- package/src/render/ShaderProgram.js +599 -0
- package/src/render/UnifiedRenderBridge.js +496 -0
- package/src/render/backends/WebGLBackend.js +1108 -0
- package/src/render/backends/WebGPUBackend.js +1409 -0
- package/src/render/commands/CommandBufferExecutor.js +607 -0
- package/src/render/commands/RenderCommandBuffer.js +661 -0
- package/src/render/commands/index.js +17 -0
- package/src/render/index.js +367 -0
- package/src/scene/Disposable.js +498 -0
- package/src/scene/MemoryPool.js +618 -0
- package/src/scene/Node4D.js +697 -0
- package/src/scene/ResourceManager.js +599 -0
- package/src/scene/Scene4D.js +540 -0
- package/src/scene/index.js +98 -0
- package/src/schemas/error.schema.json +84 -0
- package/src/schemas/extension.schema.json +88 -0
- package/src/schemas/index.js +214 -0
- package/src/schemas/parameters.schema.json +142 -0
- package/src/schemas/tool-pack.schema.json +44 -0
- package/src/schemas/tool-response.schema.json +127 -0
- package/src/shaders/common/fullscreen.vert.glsl +5 -0
- package/src/shaders/common/fullscreen.vert.wgsl +17 -0
- package/src/shaders/common/geometry24.glsl +65 -0
- package/src/shaders/common/geometry24.wgsl +54 -0
- package/src/shaders/common/rotation4d.glsl +85 -0
- package/src/shaders/common/rotation4d.wgsl +86 -0
- package/src/shaders/common/uniforms.glsl +44 -0
- package/src/shaders/common/uniforms.wgsl +48 -0
- package/src/shaders/faceted/faceted.frag.glsl +129 -0
- package/src/shaders/faceted/faceted.frag.wgsl +164 -0
- package/src/shaders/holographic/holographic.frag.glsl +406 -0
- package/src/shaders/holographic/holographic.frag.wgsl +185 -0
- package/src/shaders/quantum/quantum.frag.glsl +513 -0
- package/src/shaders/quantum/quantum.frag.wgsl +361 -0
- package/src/testing/ParallelTestFramework.js +519 -0
- package/src/testing/__snapshots__/exportFormats.test.js.snap +24 -0
- package/src/testing/exportFormats.test.js +8 -0
- package/src/testing/projections.test.js +14 -0
- package/src/testing/rotations.test.js +37 -0
- package/src/ui/InteractivityMenu.js +516 -0
- package/src/ui/StatusManager.js +96 -0
- package/src/ui/adaptive/renderers/webgpu/BufferLayout.ts +252 -0
- package/src/ui/adaptive/renderers/webgpu/PolytopeInstanceBuffer.ts +144 -0
- package/src/ui/adaptive/renderers/webgpu/TripleBufferedUniform.ts +170 -0
- package/src/ui/adaptive/renderers/webgpu/WebGPURenderer.ts +735 -0
- package/src/ui/adaptive/renderers/webgpu/index.ts +112 -0
- package/src/variations/VariationManager.js +431 -0
- package/src/viewer/AudioReactivity.js +505 -0
- package/src/viewer/CardBending.js +481 -0
- package/src/viewer/GalleryUI.js +832 -0
- package/src/viewer/ReactivityManager.js +590 -0
- package/src/viewer/TradingCardExporter.js +600 -0
- package/src/viewer/ViewerPortal.js +374 -0
- package/src/viewer/index.js +12 -0
- package/src/wasm/WasmLoader.js +296 -0
- package/src/wasm/index.js +132 -0
- package/tools/agentic/mcpTools.js +88 -0
- package/tools/cli/agent-cli.js +92 -0
- package/tools/export/formats.js +24 -0
- package/tools/math/rotation-baseline.mjs +64 -0
- package/tools/shader-sync-verify.js +937 -0
- package/tools/telemetry/manifestPipeline.js +141 -0
- package/tools/telemetry/telemetryEvents.js +35 -0
- package/types/adaptive-sdk.d.ts +185 -0
- package/types/advanced/AIPresetGenerator.d.ts +81 -0
- package/types/advanced/MIDIController.d.ts +100 -0
- package/types/advanced/OffscreenWorker.d.ts +82 -0
- package/types/advanced/WebGPUCompute.d.ts +52 -0
- package/types/advanced/WebXRRenderer.d.ts +77 -0
- package/types/advanced/index.d.ts +46 -0
- package/types/core/ErrorReporter.d.ts +50 -0
- package/types/core/VIB3Engine.d.ts +204 -0
- package/types/creative/ColorPresetsSystem.d.ts +91 -0
- package/types/creative/ParameterTimeline.d.ts +74 -0
- package/types/creative/PostProcessingPipeline.d.ts +109 -0
- package/types/creative/TransitionAnimator.d.ts +71 -0
- package/types/creative/index.d.ts +35 -0
- package/types/integrations/FigmaPlugin.d.ts +46 -0
- package/types/integrations/OBSMode.d.ts +74 -0
- package/types/integrations/ThreeJsPackage.d.ts +62 -0
- package/types/integrations/TouchDesignerExport.d.ts +36 -0
- package/types/integrations/Vib3React.d.ts +74 -0
- package/types/integrations/Vib3Svelte.d.ts +63 -0
- package/types/integrations/Vib3Vue.d.ts +55 -0
- package/types/integrations/index.d.ts +52 -0
- package/types/reactivity/SpatialInputSystem.d.ts +173 -0
- package/types/reactivity/index.d.ts +394 -0
- package/types/render/CommandBuffer.d.ts +169 -0
- package/types/render/RenderCommand.d.ts +312 -0
- package/types/render/RenderState.d.ts +279 -0
- package/types/render/RenderTarget.d.ts +254 -0
- package/types/render/ShaderProgram.d.ts +277 -0
- package/types/render/UnifiedRenderBridge.d.ts +143 -0
- package/types/render/WebGLBackend.d.ts +168 -0
- package/types/render/WebGPUBackend.d.ts +186 -0
- package/types/render/index.d.ts +141 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hypertetrahedron Core Warp
|
|
3
|
+
*
|
|
4
|
+
* Warps base geometry onto a 4D hypertetrahedron (5-cell/pentatope).
|
|
5
|
+
* Creates geometries 16-23 in the 24-variant encoding system.
|
|
6
|
+
*
|
|
7
|
+
* The 5-cell is the 4D analog of the tetrahedron, with 5 vertices,
|
|
8
|
+
* 10 edges, 10 triangular faces, and 5 tetrahedral cells.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Vec4 } from '../../math/Vec4.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Generate the 5 vertices of a regular pentatope centered at origin
|
|
15
|
+
* @param {number} size - Scale factor
|
|
16
|
+
* @returns {Vec4[]} 5 vertices
|
|
17
|
+
*/
|
|
18
|
+
export function getPentatopeVertices(size = 1) {
|
|
19
|
+
// Regular 5-cell with vertices on the 3-sphere
|
|
20
|
+
const s = size;
|
|
21
|
+
const a = 1 / Math.sqrt(10);
|
|
22
|
+
const b = 1 / Math.sqrt(6);
|
|
23
|
+
const c = 1 / Math.sqrt(3);
|
|
24
|
+
const d = 1;
|
|
25
|
+
|
|
26
|
+
return [
|
|
27
|
+
new Vec4(s * 4 * a, 0, 0, 0),
|
|
28
|
+
new Vec4(-s * a, s * 3 * b, 0, 0),
|
|
29
|
+
new Vec4(-s * a, -s * b, s * 2 * c, 0),
|
|
30
|
+
new Vec4(-s * a, -s * b, -s * c, s * d),
|
|
31
|
+
new Vec4(-s * a, -s * b, -s * c, -s * d)
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get the 10 edges of the pentatope
|
|
37
|
+
* @returns {number[][]} Edge pairs
|
|
38
|
+
*/
|
|
39
|
+
export function getPentatopeEdges() {
|
|
40
|
+
const edges = [];
|
|
41
|
+
for (let i = 0; i < 5; i++) {
|
|
42
|
+
for (let j = i + 1; j < 5; j++) {
|
|
43
|
+
edges.push([i, j]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return edges;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get the 10 triangular faces of the pentatope
|
|
51
|
+
* @returns {number[][]} Face vertex indices
|
|
52
|
+
*/
|
|
53
|
+
export function getPentatopeFaces() {
|
|
54
|
+
const faces = [];
|
|
55
|
+
for (let i = 0; i < 5; i++) {
|
|
56
|
+
for (let j = i + 1; j < 5; j++) {
|
|
57
|
+
for (let k = j + 1; k < 5; k++) {
|
|
58
|
+
faces.push([i, j, k]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return faces;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get the 5 tetrahedral cells of the pentatope
|
|
67
|
+
* @returns {number[][]} Cell vertex indices
|
|
68
|
+
*/
|
|
69
|
+
export function getPentatopeCells() {
|
|
70
|
+
const cells = [];
|
|
71
|
+
for (let i = 0; i < 5; i++) {
|
|
72
|
+
// Each cell is defined by excluding one vertex
|
|
73
|
+
const cell = [];
|
|
74
|
+
for (let j = 0; j < 5; j++) {
|
|
75
|
+
if (j !== i) cell.push(j);
|
|
76
|
+
}
|
|
77
|
+
cells.push(cell);
|
|
78
|
+
}
|
|
79
|
+
return cells;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Convert point to barycentric coordinates relative to pentatope
|
|
84
|
+
* @param {Vec4} point - Point in 4D space
|
|
85
|
+
* @param {Vec4[]} pentatopeVerts - The 5 pentatope vertices
|
|
86
|
+
* @returns {number[]} 5 barycentric coordinates
|
|
87
|
+
*/
|
|
88
|
+
export function toBarycentricCoords(point, pentatopeVerts) {
|
|
89
|
+
// Solve the system Ax = p where A is the 5 pentatope vertices
|
|
90
|
+
// and x are the barycentric weights
|
|
91
|
+
// Using least squares approximation
|
|
92
|
+
|
|
93
|
+
const coords = [0, 0, 0, 0, 0];
|
|
94
|
+
let totalDist = 0;
|
|
95
|
+
|
|
96
|
+
for (let i = 0; i < 5; i++) {
|
|
97
|
+
const dist = 1 / (point.distanceTo(pentatopeVerts[i]) + 0.0001);
|
|
98
|
+
coords[i] = dist;
|
|
99
|
+
totalDist += dist;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Normalize
|
|
103
|
+
for (let i = 0; i < 5; i++) {
|
|
104
|
+
coords[i] /= totalDist;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return coords;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Convert barycentric coordinates back to 4D point
|
|
112
|
+
* @param {number[]} coords - 5 barycentric coordinates
|
|
113
|
+
* @param {Vec4[]} pentatopeVerts - The 5 pentatope vertices
|
|
114
|
+
* @returns {Vec4} Point in 4D space
|
|
115
|
+
*/
|
|
116
|
+
export function fromBarycentricCoords(coords, pentatopeVerts) {
|
|
117
|
+
let x = 0, y = 0, z = 0, w = 0;
|
|
118
|
+
|
|
119
|
+
for (let i = 0; i < 5; i++) {
|
|
120
|
+
x += coords[i] * pentatopeVerts[i].x;
|
|
121
|
+
y += coords[i] * pentatopeVerts[i].y;
|
|
122
|
+
z += coords[i] * pentatopeVerts[i].z;
|
|
123
|
+
w += coords[i] * pentatopeVerts[i].w;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return new Vec4(x, y, z, w);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Project point onto pentatope surface (nearest face)
|
|
131
|
+
* @param {Vec4} point - Input point
|
|
132
|
+
* @param {Vec4[]} pentatopeVerts - Pentatope vertices
|
|
133
|
+
* @param {number} scale - Scale factor
|
|
134
|
+
* @returns {Vec4} Point on pentatope surface
|
|
135
|
+
*/
|
|
136
|
+
export function projectToPentatopeSurface(point, pentatopeVerts, scale = 1) {
|
|
137
|
+
// Find the nearest face and project onto it
|
|
138
|
+
const faces = getPentatopeFaces();
|
|
139
|
+
let nearestDist = Infinity;
|
|
140
|
+
let nearestPoint = point;
|
|
141
|
+
|
|
142
|
+
for (const face of faces) {
|
|
143
|
+
// Get face center
|
|
144
|
+
const center = new Vec4(
|
|
145
|
+
(pentatopeVerts[face[0]].x + pentatopeVerts[face[1]].x + pentatopeVerts[face[2]].x) / 3,
|
|
146
|
+
(pentatopeVerts[face[0]].y + pentatopeVerts[face[1]].y + pentatopeVerts[face[2]].y) / 3,
|
|
147
|
+
(pentatopeVerts[face[0]].z + pentatopeVerts[face[1]].z + pentatopeVerts[face[2]].z) / 3,
|
|
148
|
+
(pentatopeVerts[face[0]].w + pentatopeVerts[face[1]].w + pentatopeVerts[face[2]].w) / 3
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const dist = point.distanceTo(center);
|
|
152
|
+
if (dist < nearestDist) {
|
|
153
|
+
nearestDist = dist;
|
|
154
|
+
// Project onto the face plane
|
|
155
|
+
const faceNormal = computeFaceNormal(
|
|
156
|
+
pentatopeVerts[face[0]],
|
|
157
|
+
pentatopeVerts[face[1]],
|
|
158
|
+
pentatopeVerts[face[2]]
|
|
159
|
+
);
|
|
160
|
+
const toPoint = point.sub(center);
|
|
161
|
+
const projection = toPoint.sub(faceNormal.scale(toPoint.dot(faceNormal)));
|
|
162
|
+
nearestPoint = center.add(projection);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return nearestPoint.scale(scale);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Compute face normal (in 4D, use cross product analog)
|
|
171
|
+
* @param {Vec4} v0
|
|
172
|
+
* @param {Vec4} v1
|
|
173
|
+
* @param {Vec4} v2
|
|
174
|
+
* @returns {Vec4} Normal vector
|
|
175
|
+
*/
|
|
176
|
+
function computeFaceNormal(v0, v1, v2) {
|
|
177
|
+
const e1 = v1.sub(v0);
|
|
178
|
+
const e2 = v2.sub(v0);
|
|
179
|
+
|
|
180
|
+
// In 4D, use a simplified normal computation
|
|
181
|
+
// Take the component orthogonal to both edges
|
|
182
|
+
const n = new Vec4(
|
|
183
|
+
e1.y * e2.z - e1.z * e2.y,
|
|
184
|
+
e1.z * e2.x - e1.x * e2.z,
|
|
185
|
+
e1.x * e2.y - e1.y * e2.x,
|
|
186
|
+
e1.w * (e2.x + e2.y + e2.z) - e2.w * (e1.x + e1.y + e1.z)
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
return n.normalize();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Warp geometry using tetrahedral interpolation
|
|
194
|
+
* Points are mapped based on their proximity to pentatope vertices
|
|
195
|
+
* @param {Vec4[]} vertices - Input vertices
|
|
196
|
+
* @param {number} size - Pentatope size
|
|
197
|
+
* @param {number} blend - Blend factor (0=original, 1=full warp)
|
|
198
|
+
* @returns {Vec4[]} Warped vertices
|
|
199
|
+
*/
|
|
200
|
+
export function warpTetrahedral(vertices, size = 1, blend = 1) {
|
|
201
|
+
const pentatopeVerts = getPentatopeVertices(size);
|
|
202
|
+
|
|
203
|
+
return vertices.map(v => {
|
|
204
|
+
// Get barycentric coordinates
|
|
205
|
+
const bary = toBarycentricCoords(v, pentatopeVerts);
|
|
206
|
+
|
|
207
|
+
// Reconstruct from barycentric - this "snaps" toward pentatope structure
|
|
208
|
+
const warped = fromBarycentricCoords(bary, pentatopeVerts);
|
|
209
|
+
|
|
210
|
+
return v.lerp(warped, blend);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Warp geometry by projecting onto pentatope edges
|
|
216
|
+
* Creates wire-frame like structures
|
|
217
|
+
* @param {Vec4[]} vertices - Input vertices
|
|
218
|
+
* @param {number} size - Pentatope size
|
|
219
|
+
* @param {number} snap - How strongly to snap to edges
|
|
220
|
+
* @returns {Vec4[]} Warped vertices
|
|
221
|
+
*/
|
|
222
|
+
export function warpToEdges(vertices, size = 1, snap = 0.5) {
|
|
223
|
+
const pentatopeVerts = getPentatopeVertices(size);
|
|
224
|
+
const edges = getPentatopeEdges();
|
|
225
|
+
|
|
226
|
+
return vertices.map(v => {
|
|
227
|
+
// Find nearest edge and project onto it
|
|
228
|
+
let nearestDist = Infinity;
|
|
229
|
+
let nearestPoint = v;
|
|
230
|
+
|
|
231
|
+
for (const [i, j] of edges) {
|
|
232
|
+
const edgeStart = pentatopeVerts[i];
|
|
233
|
+
const edgeEnd = pentatopeVerts[j];
|
|
234
|
+
const edgeVec = edgeEnd.sub(edgeStart);
|
|
235
|
+
const edgeLen = edgeVec.length();
|
|
236
|
+
|
|
237
|
+
// Project v onto edge
|
|
238
|
+
const toV = v.sub(edgeStart);
|
|
239
|
+
let t = toV.dot(edgeVec) / (edgeLen * edgeLen);
|
|
240
|
+
t = Math.max(0, Math.min(1, t));
|
|
241
|
+
|
|
242
|
+
const projection = edgeStart.add(edgeVec.scale(t));
|
|
243
|
+
const dist = v.distanceTo(projection);
|
|
244
|
+
|
|
245
|
+
if (dist < nearestDist) {
|
|
246
|
+
nearestDist = dist;
|
|
247
|
+
nearestPoint = projection;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return v.lerp(nearestPoint, snap);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Warp geometry to lie on pentatope cells (tetrahedral cells)
|
|
257
|
+
* @param {Vec4[]} vertices - Input vertices
|
|
258
|
+
* @param {number} size - Pentatope size
|
|
259
|
+
* @param {number} cellInfluence - How much cells pull points (0-1)
|
|
260
|
+
* @returns {Vec4[]} Warped vertices
|
|
261
|
+
*/
|
|
262
|
+
export function warpToCells(vertices, size = 1, cellInfluence = 0.7) {
|
|
263
|
+
const pentatopeVerts = getPentatopeVertices(size);
|
|
264
|
+
const cells = getPentatopeCells();
|
|
265
|
+
|
|
266
|
+
return vertices.map(v => {
|
|
267
|
+
// Find nearest cell center
|
|
268
|
+
let nearestDist = Infinity;
|
|
269
|
+
let nearestCell = 0;
|
|
270
|
+
|
|
271
|
+
for (let c = 0; c < cells.length; c++) {
|
|
272
|
+
const cellVerts = cells[c].map(i => pentatopeVerts[i]);
|
|
273
|
+
const center = new Vec4(
|
|
274
|
+
(cellVerts[0].x + cellVerts[1].x + cellVerts[2].x + cellVerts[3].x) / 4,
|
|
275
|
+
(cellVerts[0].y + cellVerts[1].y + cellVerts[2].y + cellVerts[3].y) / 4,
|
|
276
|
+
(cellVerts[0].z + cellVerts[1].z + cellVerts[2].z + cellVerts[3].z) / 4,
|
|
277
|
+
(cellVerts[0].w + cellVerts[1].w + cellVerts[2].w + cellVerts[3].w) / 4
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
const dist = v.distanceTo(center);
|
|
281
|
+
if (dist < nearestDist) {
|
|
282
|
+
nearestDist = dist;
|
|
283
|
+
nearestCell = c;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Project into the cell's tetrahedral space
|
|
288
|
+
const cellVerts = cells[nearestCell].map(i => pentatopeVerts[i]);
|
|
289
|
+
|
|
290
|
+
// Simple approach: interpolate toward cell center
|
|
291
|
+
const center = new Vec4(
|
|
292
|
+
(cellVerts[0].x + cellVerts[1].x + cellVerts[2].x + cellVerts[3].x) / 4,
|
|
293
|
+
(cellVerts[0].y + cellVerts[1].y + cellVerts[2].y + cellVerts[3].y) / 4,
|
|
294
|
+
(cellVerts[0].z + cellVerts[1].z + cellVerts[2].z + cellVerts[3].z) / 4,
|
|
295
|
+
(cellVerts[0].w + cellVerts[1].w + cellVerts[2].w + cellVerts[3].w) / 4
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
// Move toward the cell but maintain some original structure
|
|
299
|
+
const toCenterDir = center.sub(v).normalize();
|
|
300
|
+
const distToCenter = v.distanceTo(center);
|
|
301
|
+
const targetDist = size * 0.5; // Target distance from center
|
|
302
|
+
|
|
303
|
+
if (distToCenter > targetDist) {
|
|
304
|
+
const adjustment = toCenterDir.scale((distToCenter - targetDist) * cellInfluence);
|
|
305
|
+
return v.add(adjustment);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return v;
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Main hypertetrahedron core warp function
|
|
314
|
+
* Wraps base geometry in a 4D pentatope structure
|
|
315
|
+
*
|
|
316
|
+
* @param {object} geometry - Base geometry with vertices and edges
|
|
317
|
+
* @param {object} options - Warp options
|
|
318
|
+
* @param {string} options.method - 'tetrahedral', 'edges', 'cells', 'surface'
|
|
319
|
+
* @param {number} options.size - Pentatope size (default 1)
|
|
320
|
+
* @param {number} options.blend - Blend factor (default 1)
|
|
321
|
+
* @param {number} options.snap - Edge snap strength (default 0.5)
|
|
322
|
+
* @returns {object} Warped geometry
|
|
323
|
+
*/
|
|
324
|
+
export function warpHypertetraCore(geometry, options = {}) {
|
|
325
|
+
const {
|
|
326
|
+
method = 'tetrahedral',
|
|
327
|
+
size = 1,
|
|
328
|
+
blend = 1,
|
|
329
|
+
snap = 0.5
|
|
330
|
+
} = options;
|
|
331
|
+
|
|
332
|
+
let warpedVertices;
|
|
333
|
+
const pentatopeVerts = getPentatopeVertices(size);
|
|
334
|
+
|
|
335
|
+
switch (method) {
|
|
336
|
+
case 'edges':
|
|
337
|
+
warpedVertices = warpToEdges(geometry.vertices, size, snap);
|
|
338
|
+
break;
|
|
339
|
+
|
|
340
|
+
case 'cells':
|
|
341
|
+
warpedVertices = warpToCells(geometry.vertices, size, blend);
|
|
342
|
+
break;
|
|
343
|
+
|
|
344
|
+
case 'surface':
|
|
345
|
+
warpedVertices = geometry.vertices.map(v =>
|
|
346
|
+
projectToPentatopeSurface(v, pentatopeVerts, size)
|
|
347
|
+
);
|
|
348
|
+
break;
|
|
349
|
+
|
|
350
|
+
case 'tetrahedral':
|
|
351
|
+
default:
|
|
352
|
+
warpedVertices = warpTetrahedral(geometry.vertices, size, blend);
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return {
|
|
357
|
+
...geometry,
|
|
358
|
+
name: `${geometry.name}_hypertetra`,
|
|
359
|
+
vertices: warpedVertices,
|
|
360
|
+
vertexCount: warpedVertices.length,
|
|
361
|
+
coreType: 'hypertetrahedron',
|
|
362
|
+
warpMethod: method,
|
|
363
|
+
pentatopeSize: size
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Get a complete pentatope geometry (for reference/debugging)
|
|
369
|
+
* @param {number} size - Scale factor
|
|
370
|
+
* @returns {object} Pentatope geometry
|
|
371
|
+
*/
|
|
372
|
+
export function generatePentatope(size = 1) {
|
|
373
|
+
return {
|
|
374
|
+
name: 'pentatope',
|
|
375
|
+
vertices: getPentatopeVertices(size),
|
|
376
|
+
edges: getPentatopeEdges(),
|
|
377
|
+
faces: getPentatopeFaces(),
|
|
378
|
+
cells: getPentatopeCells(),
|
|
379
|
+
vertexCount: 5,
|
|
380
|
+
edgeCount: 10,
|
|
381
|
+
faceCount: 10,
|
|
382
|
+
cellCount: 5
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export default warpHypertetraCore;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Geometry Warp Functions
|
|
3
|
+
*
|
|
4
|
+
* Core transformations that wrap base geometries in 4D structures.
|
|
5
|
+
* Part of the 24-variant encoding system:
|
|
6
|
+
* - geometries 0-7: Base geometries (no warp)
|
|
7
|
+
* - geometries 8-15: Hypersphere core warp
|
|
8
|
+
* - geometries 16-23: Hypertetrahedron core warp
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
warpHypersphereCore,
|
|
13
|
+
projectToHypersphere,
|
|
14
|
+
stereographicToHypersphere,
|
|
15
|
+
hopfFibration,
|
|
16
|
+
warpRadial,
|
|
17
|
+
warpStereographic,
|
|
18
|
+
warpHopf,
|
|
19
|
+
generateHypersphereSurface
|
|
20
|
+
} from './HypersphereCore.js';
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
warpHypertetraCore,
|
|
24
|
+
getPentatopeVertices,
|
|
25
|
+
getPentatopeEdges,
|
|
26
|
+
getPentatopeFaces,
|
|
27
|
+
getPentatopeCells,
|
|
28
|
+
toBarycentricCoords,
|
|
29
|
+
fromBarycentricCoords,
|
|
30
|
+
warpTetrahedral,
|
|
31
|
+
warpToEdges,
|
|
32
|
+
warpToCells,
|
|
33
|
+
generatePentatope
|
|
34
|
+
} from './HypertetraCore.js';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Core type constants
|
|
38
|
+
*/
|
|
39
|
+
export const CORE_TYPES = {
|
|
40
|
+
BASE: 0,
|
|
41
|
+
HYPERSPHERE: 1,
|
|
42
|
+
HYPERTETRAHEDRON: 2
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get core type name from index
|
|
47
|
+
* @param {number} coreIndex
|
|
48
|
+
* @returns {string}
|
|
49
|
+
*/
|
|
50
|
+
export function getCoreTypeName(coreIndex) {
|
|
51
|
+
switch (coreIndex) {
|
|
52
|
+
case 0: return 'base';
|
|
53
|
+
case 1: return 'hypersphere';
|
|
54
|
+
case 2: return 'hypertetrahedron';
|
|
55
|
+
default: return 'unknown';
|
|
56
|
+
}
|
|
57
|
+
}
|