@vib3code/sdk 2.0.1 → 2.0.3-canary.3349130
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 +36 -0
- package/DOCS/AGENT_HARNESS_ARCHITECTURE.md +243 -0
- package/DOCS/CLI_ONBOARDING.md +1 -1
- package/DOCS/CROSS_SITE_DESIGN_PATTERNS.md +117 -0
- package/DOCS/EPIC_SCROLL_EVENTS.md +773 -0
- package/DOCS/HANDOFF_LANDING_PAGE.md +154 -0
- package/DOCS/HANDOFF_SDK_DEVELOPMENT.md +493 -0
- package/DOCS/MULTIVIZ_CHOREOGRAPHY_PATTERNS.md +937 -0
- package/DOCS/PRODUCT_STRATEGY.md +63 -0
- package/DOCS/README.md +103 -0
- package/DOCS/REFERENCE_SCROLL_ANALYSIS.md +97 -0
- package/DOCS/ROADMAP.md +111 -0
- package/DOCS/SCROLL_TIMELINE_v3.md +269 -0
- package/DOCS/SITE_REFACTOR_PLAN.md +100 -0
- package/DOCS/STATUS.md +24 -0
- package/DOCS/SYSTEM_INVENTORY.md +33 -30
- package/DOCS/VISUAL_ANALYSIS_CLICKERSS.md +85 -0
- package/DOCS/VISUAL_ANALYSIS_FACETAD.md +133 -0
- package/DOCS/VISUAL_ANALYSIS_SIMONE.md +95 -0
- package/DOCS/VISUAL_ANALYSIS_TABLESIDE.md +86 -0
- package/DOCS/{BLUEPRINT_EXECUTION_PLAN_2026-01-07.md → archive/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md} +1 -1
- package/DOCS/{DEV_TRACK_ANALYSIS.md → archive/DEV_TRACK_ANALYSIS.md} +3 -0
- package/DOCS/{SYSTEM_AUDIT_2026-01-30.md → archive/SYSTEM_AUDIT_2026-01-30.md} +3 -0
- package/DOCS/{DEV_TRACK_SESSION_2026-01-31.md → dev-tracks/DEV_TRACK_SESSION_2026-01-31.md} +1 -1
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-06.md +231 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-13.md +127 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-15.md +142 -0
- package/DOCS/dev-tracks/README.md +10 -0
- package/README.md +26 -13
- package/cpp/CMakeLists.txt +236 -0
- package/cpp/bindings/embind.cpp +269 -0
- package/cpp/build.sh +129 -0
- package/cpp/geometry/Crystal.cpp +103 -0
- package/cpp/geometry/Fractal.cpp +136 -0
- package/cpp/geometry/GeometryGenerator.cpp +262 -0
- package/cpp/geometry/KleinBottle.cpp +71 -0
- package/cpp/geometry/Sphere.cpp +134 -0
- package/cpp/geometry/Tesseract.cpp +94 -0
- package/cpp/geometry/Tetrahedron.cpp +83 -0
- package/cpp/geometry/Torus.cpp +65 -0
- package/cpp/geometry/WarpFunctions.cpp +238 -0
- package/cpp/geometry/Wave.cpp +85 -0
- package/cpp/include/vib3_ffi.h +238 -0
- package/cpp/math/Mat4x4.cpp +409 -0
- package/cpp/math/Mat4x4.hpp +209 -0
- package/cpp/math/Projection.cpp +142 -0
- package/cpp/math/Projection.hpp +148 -0
- package/cpp/math/Rotor4D.cpp +322 -0
- package/cpp/math/Rotor4D.hpp +204 -0
- package/cpp/math/Vec4.cpp +303 -0
- package/cpp/math/Vec4.hpp +225 -0
- package/cpp/src/vib3_ffi.cpp +607 -0
- package/cpp/tests/Geometry_test.cpp +213 -0
- package/cpp/tests/Mat4x4_test.cpp +494 -0
- package/cpp/tests/Projection_test.cpp +298 -0
- package/cpp/tests/Rotor4D_test.cpp +423 -0
- package/cpp/tests/Vec4_test.cpp +489 -0
- package/package.json +40 -27
- package/src/agent/index.js +1 -3
- package/src/agent/mcp/MCPServer.js +1024 -7
- package/src/agent/mcp/index.js +1 -1
- package/src/agent/mcp/stdio-server.js +264 -0
- package/src/agent/mcp/tools.js +454 -0
- package/src/cli/index.js +374 -44
- package/src/core/CanvasManager.js +97 -204
- package/src/core/ErrorReporter.js +1 -1
- package/src/core/Parameters.js +1 -1
- package/src/core/VIB3Engine.js +93 -4
- package/src/core/VitalitySystem.js +53 -0
- package/src/core/index.js +18 -0
- package/src/core/renderers/FacetedRendererAdapter.js +10 -9
- package/src/core/renderers/HolographicRendererAdapter.js +13 -9
- package/src/core/renderers/QuantumRendererAdapter.js +11 -7
- package/src/creative/AestheticMapper.js +628 -0
- package/src/creative/ChoreographyPlayer.js +481 -0
- package/src/creative/index.js +11 -0
- package/src/export/TradingCardManager.js +3 -4
- package/src/export/index.js +11 -1
- package/src/faceted/FacetedSystem.js +241 -388
- package/src/games/glyph-war/GlyphWarVisualizer.js +641 -0
- package/src/holograms/HolographicVisualizer.js +29 -12
- package/src/holograms/RealHolographicSystem.js +194 -43
- package/src/math/index.js +7 -7
- package/src/polychora/PolychoraSystem.js +77 -0
- package/src/quantum/QuantumEngine.js +103 -66
- package/src/quantum/QuantumVisualizer.js +7 -2
- package/src/reactivity/index.js +3 -5
- package/src/render/LayerPresetManager.js +372 -0
- package/src/render/LayerReactivityBridge.js +344 -0
- package/src/render/LayerRelationshipGraph.js +610 -0
- package/src/render/MultiCanvasBridge.js +148 -25
- package/src/render/UnifiedRenderBridge.js +3 -0
- package/src/render/index.js +27 -2
- package/src/scene/index.js +4 -4
- package/src/shaders/faceted/faceted.frag.glsl +220 -80
- package/src/shaders/faceted/faceted.frag.wgsl +138 -97
- package/src/shaders/holographic/holographic.frag.glsl +28 -9
- package/src/shaders/holographic/holographic.frag.wgsl +107 -38
- package/src/shaders/quantum/quantum.frag.glsl +1 -0
- package/src/shaders/quantum/quantum.frag.wgsl +1 -1
- package/src/testing/ParallelTestFramework.js +2 -2
- package/src/viewer/GalleryUI.js +17 -0
- package/src/viewer/ViewerPortal.js +2 -2
- package/src/viewer/index.js +1 -1
- package/tools/headless-renderer.js +258 -0
- package/tools/shader-sync-verify.js +8 -4
- package/tools/site-analysis/all-reports.json +32 -0
- package/tools/site-analysis/combined-analysis.md +50 -0
- package/tools/site-analyzer.mjs +779 -0
- package/tools/visual-catalog/capture.js +276 -0
- package/tools/visual-catalog/composite.js +138 -0
- package/types/adaptive-sdk.d.ts +204 -5
- package/types/agent/cli.d.ts +78 -0
- package/types/agent/index.d.ts +18 -0
- package/types/agent/mcp.d.ts +87 -0
- package/types/agent/telemetry.d.ts +190 -0
- package/types/core/VIB3Engine.d.ts +26 -0
- package/types/core/index.d.ts +261 -0
- package/types/creative/AestheticMapper.d.ts +72 -0
- package/types/creative/ChoreographyPlayer.d.ts +96 -0
- package/types/creative/index.d.ts +17 -0
- package/types/export/index.d.ts +243 -0
- package/types/geometry/index.d.ts +164 -0
- package/types/math/index.d.ts +214 -0
- package/types/render/LayerPresetManager.d.ts +78 -0
- package/types/render/LayerReactivityBridge.d.ts +85 -0
- package/types/render/LayerRelationshipGraph.d.ts +174 -0
- package/types/render/index.d.ts +3 -0
- package/types/scene/index.d.ts +204 -0
- package/types/systems/index.d.ts +244 -0
- package/types/variations/index.d.ts +62 -0
- package/types/viewer/index.d.ts +225 -0
- /package/DOCS/{DEV_TRACK_PLAN_2026-01-07.md → archive/DEV_TRACK_PLAN_2026-01-07.md} +0 -0
- /package/DOCS/{SESSION_014_PLAN.md → archive/SESSION_014_PLAN.md} +0 -0
- /package/DOCS/{SESSION_LOG_2026-01-07.md → archive/SESSION_LOG_2026-01-07.md} +0 -0
- /package/DOCS/{STRATEGIC_BLUEPRINT_2026-01-07.md → archive/STRATEGIC_BLUEPRINT_2026-01-07.md} +0 -0
- /package/src/viewer/{ReactivityManager.js → ViewerInputHandler.js} +0 -0
package/README.md
CHANGED
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
**General-purpose 4D rotation visualization SDK** for plugins, extensions, wearables, and agentic AI integration.
|
|
4
4
|
|
|
5
|
-
[](DOCS/STATUS.md#test-status)
|
|
6
|
+
[](DOCS/STATUS.md#vib3-sdk-status)
|
|
7
7
|
[](LICENSE)
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
+
## Documentation
|
|
12
|
+
|
|
13
|
+
The main documentation entrypoint is [`DOCS/README.md`](./DOCS/README.md), which includes canonical docs, persona-based reading paths, taxonomy, and source-of-truth ownership.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
11
17
|
## Quick Reference
|
|
12
18
|
|
|
13
19
|
| Metric | Value |
|
|
@@ -29,7 +35,7 @@
|
|
|
29
35
|
- **Agentic Integration:** MCP server with 14 tools for AI agent control
|
|
30
36
|
- **Cross-Platform:** Web, WASM, Flutter support
|
|
31
37
|
|
|
32
|
-
### New in v2.0.
|
|
38
|
+
### New in current release (v2.0.x)
|
|
33
39
|
|
|
34
40
|
- **Universal Spatial Input:** 8 input sources (tilt, gyroscope, gamepad, mouse, MIDI, audio, programmatic, perspective) with 6 built-in profiles (card tilt, wearable, game, VJ, UI, XR)
|
|
35
41
|
- **Creative Tooling:** 22 color presets, 14 easing transitions, 14 post-processing effects, keyframe timeline with BPM sync
|
|
@@ -176,7 +182,7 @@ engine.randomizeAll();
|
|
|
176
182
|
engine.resetAll();
|
|
177
183
|
```
|
|
178
184
|
|
|
179
|
-
### Spatial Input API (v2.0.
|
|
185
|
+
### Spatial Input API (v2.0.x)
|
|
180
186
|
|
|
181
187
|
```javascript
|
|
182
188
|
// Enable spatial input with a profile
|
|
@@ -194,7 +200,7 @@ engine.setSpatialDramaticMode(true); // 8x amplification
|
|
|
194
200
|
// vjAudioSpatial, uiElement, immersiveXR
|
|
195
201
|
```
|
|
196
202
|
|
|
197
|
-
### Framework Integration (v2.0.
|
|
203
|
+
### Framework Integration (v2.0.x)
|
|
198
204
|
|
|
199
205
|
```javascript
|
|
200
206
|
// React
|
|
@@ -348,17 +354,17 @@ echo 'geometry 10' | node src/cli/index.js
|
|
|
348
354
|
│ │ ├── cli/ # CLI interface
|
|
349
355
|
│ │ └── telemetry/ # Instrumentation
|
|
350
356
|
│ ├── export/ # Export generators
|
|
351
|
-
│ ├── reactivity/ # Reactivity + SpatialInputSystem (
|
|
352
|
-
│ ├── creative/ # Color presets, transitions, post-FX, timeline (
|
|
353
|
-
│ ├── integrations/ # React, Vue, Svelte, Figma, Three.js, TD, OBS (
|
|
354
|
-
│ └── advanced/ # WebXR, WebGPU compute, MIDI, AI, Worker (
|
|
357
|
+
│ ├── reactivity/ # Reactivity + SpatialInputSystem (current release series)
|
|
358
|
+
│ ├── creative/ # Color presets, transitions, post-FX, timeline (current release series)
|
|
359
|
+
│ ├── integrations/ # React, Vue, Svelte, Figma, Three.js, TD, OBS (current release series)
|
|
360
|
+
│ └── advanced/ # WebXR, WebGPU compute, MIDI, AI, Worker (current release series)
|
|
355
361
|
├── tools/ # Tooling (+ shader-sync-verify.js)
|
|
356
362
|
├── cpp/ # C++ math core (WASM)
|
|
357
363
|
├── js/ # Client-side integration
|
|
358
|
-
├── tests/ # Test suite (
|
|
364
|
+
├── tests/ # Test suite (CI-tracked status)
|
|
359
365
|
├── DOCS/ # Documentation
|
|
360
366
|
│ ├── SYSTEM_INVENTORY.md # Complete system reference
|
|
361
|
-
│ ├── SYSTEM_AUDIT_2026-01-30.md # Full system audit
|
|
367
|
+
│ ├── archive/SYSTEM_AUDIT_2026-01-30.md # Full system audit (archived)
|
|
362
368
|
│ ├── CLI_ONBOARDING.md # Agent CLI setup
|
|
363
369
|
│ └── CONTROL_REFERENCE.md # UI parameters
|
|
364
370
|
└── types/ # TypeScript definitions
|
|
@@ -379,7 +385,7 @@ npm test -- --coverage
|
|
|
379
385
|
npm test -- tests/agent/AgentCLI.test.js
|
|
380
386
|
```
|
|
381
387
|
|
|
382
|
-
**Current Status:**
|
|
388
|
+
**Current Status:** See [`DOCS/STATUS.md`](DOCS/STATUS.md) for release and CI-linked test status.
|
|
383
389
|
|
|
384
390
|
---
|
|
385
391
|
|
|
@@ -387,13 +393,20 @@ npm test -- tests/agent/AgentCLI.test.js
|
|
|
387
393
|
|
|
388
394
|
| Document | Description |
|
|
389
395
|
|----------|-------------|
|
|
396
|
+
| [`DOCS/STATUS.md`](DOCS/STATUS.md) | Canonical release status (version, date, platforms, CI test status) |
|
|
397
|
+
| [`DOCS/SYSTEM_INVENTORY.md`](DOCS/SYSTEM_INVENTORY.md) | Complete technical reference |
|
|
398
|
+
| [`DOCS/SYSTEM_AUDIT_2026-01-30.md`](DOCS/SYSTEM_AUDIT_2026-01-30.md) | Full system audit |
|
|
390
399
|
| [`DOCS/SYSTEM_INVENTORY.md`](DOCS/SYSTEM_INVENTORY.md) | Complete technical reference (v2.0.0) |
|
|
400
|
+
| [`DOCS/PRODUCT_STRATEGY.md`](DOCS/PRODUCT_STRATEGY.md) | Product strategy: personas, use-cases, differentiation, and metrics |
|
|
401
|
+
| [`DOCS/ROADMAP.md`](DOCS/ROADMAP.md) | Strategy goals mapped to technical epics and module ownership |
|
|
402
|
+
| [`DOCS/README.md`](DOCS/README.md) | Documentation index and navigation hub |
|
|
391
403
|
| [`DOCS/SYSTEM_AUDIT_2026-01-30.md`](DOCS/SYSTEM_AUDIT_2026-01-30.md) | Full system audit (v2.0.0) |
|
|
404
|
+
| [`DOCS/archive/SYSTEM_AUDIT_2026-01-30.md`](DOCS/archive/SYSTEM_AUDIT_2026-01-30.md) | Full system audit (v2.0.0, archived) |
|
|
392
405
|
| [`DOCS/CLI_ONBOARDING.md`](DOCS/CLI_ONBOARDING.md) | Agent CLI setup guide |
|
|
393
406
|
| [`DOCS/CONTROL_REFERENCE.md`](DOCS/CONTROL_REFERENCE.md) | UI parameter reference |
|
|
394
407
|
| [`24-GEOMETRY-6D-ROTATION-SUMMARY.md`](24-GEOMETRY-6D-ROTATION-SUMMARY.md) | Geometry encoding details |
|
|
395
408
|
| [`DOCS/GPU_DISPOSAL_GUIDE.md`](DOCS/GPU_DISPOSAL_GUIDE.md) | Resource management |
|
|
396
|
-
| [`CLAUDE.md`](CLAUDE.md) | AI/Developer technical reference
|
|
409
|
+
| [`CLAUDE.md`](CLAUDE.md) | AI/Developer technical reference |
|
|
397
410
|
|
|
398
411
|
---
|
|
399
412
|
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.20)
|
|
2
|
+
project(vib3_core VERSION 1.0.0 LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
# C++20 required for concepts, ranges, and std::numbers
|
|
5
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
6
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
7
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
8
|
+
|
|
9
|
+
# Build options
|
|
10
|
+
option(VIB3_BUILD_WASM "Build WebAssembly module" ON)
|
|
11
|
+
option(VIB3_BUILD_TESTS "Build unit tests" ON)
|
|
12
|
+
option(VIB3_ENABLE_SIMD "Enable SIMD optimizations" ON)
|
|
13
|
+
option(VIB3_ENABLE_THREADS "Enable threading support" OFF)
|
|
14
|
+
|
|
15
|
+
# Output directories
|
|
16
|
+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
17
|
+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
18
|
+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
19
|
+
|
|
20
|
+
# Compiler warnings
|
|
21
|
+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
|
|
22
|
+
add_compile_options(
|
|
23
|
+
-Wall
|
|
24
|
+
-Wextra
|
|
25
|
+
-Wpedantic
|
|
26
|
+
-Wconversion
|
|
27
|
+
-Wsign-conversion
|
|
28
|
+
-Wno-unused-parameter
|
|
29
|
+
)
|
|
30
|
+
endif()
|
|
31
|
+
|
|
32
|
+
# SIMD support
|
|
33
|
+
if(VIB3_ENABLE_SIMD)
|
|
34
|
+
if(EMSCRIPTEN)
|
|
35
|
+
add_compile_options(-msimd128)
|
|
36
|
+
add_link_options(-msimd128)
|
|
37
|
+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
|
|
38
|
+
# Detect CPU architecture
|
|
39
|
+
include(CheckCXXCompilerFlag)
|
|
40
|
+
check_cxx_compiler_flag("-mavx2" COMPILER_SUPPORTS_AVX2)
|
|
41
|
+
check_cxx_compiler_flag("-msse4.1" COMPILER_SUPPORTS_SSE41)
|
|
42
|
+
|
|
43
|
+
if(COMPILER_SUPPORTS_AVX2)
|
|
44
|
+
add_compile_options(-mavx2 -mfma)
|
|
45
|
+
add_definitions(-DVIB3_HAS_AVX2)
|
|
46
|
+
elseif(COMPILER_SUPPORTS_SSE41)
|
|
47
|
+
add_compile_options(-msse4.1)
|
|
48
|
+
add_definitions(-DVIB3_HAS_SSE41)
|
|
49
|
+
endif()
|
|
50
|
+
endif()
|
|
51
|
+
endif()
|
|
52
|
+
|
|
53
|
+
# Math library (required)
|
|
54
|
+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/math/Vec4.cpp")
|
|
55
|
+
add_library(vib3_math STATIC
|
|
56
|
+
math/Vec4.cpp
|
|
57
|
+
math/Rotor4D.cpp
|
|
58
|
+
math/Mat4x4.cpp
|
|
59
|
+
math/Projection.cpp
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
target_include_directories(vib3_math PUBLIC
|
|
63
|
+
${CMAKE_CURRENT_SOURCE_DIR}
|
|
64
|
+
)
|
|
65
|
+
else()
|
|
66
|
+
message(WARNING "VIB3: math/ directory not found, skipping vib3_math library")
|
|
67
|
+
endif()
|
|
68
|
+
|
|
69
|
+
# Geometry library (optional — may not exist in Flutter/submodule checkouts)
|
|
70
|
+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/geometry/GeometryGenerator.cpp")
|
|
71
|
+
add_library(vib3_geometry STATIC
|
|
72
|
+
geometry/GeometryGenerator.cpp
|
|
73
|
+
geometry/Tesseract.cpp
|
|
74
|
+
geometry/Tetrahedron.cpp
|
|
75
|
+
geometry/Sphere.cpp
|
|
76
|
+
geometry/Torus.cpp
|
|
77
|
+
geometry/KleinBottle.cpp
|
|
78
|
+
geometry/Fractal.cpp
|
|
79
|
+
geometry/Wave.cpp
|
|
80
|
+
geometry/Crystal.cpp
|
|
81
|
+
geometry/WarpFunctions.cpp
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
target_link_libraries(vib3_geometry PUBLIC vib3_math)
|
|
85
|
+
|
|
86
|
+
target_include_directories(vib3_geometry PUBLIC
|
|
87
|
+
${CMAKE_CURRENT_SOURCE_DIR}
|
|
88
|
+
)
|
|
89
|
+
else()
|
|
90
|
+
message(WARNING "VIB3: geometry/ directory not found, skipping vib3_geometry library")
|
|
91
|
+
endif()
|
|
92
|
+
|
|
93
|
+
# WebAssembly build
|
|
94
|
+
if(EMSCRIPTEN AND VIB3_BUILD_WASM AND TARGET vib3_math AND TARGET vib3_geometry)
|
|
95
|
+
# Combined WASM module
|
|
96
|
+
add_executable(vib3_wasm
|
|
97
|
+
bindings/embind.cpp
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
target_link_libraries(vib3_wasm PRIVATE
|
|
101
|
+
vib3_math
|
|
102
|
+
vib3_geometry
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Emscripten settings
|
|
106
|
+
set_target_properties(vib3_wasm PROPERTIES
|
|
107
|
+
OUTPUT_NAME "vib3"
|
|
108
|
+
SUFFIX ".js"
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# Emscripten link options
|
|
112
|
+
target_link_options(vib3_wasm PRIVATE
|
|
113
|
+
# Output formats
|
|
114
|
+
-sWASM=1
|
|
115
|
+
-sMODULARIZE=1
|
|
116
|
+
-sEXPORT_NAME=createVIB3Module
|
|
117
|
+
-sEXPORT_ES6=1
|
|
118
|
+
|
|
119
|
+
# Memory settings
|
|
120
|
+
-sALLOW_MEMORY_GROWTH=1
|
|
121
|
+
-sINITIAL_MEMORY=16777216 # 16MB initial
|
|
122
|
+
-sMAXIMUM_MEMORY=268435456 # 256MB max
|
|
123
|
+
-sSTACK_SIZE=1048576 # 1MB stack
|
|
124
|
+
|
|
125
|
+
# Bindings
|
|
126
|
+
--bind
|
|
127
|
+
-sNO_DISABLE_EXCEPTION_CATCHING
|
|
128
|
+
|
|
129
|
+
# Optimizations
|
|
130
|
+
-sASSERTIONS=0
|
|
131
|
+
-sMALLOC=emmalloc
|
|
132
|
+
|
|
133
|
+
# Environment
|
|
134
|
+
-sENVIRONMENT=web,worker
|
|
135
|
+
-sFILESYSTEM=0
|
|
136
|
+
-sNO_EXIT_RUNTIME=1
|
|
137
|
+
|
|
138
|
+
# TypeScript definitions
|
|
139
|
+
--emit-tsd vib3.d.ts
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
# SIMD for WASM
|
|
143
|
+
if(VIB3_ENABLE_SIMD)
|
|
144
|
+
target_link_options(vib3_wasm PRIVATE -msimd128)
|
|
145
|
+
endif()
|
|
146
|
+
|
|
147
|
+
# Threading for WASM (optional)
|
|
148
|
+
if(VIB3_ENABLE_THREADS)
|
|
149
|
+
target_link_options(vib3_wasm PRIVATE
|
|
150
|
+
-pthread
|
|
151
|
+
-sPTHREAD_POOL_SIZE=4
|
|
152
|
+
)
|
|
153
|
+
endif()
|
|
154
|
+
|
|
155
|
+
# Debug vs Release
|
|
156
|
+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
157
|
+
target_link_options(vib3_wasm PRIVATE
|
|
158
|
+
-sASSERTIONS=2
|
|
159
|
+
-sSAFE_HEAP=1
|
|
160
|
+
-sSTACK_OVERFLOW_CHECK=2
|
|
161
|
+
-g
|
|
162
|
+
)
|
|
163
|
+
else()
|
|
164
|
+
target_link_options(vib3_wasm PRIVATE
|
|
165
|
+
-O3
|
|
166
|
+
-flto
|
|
167
|
+
--closure 1
|
|
168
|
+
)
|
|
169
|
+
endif()
|
|
170
|
+
|
|
171
|
+
# Install WASM files
|
|
172
|
+
install(
|
|
173
|
+
FILES
|
|
174
|
+
${CMAKE_BINARY_DIR}/bin/vib3.js
|
|
175
|
+
${CMAKE_BINARY_DIR}/bin/vib3.wasm
|
|
176
|
+
${CMAKE_BINARY_DIR}/bin/vib3.d.ts
|
|
177
|
+
DESTINATION ${CMAKE_SOURCE_DIR}/../dist/wasm
|
|
178
|
+
)
|
|
179
|
+
endif()
|
|
180
|
+
|
|
181
|
+
# Native tests (not for WASM, only if sources exist)
|
|
182
|
+
if(VIB3_BUILD_TESTS AND NOT EMSCRIPTEN AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/Vec4_test.cpp")
|
|
183
|
+
enable_testing()
|
|
184
|
+
|
|
185
|
+
# Find or fetch GoogleTest
|
|
186
|
+
include(FetchContent)
|
|
187
|
+
FetchContent_Declare(
|
|
188
|
+
googletest
|
|
189
|
+
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
|
|
190
|
+
)
|
|
191
|
+
FetchContent_MakeAvailable(googletest)
|
|
192
|
+
|
|
193
|
+
# Math tests
|
|
194
|
+
if(TARGET vib3_math)
|
|
195
|
+
add_executable(math_tests
|
|
196
|
+
tests/Vec4_test.cpp
|
|
197
|
+
tests/Rotor4D_test.cpp
|
|
198
|
+
tests/Mat4x4_test.cpp
|
|
199
|
+
tests/Projection_test.cpp
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
target_link_libraries(math_tests PRIVATE
|
|
203
|
+
vib3_math
|
|
204
|
+
GTest::gtest_main
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
include(GoogleTest)
|
|
208
|
+
gtest_discover_tests(math_tests)
|
|
209
|
+
endif()
|
|
210
|
+
|
|
211
|
+
# Geometry tests
|
|
212
|
+
if(TARGET vib3_geometry AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/Geometry_test.cpp")
|
|
213
|
+
add_executable(geometry_tests
|
|
214
|
+
tests/Geometry_test.cpp
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
target_link_libraries(geometry_tests PRIVATE
|
|
218
|
+
vib3_geometry
|
|
219
|
+
GTest::gtest_main
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
gtest_discover_tests(geometry_tests)
|
|
223
|
+
endif()
|
|
224
|
+
endif()
|
|
225
|
+
|
|
226
|
+
# Print configuration summary
|
|
227
|
+
message(STATUS "")
|
|
228
|
+
message(STATUS "VIB3 Core Configuration:")
|
|
229
|
+
message(STATUS " Version: ${PROJECT_VERSION}")
|
|
230
|
+
message(STATUS " C++ Standard: ${CMAKE_CXX_STANDARD}")
|
|
231
|
+
message(STATUS " Build WASM: ${VIB3_BUILD_WASM}")
|
|
232
|
+
message(STATUS " Build Tests: ${VIB3_BUILD_TESTS}")
|
|
233
|
+
message(STATUS " Enable SIMD: ${VIB3_ENABLE_SIMD}")
|
|
234
|
+
message(STATUS " Enable Threads:${VIB3_ENABLE_THREADS}")
|
|
235
|
+
message(STATUS " Build Type: ${CMAKE_BUILD_TYPE}")
|
|
236
|
+
message(STATUS "")
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* embind.cpp - Emscripten JavaScript Bindings
|
|
3
|
+
*
|
|
4
|
+
* Exposes VIB3+ C++ classes to JavaScript via WebAssembly.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#include <emscripten/bind.h>
|
|
8
|
+
#include "../math/Vec4.hpp"
|
|
9
|
+
#include "../math/Rotor4D.hpp"
|
|
10
|
+
#include "../math/Mat4x4.hpp"
|
|
11
|
+
#include "../math/Projection.hpp"
|
|
12
|
+
|
|
13
|
+
using namespace emscripten;
|
|
14
|
+
using namespace vib3;
|
|
15
|
+
|
|
16
|
+
// Helper to convert std::array to JS array
|
|
17
|
+
template<typename T, size_t N>
|
|
18
|
+
val arrayToVal(const std::array<T, N>& arr) {
|
|
19
|
+
val jsArray = val::array();
|
|
20
|
+
for (size_t i = 0; i < N; ++i) {
|
|
21
|
+
jsArray.call<void>("push", arr[i]);
|
|
22
|
+
}
|
|
23
|
+
return jsArray;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Helper to convert JS array to std::array
|
|
27
|
+
template<typename T, size_t N>
|
|
28
|
+
std::array<T, N> valToArray(const val& jsArray) {
|
|
29
|
+
std::array<T, N> arr;
|
|
30
|
+
for (size_t i = 0; i < N; ++i) {
|
|
31
|
+
arr[i] = jsArray[i].as<T>();
|
|
32
|
+
}
|
|
33
|
+
return arr;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
EMSCRIPTEN_BINDINGS(vib3_math) {
|
|
37
|
+
// ====== Vec4 ======
|
|
38
|
+
|
|
39
|
+
class_<Vec4>("Vec4")
|
|
40
|
+
.constructor<>()
|
|
41
|
+
.constructor<float, float, float, float>()
|
|
42
|
+
.constructor<float>()
|
|
43
|
+
|
|
44
|
+
// Properties
|
|
45
|
+
.property("x", &Vec4::x)
|
|
46
|
+
.property("y", &Vec4::y)
|
|
47
|
+
.property("z", &Vec4::z)
|
|
48
|
+
.property("w", &Vec4::w)
|
|
49
|
+
|
|
50
|
+
// Static factories
|
|
51
|
+
.class_function("zero", &Vec4::zero)
|
|
52
|
+
.class_function("one", &Vec4::one)
|
|
53
|
+
.class_function("unitX", &Vec4::unitX)
|
|
54
|
+
.class_function("unitY", &Vec4::unitY)
|
|
55
|
+
.class_function("unitZ", &Vec4::unitZ)
|
|
56
|
+
.class_function("unitW", &Vec4::unitW)
|
|
57
|
+
.class_function("randomUnit", &Vec4::randomUnit)
|
|
58
|
+
|
|
59
|
+
// Arithmetic
|
|
60
|
+
.function("add", select_overload<Vec4(const Vec4&) const>(&Vec4::operator+))
|
|
61
|
+
.function("sub", select_overload<Vec4(const Vec4&) const>(&Vec4::operator-))
|
|
62
|
+
.function("mul", select_overload<Vec4(float) const>(&Vec4::operator*))
|
|
63
|
+
.function("div", select_overload<Vec4(float) const>(&Vec4::operator/))
|
|
64
|
+
.function("neg", select_overload<Vec4() const>(&Vec4::operator-))
|
|
65
|
+
|
|
66
|
+
// Operations
|
|
67
|
+
.function("dot", &Vec4::dot)
|
|
68
|
+
.function("length", &Vec4::length)
|
|
69
|
+
.function("lengthSquared", &Vec4::lengthSquared)
|
|
70
|
+
.function("normalized", &Vec4::normalized)
|
|
71
|
+
.function("normalize", &Vec4::normalize)
|
|
72
|
+
.function("distanceTo", &Vec4::distanceTo)
|
|
73
|
+
.function("distanceSquaredTo", &Vec4::distanceSquaredTo)
|
|
74
|
+
.function("lerp", &Vec4::lerp)
|
|
75
|
+
.function("min", &Vec4::min)
|
|
76
|
+
.function("max", &Vec4::max)
|
|
77
|
+
.function("clamp", &Vec4::clamp)
|
|
78
|
+
.function("abs", &Vec4::abs)
|
|
79
|
+
.function("projectOnto", &Vec4::projectOnto)
|
|
80
|
+
.function("reflect", &Vec4::reflect)
|
|
81
|
+
.function("isZero", &Vec4::isZero)
|
|
82
|
+
.function("isNormalized", &Vec4::isNormalized)
|
|
83
|
+
|
|
84
|
+
// Projections
|
|
85
|
+
.function("projectPerspective", &Vec4::projectPerspective)
|
|
86
|
+
.function("projectStereographic", &Vec4::projectStereographic)
|
|
87
|
+
.function("projectOrthographic", &Vec4::projectOrthographic)
|
|
88
|
+
|
|
89
|
+
// Conversion
|
|
90
|
+
.function("toArray", optional_override([](const Vec4& self) {
|
|
91
|
+
return arrayToVal<float, 4>(self.data);
|
|
92
|
+
}))
|
|
93
|
+
;
|
|
94
|
+
|
|
95
|
+
// Free function for Vec4 construction from array
|
|
96
|
+
function("vec4FromArray", optional_override([](const val& arr) {
|
|
97
|
+
return Vec4(arr[0].as<float>(), arr[1].as<float>(),
|
|
98
|
+
arr[2].as<float>(), arr[3].as<float>());
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
// ====== Rotor4D ======
|
|
102
|
+
|
|
103
|
+
enum_<RotationPlane>("RotationPlane")
|
|
104
|
+
.value("XY", RotationPlane::XY)
|
|
105
|
+
.value("XZ", RotationPlane::XZ)
|
|
106
|
+
.value("YZ", RotationPlane::YZ)
|
|
107
|
+
.value("XW", RotationPlane::XW)
|
|
108
|
+
.value("YW", RotationPlane::YW)
|
|
109
|
+
.value("ZW", RotationPlane::ZW)
|
|
110
|
+
;
|
|
111
|
+
|
|
112
|
+
class_<Rotor4D>("Rotor4D")
|
|
113
|
+
.constructor<>()
|
|
114
|
+
.constructor<float, float, float, float, float, float, float, float>()
|
|
115
|
+
|
|
116
|
+
// Components
|
|
117
|
+
.property("s", &Rotor4D::s)
|
|
118
|
+
.property("xy", &Rotor4D::xy)
|
|
119
|
+
.property("xz", &Rotor4D::xz)
|
|
120
|
+
.property("yz", &Rotor4D::yz)
|
|
121
|
+
.property("xw", &Rotor4D::xw)
|
|
122
|
+
.property("yw", &Rotor4D::yw)
|
|
123
|
+
.property("zw", &Rotor4D::zw)
|
|
124
|
+
.property("xyzw", &Rotor4D::xyzw)
|
|
125
|
+
|
|
126
|
+
// Static factories
|
|
127
|
+
.class_function("identity", &Rotor4D::identity)
|
|
128
|
+
.class_function("fromPlaneAngle", &Rotor4D::fromPlaneAngle)
|
|
129
|
+
.class_function("fromEuler6", select_overload<Rotor4D(float, float, float, float, float, float)>(&Rotor4D::fromEuler6))
|
|
130
|
+
|
|
131
|
+
// Operations
|
|
132
|
+
.function("mul", select_overload<Rotor4D(const Rotor4D&) const>(&Rotor4D::operator*))
|
|
133
|
+
.function("reverse", &Rotor4D::reverse)
|
|
134
|
+
.function("magnitude", &Rotor4D::magnitude)
|
|
135
|
+
.function("magnitudeSquared", &Rotor4D::magnitudeSquared)
|
|
136
|
+
.function("normalized", &Rotor4D::normalized)
|
|
137
|
+
.function("normalize", &Rotor4D::normalize)
|
|
138
|
+
.function("inverse", &Rotor4D::inverse)
|
|
139
|
+
.function("isNormalized", &Rotor4D::isNormalized)
|
|
140
|
+
|
|
141
|
+
// Vector rotation
|
|
142
|
+
.function("rotate", &Rotor4D::rotate)
|
|
143
|
+
|
|
144
|
+
// Interpolation
|
|
145
|
+
.function("slerp", &Rotor4D::slerp)
|
|
146
|
+
.function("nlerp", &Rotor4D::nlerp)
|
|
147
|
+
.function("dot", &Rotor4D::dot)
|
|
148
|
+
|
|
149
|
+
// Matrix conversion
|
|
150
|
+
.function("toMatrix", &Rotor4D::toMatrix)
|
|
151
|
+
|
|
152
|
+
// Conversion
|
|
153
|
+
.function("toArray", optional_override([](const Rotor4D& self) {
|
|
154
|
+
return arrayToVal<float, 8>(self.toArray());
|
|
155
|
+
}))
|
|
156
|
+
;
|
|
157
|
+
|
|
158
|
+
// Free function for rotor creation from angle array
|
|
159
|
+
function("rotorFromEuler6Array", optional_override([](const val& arr) {
|
|
160
|
+
return Rotor4D::fromEuler6(
|
|
161
|
+
arr[0].as<float>(), arr[1].as<float>(), arr[2].as<float>(),
|
|
162
|
+
arr[3].as<float>(), arr[4].as<float>(), arr[5].as<float>()
|
|
163
|
+
);
|
|
164
|
+
}));
|
|
165
|
+
|
|
166
|
+
// ====== Mat4x4 ======
|
|
167
|
+
|
|
168
|
+
class_<Mat4x4>("Mat4x4")
|
|
169
|
+
.constructor<>()
|
|
170
|
+
.constructor<float>()
|
|
171
|
+
|
|
172
|
+
// Static factories
|
|
173
|
+
.class_function("identity", &Mat4x4::identity)
|
|
174
|
+
.class_function("zero", &Mat4x4::zero)
|
|
175
|
+
.class_function("rotationXY", &Mat4x4::rotationXY)
|
|
176
|
+
.class_function("rotationXZ", &Mat4x4::rotationXZ)
|
|
177
|
+
.class_function("rotationYZ", &Mat4x4::rotationYZ)
|
|
178
|
+
.class_function("rotationXW", &Mat4x4::rotationXW)
|
|
179
|
+
.class_function("rotationYW", &Mat4x4::rotationYW)
|
|
180
|
+
.class_function("rotationZW", &Mat4x4::rotationZW)
|
|
181
|
+
.class_function("rotationFromAngles", select_overload<Mat4x4(float, float, float, float, float, float)>(&Mat4x4::rotationFromAngles))
|
|
182
|
+
.class_function("scale", select_overload<Mat4x4(float)>(&Mat4x4::scale))
|
|
183
|
+
|
|
184
|
+
// Element access
|
|
185
|
+
.function("at", select_overload<float&(size_t, size_t)>(&Mat4x4::at))
|
|
186
|
+
.function("column", &Mat4x4::column)
|
|
187
|
+
.function("row", &Mat4x4::row)
|
|
188
|
+
|
|
189
|
+
// Operations
|
|
190
|
+
.function("mulMat", select_overload<Mat4x4(const Mat4x4&) const>(&Mat4x4::operator*))
|
|
191
|
+
.function("mulVec", select_overload<Vec4(const Vec4&) const>(&Mat4x4::operator*))
|
|
192
|
+
.function("mulScalar", select_overload<Mat4x4(float) const>(&Mat4x4::operator*))
|
|
193
|
+
.function("add", select_overload<Mat4x4(const Mat4x4&) const>(&Mat4x4::operator+))
|
|
194
|
+
.function("sub", select_overload<Mat4x4(const Mat4x4&) const>(&Mat4x4::operator-))
|
|
195
|
+
.function("transposed", &Mat4x4::transposed)
|
|
196
|
+
.function("transpose", &Mat4x4::transpose)
|
|
197
|
+
.function("determinant", &Mat4x4::determinant)
|
|
198
|
+
.function("inverse", &Mat4x4::inverse)
|
|
199
|
+
.function("isOrthogonal", &Mat4x4::isOrthogonal)
|
|
200
|
+
.function("isIdentity", &Mat4x4::isIdentity)
|
|
201
|
+
|
|
202
|
+
// Conversion
|
|
203
|
+
.function("toArray", optional_override([](const Mat4x4& self) {
|
|
204
|
+
return arrayToVal<float, 16>(self.data);
|
|
205
|
+
}))
|
|
206
|
+
;
|
|
207
|
+
|
|
208
|
+
// Free function for matrix from angles array
|
|
209
|
+
function("matrixFromAnglesArray", optional_override([](const val& arr) {
|
|
210
|
+
return Mat4x4::rotationFromAngles(
|
|
211
|
+
arr[0].as<float>(), arr[1].as<float>(), arr[2].as<float>(),
|
|
212
|
+
arr[3].as<float>(), arr[4].as<float>(), arr[5].as<float>()
|
|
213
|
+
);
|
|
214
|
+
}));
|
|
215
|
+
|
|
216
|
+
// ====== Projection ======
|
|
217
|
+
|
|
218
|
+
value_object<Projection3D>("Projection3D")
|
|
219
|
+
.field("x", &Projection3D::x)
|
|
220
|
+
.field("y", &Projection3D::y)
|
|
221
|
+
.field("z", &Projection3D::z)
|
|
222
|
+
;
|
|
223
|
+
|
|
224
|
+
value_object<SliceResult>("SliceResult")
|
|
225
|
+
.field("point", &SliceResult::point)
|
|
226
|
+
.field("alpha", &SliceResult::alpha)
|
|
227
|
+
.field("valid", &SliceResult::valid)
|
|
228
|
+
;
|
|
229
|
+
|
|
230
|
+
// Projection functions
|
|
231
|
+
function("projectPerspective", &projectPerspective);
|
|
232
|
+
function("projectStereographic", &projectStereographic);
|
|
233
|
+
function("projectOrthographic", &projectOrthographic);
|
|
234
|
+
function("projectOblique", &projectOblique);
|
|
235
|
+
function("projectSlice", &projectSlice);
|
|
236
|
+
|
|
237
|
+
// Batch projections (returns typed array for efficiency)
|
|
238
|
+
function("projectToFloatArray", optional_override([](const val& jsPoints, float distance) {
|
|
239
|
+
std::vector<Vec4> points;
|
|
240
|
+
size_t len = jsPoints["length"].as<size_t>();
|
|
241
|
+
points.reserve(len);
|
|
242
|
+
|
|
243
|
+
for (size_t i = 0; i < len; ++i) {
|
|
244
|
+
points.push_back(jsPoints[i].as<Vec4>());
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
auto result = projectToFloatArray(points, distance);
|
|
248
|
+
|
|
249
|
+
// Return as Float32Array for efficient GPU upload
|
|
250
|
+
return val::global("Float32Array").new_(typed_memory_view(result.size(), result.data()));
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Module initialization
|
|
255
|
+
EMSCRIPTEN_BINDINGS(vib3_module) {
|
|
256
|
+
// Version info
|
|
257
|
+
function("getVersion", optional_override([]() {
|
|
258
|
+
return std::string("1.0.0");
|
|
259
|
+
}));
|
|
260
|
+
|
|
261
|
+
// Feature detection
|
|
262
|
+
function("hasSimd", optional_override([]() {
|
|
263
|
+
#if defined(VIB3_HAS_SSE41) || defined(__wasm_simd128__)
|
|
264
|
+
return true;
|
|
265
|
+
#else
|
|
266
|
+
return false;
|
|
267
|
+
#endif
|
|
268
|
+
}));
|
|
269
|
+
}
|