@srsergio/taptapp-ar 1.0.2 → 1.0.4

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.
Files changed (99) hide show
  1. package/README.md +47 -45
  2. package/dist/compiler/aframe.js +0 -3
  3. package/dist/compiler/compiler-base.d.ts +3 -7
  4. package/dist/compiler/compiler-base.js +28 -14
  5. package/dist/compiler/compiler.js +1 -1
  6. package/dist/compiler/compiler.worker.js +1 -1
  7. package/dist/compiler/controller.d.ts +4 -4
  8. package/dist/compiler/controller.js +4 -5
  9. package/dist/compiler/controller.worker.js +0 -2
  10. package/dist/compiler/detector/crop-detector.d.ts +12 -12
  11. package/dist/compiler/detector/crop-detector.js +0 -2
  12. package/dist/compiler/detector/detector-lite.d.ts +73 -0
  13. package/dist/compiler/detector/detector-lite.js +430 -0
  14. package/dist/compiler/detector/detector.d.ts +20 -21
  15. package/dist/compiler/detector/detector.js +236 -243
  16. package/dist/compiler/detector/kernels/cpu/binomialFilter.js +0 -1
  17. package/dist/compiler/detector/kernels/cpu/computeExtremaAngles.d.ts +1 -1
  18. package/dist/compiler/detector/kernels/cpu/computeLocalization.js +0 -4
  19. package/dist/compiler/detector/kernels/cpu/computeOrientationHistograms.js +0 -18
  20. package/dist/compiler/detector/kernels/cpu/fakeShader.js +1 -1
  21. package/dist/compiler/detector/kernels/cpu/prune.d.ts +7 -1
  22. package/dist/compiler/detector/kernels/cpu/prune.js +1 -42
  23. package/dist/compiler/detector/kernels/webgl/upsampleBilinear.d.ts +1 -1
  24. package/dist/compiler/detector/kernels/webgl/upsampleBilinear.js +2 -2
  25. package/dist/compiler/estimation/refine-estimate.js +0 -1
  26. package/dist/compiler/estimation/utils.d.ts +1 -1
  27. package/dist/compiler/estimation/utils.js +1 -14
  28. package/dist/compiler/image-list.js +4 -4
  29. package/dist/compiler/input-loader.d.ts +4 -5
  30. package/dist/compiler/input-loader.js +2 -2
  31. package/dist/compiler/matching/hamming-distance.js +13 -13
  32. package/dist/compiler/matching/hierarchical-clustering.js +1 -1
  33. package/dist/compiler/matching/matching.d.ts +20 -4
  34. package/dist/compiler/matching/matching.js +67 -41
  35. package/dist/compiler/matching/ransacHomography.js +1 -2
  36. package/dist/compiler/node-worker.d.ts +1 -0
  37. package/dist/compiler/node-worker.js +84 -0
  38. package/dist/compiler/offline-compiler.d.ts +171 -6
  39. package/dist/compiler/offline-compiler.js +303 -421
  40. package/dist/compiler/tensorflow-setup.d.ts +0 -1
  41. package/dist/compiler/tensorflow-setup.js +27 -1
  42. package/dist/compiler/three.d.ts +7 -12
  43. package/dist/compiler/three.js +3 -5
  44. package/dist/compiler/tracker/extract.d.ts +1 -0
  45. package/dist/compiler/tracker/extract.js +200 -244
  46. package/dist/compiler/tracker/tracker.d.ts +9 -17
  47. package/dist/compiler/tracker/tracker.js +13 -18
  48. package/dist/compiler/utils/cumsum.d.ts +4 -2
  49. package/dist/compiler/utils/cumsum.js +17 -19
  50. package/dist/compiler/utils/gpu-compute.d.ts +57 -0
  51. package/dist/compiler/utils/gpu-compute.js +262 -0
  52. package/dist/compiler/utils/images.d.ts +4 -4
  53. package/dist/compiler/utils/images.js +67 -53
  54. package/dist/compiler/utils/worker-pool.d.ts +13 -0
  55. package/dist/compiler/utils/worker-pool.js +84 -0
  56. package/package.json +12 -14
  57. package/src/compiler/aframe.js +2 -4
  58. package/src/compiler/compiler-base.js +29 -14
  59. package/src/compiler/compiler.js +1 -1
  60. package/src/compiler/compiler.worker.js +1 -1
  61. package/src/compiler/controller.js +4 -5
  62. package/src/compiler/controller.worker.js +0 -2
  63. package/src/compiler/detector/crop-detector.js +0 -2
  64. package/src/compiler/detector/detector-lite.js +494 -0
  65. package/src/compiler/detector/detector.js +1052 -1063
  66. package/src/compiler/detector/kernels/cpu/binomialFilter.js +0 -1
  67. package/src/compiler/detector/kernels/cpu/computeLocalization.js +0 -4
  68. package/src/compiler/detector/kernels/cpu/computeOrientationHistograms.js +0 -17
  69. package/src/compiler/detector/kernels/cpu/fakeShader.js +1 -1
  70. package/src/compiler/detector/kernels/cpu/prune.js +1 -37
  71. package/src/compiler/detector/kernels/webgl/upsampleBilinear.js +2 -2
  72. package/src/compiler/estimation/refine-estimate.js +0 -1
  73. package/src/compiler/estimation/utils.js +9 -24
  74. package/src/compiler/image-list.js +4 -4
  75. package/src/compiler/input-loader.js +2 -2
  76. package/src/compiler/matching/hamming-distance.js +11 -15
  77. package/src/compiler/matching/hierarchical-clustering.js +1 -1
  78. package/src/compiler/matching/matching.js +72 -42
  79. package/src/compiler/matching/ransacHomography.js +0 -2
  80. package/src/compiler/node-worker.js +93 -0
  81. package/src/compiler/offline-compiler.js +339 -504
  82. package/src/compiler/tensorflow-setup.js +29 -1
  83. package/src/compiler/three.js +3 -5
  84. package/src/compiler/tracker/extract.js +211 -267
  85. package/src/compiler/tracker/tracker.js +13 -22
  86. package/src/compiler/utils/cumsum.js +17 -19
  87. package/src/compiler/utils/gpu-compute.js +303 -0
  88. package/src/compiler/utils/images.js +84 -53
  89. package/src/compiler/utils/worker-pool.js +89 -0
  90. package/dist/compiler/estimation/esimate-experiment.d.ts +0 -5
  91. package/dist/compiler/estimation/esimate-experiment.js +0 -267
  92. package/dist/compiler/estimation/refine-estimate-experiment.d.ts +0 -6
  93. package/dist/compiler/estimation/refine-estimate-experiment.js +0 -429
  94. package/dist/react/AREditor.d.ts +0 -5
  95. package/dist/react/AREditor.js +0 -159
  96. package/dist/react/ProgressDialog.d.ts +0 -13
  97. package/dist/react/ProgressDialog.js +0 -57
  98. package/src/compiler/estimation/esimate-experiment.js +0 -316
  99. package/src/compiler/estimation/refine-estimate-experiment.js +0 -512
@@ -1,57 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect } from "react";
3
- import { CheckCircle2, Loader2, Upload, Image as ImageIcon, Video as VideoIcon, } from "lucide-react";
4
- export function ProgressDialog({ open, imageStatus, videoStatus, arProcessingStatus, arUploadStatus, imageProgress = 0, videoProgress = 0, arProcessingProgress = 0, arUploadProgress = 0, }) {
5
- // Configurar las etapas del progreso
6
- const stages = [
7
- {
8
- label: "Subiendo imagen",
9
- status: imageStatus,
10
- progress: imageProgress,
11
- icon: _jsx(ImageIcon, { className: "h-5 w-5" }),
12
- },
13
- {
14
- label: "Subiendo video",
15
- status: videoStatus,
16
- progress: videoProgress,
17
- icon: _jsx(VideoIcon, { className: "h-5 w-5" }),
18
- },
19
- {
20
- label: "Procesando imagen para AR",
21
- status: arProcessingStatus,
22
- progress: arProcessingProgress,
23
- icon: _jsx(Loader2, { className: "h-5 w-5" }),
24
- },
25
- {
26
- label: "Subiendo experiencia AR",
27
- status: arUploadStatus,
28
- progress: arUploadProgress,
29
- icon: _jsx(Upload, { className: "h-5 w-5" }),
30
- },
31
- ];
32
- // Calcular el progreso total (promedio de todos los procesos)
33
- const completedSteps = stages.filter((stage) => stage.status === "completed").length;
34
- const totalProgress = (imageProgress + videoProgress + arProcessingProgress + arUploadProgress) / 4;
35
- const overallProgress = Math.min(Math.max(totalProgress, completedSteps * 25), 100);
36
- // Bloquear el scroll cuando el modal está abierto
37
- useEffect(() => {
38
- if (open) {
39
- document.body.style.overflow = "hidden";
40
- }
41
- else {
42
- document.body.style.overflow = "auto";
43
- }
44
- return () => {
45
- document.body.style.overflow = "auto";
46
- };
47
- }, [open]);
48
- if (!open)
49
- return null;
50
- return (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center overflow-y-auto bg-black bg-opacity-50 p-4", children: _jsxs("div", { className: "relative max-h-full w-full max-w-md overflow-hidden rounded-lg bg-white p-6 shadow-xl", children: [_jsx("div", { className: "mb-4 flex items-center justify-between", children: _jsx("h2", { className: "text-center font-semibold text-xl", children: "Guardando experiencia AR" }) }), _jsx("div", { className: "mt-2", children: _jsx("div", { className: "relative pt-1", children: _jsxs("div", { className: "mb-6", children: [_jsx("div", { className: "h-2 w-full rounded-full bg-gray-200", children: _jsx("div", { className: "h-2 rounded-full bg-blue-600 transition-all duration-500", style: { width: `${overallProgress}%` } }) }), _jsxs("div", { className: "mt-2 text-center text-gray-600 text-sm", children: ["Progreso total: ", Math.round(overallProgress), "%"] })] }) }) }), _jsx("div", { className: "mt-2 space-y-5", children: stages.map((stage, index) => (_jsx("div", { className: "relative", children: _jsxs("div", { className: "flex items-center", children: [_jsx("div", { className: `mr-3 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full ${stage.status === "completed"
51
- ? "bg-green-100"
52
- : stage.status === "processing"
53
- ? "bg-blue-100"
54
- : stage.status === "error"
55
- ? "bg-red-100"
56
- : "bg-gray-100"}`, children: stage.status === "completed" ? (_jsx(CheckCircle2, { className: "h-6 w-6 text-green-600" })) : stage.status === "processing" ? (_jsx("div", { className: "text-blue-600", children: stage.icon })) : stage.status === "error" ? (_jsx("div", { className: "text-red-600", children: stage.icon })) : (_jsx("div", { className: "text-gray-400", children: stage.icon })) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "font-medium text-sm", children: stage.label }), stage.status === "processing" && (_jsxs("div", { className: "mt-1", children: [_jsx("div", { className: "h-1.5 w-full rounded-full bg-gray-200", children: _jsx("div", { className: "h-1.5 rounded-full bg-blue-600 transition-all duration-300", style: { width: `${stage.progress || 0}%` } }) }), _jsxs("div", { className: "mt-1 text-gray-500 text-xs", children: [Math.round(stage.progress || 0), "%"] })] })), stage.status === "completed" && (_jsx("div", { className: "mt-1 text-green-600 text-xs", children: "Completado" })), stage.status === "error" && (_jsx("div", { className: "mt-1 text-red-600 text-xs", children: "Error" })), stage.status === "pending" && (_jsx("div", { className: "mt-1 text-gray-500 text-xs", children: "Pendiente" }))] })] }) }, index))) }), completedSteps === stages.length && (_jsxs("div", { className: "mt-4 rounded-lg bg-green-50 p-4 text-center", children: [_jsx(CheckCircle2, { className: "mx-auto mb-2 h-8 w-8 text-green-500" }), _jsx("p", { className: "font-medium text-green-800", children: "\u00A1Experiencia AR guardada con \u00E9xito!" }), _jsx("p", { className: "text-green-700 text-sm", children: "Tu contenido est\u00E1 listo para ser visualizado." })] }))] }) }));
57
- }
@@ -1,316 +0,0 @@
1
- // try to implement https://hal.inria.fr/inria-00174036/PDF/RR-6303.pdf
2
- import { Matrix, inverse } from "ml-matrix";
3
- import { SVD } from "svd-js";
4
- import { solveHomography } from "../utils/homography";
5
- import { computeScreenCoordiate } from "./utils";
6
-
7
- const opposites_of_minors = (M, row, col) => {
8
- let x1 = col === 0 ? 1 : 0;
9
- let x2 = col === 2 ? 1 : 2;
10
- let y1 = row === 0 ? 1 : 0;
11
- let y2 = row === 2 ? 1 : 2;
12
- return M[y1][x2] * M[y2][x1] - M[y1][x1] * M[y2][x2];
13
- };
14
-
15
- const findRmatFrom_tstar_n = (H, tstar, n, v) => {
16
- // computes R = H( I - (2/v)*te_star*ne_t )
17
- const twoDivV = 2 / v;
18
- const tmp = [
19
- [1 - twoDivV * tstar[0] * n[0], 0 - twoDivV * tstar[0] * n[1], 0 - twoDivV * tstar[0] * n[2]],
20
- [0 - twoDivV * tstar[1] * n[0], 1 - twoDivV * tstar[1] * n[1], 0 - twoDivV * tstar[1] * n[2]],
21
- [0 - twoDivV * tstar[2] * n[0], 0 - twoDivV * tstar[2] * n[1], 1 - twoDivV * tstar[2] * n[2]],
22
- ];
23
-
24
- const R = [
25
- [0, 0, 0],
26
- [0, 0, 0],
27
- [0, 0, 0],
28
- ];
29
- for (let i = 0; i < 3; i++) {
30
- for (let j = 0; j < 3; j++) {
31
- for (let k = 0; k < 3; k++) {
32
- R[i][j] += H[i][k] * tmp[k][j];
33
- }
34
- }
35
- }
36
- //const R = H.mmul( new Matrix(tmp));
37
- return R;
38
- };
39
-
40
- const estimate = ({ screenCoords, worldCoords, projectionTransform }) => {
41
- const Harray = solveHomography(
42
- worldCoords.map((p) => [p.x, p.y]),
43
- screenCoords.map((p) => [p.x, p.y]),
44
- );
45
- const G = new Matrix([
46
- [Harray[0], Harray[1], Harray[2]],
47
- [Harray[3], Harray[4], Harray[5]],
48
- [Harray[6], Harray[7], Harray[8]],
49
- ]);
50
- const K = new Matrix(projectionTransform);
51
- const KInv = inverse(K);
52
- const KInvArr = KInv.to2DArray();
53
- const KArr = K.to2DArray();
54
-
55
- const Hhat = KInv.mmul(G).mmul(K);
56
- const { q } = SVD(Hhat.to2DArray());
57
-
58
- const H = Hhat.div(q[1]);
59
-
60
- const HTH = H.transpose().mmul(H);
61
- const S = Matrix.sub(HTH, Matrix.eye(3, 3)).to2DArray();
62
-
63
- console.log("G", G);
64
- console.log("svd q", q);
65
- console.log("Hhat", Hhat);
66
- console.log("H", H);
67
- console.log("HTH", HTH);
68
- console.log("S", S);
69
-
70
- // M00, M11, M22
71
- const M00 = opposites_of_minors(S, 0, 0);
72
- const M11 = opposites_of_minors(S, 1, 1);
73
- const M22 = opposites_of_minors(S, 2, 2);
74
- const rtM00 = Math.sqrt(M00);
75
- const rtM11 = Math.sqrt(M11);
76
- const rtM22 = Math.sqrt(M22);
77
-
78
- // M01, M12, M02
79
- const M01 = opposites_of_minors(S, 0, 1);
80
- const e01 = M01 >= 0 ? 1 : -1;
81
- const M12 = opposites_of_minors(S, 1, 2);
82
- const e12 = M12 >= 0 ? 1 : -1;
83
- const M02 = opposites_of_minors(S, 0, 2);
84
- const e02 = M02 >= 0 ? 1 : -1;
85
-
86
- let maxIndex = 0;
87
- if (Math.abs(S[1][1]) > Math.abs(S[maxIndex][maxIndex])) maxIndex = 1;
88
- if (Math.abs(S[2][2]) > Math.abs(S[maxIndex][maxIndex])) maxIndex = 2;
89
-
90
- console.log("rtM00", rtM00, rtM11, rtM22);
91
- console.log("M01", M01, M12, M02, e01, e12, e02);
92
-
93
- let npa = [0, 0, 0];
94
- let npb = [0, 0, 0];
95
-
96
- console.log("max index", maxIndex);
97
- if (maxIndex === 0) {
98
- npa[0] = npb[0] = S[0][0];
99
- npa[1] = S[0][1] + rtM22;
100
- npb[1] = S[0][1] - rtM22;
101
- npa[2] = S[0][2] + e12 * rtM11;
102
- npb[2] = S[0][2] - e12 * rtM11;
103
- } else if (maxIndex === 1) {
104
- npa[0] = S[0][1] + rtM22;
105
- npb[0] = S[0][1] - rtM22;
106
- npa[1] = npb[1] = S[1][1];
107
- npa[2] = S[1][2] - e02 * rtM00;
108
- npb[2] = S[1][2] + e02 * rtM00;
109
- } else if (maxIndex === 2) {
110
- npa[0] = S[0][2] + e01 * rtM11;
111
- npb[0] = S[0][2] - e01 * rtM11;
112
- npa[1] = S[1][2] + rtM00;
113
- npb[1] = S[1][2] - rtM00;
114
- npa[2] = npb[2] = S[2][2];
115
- }
116
-
117
- console.log("npa", npa);
118
- console.log("npb", npb);
119
-
120
- const traceS = S[0][0] + S[1][1] + S[2][2];
121
- const v = 2.0 * Math.sqrt(1 + traceS - M00 - M11 - M22);
122
-
123
- const ESii = S[maxIndex][maxIndex] >= 0 ? 1 : -1;
124
-
125
- const r_2 = 2 + traceS + v;
126
- const nt_2 = 2 + traceS - v;
127
-
128
- const r = Math.sqrt(r_2);
129
- const n_t = Math.sqrt(nt_2);
130
-
131
- console.log("r n_t", r, n_t);
132
-
133
- const npaNorm = Math.sqrt(npa[0] * npa[0] + npa[1] * npa[1] + npa[2] * npa[2]);
134
- const npbNorm = Math.sqrt(npb[0] * npb[0] + npb[1] * npb[1] + npb[2] * npb[2]);
135
-
136
- const na = [npa[0] / npaNorm, npa[1] / npaNorm, npa[2] / npaNorm];
137
- const nb = [npb[0] / npbNorm, npb[1] / npbNorm, npb[2] / npbNorm];
138
-
139
- console.log("na nb", na, nb);
140
-
141
- const half_nt = 0.5 * n_t;
142
- const esii_t_r = ESii * r;
143
-
144
- const ta_star = [];
145
- for (let i = 0; i < 3; i++) {
146
- ta_star[i] = half_nt * (esii_t_r * nb[i] - n_t * na[i]);
147
- }
148
- const tb_star = [];
149
- for (let i = 0; i < 3; i++) {
150
- tb_star[i] = half_nt * (esii_t_r * na[i] - n_t * nb[i]);
151
- }
152
-
153
- const HArr = H.to2DArray();
154
- console.log("ta_star", ta_star, tb_star);
155
-
156
- /*
157
- """solutions = []
158
- # Ra, ta
159
- R = findRmatFrom_tstar_n(H, ta_star, na, v)
160
- t = R.dot(ta_star)
161
- solutions.append((R, t, na))
162
- # Ra, -ta
163
- solutions.append((R, -t, -na))
164
- # Rb, tb
165
- R = findRmatFrom_tstar_n(H, tb_star, nb, v)
166
- t = R.dot(tb_star)
167
- solutions.append((R, t, nb))
168
- # Rb, -tb
169
- solutions.append((R, -t, -nb))
170
- */
171
-
172
- const findT = (R1, ta_star) => {
173
- const t = [
174
- R1[0][0] * ta_star[0] + R1[0][1] * ta_star[1] + R1[0][2] * ta_star[2],
175
- R1[1][0] * ta_star[0] + R1[1][1] * ta_star[1] + R1[1][2] * ta_star[2],
176
- R1[2][0] * ta_star[0] + R1[2][1] * ta_star[1] + R1[2][2] * ta_star[2],
177
- ];
178
- return t;
179
- };
180
-
181
- const Ra = findRmatFrom_tstar_n(HArr, ta_star, na, v);
182
- const ta = findT(Ra, ta_star);
183
- const nta = [-ta[0], -ta[1], -ta[2]];
184
-
185
- console.log("RaTRa", new Matrix(Ra).transpose().mmul(new Matrix(Ra)));
186
-
187
- const Rb = findRmatFrom_tstar_n(HArr, tb_star, nb, v);
188
- const tb = findT(Rb, tb_star);
189
- const ntb = [-tb[0], -tb[1], -tb[2]];
190
-
191
- const findModelViewProjectionTransform = (R, t) => {
192
- const transform = [
193
- [R[0][0], R[0][1], R[0][2], t[0]],
194
- [R[1][0], R[1][1], R[1][2], t[1]],
195
- [R[2][0], R[2][1], R[2][2], t[2]],
196
- ];
197
- return transform;
198
-
199
- const modelViewProjectionTransform = [[], [], []];
200
- for (let j = 0; j < 3; j++) {
201
- for (let i = 0; i < 4; i++) {
202
- modelViewProjectionTransform[j][i] =
203
- KArr[j][0] * transform[0][i] +
204
- KArr[j][1] * transform[1][i] +
205
- KArr[j][2] * transform[2][i];
206
- }
207
- }
208
- return modelViewProjectionTransform;
209
- };
210
- console.log("Ra ta", Ra, ta);
211
- console.log("Rb tb", Rb, tb);
212
-
213
- const tnT = new Matrix([
214
- [ta[0] * na[0], ta[0] * na[1], ta[0] * na[2]],
215
- [ta[1] * na[0], ta[1] * na[1], ta[1] * na[2]],
216
- [ta[2] * na[0], ta[2] * na[1], ta[2] * na[2]],
217
- ]);
218
- const RtnT = new Matrix(Ra).add(tnT);
219
- console.log("tnT", tnT);
220
- console.log("RtnT", RtnT);
221
-
222
- const modelViewProjectionTransforms = [];
223
- modelViewProjectionTransforms.push(findModelViewProjectionTransform(Ra, ta));
224
- modelViewProjectionTransforms.push(findModelViewProjectionTransform(Ra, nta));
225
- modelViewProjectionTransforms.push(findModelViewProjectionTransform(Rb, tb));
226
- modelViewProjectionTransforms.push(findModelViewProjectionTransform(Rb, ntb));
227
-
228
- const applyMatrix = (K, pt) => {
229
- let kx = K[0][0] * pt[0] + K[0][1] * pt[1] + K[0][2];
230
- let ky = K[1][0] * pt[0] + K[1][1] * pt[1] + K[1][2];
231
- let kz = K[2][0] * pt[0] + K[2][1] * pt[1] + K[2][2];
232
- kx /= kz;
233
- ky /= kz;
234
- return [kx, ky];
235
- };
236
-
237
- for (let s = 0; s < modelViewProjectionTransforms.length; s++) {
238
- console.log("solution", s);
239
- const modelViewProjectionTransform = modelViewProjectionTransforms[s];
240
- for (let i = 0; i < worldCoords.length; i++) {
241
- let world = applyMatrix(KInvArr, [worldCoords[i].x, worldCoords[i].y]);
242
- let world2 = applyMatrix(RtnT.to2DArray(), world);
243
- let screen = applyMatrix(KInvArr, [screenCoords[i].x, screenCoords[i].y]);
244
-
245
- console.log("map", worldCoords[i], screenCoords[i]);
246
- console.log("mapped", world, world2, screen);
247
-
248
- //const mapped = computeScreenCoordiate(modelViewProjectionTransform, worldCoords[i].x, worldCoords[i].y, 0);
249
- //console.log("mapped", worldCoords[i], screenCoords[i], mapped);
250
- //console.log("mapped", worldCoords[i], screenCoords[i], kx2, ky2, mapped);
251
- }
252
- }
253
-
254
- for (let s = 0; s < modelViewProjectionTransforms.length; s++) {
255
- console.log("mvp solution", s);
256
- const modelViewProjectionTransform = modelViewProjectionTransforms[s];
257
- for (let i = 0; i < worldCoords.length; i++) {
258
- let world = applyMatrix(KInvArr, [worldCoords[i].x, worldCoords[i].y]);
259
- let screen = applyMatrix(KInvArr, [screenCoords[i].x, screenCoords[i].y]);
260
- //const mapped = computeScreenCoordiate(modelViewProjectionTransform, worldCoords[i].x, worldCoords[i].y, 0);
261
- const mapped = computeScreenCoordiate(modelViewProjectionTransform, world[0], world[1], 0);
262
- console.log("mapped", worldCoords[i], screenCoords[i], world, screen, mapped);
263
- }
264
- }
265
-
266
- return null;
267
-
268
- /*
269
-
270
- const R1 = findRmatFrom_tstar_n(HArr, ta_star, na, v);
271
- const R2 = findRmatFrom_tstar_n(HArr, tb_star, nb, v);
272
- console.log("R1", R1);
273
- console.log("R2", R2);
274
-
275
- const t = [
276
- R1[0][0] * ta_star[0] + R1[0][1] * ta_star[1] + R1[0][2] * ta_star[2],
277
- R1[1][0] * ta_star[0] + R1[1][1] * ta_star[1] + R1[1][2] * ta_star[2],
278
- R1[2][0] * ta_star[0] + R1[2][1] * ta_star[1] + R1[2][2] * ta_star[2]
279
- ]
280
-
281
- const R = R2;
282
-
283
- const modelViewProjectionTransform = [
284
- [R[0][0], R[0][1], R[0][2], t[0]],
285
- [R[1][0], R[1][1], R[1][2], t[0]],
286
- [R[2][0], R[2][1], R[2][2], t[0]],
287
- ];
288
- */
289
-
290
- for (let i = 0; i < worldCoords.length; i++) {
291
- const mapped = computeScreenCoordiate(
292
- modelViewProjectionTransform,
293
- worldCoords[i].x,
294
- worldCoords[i].y,
295
- 0,
296
- );
297
- console.log("mapped", worldCoords[i], screenCoords[i], mapped);
298
- }
299
-
300
- // this is the full computation if the projectTransform does not look like the expected format, but more computations
301
- const modelViewTransform = [[], [], []];
302
- for (let j = 0; j < 3; j++) {
303
- for (let i = 0; i < 4; i++) {
304
- modelViewTransform[j][i] =
305
- KInvArr[j][0] * modelViewProjectionTransform[0][i] +
306
- KInvArr[j][1] * modelViewProjectionTransform[1][i] +
307
- KInvArr[j][2] * modelViewProjectionTransform[2][i];
308
- }
309
- }
310
- console.log("KInvArr", KInvArr);
311
- console.log("modelViewProjectionTransform", modelViewProjectionTransform);
312
- console.log("modelViewTransform", modelViewTransform);
313
- return modelViewTransform;
314
- };
315
-
316
- export { estimate };