@vib3code/sdk 2.0.1 → 2.0.3-canary.6f35b4c
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/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 +31 -27
- package/src/agent/mcp/MCPServer.js +722 -0
- package/src/agent/mcp/stdio-server.js +264 -0
- package/src/agent/mcp/tools.js +367 -0
- package/src/cli/index.js +0 -0
- 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 +38 -1
- package/src/core/VitalitySystem.js +53 -0
- package/src/core/renderers/HolographicRendererAdapter.js +2 -2
- package/src/creative/AestheticMapper.js +628 -0
- package/src/creative/ChoreographyPlayer.js +481 -0
- package/src/export/TradingCardManager.js +3 -4
- package/src/faceted/FacetedSystem.js +237 -388
- package/src/holograms/HolographicVisualizer.js +29 -12
- package/src/holograms/RealHolographicSystem.js +68 -12
- package/src/polychora/PolychoraSystem.js +77 -0
- package/src/quantum/QuantumEngine.js +103 -66
- package/src/quantum/QuantumVisualizer.js +7 -2
- package/src/render/UnifiedRenderBridge.js +3 -0
- 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/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/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
|
@@ -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
|
+
}
|
package/cpp/build.sh
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# VIB3+ WASM Build Script
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# ./build.sh # Build release WASM
|
|
7
|
+
# ./build.sh debug # Build debug WASM
|
|
8
|
+
# ./build.sh native # Build native (with tests)
|
|
9
|
+
# ./build.sh clean # Clean build directory
|
|
10
|
+
#
|
|
11
|
+
# Requirements:
|
|
12
|
+
# - CMake 3.20+
|
|
13
|
+
# - Emscripten SDK (for WASM builds)
|
|
14
|
+
# - C++20 compiler (for native builds)
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
set -euo pipefail
|
|
18
|
+
|
|
19
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
20
|
+
BUILD_DIR="${SCRIPT_DIR}/build"
|
|
21
|
+
DIST_DIR="${SCRIPT_DIR}/../dist/wasm"
|
|
22
|
+
BUILD_TYPE="${1:-release}"
|
|
23
|
+
NPROC=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
|
|
24
|
+
|
|
25
|
+
# Colors for output
|
|
26
|
+
RED='\033[0;31m'
|
|
27
|
+
GREEN='\033[0;32m'
|
|
28
|
+
YELLOW='\033[1;33m'
|
|
29
|
+
NC='\033[0m' # No Color
|
|
30
|
+
|
|
31
|
+
log() { echo -e "${GREEN}[VIB3]${NC} $*"; }
|
|
32
|
+
warn() { echo -e "${YELLOW}[VIB3]${NC} $*"; }
|
|
33
|
+
error() { echo -e "${RED}[VIB3]${NC} $*" >&2; }
|
|
34
|
+
|
|
35
|
+
case "${BUILD_TYPE}" in
|
|
36
|
+
clean)
|
|
37
|
+
log "Cleaning build directory..."
|
|
38
|
+
rm -rf "${BUILD_DIR}"
|
|
39
|
+
log "Done."
|
|
40
|
+
exit 0
|
|
41
|
+
;;
|
|
42
|
+
|
|
43
|
+
debug)
|
|
44
|
+
log "Building WASM (Debug)..."
|
|
45
|
+
|
|
46
|
+
if ! command -v emcmake &>/dev/null; then
|
|
47
|
+
error "Emscripten not found. Install emsdk and activate it:"
|
|
48
|
+
error " git clone https://github.com/emscripten-core/emsdk.git"
|
|
49
|
+
error " cd emsdk && ./emsdk install latest && ./emsdk activate latest"
|
|
50
|
+
error " source emsdk_env.sh"
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
mkdir -p "${BUILD_DIR}/wasm-debug"
|
|
55
|
+
cd "${BUILD_DIR}/wasm-debug"
|
|
56
|
+
|
|
57
|
+
emcmake cmake "${SCRIPT_DIR}" \
|
|
58
|
+
-DCMAKE_BUILD_TYPE=Debug \
|
|
59
|
+
-DVIB3_BUILD_WASM=ON \
|
|
60
|
+
-DVIB3_BUILD_TESTS=OFF \
|
|
61
|
+
-DVIB3_ENABLE_SIMD=ON
|
|
62
|
+
|
|
63
|
+
cmake --build . -j"${NPROC}"
|
|
64
|
+
|
|
65
|
+
# Copy outputs
|
|
66
|
+
mkdir -p "${DIST_DIR}"
|
|
67
|
+
cp -f bin/vib3.js bin/vib3.wasm "${DIST_DIR}/"
|
|
68
|
+
[ -f bin/vib3.d.ts ] && cp -f bin/vib3.d.ts "${DIST_DIR}/"
|
|
69
|
+
|
|
70
|
+
log "Debug WASM build complete. Output: ${DIST_DIR}/"
|
|
71
|
+
;;
|
|
72
|
+
|
|
73
|
+
release)
|
|
74
|
+
log "Building WASM (Release)..."
|
|
75
|
+
|
|
76
|
+
if ! command -v emcmake &>/dev/null; then
|
|
77
|
+
error "Emscripten not found. Install emsdk and activate it:"
|
|
78
|
+
error " git clone https://github.com/emscripten-core/emsdk.git"
|
|
79
|
+
error " cd emsdk && ./emsdk install latest && ./emsdk activate latest"
|
|
80
|
+
error " source emsdk_env.sh"
|
|
81
|
+
exit 1
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
mkdir -p "${BUILD_DIR}/wasm-release"
|
|
85
|
+
cd "${BUILD_DIR}/wasm-release"
|
|
86
|
+
|
|
87
|
+
emcmake cmake "${SCRIPT_DIR}" \
|
|
88
|
+
-DCMAKE_BUILD_TYPE=Release \
|
|
89
|
+
-DVIB3_BUILD_WASM=ON \
|
|
90
|
+
-DVIB3_BUILD_TESTS=OFF \
|
|
91
|
+
-DVIB3_ENABLE_SIMD=ON
|
|
92
|
+
|
|
93
|
+
cmake --build . -j"${NPROC}"
|
|
94
|
+
|
|
95
|
+
# Copy outputs
|
|
96
|
+
mkdir -p "${DIST_DIR}"
|
|
97
|
+
cp -f bin/vib3.js bin/vib3.wasm "${DIST_DIR}/"
|
|
98
|
+
[ -f bin/vib3.d.ts ] && cp -f bin/vib3.d.ts "${DIST_DIR}/"
|
|
99
|
+
|
|
100
|
+
log "Release WASM build complete. Output: ${DIST_DIR}/"
|
|
101
|
+
ls -lh "${DIST_DIR}/"
|
|
102
|
+
;;
|
|
103
|
+
|
|
104
|
+
native)
|
|
105
|
+
log "Building native (with tests)..."
|
|
106
|
+
|
|
107
|
+
mkdir -p "${BUILD_DIR}/native"
|
|
108
|
+
cd "${BUILD_DIR}/native"
|
|
109
|
+
|
|
110
|
+
cmake "${SCRIPT_DIR}" \
|
|
111
|
+
-DCMAKE_BUILD_TYPE=Debug \
|
|
112
|
+
-DVIB3_BUILD_WASM=OFF \
|
|
113
|
+
-DVIB3_BUILD_TESTS=ON \
|
|
114
|
+
-DVIB3_ENABLE_SIMD=ON
|
|
115
|
+
|
|
116
|
+
cmake --build . -j"${NPROC}"
|
|
117
|
+
|
|
118
|
+
log "Running tests..."
|
|
119
|
+
ctest --output-on-failure
|
|
120
|
+
|
|
121
|
+
log "Native build and tests complete."
|
|
122
|
+
;;
|
|
123
|
+
|
|
124
|
+
*)
|
|
125
|
+
error "Unknown build type: ${BUILD_TYPE}"
|
|
126
|
+
echo "Usage: $0 [release|debug|native|clean]"
|
|
127
|
+
exit 1
|
|
128
|
+
;;
|
|
129
|
+
esac
|