@vib3code/sdk 2.0.3-canary.4fbf680 → 2.0.3-canary.539685c
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/package.json +1 -1
- package/src/math/Mat4x4.js +152 -51
- package/src/wasm/WasmLoader.js +11 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vib3code/sdk",
|
|
3
|
-
"version": "2.0.3-canary.
|
|
3
|
+
"version": "2.0.3-canary.539685c",
|
|
4
4
|
"description": "VIB3+ 4D Visualization SDK - Unified engine with 6D rotation, MCP agentic integration, and cross-platform support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/core/VIB3Engine.js",
|
package/src/math/Mat4x4.js
CHANGED
|
@@ -48,6 +48,19 @@ export class Mat4x4 {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Reset to identity matrix
|
|
53
|
+
* @returns {Mat4x4} this
|
|
54
|
+
*/
|
|
55
|
+
identity() {
|
|
56
|
+
const d = this.data;
|
|
57
|
+
d[0] = 1; d[1] = 0; d[2] = 0; d[3] = 0;
|
|
58
|
+
d[4] = 0; d[5] = 1; d[6] = 0; d[7] = 0;
|
|
59
|
+
d[8] = 0; d[9] = 0; d[10] = 1; d[11] = 0;
|
|
60
|
+
d[12] = 0; d[13] = 0; d[14] = 0; d[15] = 1;
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
|
|
51
64
|
/**
|
|
52
65
|
* Create identity matrix
|
|
53
66
|
* @returns {Mat4x4}
|
|
@@ -718,51 +731,78 @@ export class Mat4x4 {
|
|
|
718
731
|
/**
|
|
719
732
|
* Create XY plane rotation matrix (standard Z-axis rotation in 3D)
|
|
720
733
|
* @param {number} angle - Rotation angle in radians
|
|
734
|
+
* @param {Mat4x4} [target=null] - Optional target matrix
|
|
721
735
|
* @returns {Mat4x4}
|
|
722
736
|
*/
|
|
723
|
-
static rotationXY(angle) {
|
|
737
|
+
static rotationXY(angle, target = null) {
|
|
724
738
|
const c = Math.cos(angle);
|
|
725
739
|
const s = Math.sin(angle);
|
|
726
|
-
const out = new Mat4x4(Mat4x4.UNINITIALIZED);
|
|
740
|
+
const out = target || new Mat4x4(Mat4x4.UNINITIALIZED);
|
|
727
741
|
const r = out.data;
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
742
|
+
|
|
743
|
+
if (target) {
|
|
744
|
+
r[0] = c; r[1] = s; r[2] = 0; r[3] = 0;
|
|
745
|
+
r[4] = -s; r[5] = c; r[6] = 0; r[7] = 0;
|
|
746
|
+
r[8] = 0; r[9] = 0; r[10] = 1; r[11] = 0;
|
|
747
|
+
r[12] = 0; r[13] = 0; r[14] = 0; r[15] = 1;
|
|
748
|
+
} else {
|
|
749
|
+
r[0] = c; r[1] = s;
|
|
750
|
+
r[4] = -s; r[5] = c;
|
|
751
|
+
r[10] = 1;
|
|
752
|
+
r[15] = 1;
|
|
753
|
+
}
|
|
732
754
|
return out;
|
|
733
755
|
}
|
|
734
756
|
|
|
735
757
|
/**
|
|
736
758
|
* Create XZ plane rotation matrix (standard Y-axis rotation in 3D)
|
|
737
759
|
* @param {number} angle - Rotation angle in radians
|
|
760
|
+
* @param {Mat4x4} [target=null] - Optional target matrix
|
|
738
761
|
* @returns {Mat4x4}
|
|
739
762
|
*/
|
|
740
|
-
static rotationXZ(angle) {
|
|
763
|
+
static rotationXZ(angle, target = null) {
|
|
741
764
|
const c = Math.cos(angle);
|
|
742
765
|
const s = Math.sin(angle);
|
|
743
|
-
const out = new Mat4x4(Mat4x4.UNINITIALIZED);
|
|
766
|
+
const out = target || new Mat4x4(Mat4x4.UNINITIALIZED);
|
|
744
767
|
const r = out.data;
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
768
|
+
|
|
769
|
+
if (target) {
|
|
770
|
+
r[0] = c; r[1] = 0; r[2] = -s; r[3] = 0;
|
|
771
|
+
r[4] = 0; r[5] = 1; r[6] = 0; r[7] = 0;
|
|
772
|
+
r[8] = s; r[9] = 0; r[10] = c; r[11] = 0;
|
|
773
|
+
r[12] = 0; r[13] = 0; r[14] = 0; r[15] = 1;
|
|
774
|
+
} else {
|
|
775
|
+
r[0] = c; r[2] = -s;
|
|
776
|
+
r[5] = 1;
|
|
777
|
+
r[8] = s; r[10] = c;
|
|
778
|
+
r[15] = 1;
|
|
779
|
+
}
|
|
749
780
|
return out;
|
|
750
781
|
}
|
|
751
782
|
|
|
752
783
|
/**
|
|
753
784
|
* Create YZ plane rotation matrix (standard X-axis rotation in 3D)
|
|
754
785
|
* @param {number} angle - Rotation angle in radians
|
|
786
|
+
* @param {Mat4x4} [target=null] - Optional target matrix
|
|
755
787
|
* @returns {Mat4x4}
|
|
756
788
|
*/
|
|
757
|
-
static rotationYZ(angle) {
|
|
789
|
+
static rotationYZ(angle, target = null) {
|
|
758
790
|
const c = Math.cos(angle);
|
|
759
791
|
const s = Math.sin(angle);
|
|
760
|
-
const out = new Mat4x4(Mat4x4.UNINITIALIZED);
|
|
792
|
+
const out = target || new Mat4x4(Mat4x4.UNINITIALIZED);
|
|
761
793
|
const r = out.data;
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
794
|
+
|
|
795
|
+
if (target) {
|
|
796
|
+
r[0] = 1; r[1] = 0; r[2] = 0; r[3] = 0;
|
|
797
|
+
r[4] = 0; r[5] = c; r[6] = s; r[7] = 0;
|
|
798
|
+
r[8] = 0; r[9] = -s; r[10] = c; r[11] = 0;
|
|
799
|
+
r[12] = 0; r[13] = 0; r[14] = 0; r[15] = 1;
|
|
800
|
+
} else {
|
|
801
|
+
r[0] = 1;
|
|
802
|
+
r[5] = c; r[6] = s;
|
|
803
|
+
r[9] = -s; r[10] = c;
|
|
804
|
+
r[15] = 1;
|
|
805
|
+
}
|
|
766
806
|
return out;
|
|
767
807
|
}
|
|
768
808
|
|
|
@@ -770,51 +810,78 @@ export class Mat4x4 {
|
|
|
770
810
|
* Create XW plane rotation matrix (4D hyperspace rotation)
|
|
771
811
|
* Creates "inside-out" effect when w approaches viewer
|
|
772
812
|
* @param {number} angle - Rotation angle in radians
|
|
813
|
+
* @param {Mat4x4} [target=null] - Optional target matrix
|
|
773
814
|
* @returns {Mat4x4}
|
|
774
815
|
*/
|
|
775
|
-
static rotationXW(angle) {
|
|
816
|
+
static rotationXW(angle, target = null) {
|
|
776
817
|
const c = Math.cos(angle);
|
|
777
818
|
const s = Math.sin(angle);
|
|
778
|
-
const out = new Mat4x4(Mat4x4.UNINITIALIZED);
|
|
819
|
+
const out = target || new Mat4x4(Mat4x4.UNINITIALIZED);
|
|
779
820
|
const r = out.data;
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
821
|
+
|
|
822
|
+
if (target) {
|
|
823
|
+
r[0] = c; r[1] = 0; r[2] = 0; r[3] = s;
|
|
824
|
+
r[4] = 0; r[5] = 1; r[6] = 0; r[7] = 0;
|
|
825
|
+
r[8] = 0; r[9] = 0; r[10] = 1; r[11] = 0;
|
|
826
|
+
r[12] = -s; r[13] = 0; r[14] = 0; r[15] = c;
|
|
827
|
+
} else {
|
|
828
|
+
r[0] = c; r[3] = s;
|
|
829
|
+
r[5] = 1;
|
|
830
|
+
r[10] = 1;
|
|
831
|
+
r[12] = -s; r[15] = c;
|
|
832
|
+
}
|
|
784
833
|
return out;
|
|
785
834
|
}
|
|
786
835
|
|
|
787
836
|
/**
|
|
788
837
|
* Create YW plane rotation matrix (4D hyperspace rotation)
|
|
789
838
|
* @param {number} angle - Rotation angle in radians
|
|
839
|
+
* @param {Mat4x4} [target=null] - Optional target matrix
|
|
790
840
|
* @returns {Mat4x4}
|
|
791
841
|
*/
|
|
792
|
-
static rotationYW(angle) {
|
|
842
|
+
static rotationYW(angle, target = null) {
|
|
793
843
|
const c = Math.cos(angle);
|
|
794
844
|
const s = Math.sin(angle);
|
|
795
|
-
const out = new Mat4x4(Mat4x4.UNINITIALIZED);
|
|
845
|
+
const out = target || new Mat4x4(Mat4x4.UNINITIALIZED);
|
|
796
846
|
const r = out.data;
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
847
|
+
|
|
848
|
+
if (target) {
|
|
849
|
+
r[0] = 1; r[1] = 0; r[2] = 0; r[3] = 0;
|
|
850
|
+
r[4] = 0; r[5] = c; r[6] = 0; r[7] = s;
|
|
851
|
+
r[8] = 0; r[9] = 0; r[10] = 1; r[11] = 0;
|
|
852
|
+
r[12] = 0; r[13] = -s; r[14] = 0; r[15] = c;
|
|
853
|
+
} else {
|
|
854
|
+
r[0] = 1;
|
|
855
|
+
r[5] = c; r[7] = s;
|
|
856
|
+
r[10] = 1;
|
|
857
|
+
r[13] = -s; r[15] = c;
|
|
858
|
+
}
|
|
801
859
|
return out;
|
|
802
860
|
}
|
|
803
861
|
|
|
804
862
|
/**
|
|
805
863
|
* Create ZW plane rotation matrix (4D hyperspace rotation)
|
|
806
864
|
* @param {number} angle - Rotation angle in radians
|
|
865
|
+
* @param {Mat4x4} [target=null] - Optional target matrix
|
|
807
866
|
* @returns {Mat4x4}
|
|
808
867
|
*/
|
|
809
|
-
static rotationZW(angle) {
|
|
868
|
+
static rotationZW(angle, target = null) {
|
|
810
869
|
const c = Math.cos(angle);
|
|
811
870
|
const s = Math.sin(angle);
|
|
812
|
-
const out = new Mat4x4(Mat4x4.UNINITIALIZED);
|
|
871
|
+
const out = target || new Mat4x4(Mat4x4.UNINITIALIZED);
|
|
813
872
|
const r = out.data;
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
873
|
+
|
|
874
|
+
if (target) {
|
|
875
|
+
r[0] = 1; r[1] = 0; r[2] = 0; r[3] = 0;
|
|
876
|
+
r[4] = 0; r[5] = 1; r[6] = 0; r[7] = 0;
|
|
877
|
+
r[8] = 0; r[9] = 0; r[10] = c; r[11] = s;
|
|
878
|
+
r[12] = 0; r[13] = 0; r[14] = -s; r[15] = c;
|
|
879
|
+
} else {
|
|
880
|
+
r[0] = 1;
|
|
881
|
+
r[5] = 1;
|
|
882
|
+
r[10] = c; r[11] = s;
|
|
883
|
+
r[14] = -s; r[15] = c;
|
|
884
|
+
}
|
|
818
885
|
return out;
|
|
819
886
|
}
|
|
820
887
|
|
|
@@ -841,24 +908,58 @@ export class Mat4x4 {
|
|
|
841
908
|
* Create combined rotation matrix from all 6 angles
|
|
842
909
|
* Order: XY, XZ, YZ, XW, YW, ZW
|
|
843
910
|
*
|
|
844
|
-
*
|
|
845
|
-
*
|
|
846
|
-
*
|
|
847
|
-
*
|
|
848
|
-
* @param {number}
|
|
849
|
-
* @param {number} [
|
|
850
|
-
* @param {number} [
|
|
911
|
+
* Supports two signatures:
|
|
912
|
+
* 1. rotationFromAngles(angles, target?)
|
|
913
|
+
* 2. rotationFromAngles(xy, xz, yz, xw, yw, zw, target?)
|
|
914
|
+
*
|
|
915
|
+
* @param {object|number} anglesOrXY - Rotation angles object OR XY angle
|
|
916
|
+
* @param {number|Mat4x4} [xzOrTarget] - XZ angle OR target matrix
|
|
917
|
+
* @param {number} [yz=0] - YZ angle
|
|
918
|
+
* @param {number} [xw=0] - XW angle
|
|
919
|
+
* @param {number} [yw=0] - YW angle
|
|
920
|
+
* @param {number} [zw=0] - ZW angle
|
|
921
|
+
* @param {Mat4x4} [target=null] - Target matrix (if using 6-arg signature)
|
|
851
922
|
* @returns {Mat4x4}
|
|
852
923
|
*/
|
|
853
|
-
static rotationFromAngles(
|
|
854
|
-
let
|
|
924
|
+
static rotationFromAngles(anglesOrXY, xzOrTarget, yz, xw, yw, zw, target) {
|
|
925
|
+
let xy = 0, xz = 0;
|
|
926
|
+
let _yz = 0, _xw = 0, _yw = 0, _zw = 0;
|
|
927
|
+
let out = null;
|
|
928
|
+
|
|
929
|
+
if (typeof anglesOrXY === 'number') {
|
|
930
|
+
// Signature: (xy, xz, yz, xw, yw, zw, target)
|
|
931
|
+
xy = anglesOrXY;
|
|
932
|
+
xz = typeof xzOrTarget === 'number' ? xzOrTarget : 0;
|
|
933
|
+
_yz = yz || 0;
|
|
934
|
+
_xw = xw || 0;
|
|
935
|
+
_yw = yw || 0;
|
|
936
|
+
_zw = zw || 0;
|
|
937
|
+
out = target || null;
|
|
938
|
+
} else {
|
|
939
|
+
// Signature: (angles, target)
|
|
940
|
+
const angles = anglesOrXY || {};
|
|
941
|
+
xy = angles.xy || 0;
|
|
942
|
+
xz = angles.xz || 0;
|
|
943
|
+
_yz = angles.yz || 0;
|
|
944
|
+
_xw = angles.xw || 0;
|
|
945
|
+
_yw = angles.yw || 0;
|
|
946
|
+
_zw = angles.zw || 0;
|
|
947
|
+
// The second argument is the target in this case
|
|
948
|
+
// Use duck typing or check constructor name to avoid circular dependency issues if any
|
|
949
|
+
if (xzOrTarget && typeof xzOrTarget === 'object' && xzOrTarget.data) {
|
|
950
|
+
out = xzOrTarget;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
const result = out || new Mat4x4(); // Default constructor is identity
|
|
955
|
+
if (out) result.identity(); // Reset if reused
|
|
855
956
|
|
|
856
|
-
if (
|
|
857
|
-
if (
|
|
858
|
-
if (
|
|
859
|
-
if (
|
|
860
|
-
if (
|
|
861
|
-
if (
|
|
957
|
+
if (xy) result.rotateXY(xy);
|
|
958
|
+
if (xz) result.rotateXZ(xz);
|
|
959
|
+
if (_yz) result.rotateYZ(_yz);
|
|
960
|
+
if (_xw) result.rotateXW(_xw);
|
|
961
|
+
if (_yw) result.rotateYW(_yw);
|
|
962
|
+
if (_zw) result.rotateZW(_zw);
|
|
862
963
|
|
|
863
964
|
return result;
|
|
864
965
|
}
|
package/src/wasm/WasmLoader.js
CHANGED
|
@@ -200,12 +200,17 @@ function createFallbackModule() {
|
|
|
200
200
|
),
|
|
201
201
|
|
|
202
202
|
// Projections
|
|
203
|
-
projectPerspective: JsProjection.
|
|
204
|
-
projectStereographic: JsProjection.
|
|
205
|
-
projectOrthographic: JsProjection.
|
|
206
|
-
projectOblique: JsProjection.
|
|
207
|
-
projectSlice:
|
|
208
|
-
|
|
203
|
+
projectPerspective: JsProjection.Projection.perspective,
|
|
204
|
+
projectStereographic: JsProjection.Projection.stereographic,
|
|
205
|
+
projectOrthographic: JsProjection.Projection.orthographic,
|
|
206
|
+
projectOblique: JsProjection.Projection.oblique,
|
|
207
|
+
projectSlice: (v, wPlane, tolerance) => {
|
|
208
|
+
if (JsProjection.SliceProjection.isInSlice(v, wPlane, tolerance)) {
|
|
209
|
+
return JsProjection.Projection.orthographic(v);
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
},
|
|
213
|
+
projectToFloatArray: JsProjection.Projection.perspectivePacked
|
|
209
214
|
};
|
|
210
215
|
}
|
|
211
216
|
|