@plurid/plurid-engine 0.0.0-13 → 0.0.0-16

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.
@@ -1,6 +1,6 @@
1
- import { defaultConfiguration, protocols, HTTPS_PROTOCOL, HTTP_PROTOCOL, compareTypes, defaultTreePlane, internationalization, ROOTS_GAP, LAYOUT_TYPES, PLANE_DEFAULT_ANGLE, PLURID_ROUTER_LOCATION_CHANGED } from "@plurid/plurid-data";
1
+ import { defaultConfiguration, protocols, HTTPS_PROTOCOL, HTTP_PROTOCOL, compareTypes, internationalization, ROOTS_GAP, LAYOUT_TYPES, PLANE_DEFAULT_ANGLE, PLURID_ROUTER_LOCATION_CHANGED } from "@plurid/plurid-data";
2
2
 
3
- import { objects, uuid, mathematics } from "@plurid/plurid-functions";
3
+ import { objects, mathematics, uuid } from "@plurid/plurid-functions";
4
4
 
5
5
  import themes, { THEME_NAMES } from "@plurid/plurid-themes";
6
6
 
@@ -25,91 +25,17 @@ const resolveTheme = (theme, type) => {
25
25
  };
26
26
 
27
27
  const merge = (configuration, target) => {
28
- var _a, _b, _c, _d, _e;
29
- const targetConfiguration = Object.assign(Object.assign({}, defaultConfiguration), target);
28
+ const targetConfiguration = Object.assign(Object.assign({}, objects.clone(defaultConfiguration)), objects.clone(target || {}));
30
29
  if (!configuration) {
31
- return Object.assign({}, targetConfiguration);
30
+ return targetConfiguration;
32
31
  }
33
- const specifiedOrDefault = (path, type, configuration) => {
34
- const item = objects.getNested(configuration, path);
35
- if (typeof item === type) {
36
- return item;
37
- }
38
- return objects.getNested(targetConfiguration, path);
39
- };
40
- const layout = configuration && configuration.space && typeof configuration.space.layout === "object" ? configuration.space.layout : targetConfiguration.space.layout;
41
- const mergedConfiguration = Object.assign(Object.assign({}, targetConfiguration), {
42
- global: {
43
- micro: specifiedOrDefault("global.micro", "boolean", configuration),
44
- transparentUI: specifiedOrDefault("global.transparentUI", "boolean", configuration),
45
- language: specifiedOrDefault("global.language", "string", configuration),
46
- render: specifiedOrDefault("global.render", "string", configuration),
47
- theme: {
32
+ const mergedConfiguration = objects.merge(targetConfiguration, configuration, {
33
+ "global.theme": () => {
34
+ var _a, _b;
35
+ return {
48
36
  general: resolveTheme((_a = configuration.global) === null || _a === void 0 ? void 0 : _a.theme, "general"),
49
37
  interaction: resolveTheme((_b = configuration.global) === null || _b === void 0 ? void 0 : _b.theme, "interaction")
50
- }
51
- },
52
- elements: Object.assign(Object.assign({}, targetConfiguration.elements), {
53
- toolbar: {
54
- show: specifiedOrDefault("elements.toolbar.show", "boolean", configuration),
55
- opaque: specifiedOrDefault("elements.toolbar.opaque", "boolean", configuration),
56
- conceal: specifiedOrDefault("elements.toolbar.conceal", "boolean", configuration),
57
- transformIcons: specifiedOrDefault("elements.toolbar.transformIcons", "boolean", configuration),
58
- transformButtons: specifiedOrDefault("elements.toolbar.transformButtons", "boolean", configuration),
59
- drawers: configuration.elements && configuration.elements.toolbar && configuration.elements.toolbar.drawers ? configuration.elements.toolbar.drawers : targetConfiguration.elements.toolbar.drawers,
60
- toggledDrawers: configuration.elements && configuration.elements.toolbar && configuration.elements.toolbar.toggledDrawers ? configuration.elements.toolbar.toggledDrawers : targetConfiguration.elements.toolbar.toggledDrawers
61
- },
62
- viewcube: {
63
- show: specifiedOrDefault("elements.viewcube.show", "boolean", configuration),
64
- opaque: specifiedOrDefault("elements.viewcube.opaque", "boolean", configuration),
65
- conceal: specifiedOrDefault("elements.viewcube.conceal", "boolean", configuration),
66
- buttons: specifiedOrDefault("elements.viewcube.buttons", "boolean", configuration)
67
- },
68
- plane: {
69
- width: specifiedOrDefault("elements.plane.width", "number", configuration),
70
- opacity: specifiedOrDefault("elements.plane.opacity", "number", configuration),
71
- controls: {
72
- show: specifiedOrDefault("elements.plane.controls.show", "boolean", configuration),
73
- pathbar: {
74
- domainURL: specifiedOrDefault("elements.plane.controls.pathbar.domainURL", "boolean", configuration)
75
- }
76
- }
77
- },
78
- switch: {
79
- show: (_e = (_d = (_c = configuration === null || configuration === void 0 ? void 0 : configuration.elements) === null || _c === void 0 ? void 0 : _c.switch) === null || _d === void 0 ? void 0 : _d.show) !== null && _e !== void 0 ? _e : false
80
- }
81
- }),
82
- space: Object.assign(Object.assign({}, targetConfiguration.space), {
83
- layout: layout,
84
- camera: specifiedOrDefault("space.camera", "string", configuration),
85
- perspective: specifiedOrDefault("space.perspective", "number", configuration),
86
- opaque: specifiedOrDefault("space.opaque", "boolean", configuration),
87
- fadeInTime: specifiedOrDefault("space.fadeInTime", "number", configuration),
88
- center: specifiedOrDefault("space.center", "boolean", configuration),
89
- transformOrigin: {
90
- show: specifiedOrDefault("space.transformOrigin.show", "boolean", configuration),
91
- size: specifiedOrDefault("space.transformOrigin.size", "string", configuration)
92
- },
93
- transformLocks: {
94
- rotationX: specifiedOrDefault("space.transformLocks.rotationX", "boolean", configuration),
95
- rotationY: specifiedOrDefault("space.transformLocks.rotationY", "boolean", configuration),
96
- translationX: specifiedOrDefault("space.transformLocks.translationX", "boolean", configuration),
97
- translationY: specifiedOrDefault("space.transformLocks.translationY", "boolean", configuration),
98
- translationZ: specifiedOrDefault("space.transformLocks.translationZ", "boolean", configuration),
99
- scale: specifiedOrDefault("space.transformLocks.scale", "boolean", configuration)
100
- },
101
- transformMode: specifiedOrDefault("space.transformMode", "string", configuration),
102
- transformMultimode: specifiedOrDefault("space.transformMultimode", "boolean", configuration),
103
- transformTouch: specifiedOrDefault("space.transformTouch", "string", configuration),
104
- firstPerson: specifiedOrDefault("space.firstPerson", "boolean", configuration)
105
- }),
106
- network: {
107
- host: specifiedOrDefault("network.host", "string", configuration),
108
- protocol: specifiedOrDefault("network.protocol", "string", configuration)
109
- },
110
- development: {
111
- planeDebugger: specifiedOrDefault("development.planeDebugger", "boolean", configuration),
112
- spaceDebugger: specifiedOrDefault("development.spaceDebugger", "boolean", configuration)
38
+ };
113
39
  }
114
40
  });
115
41
  return mergedConfiguration;
@@ -313,7 +239,7 @@ const cleanupPath = value => {
313
239
  };
314
240
 
315
241
  const computePlaneAddress = (plane, route, origin = "origin") => {
316
- if (origin === "origin" && typeof location !== "undefined") {
242
+ if (origin === "origin" && typeof location !== "undefined" && location.host) {
317
243
  origin = location.host;
318
244
  }
319
245
  const cleanPlane = extractPathname(plane);
@@ -689,18 +615,6 @@ const resolveRoute = (route, protocol, host) => {
689
615
  };
690
616
  };
691
617
 
692
- const createTreePlane = (contextPlane, documentPlane) => {
693
- const routeDivisions = pluridLinkPathDivider(contextPlane.path);
694
- const treePlane = Object.assign(Object.assign({}, defaultTreePlane), {
695
- routeDivisions: routeDivisions,
696
- sourceID: contextPlane.id,
697
- planeID: uuid.generate(),
698
- route: contextPlane.path,
699
- show: true
700
- });
701
- return treePlane;
702
- };
703
-
704
618
  const updateTreePlane$1 = (tree, page) => {
705
619
  const updatedTree = tree.map((treePlane => {
706
620
  if (treePlane.planeID === page.planeID) {
@@ -738,7 +652,6 @@ const updateTreeByPlaneIDWithLinkCoordinates = (tree, planeID, linkCoordinates)
738
652
 
739
653
  var index$i = Object.freeze({
740
654
  __proto__: null,
741
- createTreePlane: createTreePlane,
742
655
  updateTreePlane: updateTreePlane$1,
743
656
  updateTreeByPlaneIDWithLinkCoordinates: updateTreeByPlaneIDWithLinkCoordinates
744
657
  });
@@ -796,10 +709,10 @@ function conjugateQuaternion(quaternion) {
796
709
  return makeQuaternion(-quaternion.x, -quaternion.y, -quaternion.z, quaternion.w);
797
710
  }
798
711
 
799
- function computeQuaternionFromEulers(alpha, beta, gamma) {
800
- const x = beta;
801
- const y = gamma;
802
- const z = alpha;
712
+ function computeQuaternionFromEulers(alpha, beta, gamma, radians = true) {
713
+ const x = radians ? beta : degToRad(beta);
714
+ const y = radians ? gamma : degToRad(gamma);
715
+ const z = radians ? alpha : degToRad(alpha);
803
716
  const cX = Math.cos(x / 2);
804
717
  const cY = Math.cos(y / 2);
805
718
  const cZ = Math.cos(z / 2);
@@ -816,39 +729,29 @@ function computeQuaternionFromEulers(alpha, beta, gamma) {
816
729
  function quaternionFromAxisAngle(x, y, z, angle) {
817
730
  const q = zeroQuaternion();
818
731
  const halfAngle = angle / 2;
819
- q.x = x * Math.sin(halfAngle);
820
- q.y = y * Math.sin(halfAngle);
821
- q.z = z * Math.sin(halfAngle);
732
+ const sine = Math.sin(halfAngle);
733
+ q.x = x * sine;
734
+ q.y = y * sine;
735
+ q.z = z * sine;
822
736
  q.w = Math.cos(halfAngle);
823
737
  return q;
824
738
  }
825
739
 
826
740
  function quaternionMultiply(quaternionArray) {
827
- const temporaryQuaternion = quaternionArray[0];
828
- const copyQuaternion = {
829
- x: temporaryQuaternion.x,
830
- y: temporaryQuaternion.y,
831
- z: temporaryQuaternion.z,
832
- w: temporaryQuaternion.w
833
- };
741
+ const firstQuaternion = quaternionArray[0];
742
+ const valueQuaternion = Object.assign({}, firstQuaternion);
834
743
  for (let i = 1; i < quaternionArray.length; i++) {
835
- const secondaryTemporaryQuaternion = quaternionArray[i];
836
- const nextQuaternion = {
837
- x: secondaryTemporaryQuaternion.x,
838
- y: secondaryTemporaryQuaternion.y,
839
- z: secondaryTemporaryQuaternion.z,
840
- w: secondaryTemporaryQuaternion.w
841
- };
842
- const w = copyQuaternion.w * nextQuaternion.w - copyQuaternion.x * nextQuaternion.x - copyQuaternion.y * nextQuaternion.y - copyQuaternion.z * nextQuaternion.z;
843
- const x = copyQuaternion.x * nextQuaternion.w + copyQuaternion.w * nextQuaternion.x + copyQuaternion.y * nextQuaternion.z - copyQuaternion.z * nextQuaternion.y;
844
- const y = copyQuaternion.y * nextQuaternion.w + copyQuaternion.w * nextQuaternion.y + copyQuaternion.z * nextQuaternion.x - copyQuaternion.x * nextQuaternion.z;
845
- const z = copyQuaternion.z * nextQuaternion.w + copyQuaternion.w * nextQuaternion.z + copyQuaternion.x * nextQuaternion.y - copyQuaternion.y * nextQuaternion.x;
846
- copyQuaternion.x = x;
847
- copyQuaternion.y = y;
848
- copyQuaternion.z = z;
849
- copyQuaternion.w = w;
850
- }
851
- return copyQuaternion;
744
+ const nextQuaternion = quaternionArray[i];
745
+ const w = valueQuaternion.w * nextQuaternion.w - valueQuaternion.x * nextQuaternion.x - valueQuaternion.y * nextQuaternion.y - valueQuaternion.z * nextQuaternion.z;
746
+ const x = valueQuaternion.x * nextQuaternion.w + valueQuaternion.w * nextQuaternion.x + valueQuaternion.y * nextQuaternion.z - valueQuaternion.z * nextQuaternion.y;
747
+ const y = valueQuaternion.y * nextQuaternion.w + valueQuaternion.w * nextQuaternion.y + valueQuaternion.z * nextQuaternion.x - valueQuaternion.x * nextQuaternion.z;
748
+ const z = valueQuaternion.z * nextQuaternion.w + valueQuaternion.w * nextQuaternion.z + valueQuaternion.x * nextQuaternion.y - valueQuaternion.y * nextQuaternion.x;
749
+ valueQuaternion.x = x;
750
+ valueQuaternion.y = y;
751
+ valueQuaternion.z = z;
752
+ valueQuaternion.w = w;
753
+ }
754
+ return valueQuaternion;
852
755
  }
853
756
 
854
757
  function rotatePointViaQuaternion(pointRotate, quaternion) {
@@ -858,13 +761,8 @@ function rotatePointViaQuaternion(pointRotate, quaternion) {
858
761
  z: pointRotate[2],
859
762
  w: 0
860
763
  };
861
- const rotatedPoint = quaternionMultiply([ quaternion, temporaryQuaternion, conjugateQuaternion(quaternion) ]);
862
- return {
863
- x: rotatedPoint.x,
864
- y: rotatedPoint.y,
865
- z: rotatedPoint.z,
866
- w: rotatedPoint.w
867
- };
764
+ const rotatedPointQuaternion = quaternionMultiply([ quaternion, temporaryQuaternion, conjugateQuaternion(quaternion) ]);
765
+ return rotatedPointQuaternion;
868
766
  }
869
767
 
870
768
  function makeRotationMatrixFromQuaternion(quaternion) {
@@ -911,7 +809,7 @@ function translateMatrix$1(x, y, z) {
911
809
  return [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 ];
912
810
  }
913
811
 
914
- function scaleMatrix(s) {
812
+ function scaleMatrix$1(s) {
915
813
  return [ s, 0, 0, 0, 0, s, 0, 0, 0, 0, s, 0, 0, 0, 0, 1 ];
916
814
  }
917
815
 
@@ -984,12 +882,17 @@ var index$e = Object.freeze({
984
882
  __proto__: null,
985
883
  rotateMatrix: rotateMatrix,
986
884
  translateMatrix: translateMatrix$1,
987
- scaleMatrix: scaleMatrix,
885
+ scaleMatrix: scaleMatrix$1,
988
886
  multiplyMatrices: multiplyMatrices$1,
989
887
  multiplyArrayOfMatrices: multiplyArrayOfMatrices,
990
888
  matrixArrayToCSSMatrix: matrixArrayToCSSMatrix
991
889
  });
992
890
 
891
+ const getInitialMatrix = () => {
892
+ const matrix = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
893
+ return matrix;
894
+ };
895
+
993
896
  const multiplyMatrices = (m1, m2) => {
994
897
  const result = [];
995
898
  for (let i = 0; i < m1.length; i++) {
@@ -1005,6 +908,21 @@ const multiplyMatrices = (m1, m2) => {
1005
908
  return result;
1006
909
  };
1007
910
 
911
+ const multiplyMatricesArray = matrices => {
912
+ if (matrices.length < 2) {
913
+ throw new Error("invalid number of matrices");
914
+ }
915
+ const first = matrices[0];
916
+ let result = first;
917
+ for (const [index, matrix] of matrices.entries()) {
918
+ if (index === 0) {
919
+ continue;
920
+ }
921
+ result = multiplyMatrices(result, matrix);
922
+ }
923
+ return result;
924
+ };
925
+
1008
926
  const arrayToMatrix = array => {
1009
927
  const matrix = [];
1010
928
  for (let i = 0; i < array.length; i += 4) {
@@ -1020,6 +938,11 @@ const arrayToMatrix = array => {
1020
938
 
1021
939
  const matrixToArray = matrix => matrix.flat();
1022
940
 
941
+ const matrix3DToMatrix = value => {
942
+ const values = value.replace("matrix3d(", "").replace(")", "").split(",").map((val => parseFloat(val)));
943
+ return arrayToMatrix(values);
944
+ };
945
+
1023
946
  const printMatrix = (matrix, name) => {
1024
947
  const normalize = value => {
1025
948
  if (value === 1 || value === 0) {
@@ -1067,16 +990,113 @@ const translateMatrix = (x = 0, y = 0, z = 0) => {
1067
990
  return m;
1068
991
  };
1069
992
 
993
+ const scaleMatrix = s => [ [ s, 0, 0, 0 ], [ 0, s, 0, 0 ], [ 0, 0, s, 0 ], [ 0, 0, 0, 1 ] ];
994
+
995
+ function rotationMatrixFromQuaternion(quaternion) {
996
+ const num = quaternion.x * 2;
997
+ const num2 = quaternion.y * 2;
998
+ const num3 = quaternion.z * 2;
999
+ const num4 = quaternion.x * num;
1000
+ const num5 = quaternion.y * num2;
1001
+ const num6 = quaternion.z * num3;
1002
+ const num7 = quaternion.x * num2;
1003
+ const num8 = quaternion.x * num3;
1004
+ const num9 = quaternion.y * num3;
1005
+ const num10 = quaternion.w * num;
1006
+ const num11 = quaternion.w * num2;
1007
+ const num12 = quaternion.w * num3;
1008
+ return [ [ 1 - (num5 + num6), num7 - num12, num8 + num11, 0 ], [ num7 + num12, 1 - (num4 + num6), num9 - num10, 0 ], [ num8 - num11, num9 + num10, 1 - (num4 + num5), 0 ], [ 0, 0, 0, 1 ] ];
1009
+ }
1010
+
1011
+ const matrixToCSSMatrix = matrix => {
1012
+ const value = matrix.flat().join(",");
1013
+ return `matrix3d(${value})`;
1014
+ };
1015
+
1016
+ const identityMatrix = () => {
1017
+ const matrix = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
1018
+ return matrix;
1019
+ };
1020
+
1021
+ const inverseMatrix = matrix => {
1022
+ const cols = 4;
1023
+ const rows = 4;
1024
+ const A = [ ...matrix ];
1025
+ const B = identityMatrix();
1026
+ let r;
1027
+ let s;
1028
+ let f;
1029
+ let temp;
1030
+ for (let c = 0; c < cols; c++) {
1031
+ let ABig = Math.abs(A[c][c]);
1032
+ let rBig = c;
1033
+ r = c + 1;
1034
+ while (r < rows) {
1035
+ if (Math.abs(A[r][c]) > ABig) {
1036
+ ABig = Math.abs(A[r][c]);
1037
+ rBig = r;
1038
+ }
1039
+ r++;
1040
+ }
1041
+ if (ABig === 0) {
1042
+ throw Error("Cannot calculate inverse, determinant is zero");
1043
+ }
1044
+ r = rBig;
1045
+ if (r !== c) {
1046
+ temp = A[c];
1047
+ A[c] = A[r];
1048
+ A[r] = temp;
1049
+ temp = B[c];
1050
+ B[c] = B[r];
1051
+ B[r] = temp;
1052
+ }
1053
+ const Ac = A[c];
1054
+ const Bc = B[c];
1055
+ for (r = 0; r < rows; r++) {
1056
+ const Ar = A[r];
1057
+ const Br = B[r];
1058
+ if (r !== c) {
1059
+ if (Ar[c] !== 0) {
1060
+ f = -Ar[c] / Ac[c];
1061
+ for (s = c; s < cols; s++) {
1062
+ Ar[s] = Ar[s] + f * Ac[s];
1063
+ }
1064
+ for (s = 0; s < cols; s++) {
1065
+ Br[s] = Br[s] + f * Bc[s];
1066
+ }
1067
+ }
1068
+ } else {
1069
+ f = Ac[c];
1070
+ for (s = c; s < cols; s++) {
1071
+ Ar[s] = Ar[s] / f;
1072
+ }
1073
+ for (s = 0; s < cols; s++) {
1074
+ Br[s] = Br[s] / f;
1075
+ }
1076
+ }
1077
+ }
1078
+ }
1079
+ return B;
1080
+ };
1081
+
1070
1082
  var index$d = Object.freeze({
1071
1083
  __proto__: null,
1084
+ getInitialMatrix: getInitialMatrix,
1072
1085
  multiplyMatrices: multiplyMatrices,
1086
+ multiplyMatricesArray: multiplyMatricesArray,
1073
1087
  arrayToMatrix: arrayToMatrix,
1074
1088
  matrixToArray: matrixToArray,
1089
+ matrix3DToMatrix: matrix3DToMatrix,
1075
1090
  printMatrix: printMatrix,
1076
1091
  rotateXMatrix: rotateXMatrix,
1077
1092
  rotateYMatrix: rotateYMatrix,
1078
1093
  rotateZMatrix: rotateZMatrix,
1079
- translateMatrix: translateMatrix
1094
+ translateMatrix: translateMatrix,
1095
+ scaleMatrix: scaleMatrix,
1096
+ rotationMatrixFromQuaternion: rotationMatrixFromQuaternion,
1097
+ matrixToCSSMatrix: matrixToCSSMatrix,
1098
+ identityMatrix: identityMatrix,
1099
+ inverseMatrix: inverseMatrix
1080
1100
  });
1081
1101
 
1082
1102
  function getMatrixValues(matrix3d) {
@@ -1209,7 +1229,7 @@ function rotatePlurid(matrix3d, direction = "", angleIncrement = .07) {
1209
1229
  const scale = getTransformScale(matrix3d).scale;
1210
1230
  let valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1211
1231
  const valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1212
- const valScalationMatrix = scaleMatrix(scale);
1232
+ const valScalationMatrix = scaleMatrix$1(scale);
1213
1233
  if (direction === "left") {
1214
1234
  rotateY -= angleIncrement;
1215
1235
  valRotationMatrix = rotateMatrix(rotateX, rotateY);
@@ -1242,7 +1262,7 @@ function translatePlurid(matrix3d, direction = "", linearIncrement = 50) {
1242
1262
  const scale = getTransformScale(matrix3d).scale;
1243
1263
  const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1244
1264
  let valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1245
- const valScalationMatrix = scaleMatrix(scale);
1265
+ const valScalationMatrix = scaleMatrix$1(scale);
1246
1266
  scale < .5 ? linearIncrement = 50 : linearIncrement = 30;
1247
1267
  if (direction === "left") {
1248
1268
  translateX += linearIncrement;
@@ -1276,20 +1296,20 @@ function scalePlurid(matrix3d, direction = "", scaleIncrement = .05) {
1276
1296
  let scale = getTransformScale(matrix3d).scale;
1277
1297
  const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1278
1298
  const valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1279
- let valScalationMatrix = scaleMatrix(scale);
1299
+ let valScalationMatrix = scaleMatrix$1(scale);
1280
1300
  if (direction === "up") {
1281
1301
  scale -= scaleIncrement;
1282
1302
  if (scale < .1) {
1283
1303
  scale = .1;
1284
1304
  }
1285
- valScalationMatrix = scaleMatrix(scale);
1305
+ valScalationMatrix = scaleMatrix$1(scale);
1286
1306
  }
1287
1307
  if (direction === "down") {
1288
1308
  scale += scaleIncrement;
1289
1309
  if (scale > 4) {
1290
1310
  scale = 4;
1291
1311
  }
1292
- valScalationMatrix = scaleMatrix(scale);
1312
+ valScalationMatrix = scaleMatrix$1(scale);
1293
1313
  }
1294
1314
  const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1295
1315
  return transformedMatrix3d;
@@ -1348,26 +1368,6 @@ const resolvePluridRoutePlaneData = plane => {
1348
1368
  return plane;
1349
1369
  };
1350
1370
 
1351
- const createInternalStatePlane = plane => {
1352
- const planeData = resolvePluridPlaneData(plane);
1353
- const statePlane = {
1354
- id: uuid.generate(),
1355
- path: planeData.route
1356
- };
1357
- return statePlane;
1358
- };
1359
-
1360
- const createInternalContextPlane = plane => {
1361
- const planeData = resolvePluridPlaneData(plane);
1362
- const {route: route, component: component} = planeData;
1363
- const contextPlane = {
1364
- id: uuid.generate(),
1365
- path: route,
1366
- component: component
1367
- };
1368
- return contextPlane;
1369
- };
1370
-
1371
1371
  const getPluridPlaneIDByData = element => {
1372
1372
  if (!element) {
1373
1373
  return "";
@@ -1385,7 +1385,7 @@ class IsoMatcher {
1385
1385
  this.planesIndex = new Map;
1386
1386
  this.routesKeys = [];
1387
1387
  this.planesKeys = [];
1388
- if (origin === "origin" && typeof location !== "undefined") {
1388
+ if (origin === "origin" && typeof location !== "undefined" && location.host) {
1389
1389
  this.origin = location.host;
1390
1390
  } else {
1391
1391
  this.origin = origin;
@@ -1664,10 +1664,10 @@ var index$9 = Object.freeze({
1664
1664
  });
1665
1665
 
1666
1666
  class PluridPlanesRegistrar {
1667
- constructor(planes) {
1667
+ constructor(planes, origin = "origin") {
1668
1668
  this.isoMatcher = new IsoMatcher({
1669
1669
  planes: planes
1670
- });
1670
+ }, origin);
1671
1671
  }
1672
1672
  register(planes) {
1673
1673
  this.isoMatcher.index({
@@ -1718,7 +1718,7 @@ class PluridPlanesRegistrar {
1718
1718
  }
1719
1719
  }
1720
1720
 
1721
- const registerPlanes = (planes, planesRegistrar) => {
1721
+ const registerPlanes = (planes, planesRegistrar, origin = "origin") => {
1722
1722
  if (!planes) {
1723
1723
  return;
1724
1724
  }
@@ -1730,7 +1730,7 @@ const registerPlanes = (planes, planesRegistrar) => {
1730
1730
  return;
1731
1731
  }
1732
1732
  if (typeof window.__pluridPlanesRegistrar__ === "undefined") {
1733
- const pluridPlanesRegistrar = new PluridPlanesRegistrar;
1733
+ const pluridPlanesRegistrar = new PluridPlanesRegistrar([], origin);
1734
1734
  window.__pluridPlanesRegistrar__ = pluridPlanesRegistrar;
1735
1735
  window.__pluridPlanesRegistrar__.register(planes);
1736
1736
  return;
@@ -1779,8 +1779,6 @@ var index$8 = Object.freeze({
1779
1779
  __proto__: null,
1780
1780
  resolvePluridPlaneData: resolvePluridPlaneData,
1781
1781
  resolvePluridRoutePlaneData: resolvePluridRoutePlaneData,
1782
- createInternalStatePlane: createInternalStatePlane,
1783
- createInternalContextPlane: createInternalContextPlane,
1784
1782
  getPluridPlaneIDByData: getPluridPlaneIDByData,
1785
1783
  registerPlanes: registerPlanes,
1786
1784
  getPlanesRegistrar: getPlanesRegistrar,
@@ -2125,7 +2123,7 @@ const resolveViewItem = (planes, view, configuration, origin = "origin") => {
2125
2123
  }
2126
2124
  const isoMatcher = new IsoMatcher({
2127
2125
  planes: pluridPlanes
2128
- });
2126
+ }, origin);
2129
2127
  const match = isoMatcher.match(viewData);
2130
2128
  if (match) {
2131
2129
  const route = match.match.value;
@@ -2276,14 +2274,14 @@ const assignPagesFromView = (planes, view) => {
2276
2274
  return tree;
2277
2275
  };
2278
2276
 
2279
- const updateTreePlane = (tree, updatedPage) => {
2277
+ const updateTreePlane = (tree, updatedPlane) => {
2280
2278
  const updatedTree = tree.map((treePlane => {
2281
- if (treePlane.planeID === updatedPage.planeID) {
2282
- return updatedPage;
2279
+ if (treePlane.planeID === updatedPlane.planeID) {
2280
+ return updatedPlane;
2283
2281
  }
2284
2282
  if (treePlane.children) {
2285
- const pageTree = updateTreePlane(treePlane.children, updatedPage);
2286
- treePlane.children = pageTree;
2283
+ const children = updateTreePlane(treePlane.children, updatedPlane);
2284
+ treePlane.children = children;
2287
2285
  return treePlane;
2288
2286
  }
2289
2287
  return treePlane;
@@ -2291,7 +2289,7 @@ const updateTreePlane = (tree, updatedPage) => {
2291
2289
  return updatedTree;
2292
2290
  };
2293
2291
 
2294
- const updateTreeWithNewPlane = (planeRoute, parentPlaneID, linkCoordinates, tree, planesRegistry, configuration) => {
2292
+ const updateTreeWithNewPlane = (planeRoute, parentPlaneID, linkCoordinates, tree, planesRegistry, configuration, hostname = "origin") => {
2295
2293
  const parentPlane = getTreePlaneByPlaneID(tree, parentPlaneID);
2296
2294
  if (!parentPlane) {
2297
2295
  return {
@@ -2300,7 +2298,7 @@ const updateTreeWithNewPlane = (planeRoute, parentPlaneID, linkCoordinates, tree
2300
2298
  };
2301
2299
  }
2302
2300
  const location = computePluridPlaneLocation(linkCoordinates, parentPlane);
2303
- const treePlane = resolveViewItem(planesRegistry, planeRoute, configuration);
2301
+ const treePlane = resolveViewItem(planesRegistry, planeRoute, configuration, hostname);
2304
2302
  if (!treePlane) {
2305
2303
  return {
2306
2304
  pluridPlaneID: "",
@@ -2334,6 +2332,24 @@ const updateTreeWithNewPlane = (planeRoute, parentPlaneID, linkCoordinates, tree
2334
2332
  };
2335
2333
  };
2336
2334
 
2335
+ const updatePlaneLocation = (tree, parentPlaneID, planeID, linkCoordinates) => {
2336
+ const parentPlane = getTreePlaneByPlaneID(tree, parentPlaneID);
2337
+ const plane = getTreePlaneByPlaneID(tree, planeID);
2338
+ if (!parentPlane || !plane) {
2339
+ return tree;
2340
+ }
2341
+ const location = computePluridPlaneLocation(linkCoordinates, parentPlane);
2342
+ plane.location = {
2343
+ translateX: location.x,
2344
+ translateY: location.y,
2345
+ translateZ: location.z,
2346
+ rotateX: 0,
2347
+ rotateY: parentPlane.location.rotateY + PLANE_DEFAULT_ANGLE
2348
+ };
2349
+ const updatedTree = updateTreePlane(tree, plane);
2350
+ return updatedTree;
2351
+ };
2352
+
2337
2353
  const updateTreeWithNewPage = (tree, treePageParentPlaneID, pagePath, pageID, linkCoordinates, parameters) => {
2338
2354
  const treePageParent = getTreePlaneByPlaneID(tree, treePageParentPlaneID);
2339
2355
  if (treePageParent) {
@@ -2448,21 +2464,35 @@ const toggleChildren = children => {
2448
2464
  return updatedChildren;
2449
2465
  };
2450
2466
 
2451
- const togglePlaneFromTree = (tree, pluridPlaneID) => {
2467
+ const toggleAllChildren = (tree, show) => {
2468
+ for (const plane of tree) {
2469
+ if (plane.children) {
2470
+ plane.children = toggleAllChildren(plane.children, show);
2471
+ }
2472
+ plane.show = show;
2473
+ }
2474
+ return tree;
2475
+ };
2476
+
2477
+ const togglePlaneFromTree = (tree, pluridPlaneID, forceShow) => {
2452
2478
  const updatedTree = [];
2453
2479
  let updatedPlane;
2454
2480
  for (const plane of tree) {
2455
2481
  if (plane.planeID === pluridPlaneID) {
2482
+ const show = forceShow !== null && forceShow !== void 0 ? forceShow : !plane.show;
2456
2483
  const treeUpdatedPlane = Object.assign(Object.assign({}, plane), {
2457
- show: !plane.show,
2458
- children: []
2484
+ show: show
2459
2485
  });
2486
+ if (treeUpdatedPlane.children) {
2487
+ const children = toggleAllChildren(treeUpdatedPlane.children, show);
2488
+ treeUpdatedPlane.children = children;
2489
+ }
2460
2490
  updatedTree.push(treeUpdatedPlane);
2461
2491
  updatedPlane = Object.assign({}, treeUpdatedPlane);
2462
2492
  continue;
2463
2493
  }
2464
2494
  if (plane.children) {
2465
- const {updatedTree: childrenUpdatedTree, updatedPlane: childrenUpdatedPlane} = togglePlaneFromTree(plane.children, pluridPlaneID);
2495
+ const {updatedTree: childrenUpdatedTree, updatedPlane: childrenUpdatedPlane} = togglePlaneFromTree(plane.children, pluridPlaneID, forceShow);
2466
2496
  plane.children = [ ...childrenUpdatedTree ];
2467
2497
  updatedTree.push(plane);
2468
2498
  if (childrenUpdatedPlane) {
@@ -2478,6 +2508,46 @@ const togglePlaneFromTree = (tree, pluridPlaneID) => {
2478
2508
  };
2479
2509
  };
2480
2510
 
2511
+ const getTreePlaneByID = (stateTree, id) => {
2512
+ if (!id) {
2513
+ return;
2514
+ }
2515
+ for (const plane of stateTree) {
2516
+ if (plane.planeID === id) {
2517
+ return plane;
2518
+ }
2519
+ if (plane.children) {
2520
+ const found = getTreePlaneByID(plane.children, id);
2521
+ if (found) {
2522
+ return found;
2523
+ }
2524
+ }
2525
+ }
2526
+ return;
2527
+ };
2528
+
2529
+ const removeRootFromTree = (tree, pluridPlaneID) => {
2530
+ const updatedTree = tree.filter((plane => plane.planeID !== pluridPlaneID));
2531
+ return {
2532
+ updatedTree: updatedTree
2533
+ };
2534
+ };
2535
+
2536
+ const removePlaneFromTree = (tree, pluridPlaneID) => {
2537
+ const updatedTree = [];
2538
+ for (const plane of tree) {
2539
+ if (plane.planeID === pluridPlaneID) {
2540
+ continue;
2541
+ }
2542
+ if (plane.children) {
2543
+ const children = removePlaneFromTree(plane.children, pluridPlaneID);
2544
+ plane.children = children;
2545
+ }
2546
+ updatedTree.push(plane);
2547
+ }
2548
+ return updatedTree;
2549
+ };
2550
+
2481
2551
  var logic = Object.freeze({
2482
2552
  __proto__: null,
2483
2553
  resolveViewItem: resolveViewItem,
@@ -2487,10 +2557,15 @@ var logic = Object.freeze({
2487
2557
  assignPagesFromView: assignPagesFromView,
2488
2558
  updateTreePlane: updateTreePlane,
2489
2559
  updateTreeWithNewPlane: updateTreeWithNewPlane,
2560
+ updatePlaneLocation: updatePlaneLocation,
2490
2561
  updateTreeWithNewPage: updateTreeWithNewPage,
2491
2562
  removePageFromTree: removePageFromTree,
2492
2563
  toggleChildren: toggleChildren,
2493
- togglePlaneFromTree: togglePlaneFromTree
2564
+ toggleAllChildren: toggleAllChildren,
2565
+ togglePlaneFromTree: togglePlaneFromTree,
2566
+ getTreePlaneByID: getTreePlaneByID,
2567
+ removeRootFromTree: removeRootFromTree,
2568
+ removePlaneFromTree: removePlaneFromTree
2494
2569
  });
2495
2570
 
2496
2571
  class Tree {
@@ -2576,7 +2651,7 @@ const resolveSpace = (view, configuration, planesRegistrar, currentState, localS
2576
2651
  view: view
2577
2652
  }, hostname);
2578
2653
  const computedTree = spaceTree.compute();
2579
- const stateSpace = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
2654
+ const stateSpace = Object.assign(Object.assign(Object.assign(Object.assign({
2580
2655
  loading: true,
2581
2656
  animatedTransform: false,
2582
2657
  transformTime: 450,
@@ -2606,12 +2681,10 @@ const resolveSpace = (view, configuration, planesRegistrar, currentState, localS
2606
2681
  z: 0
2607
2682
  }
2608
2683
  },
2609
- culledView: []
2610
- }, precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.space), contextState === null || contextState === void 0 ? void 0 : contextState.space), localState === null || localState === void 0 ? void 0 : localState.space), currentState === null || currentState === void 0 ? void 0 : currentState.space), {
2684
+ culledView: [],
2611
2685
  view: view,
2612
- initialTree: computedTree,
2613
2686
  tree: computedTree
2614
- });
2687
+ }, precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.space), contextState === null || contextState === void 0 ? void 0 : contextState.space), localState === null || localState === void 0 ? void 0 : localState.space), currentState === null || currentState === void 0 ? void 0 : currentState.space);
2615
2688
  if (currentState) {
2616
2689
  stateSpace.translationX = currentState.space.translationX;
2617
2690
  stateSpace.translationY = currentState.space.translationY;
@@ -2660,8 +2733,13 @@ const resolveThemes = (configuration, precomputedState) => {
2660
2733
  };
2661
2734
 
2662
2735
  const compute = (view, configuration, planesRegistrar, currentState, localState, precomputedState, contextState, hostname = "origin") => {
2663
- const specifiedConfiguration = merge(configuration);
2664
- const stateConfiguration = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, specifiedConfiguration), precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.configuration), contextState === null || contextState === void 0 ? void 0 : contextState.configuration), localState === null || localState === void 0 ? void 0 : localState.configuration), currentState === null || currentState === void 0 ? void 0 : currentState.configuration);
2736
+ let stateConfiguration = merge(configuration);
2737
+ const configurations = [ precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.configuration, contextState === null || contextState === void 0 ? void 0 : contextState.configuration, localState === null || localState === void 0 ? void 0 : localState.configuration, currentState === null || currentState === void 0 ? void 0 : currentState.configuration ];
2738
+ for (const configuration of configurations) {
2739
+ if (configuration) {
2740
+ stateConfiguration = merge(configuration);
2741
+ }
2742
+ }
2665
2743
  const stateSpace = resolveSpace(view, stateConfiguration, planesRegistrar, currentState, localState, precomputedState, contextState, hostname);
2666
2744
  const stateThemes = resolveThemes(stateConfiguration, precomputedState);
2667
2745
  const state = {