x_ite 12.0.0 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/assets/components/AnnotationComponent.js +2 -2
- package/dist/assets/components/AnnotationComponent.min.js +2 -2
- package/dist/assets/components/CADGeometryComponent.js +2 -2
- package/dist/assets/components/CADGeometryComponent.min.js +2 -2
- package/dist/assets/components/CubeMapTexturingComponent.js +2 -2
- package/dist/assets/components/CubeMapTexturingComponent.min.js +2 -2
- package/dist/assets/components/DISComponent.js +2 -2
- package/dist/assets/components/DISComponent.min.js +2 -2
- package/dist/assets/components/EventUtilitiesComponent.js +2 -2
- package/dist/assets/components/EventUtilitiesComponent.min.js +2 -2
- package/dist/assets/components/Geometry2DComponent.js +2 -2
- package/dist/assets/components/Geometry2DComponent.min.js +2 -2
- package/dist/assets/components/GeospatialComponent.js +28 -25
- package/dist/assets/components/GeospatialComponent.min.js +2 -2
- package/dist/assets/components/HAnimComponent.js +2 -2
- package/dist/assets/components/HAnimComponent.min.js +2 -2
- package/dist/assets/components/KeyDeviceSensorComponent.js +2 -2
- package/dist/assets/components/KeyDeviceSensorComponent.min.js +2 -2
- package/dist/assets/components/LayoutComponent.js +2 -2
- package/dist/assets/components/LayoutComponent.min.js +2 -2
- package/dist/assets/components/NURBSComponent.js +247 -245
- package/dist/assets/components/NURBSComponent.min.js +2 -2
- package/dist/assets/components/ParticleSystemsComponent.js +8 -4
- package/dist/assets/components/ParticleSystemsComponent.min.js +2 -2
- package/dist/assets/components/PickingComponent.js +33 -58
- package/dist/assets/components/PickingComponent.min.js +2 -2
- package/dist/assets/components/RigidBodyPhysicsComponent.js +2 -2
- package/dist/assets/components/RigidBodyPhysicsComponent.min.js +2 -2
- package/dist/assets/components/ScriptingComponent.js +4 -3
- package/dist/assets/components/ScriptingComponent.min.js +2 -2
- package/dist/assets/components/TextComponent.js +3 -3
- package/dist/assets/components/TextComponent.min.js +2 -2
- package/dist/assets/components/TextureProjectionComponent.js +8 -10
- package/dist/assets/components/TextureProjectionComponent.min.js +2 -2
- package/dist/assets/components/Texturing3DComponent.js +3571 -3569
- package/dist/assets/components/Texturing3DComponent.min.js +2 -2
- package/dist/assets/components/VolumeRenderingComponent.js +2 -2
- package/dist/assets/components/VolumeRenderingComponent.min.js +2 -2
- package/dist/assets/components/WebXRComponent.js +5 -4
- package/dist/assets/components/WebXRComponent.min.js +2 -2
- package/dist/assets/components/X_ITEComponent.js +12 -9
- package/dist/assets/components/X_ITEComponent.min.js +2 -2
- package/dist/example.html +1 -1
- package/dist/x_ite.css +1 -1
- package/dist/x_ite.js +81285 -81345
- package/dist/x_ite.min.js +2 -2
- package/dist/x_ite.min.mjs +2 -2
- package/dist/x_ite.mjs +80660 -80720
- package/dist/x_ite.zip +0 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* X_ITE v12.0.
|
|
2
|
-
const __X_ITE_X3D__ = window [Symbol .for ("X_ITE.X3D-12.0.
|
|
1
|
+
/* X_ITE v12.0.1 */
|
|
2
|
+
const __X_ITE_X3D__ = window [Symbol .for ("X_ITE.X3D-12.0.1")];
|
|
3
3
|
/******/ (() => { // webpackBootstrap
|
|
4
4
|
/******/ "use strict";
|
|
5
5
|
/******/ // The require scope
|
|
@@ -742,13 +742,13 @@ var external_X_ITE_X3D_X3DLineGeometryNode_default = /*#__PURE__*/__webpack_requ
|
|
|
742
742
|
|
|
743
743
|
const is_ndarray_default_ = function (arr)
|
|
744
744
|
{
|
|
745
|
-
if (!
|
|
745
|
+
if (!arr)
|
|
746
746
|
return false;
|
|
747
747
|
|
|
748
|
-
if (!
|
|
748
|
+
if (!arr .dtype)
|
|
749
749
|
return false;
|
|
750
750
|
|
|
751
|
-
|
|
751
|
+
const re = new RegExp ("function View[0-9]+d(:?" + arr .dtype + ")+");
|
|
752
752
|
|
|
753
753
|
return re .test (String (arr .constructor));
|
|
754
754
|
};
|
|
@@ -789,7 +789,7 @@ const is_array_like_default_ = function isArrayLike (data)
|
|
|
789
789
|
|
|
790
790
|
function inferType (x)
|
|
791
791
|
{
|
|
792
|
-
if (!
|
|
792
|
+
if (!x)
|
|
793
793
|
return undefined;
|
|
794
794
|
|
|
795
795
|
if (is_ndarray (x) || is_ndarray_like (x))
|
|
@@ -803,8 +803,10 @@ function inferType (x)
|
|
|
803
803
|
{
|
|
804
804
|
if (is_array_like (x))
|
|
805
805
|
{
|
|
806
|
-
|
|
807
|
-
|
|
806
|
+
let ptr = x;
|
|
807
|
+
|
|
808
|
+
while (is_array_like (ptr [0]))
|
|
809
|
+
ptr = ptr [0];
|
|
808
810
|
|
|
809
811
|
if ("x" in ptr)
|
|
810
812
|
return inferType .ARRAY_OF_OBJECTS;
|
|
@@ -838,11 +840,10 @@ function capitalize (str) {
|
|
|
838
840
|
}
|
|
839
841
|
|
|
840
842
|
const cache_key_default_ = function (nurbs, debug, checkBounds, pointType, weightType, knotType) {
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
var hasKnots = is_array_like(nurbs.knots) && is_array_like(nurbs.knots[d]);
|
|
843
|
+
const degreeParts = [];
|
|
844
|
+
let hasAnyKnots = false;
|
|
845
|
+
for (let d = 0; d < nurbs.splineDimension; ++ d) {
|
|
846
|
+
const hasKnots = is_array_like(nurbs.knots) && is_array_like(nurbs.knots[d]);
|
|
846
847
|
if (hasKnots) hasAnyKnots = true;
|
|
847
848
|
degreeParts.push(
|
|
848
849
|
"Deg" +
|
|
@@ -851,7 +852,7 @@ const cache_key_default_ = function (nurbs, debug, checkBounds, pointType, weigh
|
|
|
851
852
|
capitalize(nurbs.boundary[d])
|
|
852
853
|
);
|
|
853
854
|
}
|
|
854
|
-
|
|
855
|
+
const parts = [
|
|
855
856
|
[
|
|
856
857
|
hasAnyKnots ? "NU" : "",
|
|
857
858
|
nurbs.weights ? "RBS" : "BS"
|
|
@@ -885,15 +886,16 @@ const cache_key_default_ = function (nurbs, debug, checkBounds, pointType, weigh
|
|
|
885
886
|
/* harmony default export */ const cache_key = (external_X_ITE_X3D_Namespace_default().add ("cache-key", cache_key_default_));
|
|
886
887
|
;// ./src/lib/nurbs/src/utils/variable.js
|
|
887
888
|
|
|
888
|
-
|
|
889
|
+
const createVariable = function createVariable (name, nurbs) {
|
|
889
890
|
return function (i, period) {
|
|
890
891
|
if (i !== undefined && !Array.isArray(i)) i = [i];
|
|
891
|
-
|
|
892
|
-
for (
|
|
892
|
+
const dimAccessors = [];
|
|
893
|
+
for (let j = 0; j < i.length; ++ j) {
|
|
893
894
|
dimAccessors.push(createVariable.sum(i[j]));
|
|
894
895
|
}
|
|
895
|
-
if (period)
|
|
896
|
-
|
|
896
|
+
if (period)
|
|
897
|
+
{
|
|
898
|
+
for (let i = 0; i < dimAccessors.length; ++ i) {
|
|
897
899
|
if (period[i] === undefined) continue;
|
|
898
900
|
dimAccessors[i] = "(" + dimAccessors[i] + " + " + period[i] + ") % " + period[i];
|
|
899
901
|
}
|
|
@@ -918,7 +920,7 @@ const variable_default_ = createVariable;
|
|
|
918
920
|
|
|
919
921
|
|
|
920
922
|
|
|
921
|
-
|
|
923
|
+
const properties = [".x", ".y", ".z", ".w"];
|
|
922
924
|
|
|
923
925
|
function wrapAccessor (callback)
|
|
924
926
|
{
|
|
@@ -927,14 +929,14 @@ function wrapAccessor (callback)
|
|
|
927
929
|
if (i !== undefined && ! Array .isArray(i))
|
|
928
930
|
i = [i];
|
|
929
931
|
|
|
930
|
-
|
|
932
|
+
const dimAccessors = [ ];
|
|
931
933
|
|
|
932
|
-
for (
|
|
934
|
+
for (let j = 0; j < i .length; ++ j)
|
|
933
935
|
dimAccessors .push (variable .sum (i [j]));
|
|
934
936
|
|
|
935
937
|
if (period)
|
|
936
938
|
{
|
|
937
|
-
for (i = 0; i < dimAccessors .length; i
|
|
939
|
+
for (let i = 0; i < dimAccessors .length; ++ i)
|
|
938
940
|
{
|
|
939
941
|
if (period [i] === undefined)
|
|
940
942
|
continue;
|
|
@@ -957,7 +959,7 @@ function createAccessor (name, data)
|
|
|
957
959
|
{
|
|
958
960
|
return wrapAccessor (accessors =>
|
|
959
961
|
{
|
|
960
|
-
|
|
962
|
+
const e = accessors .pop ();
|
|
961
963
|
|
|
962
964
|
return name + "[" + accessors .join ("][") + "]" + properties [e];
|
|
963
965
|
});
|
|
@@ -980,9 +982,9 @@ function createAccessor (name, data)
|
|
|
980
982
|
{
|
|
981
983
|
return wrapAccessor (accessors =>
|
|
982
984
|
{
|
|
983
|
-
|
|
985
|
+
const code = [name + "Offset"];
|
|
984
986
|
|
|
985
|
-
for (
|
|
987
|
+
for (let i = 0; i < accessors.length; ++ i)
|
|
986
988
|
{
|
|
987
989
|
code.push(name + "Stride" + i + " * (" + accessors[i] + ")");
|
|
988
990
|
}
|
|
@@ -998,19 +1000,19 @@ function createAccessor (name, data)
|
|
|
998
1000
|
|
|
999
1001
|
const create_accessors_default_ = function (nurbs)
|
|
1000
1002
|
{
|
|
1001
|
-
|
|
1003
|
+
const accessors = { };
|
|
1002
1004
|
|
|
1003
|
-
|
|
1005
|
+
let accessor = createAccessor ("x", nurbs .points);
|
|
1004
1006
|
|
|
1005
1007
|
if (accessor)
|
|
1006
1008
|
accessors .point = accessor;
|
|
1007
1009
|
|
|
1008
|
-
|
|
1010
|
+
accessor = createAccessor ("w", nurbs .weights);
|
|
1009
1011
|
|
|
1010
1012
|
if (accessor)
|
|
1011
1013
|
accessors .weight = accessor;
|
|
1012
1014
|
|
|
1013
|
-
|
|
1015
|
+
accessor = createAccessor ("k", nurbs .knots);
|
|
1014
1016
|
|
|
1015
1017
|
if (accessor)
|
|
1016
1018
|
accessors .knot = accessor;
|
|
@@ -1022,31 +1024,30 @@ const create_accessors_default_ = function (nurbs)
|
|
|
1022
1024
|
/* harmony default export */ const create_accessors = (external_X_ITE_X3D_Namespace_default().add ("create-accessors", create_accessors_default_));
|
|
1023
1025
|
;// ./src/lib/nurbs/src/numerical-derivative.js
|
|
1024
1026
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
+
const args = [];
|
|
1028
|
+
const tmp = [];
|
|
1027
1029
|
|
|
1028
1030
|
const numerical_derivative_default_ = function numericalDerivative (out, order, dimension) {
|
|
1029
1031
|
if (order !== 1) {
|
|
1030
1032
|
throw new Error("Numerical derivative not implemented for order n = " + order + ".");
|
|
1031
1033
|
}
|
|
1032
1034
|
|
|
1033
|
-
|
|
1034
|
-
var h = arguments[this.splineDimension + 3] === undefined ? 1e-4 : arguments[this.splineDimension + 3];
|
|
1035
|
+
const h = arguments[this.splineDimension + 3] === undefined ? 1e-4 : arguments[this.splineDimension + 3];
|
|
1035
1036
|
|
|
1036
1037
|
args.length = this.splineDimension;
|
|
1037
|
-
for (i = 0; i < this.splineDimension; i
|
|
1038
|
+
for (let i = 0; i < this.splineDimension; ++ i) {
|
|
1038
1039
|
args[i + 1] = arguments[i + 3];
|
|
1039
1040
|
}
|
|
1040
1041
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1042
|
+
const domain = this.domain;
|
|
1043
|
+
const k0 = domain[dimension][0];
|
|
1044
|
+
const k1 = domain[dimension][1];
|
|
1044
1045
|
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1046
|
+
const t0 = args[dimension + 1];
|
|
1047
|
+
let tm, tp;
|
|
1048
|
+
let dt = (k1 - k0) * h;
|
|
1048
1049
|
if (this.boundary[dimension] === "closed") {
|
|
1049
|
-
T = k1 - k0;
|
|
1050
|
+
const T = k1 - k0;
|
|
1050
1051
|
tm = k0 + ((t0 - k0 - dt + T) % T);
|
|
1051
1052
|
tp = k0 + ((t0 - k0 + dt + T) % T);
|
|
1052
1053
|
dt *= 2;
|
|
@@ -1064,7 +1065,7 @@ const numerical_derivative_default_ = function numericalDerivative (out, order,
|
|
|
1064
1065
|
args[0] = out;
|
|
1065
1066
|
this.evaluate.apply(null, args);
|
|
1066
1067
|
|
|
1067
|
-
for (i = 0; i < this.dimension; i
|
|
1068
|
+
for (let i = 0; i < this .dimension; ++ i) {
|
|
1068
1069
|
out[i] = (out[i] - tmp[i]) / dt;
|
|
1069
1070
|
}
|
|
1070
1071
|
|
|
@@ -1075,18 +1076,29 @@ const numerical_derivative_default_ = function numericalDerivative (out, order,
|
|
|
1075
1076
|
/* harmony default export */ const numerical_derivative = (external_X_ITE_X3D_Namespace_default().add ("numerical-derivative", numerical_derivative_default_));
|
|
1076
1077
|
;// ./src/lib/nurbs/src/utils/ndloop.js
|
|
1077
1078
|
|
|
1078
|
-
const ndloop_default_ = function ndloop (n, callback)
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1079
|
+
const ndloop_default_ = function ndloop (n, callback)
|
|
1080
|
+
{
|
|
1081
|
+
let m = 1, i = [ ];
|
|
1082
|
+
|
|
1083
|
+
for (let k = 0; k < n .length; ++ k)
|
|
1084
|
+
{
|
|
1085
|
+
m *= Array .isArray (n [k]) ? (n [k] [1] - n [k] [0]) : n [k];
|
|
1086
|
+
i [k] = Array .isArray (n [k]) ? n [k] [0] : 0;
|
|
1082
1087
|
}
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1088
|
+
|
|
1089
|
+
for (let ptr = 0; ptr < m; ++ ptr)
|
|
1090
|
+
{
|
|
1091
|
+
callback (i .slice ());
|
|
1092
|
+
|
|
1093
|
+
for (let k = n .length - 1; k >= 0; -- k)
|
|
1094
|
+
{
|
|
1095
|
+
if (i [k] === (Array .isArray (n [k]) ? n [k] [1] : n [k]) - 1)
|
|
1096
|
+
{
|
|
1097
|
+
i [k] = Array .isArray (n [k]) ? n [k] [0] : 0;
|
|
1098
|
+
}
|
|
1099
|
+
else
|
|
1100
|
+
{
|
|
1101
|
+
++ i [k];
|
|
1090
1102
|
break;
|
|
1091
1103
|
}
|
|
1092
1104
|
}
|
|
@@ -1101,24 +1113,27 @@ const ndloop_default_ = function ndloop (n, callback) {
|
|
|
1101
1113
|
|
|
1102
1114
|
const accessor_preamble_default_ = function (nurbs, variableName, propertyName, data)
|
|
1103
1115
|
{
|
|
1104
|
-
|
|
1116
|
+
const code = [ ];
|
|
1105
1117
|
|
|
1106
1118
|
switch (infer_type (data))
|
|
1107
1119
|
{
|
|
1108
1120
|
case infer_type .NDARRAY:
|
|
1109
1121
|
{
|
|
1110
|
-
code .push (
|
|
1111
|
-
code .push (
|
|
1122
|
+
code .push (` var ${variableName} = ${propertyName}.data;`);
|
|
1123
|
+
code .push (` var ${variableName}Offset = ${propertyName}.offset;`);
|
|
1112
1124
|
|
|
1113
|
-
for (
|
|
1114
|
-
code .push (
|
|
1125
|
+
for (let i = 0; i < data .dimension; ++ i) {
|
|
1126
|
+
code .push (` var ${variableName}Stride${i} = ${propertyName}.stride[${i}];`);
|
|
1115
1127
|
}
|
|
1116
1128
|
|
|
1117
1129
|
break;
|
|
1118
1130
|
}
|
|
1119
1131
|
case infer_type .ARRAY_OF_OBJECTS:
|
|
1120
1132
|
case infer_type .ARRAY_OF_ARRAYS:
|
|
1121
|
-
|
|
1133
|
+
{
|
|
1134
|
+
code .push (` var ${variableName} = ${propertyName};`);
|
|
1135
|
+
break;
|
|
1136
|
+
}
|
|
1122
1137
|
}
|
|
1123
1138
|
|
|
1124
1139
|
return code .join ("\n");
|
|
@@ -1136,8 +1151,8 @@ const size_getter_default_ = function (data, dataVariableName, dimension) {
|
|
|
1136
1151
|
} else if (is_ndarray_like(data)) {
|
|
1137
1152
|
return dataVariableName + ".shape[" + dimension + "]";
|
|
1138
1153
|
} else {
|
|
1139
|
-
|
|
1140
|
-
for (
|
|
1154
|
+
let str = dataVariableName;
|
|
1155
|
+
for (let i = 0; i < dimension; ++ i) {
|
|
1141
1156
|
str += "[0]";
|
|
1142
1157
|
}
|
|
1143
1158
|
return str + ".length";
|
|
@@ -1155,27 +1170,25 @@ const size_getter_default_ = function (data, dataVariableName, dimension) {
|
|
|
1155
1170
|
|
|
1156
1171
|
|
|
1157
1172
|
|
|
1158
|
-
|
|
1159
|
-
|
|
1173
|
+
const evaluatorCache = {};
|
|
1174
|
+
const codeCache = {};
|
|
1160
1175
|
|
|
1161
1176
|
const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBounds, isBasis, derivative) {
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
var spaceDimension = nurbs.dimension;
|
|
1171
|
-
var boundary = nurbs.boundary;
|
|
1177
|
+
const splineDimension = nurbs.splineDimension;
|
|
1178
|
+
const points = nurbs.points;
|
|
1179
|
+
const degree = nurbs.degree;
|
|
1180
|
+
const weights = nurbs.weights;
|
|
1181
|
+
const hasWeights = weights !== undefined;
|
|
1182
|
+
const knots = nurbs.knots;
|
|
1183
|
+
const spaceDimension = nurbs.dimension;
|
|
1184
|
+
const boundary = nurbs.boundary;
|
|
1172
1185
|
|
|
1173
1186
|
if (derivative !== undefined && derivative !== null) {
|
|
1174
1187
|
if (!Array.isArray(derivative)) {
|
|
1175
1188
|
derivative = [derivative];
|
|
1176
1189
|
}
|
|
1177
|
-
|
|
1178
|
-
for (i = 0; i < splineDimension; i
|
|
1190
|
+
let totalDerivativeOrder = 0;
|
|
1191
|
+
for (let i = 0; i < splineDimension; ++ i) {
|
|
1179
1192
|
if (derivative[i] === undefined) derivative[i] = 0;
|
|
1180
1193
|
totalDerivativeOrder += derivative[i];
|
|
1181
1194
|
}
|
|
@@ -1186,10 +1199,8 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1186
1199
|
|
|
1187
1200
|
if (isBasis) cacheKey = "Basis" + cacheKey;
|
|
1188
1201
|
if (derivative) cacheKey = "Der" + derivative.join("_") + "_" + cacheKey;
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
var logger = typeof debug === "function" ? debug : console.log;
|
|
1192
|
-
}
|
|
1202
|
+
const cachedEvaluator = evaluatorCache[cacheKey];
|
|
1203
|
+
const logger = debug ? (typeof debug === "function" ? debug : console.log) : null;
|
|
1193
1204
|
|
|
1194
1205
|
if (cachedEvaluator) {
|
|
1195
1206
|
if (debug) {
|
|
@@ -1199,17 +1210,17 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1199
1210
|
return cachedEvaluator.bind(nurbs);
|
|
1200
1211
|
}
|
|
1201
1212
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1213
|
+
const code = [];
|
|
1214
|
+
const functionName = "evaluate" + cacheKey;
|
|
1204
1215
|
|
|
1205
|
-
|
|
1216
|
+
let pointAccessor = accessors.point;
|
|
1206
1217
|
if (isBasis) {
|
|
1207
1218
|
pointAccessor = function (src, period) {
|
|
1208
|
-
|
|
1209
|
-
for (
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
for (
|
|
1219
|
+
const terms = [];
|
|
1220
|
+
for (let i = 0; i < src.length; ++ i) {
|
|
1221
|
+
const terms2 = [];
|
|
1222
|
+
let accessor = src[i];
|
|
1223
|
+
for (let j = 0; j < accessor.length; ++ j) {
|
|
1213
1224
|
if (accessor[j] !== 0) terms2.push(accessor[j]);
|
|
1214
1225
|
}
|
|
1215
1226
|
accessor = terms2.join(" + ");
|
|
@@ -1221,20 +1232,20 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1221
1232
|
return "((" + terms.join(" && ") + ") ? 1 : 0)";
|
|
1222
1233
|
};
|
|
1223
1234
|
}
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
for (d = 0; d < splineDimension; d
|
|
1235
|
+
const weightAccessor = accessors.weight;
|
|
1236
|
+
const knotAccessor = accessors.knot;
|
|
1237
|
+
|
|
1238
|
+
const knotVar = variable("k");
|
|
1239
|
+
const pointVar = variable("x");
|
|
1240
|
+
const weightVar = variable("w");
|
|
1241
|
+
const indexVar = variable("i");
|
|
1242
|
+
const tVar = variable("t");
|
|
1243
|
+
const domainVar = debug ? "domain" : "d";
|
|
1244
|
+
const sizeVar = variable(debug ? "size" : "s");
|
|
1245
|
+
const knotIndex = variable(debug ? "knotIndex" : "j");
|
|
1246
|
+
|
|
1247
|
+
let allDimensionUniform = true;
|
|
1248
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1238
1249
|
if (is_array_like(knots) && is_array_like(knots[d])) {
|
|
1239
1250
|
allDimensionUniform = false;
|
|
1240
1251
|
}
|
|
@@ -1251,11 +1262,9 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1251
1262
|
// if (debug) code.push("console.log(\"" + str + " =\", " + str + ");");
|
|
1252
1263
|
// }
|
|
1253
1264
|
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
var parameterArgs = [];
|
|
1258
|
-
for (i = 0; i < splineDimension; i++) {
|
|
1265
|
+
const indexArgs = isBasis ? [] : null;
|
|
1266
|
+
const parameterArgs = [];
|
|
1267
|
+
for (let i = 0; i < splineDimension; ++ i) {
|
|
1259
1268
|
if (isBasis) {
|
|
1260
1269
|
indexArgs.push(indexVar([i]));
|
|
1261
1270
|
}
|
|
@@ -1272,7 +1281,7 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1272
1281
|
|
|
1273
1282
|
if (checkBounds) {
|
|
1274
1283
|
line("var " + domainVar + " = this.domain;");
|
|
1275
|
-
line("for (var i = 0; i < this.splineDimension; i
|
|
1284
|
+
line("for (var i = 0; i < this.splineDimension; ++ i) {");
|
|
1276
1285
|
line(" a = arguments[i + 1];");
|
|
1277
1286
|
line(" if (a < " + domainVar + "[i][0] || a > " + domainVar + "[i][1] || a === undefined || isNaN(a)) {");
|
|
1278
1287
|
line(" throw new Error(\"Invalid Spline parameter in dimension \"+i+\". Valid domain is [\"+" + domainVar + "[i][0]+\", \"+" + domainVar + "[i][1]+\"]. but got t\"+i+\" = \"+arguments[i + 1]+\".\");");
|
|
@@ -1280,7 +1289,7 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1280
1289
|
line("}");
|
|
1281
1290
|
}
|
|
1282
1291
|
|
|
1283
|
-
for (d = 0; d < splineDimension; d
|
|
1292
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1284
1293
|
line("var " + sizeVar(d) + " = " + size_getter(points, "this.points", d) + ";");
|
|
1285
1294
|
}
|
|
1286
1295
|
code.push(accessor_preamble(nurbs, "x", "this.points", points));
|
|
@@ -1297,8 +1306,8 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1297
1306
|
return "(" + cond + ") ? (" + a + ") : (" + b + ")";
|
|
1298
1307
|
}
|
|
1299
1308
|
|
|
1300
|
-
|
|
1301
|
-
for (d = 0; d < splineDimension; d
|
|
1309
|
+
const hasKnots = [];
|
|
1310
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1302
1311
|
switch (infer_type(knots)) {
|
|
1303
1312
|
case infer_type.NDARRAY:
|
|
1304
1313
|
hasKnots[d] = true;
|
|
@@ -1309,7 +1318,7 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1309
1318
|
}
|
|
1310
1319
|
}
|
|
1311
1320
|
|
|
1312
|
-
for (d = 0; d < splineDimension; d
|
|
1321
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1313
1322
|
if (hasKnots[d]) {
|
|
1314
1323
|
//
|
|
1315
1324
|
// LOCATE KNOTS
|
|
@@ -1325,7 +1334,7 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1325
1334
|
|
|
1326
1335
|
debugLine("\n // Fetch knots for dimension " + d + "\n");
|
|
1327
1336
|
|
|
1328
|
-
for (i = -degree[d] + 1; i <= degree[d]; i
|
|
1337
|
+
for (let i = -degree[d] + 1; i <= degree[d]; ++ i) {
|
|
1329
1338
|
if (boundary[d] === "closed") {
|
|
1330
1339
|
if (i < 0) {
|
|
1331
1340
|
// line("var " + knotVar([d, i + degree[d] - 1]) + " = " + knotAccessor([d, [knotIndex(d), i]]) + ";");
|
|
@@ -1364,14 +1373,14 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1364
1373
|
}
|
|
1365
1374
|
|
|
1366
1375
|
debugLine("\n // Compute and clamp knots for dimension " + d + "\n");
|
|
1367
|
-
for (i = -degree[d] + 1; i <= degree[d]; i
|
|
1368
|
-
kvar = knotVar([d, i + degree[d] - 1]);
|
|
1376
|
+
for (let i = -degree[d] + 1; i <= degree[d]; ++ i) {
|
|
1377
|
+
const kvar = knotVar([d, i + degree[d] - 1]);
|
|
1369
1378
|
line("var " + kvar + " = " + knotIndex(d) + " + " + (i) + ";");
|
|
1370
1379
|
}
|
|
1371
1380
|
|
|
1372
1381
|
if (boundary[d] === "clamped") {
|
|
1373
|
-
for (i = -degree[d] + 1; i <= degree[d]; i
|
|
1374
|
-
kvar = knotVar([d, i + degree[d] - 1]);
|
|
1382
|
+
for (let i = -degree[d] + 1; i <= degree[d]; ++ i) {
|
|
1383
|
+
const kvar = knotVar([d, i + degree[d] - 1]);
|
|
1375
1384
|
if (i < 0) {
|
|
1376
1385
|
line("if (" + kvar + " < " + degree[d] + ") " + kvar + " = " + degree[d] + ";");
|
|
1377
1386
|
}
|
|
@@ -1388,16 +1397,18 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1388
1397
|
}
|
|
1389
1398
|
}
|
|
1390
1399
|
|
|
1391
|
-
|
|
1400
|
+
const n = [ ];
|
|
1401
|
+
|
|
1402
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1392
1403
|
n[d] = degree[d] + 1;
|
|
1393
1404
|
}
|
|
1394
1405
|
|
|
1395
1406
|
if (hasWeights) {
|
|
1396
1407
|
debugLine("\n // Fetch weights\n");
|
|
1397
1408
|
ndloop(n, function (dst) {
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
for (
|
|
1409
|
+
const readIdx = [];
|
|
1410
|
+
const period = [];
|
|
1411
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1401
1412
|
readIdx[d] = [knotIndex(d), dst[d] - degree[d]];
|
|
1402
1413
|
if (boundary[d] === "closed" && dst[d] - degree[d] < 0) period[d] = sizeVar(d);
|
|
1403
1414
|
}
|
|
@@ -1414,9 +1425,9 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1414
1425
|
}
|
|
1415
1426
|
|
|
1416
1427
|
ndloop(n, function (dst) {
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
for (
|
|
1428
|
+
const readIdx = [];
|
|
1429
|
+
const period = [];
|
|
1430
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1420
1431
|
readIdx[d] = [knotIndex(d), dst[d] - degree[d]];
|
|
1421
1432
|
if (boundary[d] === "closed" && dst[d] - degree[d] < 0) period[d] = sizeVar(d);
|
|
1422
1433
|
}
|
|
@@ -1427,8 +1438,8 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1427
1438
|
line("var " + pointVar(dst) + " = " + pointAccessor(readIdx, period) + ";");
|
|
1428
1439
|
}
|
|
1429
1440
|
} else {
|
|
1430
|
-
for (d = 0; d < spaceDimension; d
|
|
1431
|
-
|
|
1441
|
+
for (let d = 0; d < spaceDimension; ++ d) {
|
|
1442
|
+
const dstWithDim = dst.concat(d);
|
|
1432
1443
|
readIdx[splineDimension] = d;
|
|
1433
1444
|
if (hasWeights) {
|
|
1434
1445
|
line("var " + pointVar(dstWithDim) + " = " + pointAccessor(readIdx, period) + " * " + weightVar(dst) + ";");
|
|
@@ -1441,12 +1452,12 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1441
1452
|
debugLine("\n");
|
|
1442
1453
|
|
|
1443
1454
|
debugLine("// Perform De Boor\"s algorithm");
|
|
1444
|
-
for (d = n.length - 1; d >= 0; d
|
|
1455
|
+
for (let d = n.length - 1; d >= 0; -- d) {
|
|
1445
1456
|
n[d] = [degree[d], degree[d] + 1];
|
|
1446
|
-
for (i = 0; i < degree[d]; i
|
|
1457
|
+
for (let i = 0; i < degree[d]; ++ i) {
|
|
1447
1458
|
debugLine("\n // Degree " + degree[d] + " evaluation in dimension " + d + ", step " + (i + 1) + "\n");
|
|
1448
|
-
for (j = degree[d]; j > i; j
|
|
1449
|
-
|
|
1459
|
+
for (let j = degree[d]; j > i; -- j) {
|
|
1460
|
+
const isDerivative = derivative && (degree[d] - i - derivative[d] <= 0);
|
|
1450
1461
|
|
|
1451
1462
|
if (isDerivative) {
|
|
1452
1463
|
line("m = 1 / (" + knotVar([d, j - i + degree[d] - 1]) + " - " + knotVar([d, j - 1]) + ");");
|
|
@@ -1461,8 +1472,8 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1461
1472
|
|
|
1462
1473
|
if (hasWeights) {
|
|
1463
1474
|
ndloop(n, function (ii) {
|
|
1464
|
-
|
|
1465
|
-
|
|
1475
|
+
const ij = ii.slice();
|
|
1476
|
+
const ij1 = ii.slice();
|
|
1466
1477
|
ij[d] = j;
|
|
1467
1478
|
ij1[d] = j - 1;
|
|
1468
1479
|
if (isDerivative && hasWeights) line("h = " + weightVar(ij) + ";");
|
|
@@ -1470,24 +1481,24 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1470
1481
|
});
|
|
1471
1482
|
}
|
|
1472
1483
|
ndloop(n, function (ii) {
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1484
|
+
let weightFactor, pt1, pt2;
|
|
1485
|
+
const ij = ii.slice();
|
|
1486
|
+
const ij1 = ii.slice();
|
|
1476
1487
|
// Replace the dimension being interpolated with the interpolation indices
|
|
1477
1488
|
ij[d] = j;
|
|
1478
1489
|
ij1[d] = j - 1;
|
|
1479
1490
|
// Create a version to which we can append the dimension when we loop over spatial dimension
|
|
1480
1491
|
if (isDerivative) {
|
|
1481
|
-
|
|
1492
|
+
const derivCoeff = i + 1;
|
|
1482
1493
|
if (isBasis) {
|
|
1483
1494
|
weightFactor = hasWeights ? "h * " + weightVar(ij1) + " / " + weightVar(ij) + " * " : "";
|
|
1484
1495
|
pt1 = pointVar(ij) + (hasWeights ? " / h" : "");
|
|
1485
1496
|
pt2 = pointVar(ij1) + (hasWeights ? " / " + weightVar(ij1) : "");
|
|
1486
1497
|
line(pointVar(ij) + " = " + derivCoeff + " * " + weightFactor + "(" + pt1 + " - " + pt2 + ") * m;");
|
|
1487
1498
|
} else {
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
for (m = 0; m < spaceDimension; m
|
|
1499
|
+
const ijWithDimension = ij.slice();
|
|
1500
|
+
const ij1WithDimension = ij1.slice();
|
|
1501
|
+
for (let m = 0; m < spaceDimension; ++ m) {
|
|
1491
1502
|
ijWithDimension[splineDimension] = ij1WithDimension[splineDimension] = m;
|
|
1492
1503
|
weightFactor = hasWeights ? "h * " + weightVar(ij1) + " / " + weightVar(ij) + " * " : "";
|
|
1493
1504
|
pt1 = pointVar(ijWithDimension) + (hasWeights ? " / h" : "");
|
|
@@ -1499,7 +1510,7 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1499
1510
|
if (isBasis) {
|
|
1500
1511
|
line(pointVar(ij) + " = b * " + pointVar(ij1) + " + a * " + pointVar(ij) + ";");
|
|
1501
1512
|
} else {
|
|
1502
|
-
for (m = 0; m < spaceDimension; m
|
|
1513
|
+
for (let m = 0; m < spaceDimension; ++ m) {
|
|
1503
1514
|
ij[splineDimension] = ij1[splineDimension] = m;
|
|
1504
1515
|
line(pointVar(ij) + " = b * " + pointVar(ij1) + " + a * " + pointVar(ij) + ";");
|
|
1505
1516
|
}
|
|
@@ -1525,7 +1536,7 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1525
1536
|
line("return " + pointVar(degree) + ";");
|
|
1526
1537
|
}
|
|
1527
1538
|
} else {
|
|
1528
|
-
for (d = 0; d < spaceDimension; d
|
|
1539
|
+
for (let d = 0; d < spaceDimension; ++ d) {
|
|
1529
1540
|
if (hasWeights) {
|
|
1530
1541
|
line("out[" + d + "] = " + pointVar(degree.concat([d])) + " / " + weightVar(degree) + ";");
|
|
1531
1542
|
} else {
|
|
@@ -1539,13 +1550,13 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1539
1550
|
code.push("}");
|
|
1540
1551
|
|
|
1541
1552
|
if (debug) {
|
|
1542
|
-
|
|
1553
|
+
const codeStr = code.join("\n");
|
|
1543
1554
|
logger(codeStr);
|
|
1544
1555
|
|
|
1545
1556
|
codeCache[cacheKey] = codeStr;
|
|
1546
1557
|
}
|
|
1547
1558
|
|
|
1548
|
-
|
|
1559
|
+
const evaluator = new Function([code.join("\n"), "; return ", functionName].join(""))();
|
|
1549
1560
|
evaluatorCache[cacheKey] = evaluator;
|
|
1550
1561
|
return evaluator.bind(nurbs);
|
|
1551
1562
|
};
|
|
@@ -1558,65 +1569,66 @@ const evaluator_default_ = function (cacheKey, nurbs, accessors, debug, checkBou
|
|
|
1558
1569
|
|
|
1559
1570
|
|
|
1560
1571
|
|
|
1561
|
-
|
|
1572
|
+
const transformerCache = {};
|
|
1562
1573
|
|
|
1563
|
-
const transform_default_ = function createTransform (cacheKey, nurbs, accessors, debug)
|
|
1564
|
-
|
|
1565
|
-
|
|
1574
|
+
const transform_default_ = function createTransform (cacheKey, nurbs, accessors, debug)
|
|
1575
|
+
{
|
|
1576
|
+
const cachedTransformer = transformerCache[cacheKey];
|
|
1566
1577
|
if (cachedTransformer) {
|
|
1567
1578
|
return cachedTransformer.bind(nurbs);
|
|
1568
1579
|
}
|
|
1569
1580
|
|
|
1570
|
-
|
|
1571
|
-
|
|
1581
|
+
const code = [];
|
|
1582
|
+
const functionName = "transform" + cacheKey;
|
|
1572
1583
|
|
|
1573
1584
|
code.push("function " + functionName + "(m) {");
|
|
1574
1585
|
code.push("var i, w;");
|
|
1575
1586
|
code.push(accessor_preamble(nurbs, "x", "this.points", nurbs.points));
|
|
1576
1587
|
|
|
1577
|
-
|
|
1578
|
-
for (i = 0; i < nurbs.splineDimension; i
|
|
1588
|
+
const sizeVar = variable(debug ? "size" : "s");
|
|
1589
|
+
for (let i = 0; i < nurbs.splineDimension; ++ i) {
|
|
1579
1590
|
code.push("var " + sizeVar(i) + " = " + size_getter(nurbs.points, "this.points", i) + ";");
|
|
1580
1591
|
}
|
|
1581
1592
|
|
|
1582
|
-
iterators = [];
|
|
1583
|
-
for (i = 0; i < nurbs.splineDimension; i
|
|
1584
|
-
iterator = "i" + i;
|
|
1593
|
+
const iterators = [];
|
|
1594
|
+
for (let i = 0; i < nurbs .splineDimension; ++ i) {
|
|
1595
|
+
const iterator = "i" + i;
|
|
1585
1596
|
iterators.push(iterator);
|
|
1586
|
-
code.push("for (" + iterator + " = " + sizeVar(i) + "- 1; " + iterator + " >= 0; " + iterator + "
|
|
1597
|
+
code.push("for (" + iterator + " = " + sizeVar(i) + "- 1; " + iterator + " >= 0; -- " + iterator + ") {");
|
|
1587
1598
|
}
|
|
1588
1599
|
|
|
1589
|
-
for (i = 0; i < nurbs.dimension; i
|
|
1600
|
+
for (let i = 0; i < nurbs.dimension; ++ i) {
|
|
1590
1601
|
code.push("x" + i + " = " + accessors.point(iterators.concat([i])));
|
|
1591
1602
|
}
|
|
1592
1603
|
|
|
1593
|
-
terms = [];
|
|
1594
|
-
for (i = 0; i < nurbs.dimension; i
|
|
1604
|
+
const terms = [];
|
|
1605
|
+
for (let i = 0; i < nurbs.dimension; ++ i) {
|
|
1595
1606
|
terms.push("m[" + ((nurbs.dimension + 1) * (i + 1) - 1) + "] * x" + i);
|
|
1596
1607
|
}
|
|
1597
1608
|
terms.push("m[" + ((nurbs.dimension + 1) * (nurbs.dimension + 1) - 1) + "]");
|
|
1598
1609
|
code.push("var w = (" + terms.join(" + ") + ") || 1.0;");
|
|
1599
1610
|
|
|
1600
|
-
for (i = 0; i < nurbs.dimension; i
|
|
1601
|
-
terms = [];
|
|
1602
|
-
n = nurbs.dimension;
|
|
1603
|
-
|
|
1611
|
+
for (let i = 0; i < nurbs.dimension; ++ i) {
|
|
1612
|
+
const terms = [];
|
|
1613
|
+
const n = nurbs.dimension;
|
|
1614
|
+
let j = 0;
|
|
1615
|
+
for (; j < n; ++ j) {
|
|
1604
1616
|
terms.push("m[" + (j * (n + 1) + i) + "] * x" + j);
|
|
1605
1617
|
}
|
|
1606
1618
|
terms.push("m[" + (j * (n + 1) + i) + "]");
|
|
1607
|
-
lvalue = accessors.point(iterators.concat([i]));
|
|
1608
|
-
rvalue = "(" + terms.join(" + ") + ") / w";
|
|
1619
|
+
const lvalue = accessors.point(iterators.concat([i]));
|
|
1620
|
+
const rvalue = "(" + terms.join(" + ") + ") / w";
|
|
1609
1621
|
code.push(lvalue + " = " + rvalue + ";");
|
|
1610
1622
|
}
|
|
1611
1623
|
|
|
1612
|
-
for (i = nurbs.splineDimension - 1; i >= 0; i
|
|
1624
|
+
for (let i = nurbs.splineDimension - 1; i >= 0; -- i) {
|
|
1613
1625
|
code.push("}");
|
|
1614
1626
|
}
|
|
1615
1627
|
|
|
1616
1628
|
code.push("return this;");
|
|
1617
1629
|
code.push("}");
|
|
1618
1630
|
|
|
1619
|
-
|
|
1631
|
+
const transform = new Function([code.join("\n"), "; return ", functionName].join(""))();
|
|
1620
1632
|
|
|
1621
1633
|
if (debug) console.log(code.join("\n"));
|
|
1622
1634
|
|
|
@@ -1635,32 +1647,31 @@ const transform_default_ = function createTransform (cacheKey, nurbs, accessors,
|
|
|
1635
1647
|
|
|
1636
1648
|
|
|
1637
1649
|
|
|
1638
|
-
|
|
1650
|
+
const supportCache = {};
|
|
1639
1651
|
|
|
1640
1652
|
const support_default_ = function (cacheKey, nurbs, accessors, debug, checkBounds) {
|
|
1641
|
-
|
|
1653
|
+
const cachedSupport = supportCache[cacheKey];
|
|
1642
1654
|
if (cachedSupport) {
|
|
1643
1655
|
return cachedSupport.bind(nurbs);
|
|
1644
1656
|
}
|
|
1645
1657
|
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1658
|
+
const degree = nurbs.degree;
|
|
1659
|
+
const knots = nurbs.knots;
|
|
1660
|
+
const splineDimension = nurbs.splineDimension;
|
|
1661
|
+
const boundary = nurbs.boundary;
|
|
1650
1662
|
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
var functionName = "support" + cacheKey;
|
|
1663
|
+
const code = [];
|
|
1664
|
+
const functionName = "support" + cacheKey;
|
|
1654
1665
|
|
|
1655
|
-
|
|
1666
|
+
const knotAccessor = accessors.knot;
|
|
1656
1667
|
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1668
|
+
const tVar = variable("t");
|
|
1669
|
+
const domainVar = debug ? "domain" : "d";
|
|
1670
|
+
const sizeVar = variable(debug ? "size" : "s");
|
|
1671
|
+
const knotIndex = variable(debug ? "knotIndex" : "i");
|
|
1661
1672
|
|
|
1662
|
-
|
|
1663
|
-
for (d = 0; d < splineDimension; d
|
|
1673
|
+
let allDimensionUniform = true;
|
|
1674
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1664
1675
|
if (is_array_like(knots) && is_array_like(knots[d])) {
|
|
1665
1676
|
allDimensionUniform = false;
|
|
1666
1677
|
}
|
|
@@ -1671,19 +1682,19 @@ const support_default_ = function (cacheKey, nurbs, accessors, debug, checkBound
|
|
|
1671
1682
|
code.push(" " + (str || ""));
|
|
1672
1683
|
}
|
|
1673
1684
|
|
|
1674
|
-
|
|
1675
|
-
for (i = 0; i < splineDimension; i
|
|
1685
|
+
const parameterArgs = [];
|
|
1686
|
+
for (let i = 0; i < splineDimension; ++ i) {
|
|
1676
1687
|
parameterArgs.push(tVar([i]));
|
|
1677
1688
|
}
|
|
1678
1689
|
|
|
1679
1690
|
code.push("function " + functionName + " (out, " + parameterArgs.join(", ") + ") {");
|
|
1680
1691
|
|
|
1681
|
-
|
|
1692
|
+
let c = 0;
|
|
1682
1693
|
function pushSupport (args, period) {
|
|
1683
1694
|
if (period === undefined) {
|
|
1684
|
-
line("out[" + (c++) + "] = " + args.join(" + ") + ";");
|
|
1695
|
+
line("out[" + (c ++) + "] = " + args.join(" + ") + ";");
|
|
1685
1696
|
} else {
|
|
1686
|
-
line("out[" + (c++) + "] = (" + args.join(" + ") + " + " + period + ") % " + period + ";");
|
|
1697
|
+
line("out[" + (c ++) + "] = (" + args.join(" + ") + " + " + period + ") % " + period + ";");
|
|
1687
1698
|
}
|
|
1688
1699
|
}
|
|
1689
1700
|
|
|
@@ -1692,7 +1703,7 @@ const support_default_ = function (cacheKey, nurbs, accessors, debug, checkBound
|
|
|
1692
1703
|
|
|
1693
1704
|
if (checkBounds) {
|
|
1694
1705
|
line("var " + domainVar + " = this.domain;");
|
|
1695
|
-
line("for (var i = 0; i < this.splineDimension; i
|
|
1706
|
+
line("for (var i = 0; i < this.splineDimension; ++ i) {");
|
|
1696
1707
|
line(" a = arguments[i + 1];");
|
|
1697
1708
|
line(" if (a < " + domainVar + "[i][0] || a > " + domainVar + "[i][1] || a === undefined || isNaN(a)) {");
|
|
1698
1709
|
line(" throw new Error(\"Invalid Spline parameter in dimension \"+i+\". Valid domain is [\"+" + domainVar + "[i][0]+\", \"+" + domainVar + "[i][1]+\"]. but got t\"+i+\" = \"+arguments[i + 1]+\".\");");
|
|
@@ -1700,7 +1711,7 @@ const support_default_ = function (cacheKey, nurbs, accessors, debug, checkBound
|
|
|
1700
1711
|
line("}");
|
|
1701
1712
|
}
|
|
1702
1713
|
|
|
1703
|
-
for (d = 0; d < splineDimension; d
|
|
1714
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1704
1715
|
line("var " + sizeVar(d) + " = " + size_getter(nurbs.points, "this.points", d) + ";");
|
|
1705
1716
|
}
|
|
1706
1717
|
|
|
@@ -1708,8 +1719,8 @@ const support_default_ = function (cacheKey, nurbs, accessors, debug, checkBound
|
|
|
1708
1719
|
code.push(accessor_preamble(nurbs, "k", "this.knots", knots));
|
|
1709
1720
|
}
|
|
1710
1721
|
|
|
1711
|
-
|
|
1712
|
-
for (d = 0; d < splineDimension; d
|
|
1722
|
+
const hasKnots = [];
|
|
1723
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1713
1724
|
switch (infer_type(knots)) {
|
|
1714
1725
|
case infer_type.NDARRAY:
|
|
1715
1726
|
hasKnots[d] = true;
|
|
@@ -1720,7 +1731,7 @@ const support_default_ = function (cacheKey, nurbs, accessors, debug, checkBound
|
|
|
1720
1731
|
}
|
|
1721
1732
|
}
|
|
1722
1733
|
|
|
1723
|
-
for (d = 0; d < splineDimension; d
|
|
1734
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1724
1735
|
if (hasKnots[d]) {
|
|
1725
1736
|
line("var " + knotIndex(d) + " = 0;");
|
|
1726
1737
|
line("h = " + sizeVar(d) + ";");
|
|
@@ -1740,18 +1751,20 @@ const support_default_ = function (cacheKey, nurbs, accessors, debug, checkBound
|
|
|
1740
1751
|
}
|
|
1741
1752
|
}
|
|
1742
1753
|
|
|
1743
|
-
|
|
1754
|
+
const n = [];
|
|
1755
|
+
|
|
1756
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1744
1757
|
n[d] = degree[d] + 1;
|
|
1745
1758
|
}
|
|
1746
1759
|
|
|
1747
1760
|
ndloop(n, function (dst) {
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
for (
|
|
1761
|
+
const readIdx = [];
|
|
1762
|
+
const period = [];
|
|
1763
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1751
1764
|
readIdx[d] = [knotIndex(d), dst[d] - degree[d]];
|
|
1752
1765
|
if (boundary[d] === "closed" && dst[d] - degree[d] < 0) period[d] = sizeVar(d);
|
|
1753
1766
|
}
|
|
1754
|
-
for (d = 0; d < splineDimension; d
|
|
1767
|
+
for (let d = 0; d < splineDimension; ++ d) {
|
|
1755
1768
|
pushSupport(readIdx[d], period[d]);
|
|
1756
1769
|
}
|
|
1757
1770
|
});
|
|
@@ -1763,10 +1776,10 @@ const support_default_ = function (cacheKey, nurbs, accessors, debug, checkBound
|
|
|
1763
1776
|
|
|
1764
1777
|
if (debug) console.log(code.join("\n"));
|
|
1765
1778
|
|
|
1766
|
-
|
|
1779
|
+
const evaluator = new Function([code.join("\n"), "; return ", functionName].join(""))();
|
|
1767
1780
|
supportCache[cacheKey] = evaluator;
|
|
1768
1781
|
return evaluator.bind(nurbs);
|
|
1769
|
-
}
|
|
1782
|
+
}
|
|
1770
1783
|
;
|
|
1771
1784
|
|
|
1772
1785
|
/* harmony default export */ const support = (external_X_ITE_X3D_Namespace_default().add ("support", support_default_));
|
|
@@ -1952,7 +1965,7 @@ function uSeam (u0, nuBound, nvBound, dimension, points, pointIndex, seamIndex)
|
|
|
1952
1965
|
}
|
|
1953
1966
|
}
|
|
1954
1967
|
|
|
1955
|
-
function vSeam (v0, nuBound, nvBound
|
|
1968
|
+
function vSeam (v0, nuBound, _ /* nvBound */, dimension, points, pointIndex, seamIndex)
|
|
1956
1969
|
{
|
|
1957
1970
|
for (let u0 = 0; u0 < nuBound; ++ u0)
|
|
1958
1971
|
{
|
|
@@ -1995,7 +2008,7 @@ const sample_default_ = sample;
|
|
|
1995
2008
|
|
|
1996
2009
|
|
|
1997
2010
|
|
|
1998
|
-
|
|
2011
|
+
const BOUNDARY_TYPES = {
|
|
1999
2012
|
open: "open",
|
|
2000
2013
|
closed: "closed",
|
|
2001
2014
|
clamped: "clamped"
|
|
@@ -2006,8 +2019,6 @@ function isBlank (x) {
|
|
|
2006
2019
|
}
|
|
2007
2020
|
|
|
2008
2021
|
function parseNURBS (points, degree, knots, weights, boundary, opts) {
|
|
2009
|
-
var i, dflt;
|
|
2010
|
-
|
|
2011
2022
|
if (points && !is_array_like(points) && !is_ndarray(points)) {
|
|
2012
2023
|
opts = points;
|
|
2013
2024
|
this.debug = points.debug;
|
|
@@ -2030,9 +2041,9 @@ function parseNURBS (points, degree, knots, weights, boundary, opts) {
|
|
|
2030
2041
|
Object.defineProperty(this, "size", {value: opts.size, writable: true, configurable: true});
|
|
2031
2042
|
}
|
|
2032
2043
|
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2044
|
+
const pointType = infer_type(this.points);
|
|
2045
|
+
const weightType = infer_type(this.weights);
|
|
2046
|
+
const knotType = infer_type(this.knots);
|
|
2036
2047
|
|
|
2037
2048
|
if (this.points) {
|
|
2038
2049
|
//
|
|
@@ -2067,11 +2078,12 @@ function parseNURBS (points, degree, knots, weights, boundary, opts) {
|
|
|
2067
2078
|
case infer_type.ARRAY_OF_OBJECTS:
|
|
2068
2079
|
case infer_type.ARRAY_OF_ARRAYS:
|
|
2069
2080
|
// Follow the zeroth entries until we hit something that"s not an array
|
|
2070
|
-
|
|
2071
|
-
|
|
2081
|
+
const size = this.size || [];
|
|
2082
|
+
let splineDimension = 0;
|
|
2083
|
+
let ptr = this.points;
|
|
2072
2084
|
size.length = 0;
|
|
2073
|
-
for (
|
|
2074
|
-
splineDimension
|
|
2085
|
+
for (; is_array_like(ptr[0]); ptr = ptr[0]) {
|
|
2086
|
+
++ splineDimension;
|
|
2075
2087
|
size.push(ptr.length);
|
|
2076
2088
|
}
|
|
2077
2089
|
if (splineDimension === 0) {
|
|
@@ -2091,9 +2103,9 @@ function parseNURBS (points, degree, knots, weights, boundary, opts) {
|
|
|
2091
2103
|
},
|
|
2092
2104
|
size: {
|
|
2093
2105
|
get: function () {
|
|
2094
|
-
|
|
2106
|
+
const size = [];
|
|
2095
2107
|
size.length = 0;
|
|
2096
|
-
for (
|
|
2108
|
+
for (let i = 0, ptr = this.points; i < this.splineDimension; ++ i, ptr = ptr[0]) {
|
|
2097
2109
|
size[i] = ptr.length;
|
|
2098
2110
|
}
|
|
2099
2111
|
return size;
|
|
@@ -2143,16 +2155,16 @@ function parseNURBS (points, degree, knots, weights, boundary, opts) {
|
|
|
2143
2155
|
// Sanitize the degree into an array
|
|
2144
2156
|
//
|
|
2145
2157
|
if (is_array_like(this.degree)) {
|
|
2146
|
-
for (i = 0; i < this.splineDimension; i
|
|
2158
|
+
for (let i = 0; i < this.splineDimension; ++ i) {
|
|
2147
2159
|
if (isBlank(this.degree[i])) {
|
|
2148
2160
|
throw new Error("Missing degree in dimension " + (i + 1));
|
|
2149
2161
|
}
|
|
2150
2162
|
}
|
|
2151
2163
|
} else {
|
|
2152
|
-
|
|
2153
|
-
|
|
2164
|
+
const hasBaseDegree = !isBlank(this.degree);
|
|
2165
|
+
const baseDegree = isBlank(this.degree) ? 2 : this.degree;
|
|
2154
2166
|
this.degree = [];
|
|
2155
|
-
for (i = 0; i < this.splineDimension; i
|
|
2167
|
+
for (let i = 0; i < this.splineDimension; ++ i) {
|
|
2156
2168
|
if (this.size[i] <= baseDegree) {
|
|
2157
2169
|
if (hasBaseDegree) {
|
|
2158
2170
|
throw new Error("Expected at least " + (baseDegree + 1) + " points for degree " + baseDegree + " spline in dimension " + (i + 1) + " but got only " + this.size[i]);
|
|
@@ -2168,13 +2180,13 @@ function parseNURBS (points, degree, knots, weights, boundary, opts) {
|
|
|
2168
2180
|
//
|
|
2169
2181
|
// Sanitize boundaries
|
|
2170
2182
|
//
|
|
2171
|
-
dflt = (typeof this.boundary !== "string") ? "open" : this.boundary;
|
|
2183
|
+
const dflt = (typeof this.boundary !== "string") ? "open" : this.boundary;
|
|
2172
2184
|
if (!BOUNDARY_TYPES[dflt]) {
|
|
2173
2185
|
throw new Error("Boundary type must be one of " + Object.keys(BOUNDARY_TYPES) + ". Got " + dflt);
|
|
2174
2186
|
}
|
|
2175
2187
|
this.boundary = is_array_like(this.boundary) ? this.boundary : [];
|
|
2176
2188
|
this.boundary.length = this.splineDimension;
|
|
2177
|
-
for (i = 0; i < this.splineDimension; i
|
|
2189
|
+
for (let i = 0; i < this.splineDimension; ++ i) {
|
|
2178
2190
|
this.boundary[i] = isBlank(this.boundary[i]) ? dflt : this.boundary[i];
|
|
2179
2191
|
|
|
2180
2192
|
if (!BOUNDARY_TYPES[dflt]) {
|
|
@@ -2192,7 +2204,7 @@ function parseNURBS (points, degree, knots, weights, boundary, opts) {
|
|
|
2192
2204
|
this.knots = [this.knots];
|
|
2193
2205
|
}
|
|
2194
2206
|
|
|
2195
|
-
for (i = 0; i < this.splineDimension; i
|
|
2207
|
+
for (let i = 0; i < this.splineDimension; ++ i) {
|
|
2196
2208
|
if (this.size[i] <= this.degree[i]) {
|
|
2197
2209
|
throw new Error("Expected at least " + (this.degree[i] + 1) + " points in dimension " + (i + 1) + " but got " + this.size[i] + ".");
|
|
2198
2210
|
}
|
|
@@ -2204,7 +2216,7 @@ function parseNURBS (points, degree, knots, weights, boundary, opts) {
|
|
|
2204
2216
|
// Fudge factor allowance for just ignoring extra knots. This makes some allowance
|
|
2205
2217
|
// for passing regular clamped/open spline knots to a closed spline by ignoring extra
|
|
2206
2218
|
// knots instead of simply truncating.
|
|
2207
|
-
|
|
2219
|
+
const canBeFudged = this.knots[i].length === this.size[i] + this.degree[i] + 1;
|
|
2208
2220
|
if (!canBeFudged) {
|
|
2209
2221
|
throw new Error("Expected " + (this.size[i] + 1) + " knots for closed spline in dimension " + (i + 1) + " but got " + this.knots[i].length + ".");
|
|
2210
2222
|
}
|
|
@@ -2219,12 +2231,12 @@ function parseNURBS (points, degree, knots, weights, boundary, opts) {
|
|
|
2219
2231
|
//
|
|
2220
2232
|
// Create evaluator
|
|
2221
2233
|
//
|
|
2222
|
-
|
|
2234
|
+
const newCacheKey = cache_key(this, this.debug, this.checkBounds, pointType, weightType, knotType);
|
|
2223
2235
|
|
|
2224
2236
|
if (newCacheKey !== this.__cacheKey) {
|
|
2225
2237
|
this.__cacheKey = newCacheKey;
|
|
2226
2238
|
|
|
2227
|
-
|
|
2239
|
+
const accessors = create_accessors(this);
|
|
2228
2240
|
|
|
2229
2241
|
this.evaluate = evaluator(this.__cacheKey, this, accessors, this.debug, this.checkBounds, false);
|
|
2230
2242
|
this.transform = transform(this.__cacheKey, this, accessors, this.debug);
|
|
@@ -2241,8 +2253,8 @@ function parseNURBS (points, degree, knots, weights, boundary, opts) {
|
|
|
2241
2253
|
}
|
|
2242
2254
|
|
|
2243
2255
|
function domainGetter () {
|
|
2244
|
-
|
|
2245
|
-
|
|
2256
|
+
const ret = [];
|
|
2257
|
+
let sizeArray;
|
|
2246
2258
|
|
|
2247
2259
|
// If the reference to size is hard-coded, then the size cannot change, or
|
|
2248
2260
|
// if you change points manually (like by appending a point) without re-running
|
|
@@ -2250,7 +2262,7 @@ function domainGetter () {
|
|
|
2250
2262
|
// by querying the size directly, based on the point data type
|
|
2251
2263
|
//
|
|
2252
2264
|
// A pointer to the point array-of-arrays:
|
|
2253
|
-
|
|
2265
|
+
let ptr = this.points;
|
|
2254
2266
|
|
|
2255
2267
|
if (!ptr) {
|
|
2256
2268
|
// If there are no points, then just use this.size
|
|
@@ -2260,13 +2272,13 @@ function domainGetter () {
|
|
|
2260
2272
|
sizeArray = ptr.shape;
|
|
2261
2273
|
}
|
|
2262
2274
|
|
|
2263
|
-
for (
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2275
|
+
for (let d = 0; d < this.splineDimension; ++ d) {
|
|
2276
|
+
const size = sizeArray ? sizeArray[d] : ptr.length;
|
|
2277
|
+
const p = this.degree[d];
|
|
2278
|
+
const isClosed = this.boundary[d] === "closed";
|
|
2267
2279
|
|
|
2268
2280
|
if (this.knots && this.knots[d]) {
|
|
2269
|
-
|
|
2281
|
+
const k = this.knots[d];
|
|
2270
2282
|
ret[d] = [k[isClosed ? 0 : p], k[size]];
|
|
2271
2283
|
} else {
|
|
2272
2284
|
ret[d] = [isClosed ? 0 : p, size];
|
|
@@ -2287,13 +2299,13 @@ function domainGetter () {
|
|
|
2287
2299
|
// @param opts {object} - additional options
|
|
2288
2300
|
function nurbs (points, degree, knots, weights, boundary, opts)
|
|
2289
2301
|
{
|
|
2290
|
-
|
|
2302
|
+
const ctor = function (points, degree, knots, weights, boundary, opts)
|
|
2291
2303
|
{
|
|
2292
2304
|
parseFcn (points, degree, knots, weights, boundary, opts);
|
|
2293
2305
|
return ctor;
|
|
2294
2306
|
};
|
|
2295
2307
|
|
|
2296
|
-
|
|
2308
|
+
const parseFcn = parseNURBS .bind (ctor);
|
|
2297
2309
|
|
|
2298
2310
|
Object .defineProperty (ctor, "domain",
|
|
2299
2311
|
{
|
|
@@ -2425,9 +2437,7 @@ Object .assign (Object .setPrototypeOf (NurbsCurve .prototype, NURBS_X3DParametr
|
|
|
2425
2437
|
|
|
2426
2438
|
// Knots
|
|
2427
2439
|
|
|
2428
|
-
const
|
|
2429
|
-
knots = this .getKnots (this .knots, closed, this ._order .getValue (), this .controlPointNode .getSize (), this ._knot),
|
|
2430
|
-
scale = knots .at (-1) - knots [0];
|
|
2440
|
+
const knots = this .getKnots (this .knots, closed, this ._order .getValue (), this .controlPointNode .getSize (), this ._knot);
|
|
2431
2441
|
|
|
2432
2442
|
// Initialize NURBS tessellator
|
|
2433
2443
|
|
|
@@ -2552,9 +2562,7 @@ Object .assign (Object .setPrototypeOf (NurbsCurve2D .prototype, NURBS_X3DNurbsC
|
|
|
2552
2562
|
|
|
2553
2563
|
// Knots
|
|
2554
2564
|
|
|
2555
|
-
const
|
|
2556
|
-
knots = this .getKnots (this .knots, closed, this ._order .getValue (), this ._controlPoint .length, this ._knot),
|
|
2557
|
-
scale = knots .at (-1) - knots [0];
|
|
2565
|
+
const knots = this .getKnots (this .knots, closed, this ._order .getValue (), this ._controlPoint .length, this ._knot);
|
|
2558
2566
|
|
|
2559
2567
|
// Initialize NURBS tessellator
|
|
2560
2568
|
|
|
@@ -2653,7 +2661,6 @@ var external_X_ITE_X3D_Algorithm_default = /*#__PURE__*/__webpack_require__.n(ex
|
|
|
2653
2661
|
|
|
2654
2662
|
|
|
2655
2663
|
|
|
2656
|
-
|
|
2657
2664
|
function NurbsOrientationInterpolator (executionContext)
|
|
2658
2665
|
{
|
|
2659
2666
|
external_X_ITE_X3D_X3DChildNode_default().call (this, executionContext);
|
|
@@ -2890,9 +2897,7 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
|
|
|
2890
2897
|
|
|
2891
2898
|
const
|
|
2892
2899
|
uKnots = this .getKnots (this .uKnots, uClosed, this ._uOrder .getValue (), this ._uDimension .getValue (), this ._uKnot),
|
|
2893
|
-
vKnots = this .getKnots (this .vKnots, vClosed, this ._vOrder .getValue (), this ._vDimension .getValue (), this ._vKnot)
|
|
2894
|
-
uScale = uKnots .at (-1) - uKnots [0],
|
|
2895
|
-
vScale = vKnots .at (-1) - vKnots [0];
|
|
2900
|
+
vKnots = this .getKnots (this .vKnots, vClosed, this ._vOrder .getValue (), this ._vDimension .getValue (), this ._vKnot);
|
|
2896
2901
|
|
|
2897
2902
|
// Initialize NURBS tessellator
|
|
2898
2903
|
|
|
@@ -3168,7 +3173,6 @@ const NurbsPatchSurface_default_ = NurbsPatchSurface;
|
|
|
3168
3173
|
|
|
3169
3174
|
|
|
3170
3175
|
|
|
3171
|
-
|
|
3172
3176
|
function NurbsPositionInterpolator (executionContext)
|
|
3173
3177
|
{
|
|
3174
3178
|
external_X_ITE_X3D_X3DChildNode_default().call (this, executionContext);
|
|
@@ -3396,7 +3400,6 @@ const NurbsSet_default_ = NurbsSet;
|
|
|
3396
3400
|
|
|
3397
3401
|
|
|
3398
3402
|
|
|
3399
|
-
|
|
3400
3403
|
function NurbsSurfaceInterpolator (executionContext)
|
|
3401
3404
|
{
|
|
3402
3405
|
external_X_ITE_X3D_X3DChildNode_default().call (this, executionContext);
|
|
@@ -3960,7 +3963,6 @@ var external_X_ITE_X3D_libtess_default = /*#__PURE__*/__webpack_require__.n(exte
|
|
|
3960
3963
|
|
|
3961
3964
|
|
|
3962
3965
|
|
|
3963
|
-
|
|
3964
3966
|
function NurbsTrimmedSurface (executionContext)
|
|
3965
3967
|
{
|
|
3966
3968
|
NURBS_X3DNurbsSurfaceGeometryNode .call (this, executionContext);
|