@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,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Klein Bottle Generator
|
|
3
|
+
*
|
|
4
|
+
* The Klein bottle is a non-orientable surface that cannot exist
|
|
5
|
+
* in 3D without self-intersection, but can be properly embedded in 4D.
|
|
6
|
+
*
|
|
7
|
+
* In 4D, it's a closed surface with no boundary and no inside/outside.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Vec4 } from '../../math/Vec4.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Generate Klein Bottle vertices using 4D embedding
|
|
14
|
+
* The "figure-8" immersion extended to 4D to remove self-intersection
|
|
15
|
+
*
|
|
16
|
+
* @param {number} radius - Overall scale
|
|
17
|
+
* @param {number} uSegments - Segments around length
|
|
18
|
+
* @param {number} vSegments - Segments around circumference
|
|
19
|
+
* @returns {Vec4[]} Array of vertices
|
|
20
|
+
*/
|
|
21
|
+
export function generateKleinBottleVertices(radius = 1, uSegments = 32, vSegments = 16) {
|
|
22
|
+
const vertices = [];
|
|
23
|
+
const r = radius;
|
|
24
|
+
|
|
25
|
+
for (let i = 0; i <= uSegments; i++) {
|
|
26
|
+
const u = (i / uSegments) * Math.PI * 2;
|
|
27
|
+
const cosU = Math.cos(u);
|
|
28
|
+
const sinU = Math.sin(u);
|
|
29
|
+
const cos2U = Math.cos(2 * u);
|
|
30
|
+
const sin2U = Math.sin(2 * u);
|
|
31
|
+
|
|
32
|
+
for (let j = 0; j <= vSegments; j++) {
|
|
33
|
+
const v = (j / vSegments) * Math.PI * 2;
|
|
34
|
+
const cosV = Math.cos(v);
|
|
35
|
+
const sinV = Math.sin(v);
|
|
36
|
+
|
|
37
|
+
// Klein bottle parametric equations in 4D
|
|
38
|
+
// This is the "figure-8" Klein bottle lifted to 4D
|
|
39
|
+
const x = r * (cosU * (cosU * cosV + 1) - sinU * sin2U * cosV / 2);
|
|
40
|
+
const y = r * (sinU * (cosU * cosV + 1) + cosU * sin2U * cosV / 2);
|
|
41
|
+
const z = r * sinV * (1 + cos2U / 2);
|
|
42
|
+
const w = r * sinV * sin2U / 2;
|
|
43
|
+
|
|
44
|
+
vertices.push(new Vec4(x, y, z, w));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return vertices;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Generate Klein Bottle using "bottle" parameterization
|
|
53
|
+
* @param {number} scale - Overall scale
|
|
54
|
+
* @param {number} segments - Resolution
|
|
55
|
+
* @returns {Vec4[]} Vertices
|
|
56
|
+
*/
|
|
57
|
+
export function generateKleinBottleBottle(scale = 1, segments = 24) {
|
|
58
|
+
const vertices = [];
|
|
59
|
+
const a = scale * 2;
|
|
60
|
+
const b = scale;
|
|
61
|
+
|
|
62
|
+
for (let i = 0; i <= segments; i++) {
|
|
63
|
+
const u = (i / segments) * Math.PI * 2;
|
|
64
|
+
|
|
65
|
+
for (let j = 0; j <= segments; j++) {
|
|
66
|
+
const v = (j / segments) * Math.PI * 2;
|
|
67
|
+
|
|
68
|
+
let x, y, z, w;
|
|
69
|
+
|
|
70
|
+
if (u < Math.PI) {
|
|
71
|
+
// First half: bottle body
|
|
72
|
+
x = (a + b * Math.cos(u)) * Math.cos(v);
|
|
73
|
+
y = (a + b * Math.cos(u)) * Math.sin(v);
|
|
74
|
+
z = b * Math.sin(u);
|
|
75
|
+
w = b * Math.sin(u) * Math.sin(v / 2);
|
|
76
|
+
} else {
|
|
77
|
+
// Second half: handle that passes through
|
|
78
|
+
const uShift = u - Math.PI;
|
|
79
|
+
x = a * Math.cos(v) + b * Math.cos(uShift) * Math.cos(v);
|
|
80
|
+
y = a * Math.sin(v) + b * Math.cos(uShift) * Math.sin(v);
|
|
81
|
+
z = -b * Math.sin(uShift);
|
|
82
|
+
w = -b * Math.sin(uShift) * Math.cos(v / 2);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
vertices.push(new Vec4(x, y, z, w));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return vertices;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Generate Klein Bottle edges
|
|
94
|
+
* @param {number} uSegments
|
|
95
|
+
* @param {number} vSegments
|
|
96
|
+
* @returns {number[][]} Edge pairs
|
|
97
|
+
*/
|
|
98
|
+
export function generateKleinBottleEdges(uSegments = 32, vSegments = 16) {
|
|
99
|
+
const edges = [];
|
|
100
|
+
|
|
101
|
+
for (let i = 0; i < uSegments; i++) {
|
|
102
|
+
for (let j = 0; j < vSegments; j++) {
|
|
103
|
+
const idx = i * (vSegments + 1) + j;
|
|
104
|
+
const nextU = (i + 1) * (vSegments + 1) + j;
|
|
105
|
+
const nextV = i * (vSegments + 1) + j + 1;
|
|
106
|
+
|
|
107
|
+
edges.push([idx, nextU]);
|
|
108
|
+
edges.push([idx, nextV]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Close the surface by connecting last to first
|
|
113
|
+
// Note: Klein bottle has twisted identification
|
|
114
|
+
for (let j = 0; j < vSegments; j++) {
|
|
115
|
+
const lastU = uSegments * (vSegments + 1) + j;
|
|
116
|
+
// Connect to reversed v on first u
|
|
117
|
+
const firstU = (vSegments - j);
|
|
118
|
+
edges.push([lastU, firstU]);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return edges;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Generate Möbius strip (related to Klein bottle)
|
|
126
|
+
* A Möbius strip is a one-sided surface that can be embedded in 4D
|
|
127
|
+
* @param {number} radius - Major radius
|
|
128
|
+
* @param {number} width - Strip width
|
|
129
|
+
* @param {number} segments - Resolution
|
|
130
|
+
* @returns {object} Geometry
|
|
131
|
+
*/
|
|
132
|
+
export function generateMobiusStrip(radius = 1, width = 0.3, segments = 32) {
|
|
133
|
+
const vertices = [];
|
|
134
|
+
const edges = [];
|
|
135
|
+
|
|
136
|
+
for (let i = 0; i <= segments; i++) {
|
|
137
|
+
const u = (i / segments) * Math.PI * 2;
|
|
138
|
+
const halfU = u / 2;
|
|
139
|
+
|
|
140
|
+
for (let j = 0; j <= 4; j++) {
|
|
141
|
+
const v = (j / 4) * 2 - 1; // -1 to 1
|
|
142
|
+
|
|
143
|
+
const x = (radius + width * v * Math.cos(halfU)) * Math.cos(u);
|
|
144
|
+
const y = (radius + width * v * Math.cos(halfU)) * Math.sin(u);
|
|
145
|
+
const z = width * v * Math.sin(halfU);
|
|
146
|
+
const w = width * v * Math.sin(halfU) * 0.5; // Lift to 4D
|
|
147
|
+
|
|
148
|
+
vertices.push(new Vec4(x, y, z, w));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Generate grid edges
|
|
153
|
+
for (let i = 0; i < segments; i++) {
|
|
154
|
+
for (let j = 0; j < 4; j++) {
|
|
155
|
+
const idx = i * 5 + j;
|
|
156
|
+
edges.push([idx, idx + 1]); // Along width
|
|
157
|
+
edges.push([idx, idx + 5]); // Along length
|
|
158
|
+
}
|
|
159
|
+
edges.push([i * 5 + 4, (i + 1) * 5 + 4]); // Last row
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
name: 'mobius_strip',
|
|
164
|
+
vertices,
|
|
165
|
+
edges,
|
|
166
|
+
faces: [],
|
|
167
|
+
vertexCount: vertices.length,
|
|
168
|
+
edgeCount: edges.length,
|
|
169
|
+
faceCount: 0
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Generate complete Klein Bottle geometry
|
|
175
|
+
* @param {number} scale - Overall scale
|
|
176
|
+
* @param {number} density - Vertex density
|
|
177
|
+
* @returns {object} Geometry
|
|
178
|
+
*/
|
|
179
|
+
export function generateKleinBottle(scale = 1, density = 24) {
|
|
180
|
+
const uSeg = density;
|
|
181
|
+
const vSeg = Math.floor(density / 2);
|
|
182
|
+
const vertices = generateKleinBottleVertices(scale, uSeg, vSeg);
|
|
183
|
+
const edges = generateKleinBottleEdges(uSeg, vSeg);
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
name: 'klein_bottle',
|
|
187
|
+
vertices,
|
|
188
|
+
edges,
|
|
189
|
+
faces: [],
|
|
190
|
+
vertexCount: vertices.length,
|
|
191
|
+
edgeCount: edges.length,
|
|
192
|
+
faceCount: 0,
|
|
193
|
+
nonOrientable: true
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export default generateKleinBottle;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 4D Hypersphere Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates points on a 4D hypersphere using various sampling methods.
|
|
5
|
+
* The 3-sphere (hypersphere) is the set of points equidistant from origin in 4D.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Vec4 } from '../../math/Vec4.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generate hypersphere vertices using spherical coordinates
|
|
12
|
+
* Uses 3 angles (θ, φ, ψ) to parameterize the 3-sphere
|
|
13
|
+
*
|
|
14
|
+
* @param {number} radius - Sphere radius
|
|
15
|
+
* @param {number} segments - Points per dimension
|
|
16
|
+
* @returns {Vec4[]} Array of vertices on hypersphere
|
|
17
|
+
*/
|
|
18
|
+
export function generateHypersphereVertices(radius = 1, segments = 8) {
|
|
19
|
+
const vertices = [];
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i <= segments; i++) {
|
|
22
|
+
const theta = (i / segments) * Math.PI;
|
|
23
|
+
const sinTheta = Math.sin(theta);
|
|
24
|
+
const cosTheta = Math.cos(theta);
|
|
25
|
+
|
|
26
|
+
for (let j = 0; j <= segments; j++) {
|
|
27
|
+
const phi = (j / segments) * Math.PI;
|
|
28
|
+
const sinPhi = Math.sin(phi);
|
|
29
|
+
const cosPhi = Math.cos(phi);
|
|
30
|
+
|
|
31
|
+
for (let k = 0; k <= segments * 2; k++) {
|
|
32
|
+
const psi = (k / (segments * 2)) * Math.PI * 2;
|
|
33
|
+
const sinPsi = Math.sin(psi);
|
|
34
|
+
const cosPsi = Math.cos(psi);
|
|
35
|
+
|
|
36
|
+
// Hyperspherical coordinates
|
|
37
|
+
const x = radius * sinTheta * sinPhi * cosPsi;
|
|
38
|
+
const y = radius * sinTheta * sinPhi * sinPsi;
|
|
39
|
+
const z = radius * sinTheta * cosPhi;
|
|
40
|
+
const w = radius * cosTheta;
|
|
41
|
+
|
|
42
|
+
vertices.push(new Vec4(x, y, z, w));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return vertices;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Generate hypersphere using Fibonacci lattice (more uniform distribution)
|
|
52
|
+
* @param {number} radius - Sphere radius
|
|
53
|
+
* @param {number} count - Number of points
|
|
54
|
+
* @returns {Vec4[]} Array of uniformly distributed vertices
|
|
55
|
+
*/
|
|
56
|
+
export function generateHypersphereFibonacci(radius = 1, count = 200) {
|
|
57
|
+
const vertices = [];
|
|
58
|
+
const phi = (1 + Math.sqrt(5)) / 2; // Golden ratio
|
|
59
|
+
|
|
60
|
+
for (let i = 0; i < count; i++) {
|
|
61
|
+
// Use 4D Fibonacci-like sequence
|
|
62
|
+
const t1 = i / phi;
|
|
63
|
+
const t2 = i / (phi * phi);
|
|
64
|
+
const t3 = i / (phi * phi * phi);
|
|
65
|
+
|
|
66
|
+
// Convert to angles
|
|
67
|
+
const theta = Math.acos(1 - 2 * (i + 0.5) / count);
|
|
68
|
+
const phi1 = 2 * Math.PI * (t1 % 1);
|
|
69
|
+
const phi2 = 2 * Math.PI * (t2 % 1);
|
|
70
|
+
|
|
71
|
+
// Map to 4D sphere
|
|
72
|
+
const sinTheta = Math.sin(theta);
|
|
73
|
+
const cosTheta = Math.cos(theta);
|
|
74
|
+
const sinPhi1 = Math.sin(phi1);
|
|
75
|
+
const cosPhi1 = Math.cos(phi1);
|
|
76
|
+
const sinPhi2 = Math.sin(phi2);
|
|
77
|
+
const cosPhi2 = Math.cos(phi2);
|
|
78
|
+
|
|
79
|
+
const x = radius * sinTheta * cosPhi1;
|
|
80
|
+
const y = radius * sinTheta * sinPhi1 * cosPhi2;
|
|
81
|
+
const z = radius * sinTheta * sinPhi1 * sinPhi2;
|
|
82
|
+
const w = radius * cosTheta;
|
|
83
|
+
|
|
84
|
+
vertices.push(new Vec4(x, y, z, w));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return vertices;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Generate hypersphere edges connecting nearby vertices
|
|
92
|
+
* @param {Vec4[]} vertices - Vertices to connect
|
|
93
|
+
* @param {number} threshold - Distance threshold for connection
|
|
94
|
+
* @returns {number[][]} Edge pairs
|
|
95
|
+
*/
|
|
96
|
+
export function generateHypersphereEdges(vertices, threshold = 0.5) {
|
|
97
|
+
const edges = [];
|
|
98
|
+
|
|
99
|
+
for (let i = 0; i < vertices.length; i++) {
|
|
100
|
+
for (let j = i + 1; j < vertices.length; j++) {
|
|
101
|
+
const dist = vertices[i].distanceTo(vertices[j]);
|
|
102
|
+
if (dist < threshold) {
|
|
103
|
+
edges.push([i, j]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return edges;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Generate latitude circles on hypersphere
|
|
113
|
+
* @param {number} radius - Sphere radius
|
|
114
|
+
* @param {number} latitudes - Number of latitude circles
|
|
115
|
+
* @param {number} pointsPerCircle - Points per circle
|
|
116
|
+
* @returns {object} Geometry with latitude circles
|
|
117
|
+
*/
|
|
118
|
+
export function generateHypersphereLatitudes(radius = 1, latitudes = 8, pointsPerCircle = 16) {
|
|
119
|
+
const vertices = [];
|
|
120
|
+
const edges = [];
|
|
121
|
+
|
|
122
|
+
// Generate latitude circles at different W values
|
|
123
|
+
for (let lat = 0; lat <= latitudes; lat++) {
|
|
124
|
+
const w = radius * Math.cos((lat / latitudes) * Math.PI);
|
|
125
|
+
const circleRadius = Math.sqrt(radius * radius - w * w);
|
|
126
|
+
|
|
127
|
+
if (circleRadius < 0.001) {
|
|
128
|
+
// Just a point at poles
|
|
129
|
+
vertices.push(new Vec4(0, 0, 0, w));
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const startIdx = vertices.length;
|
|
134
|
+
|
|
135
|
+
// Generate circle at this latitude
|
|
136
|
+
for (let i = 0; i < pointsPerCircle; i++) {
|
|
137
|
+
const angle1 = (i / pointsPerCircle) * Math.PI * 2;
|
|
138
|
+
|
|
139
|
+
// Inner loop for the 3D circle at this W slice
|
|
140
|
+
for (let j = 0; j < pointsPerCircle / 2; j++) {
|
|
141
|
+
const angle2 = (j / (pointsPerCircle / 2)) * Math.PI * 2;
|
|
142
|
+
|
|
143
|
+
const x = circleRadius * Math.cos(angle1) * Math.cos(angle2);
|
|
144
|
+
const y = circleRadius * Math.cos(angle1) * Math.sin(angle2);
|
|
145
|
+
const z = circleRadius * Math.sin(angle1);
|
|
146
|
+
|
|
147
|
+
vertices.push(new Vec4(x, y, z, w));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Connect points in this latitude
|
|
152
|
+
const endIdx = vertices.length;
|
|
153
|
+
for (let i = startIdx; i < endIdx - 1; i++) {
|
|
154
|
+
edges.push([i, i + 1]);
|
|
155
|
+
}
|
|
156
|
+
if (endIdx > startIdx + 1) {
|
|
157
|
+
edges.push([endIdx - 1, startIdx]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
name: 'hypersphere_latitudes',
|
|
163
|
+
vertices,
|
|
164
|
+
edges,
|
|
165
|
+
faces: [],
|
|
166
|
+
vertexCount: vertices.length,
|
|
167
|
+
edgeCount: edges.length
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Generate complete hypersphere geometry
|
|
173
|
+
* @param {number} radius - Sphere radius
|
|
174
|
+
* @param {number} density - Vertex density
|
|
175
|
+
* @returns {object} Geometry object
|
|
176
|
+
*/
|
|
177
|
+
export function generateSphere(radius = 1, density = 8) {
|
|
178
|
+
const vertices = generateHypersphereFibonacci(radius, density * density * 4);
|
|
179
|
+
const edges = generateHypersphereEdges(vertices, radius * 0.4);
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
name: 'hypersphere',
|
|
183
|
+
vertices,
|
|
184
|
+
edges,
|
|
185
|
+
faces: [],
|
|
186
|
+
vertexCount: vertices.length,
|
|
187
|
+
edgeCount: edges.length,
|
|
188
|
+
faceCount: 0
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export default generateSphere;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tesseract (Hypercube) Generator
|
|
3
|
+
*
|
|
4
|
+
* The tesseract is the 4D analog of a cube.
|
|
5
|
+
* - 16 vertices (2^4)
|
|
6
|
+
* - 32 edges
|
|
7
|
+
* - 24 square faces
|
|
8
|
+
* - 8 cubic cells
|
|
9
|
+
*
|
|
10
|
+
* Vertices are at all combinations of (±1, ±1, ±1, ±1)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { Vec4 } from '../../math/Vec4.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Generate tesseract vertices
|
|
17
|
+
* @param {number} size - Half-edge length (default 1)
|
|
18
|
+
* @returns {Vec4[]} Array of 16 vertices
|
|
19
|
+
*/
|
|
20
|
+
export function generateTesseractVertices(size = 1) {
|
|
21
|
+
const vertices = [];
|
|
22
|
+
|
|
23
|
+
// Generate all 16 vertices at (±size, ±size, ±size, ±size)
|
|
24
|
+
for (let i = 0; i < 16; i++) {
|
|
25
|
+
const x = (i & 1) ? size : -size;
|
|
26
|
+
const y = (i & 2) ? size : -size;
|
|
27
|
+
const z = (i & 4) ? size : -size;
|
|
28
|
+
const w = (i & 8) ? size : -size;
|
|
29
|
+
vertices.push(new Vec4(x, y, z, w));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return vertices;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Generate tesseract edges
|
|
37
|
+
* Two vertices are connected if they differ in exactly one coordinate
|
|
38
|
+
* @returns {number[][]} Array of [i, j] index pairs
|
|
39
|
+
*/
|
|
40
|
+
export function generateTesseractEdges() {
|
|
41
|
+
const edges = [];
|
|
42
|
+
|
|
43
|
+
for (let i = 0; i < 16; i++) {
|
|
44
|
+
for (let j = i + 1; j < 16; j++) {
|
|
45
|
+
// Count differing bits (Hamming distance)
|
|
46
|
+
const diff = i ^ j;
|
|
47
|
+
// If exactly one bit differs, they're connected
|
|
48
|
+
if (diff && !(diff & (diff - 1))) {
|
|
49
|
+
edges.push([i, j]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return edges;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Generate tesseract faces (squares)
|
|
59
|
+
* Each face is defined by fixing 2 coordinates and varying 2
|
|
60
|
+
* @returns {number[][]} Array of [a, b, c, d] vertex indices (counterclockwise)
|
|
61
|
+
*/
|
|
62
|
+
export function generateTesseractFaces() {
|
|
63
|
+
const faces = [];
|
|
64
|
+
|
|
65
|
+
// For each pair of dimensions, and each combination of fixed values
|
|
66
|
+
for (let dim1 = 0; dim1 < 4; dim1++) {
|
|
67
|
+
for (let dim2 = dim1 + 1; dim2 < 4; dim2++) {
|
|
68
|
+
// Fixed dimensions
|
|
69
|
+
const fixedDims = [];
|
|
70
|
+
for (let d = 0; d < 4; d++) {
|
|
71
|
+
if (d !== dim1 && d !== dim2) fixedDims.push(d);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// For each combination of fixed dimension values
|
|
75
|
+
for (let fixed0 = 0; fixed0 < 2; fixed0++) {
|
|
76
|
+
for (let fixed1 = 0; fixed1 < 2; fixed1++) {
|
|
77
|
+
// Build the 4 vertices of this face
|
|
78
|
+
const faceVertices = [];
|
|
79
|
+
for (let v1 = 0; v1 < 2; v1++) {
|
|
80
|
+
for (let v2 = 0; v2 < 2; v2++) {
|
|
81
|
+
let idx = 0;
|
|
82
|
+
// Set varying dimensions
|
|
83
|
+
if (v1) idx |= (1 << dim1);
|
|
84
|
+
if (v2) idx |= (1 << dim2);
|
|
85
|
+
// Set fixed dimensions
|
|
86
|
+
if (fixed0) idx |= (1 << fixedDims[0]);
|
|
87
|
+
if (fixed1) idx |= (1 << fixedDims[1]);
|
|
88
|
+
faceVertices.push(idx);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Reorder for counterclockwise winding
|
|
92
|
+
faces.push([faceVertices[0], faceVertices[1], faceVertices[3], faceVertices[2]]);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return faces;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Generate complete tesseract geometry
|
|
103
|
+
* @param {number} size - Half-edge length
|
|
104
|
+
* @returns {object} { vertices, edges, faces, cells }
|
|
105
|
+
*/
|
|
106
|
+
export function generateTesseract(size = 1) {
|
|
107
|
+
return {
|
|
108
|
+
name: 'tesseract',
|
|
109
|
+
vertices: generateTesseractVertices(size),
|
|
110
|
+
edges: generateTesseractEdges(),
|
|
111
|
+
faces: generateTesseractFaces(),
|
|
112
|
+
cells: 8,
|
|
113
|
+
vertexCount: 16,
|
|
114
|
+
edgeCount: 32,
|
|
115
|
+
faceCount: 24
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Generate tesseract with subdivided edges for smoother rendering
|
|
121
|
+
* @param {number} size - Half-edge length
|
|
122
|
+
* @param {number} subdivisions - Points per edge (default 1 = no subdivision)
|
|
123
|
+
* @returns {object} Geometry with subdivided edges
|
|
124
|
+
*/
|
|
125
|
+
export function generateTesseractSubdivided(size = 1, subdivisions = 1) {
|
|
126
|
+
const baseGeom = generateTesseract(size);
|
|
127
|
+
const vertices = [...baseGeom.vertices];
|
|
128
|
+
const edges = [];
|
|
129
|
+
|
|
130
|
+
if (subdivisions <= 1) {
|
|
131
|
+
return baseGeom;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// For each edge, add intermediate points
|
|
135
|
+
for (const [i, j] of baseGeom.edges) {
|
|
136
|
+
const v1 = baseGeom.vertices[i];
|
|
137
|
+
const v2 = baseGeom.vertices[j];
|
|
138
|
+
|
|
139
|
+
let prevIdx = i;
|
|
140
|
+
for (let s = 1; s < subdivisions; s++) {
|
|
141
|
+
const t = s / subdivisions;
|
|
142
|
+
const intermediate = v1.lerp(v2, t);
|
|
143
|
+
const newIdx = vertices.length;
|
|
144
|
+
vertices.push(intermediate);
|
|
145
|
+
edges.push([prevIdx, newIdx]);
|
|
146
|
+
prevIdx = newIdx;
|
|
147
|
+
}
|
|
148
|
+
edges.push([prevIdx, j]);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
...baseGeom,
|
|
153
|
+
vertices,
|
|
154
|
+
edges,
|
|
155
|
+
vertexCount: vertices.length,
|
|
156
|
+
edgeCount: edges.length
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export default generateTesseract;
|