@srsergio/taptapp-ar 1.0.84 → 1.0.86

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 (140) hide show
  1. package/dist/compiler/node-worker.js +5 -18
  2. package/dist/compiler/offline-compiler.d.ts +0 -48
  3. package/dist/compiler/offline-compiler.js +12 -208
  4. package/dist/{compiler → core}/detector/detector-lite.d.ts +6 -0
  5. package/dist/{compiler → core}/detector/detector-lite.js +9 -9
  6. package/dist/{compiler → core}/matching/matching.js +1 -1
  7. package/dist/core/protocol.d.ts +43 -0
  8. package/dist/core/protocol.js +195 -0
  9. package/dist/{compiler → core}/tracker/tracker.js +3 -2
  10. package/dist/index.d.ts +3 -2
  11. package/dist/index.js +3 -2
  12. package/dist/react/use-ar.js +1 -1
  13. package/dist/{compiler → runtime}/controller.d.ts +10 -6
  14. package/dist/{compiler → runtime}/controller.js +76 -22
  15. package/dist/{compiler → runtime}/controller.worker.js +33 -3
  16. package/dist/runtime/index.d.ts +4 -0
  17. package/dist/runtime/index.js +4 -0
  18. package/dist/{compiler → runtime}/simple-ar.js +1 -1
  19. package/package.json +1 -1
  20. package/src/compiler/node-worker.js +5 -19
  21. package/src/compiler/offline-compiler.ts +12 -241
  22. package/src/{compiler → core}/detector/detector-lite.js +10 -10
  23. package/src/{compiler → core}/matching/matching.js +1 -1
  24. package/src/core/protocol.ts +223 -0
  25. package/src/{compiler → core}/tracker/tracker.js +3 -2
  26. package/src/index.ts +3 -2
  27. package/src/react/use-ar.ts +2 -2
  28. package/src/{compiler → runtime}/controller.ts +85 -24
  29. package/src/{compiler → runtime}/controller.worker.js +45 -3
  30. package/src/runtime/index.ts +4 -0
  31. package/src/{compiler → runtime}/simple-ar.ts +1 -1
  32. package/dist/compiler/utils/fourier-encoder.d.ts +0 -25
  33. package/dist/compiler/utils/fourier-encoder.js +0 -47
  34. package/src/compiler/utils/fourier-encoder.ts +0 -53
  35. /package/dist/compiler/{index.d.ts → offline-compiler-browsertest.d.ts} +0 -0
  36. /package/dist/compiler/{index.js → offline-compiler-browsertest.js} +0 -0
  37. /package/dist/{compiler → core}/detector/crop-detector.d.ts +0 -0
  38. /package/dist/{compiler → core}/detector/crop-detector.js +0 -0
  39. /package/dist/{compiler → core}/detector/freak.d.ts +0 -0
  40. /package/dist/{compiler → core}/detector/freak.js +0 -0
  41. /package/dist/{compiler → core}/estimation/estimate.d.ts +0 -0
  42. /package/dist/{compiler → core}/estimation/estimate.js +0 -0
  43. /package/dist/{compiler → core}/estimation/estimator.d.ts +0 -0
  44. /package/dist/{compiler → core}/estimation/estimator.js +0 -0
  45. /package/dist/{compiler → core}/estimation/refine-estimate.d.ts +0 -0
  46. /package/dist/{compiler → core}/estimation/refine-estimate.js +0 -0
  47. /package/dist/{compiler → core}/estimation/utils.d.ts +0 -0
  48. /package/dist/{compiler → core}/estimation/utils.js +0 -0
  49. /package/dist/{compiler → core}/features/auto-rotation-feature.d.ts +0 -0
  50. /package/dist/{compiler → core}/features/auto-rotation-feature.js +0 -0
  51. /package/dist/{compiler → core}/features/crop-detection-feature.d.ts +0 -0
  52. /package/dist/{compiler → core}/features/crop-detection-feature.js +0 -0
  53. /package/dist/{compiler → core}/features/feature-base.d.ts +0 -0
  54. /package/dist/{compiler → core}/features/feature-base.js +0 -0
  55. /package/dist/{compiler → core}/features/feature-manager.d.ts +0 -0
  56. /package/dist/{compiler → core}/features/feature-manager.js +0 -0
  57. /package/dist/{compiler → core}/features/one-euro-filter-feature.d.ts +0 -0
  58. /package/dist/{compiler → core}/features/one-euro-filter-feature.js +0 -0
  59. /package/dist/{compiler → core}/features/temporal-filter-feature.d.ts +0 -0
  60. /package/dist/{compiler → core}/features/temporal-filter-feature.js +0 -0
  61. /package/dist/{compiler → core}/image-list.d.ts +0 -0
  62. /package/dist/{compiler → core}/image-list.js +0 -0
  63. /package/dist/{compiler → core}/input-loader.d.ts +0 -0
  64. /package/dist/{compiler → core}/input-loader.js +0 -0
  65. /package/dist/{compiler → core}/matching/hamming-distance.d.ts +0 -0
  66. /package/dist/{compiler → core}/matching/hamming-distance.js +0 -0
  67. /package/dist/{compiler → core}/matching/hierarchical-clustering.d.ts +0 -0
  68. /package/dist/{compiler → core}/matching/hierarchical-clustering.js +0 -0
  69. /package/dist/{compiler → core}/matching/hough.d.ts +0 -0
  70. /package/dist/{compiler → core}/matching/hough.js +0 -0
  71. /package/dist/{compiler → core}/matching/matcher.d.ts +0 -0
  72. /package/dist/{compiler → core}/matching/matcher.js +0 -0
  73. /package/dist/{compiler → core}/matching/matching.d.ts +0 -0
  74. /package/dist/{compiler → core}/matching/ransacHomography.d.ts +0 -0
  75. /package/dist/{compiler → core}/matching/ransacHomography.js +0 -0
  76. /package/dist/{compiler → core}/tracker/extract-utils.d.ts +0 -0
  77. /package/dist/{compiler → core}/tracker/extract-utils.js +0 -0
  78. /package/dist/{compiler → core}/tracker/extract.d.ts +0 -0
  79. /package/dist/{compiler → core}/tracker/extract.js +0 -0
  80. /package/dist/{compiler → core}/tracker/tracker.d.ts +0 -0
  81. /package/dist/{compiler → core}/utils/cumsum.d.ts +0 -0
  82. /package/dist/{compiler → core}/utils/cumsum.js +0 -0
  83. /package/dist/{compiler → core}/utils/geometry.d.ts +0 -0
  84. /package/dist/{compiler → core}/utils/geometry.js +0 -0
  85. /package/dist/{compiler → core}/utils/gpu-compute.d.ts +0 -0
  86. /package/dist/{compiler → core}/utils/gpu-compute.js +0 -0
  87. /package/dist/{compiler → core}/utils/homography.d.ts +0 -0
  88. /package/dist/{compiler → core}/utils/homography.js +0 -0
  89. /package/dist/{compiler → core}/utils/images.d.ts +0 -0
  90. /package/dist/{compiler → core}/utils/images.js +0 -0
  91. /package/dist/{compiler → core}/utils/lsh-binarizer.d.ts +0 -0
  92. /package/dist/{compiler → core}/utils/lsh-binarizer.js +0 -0
  93. /package/dist/{compiler → core}/utils/lsh-direct.d.ts +0 -0
  94. /package/dist/{compiler → core}/utils/lsh-direct.js +0 -0
  95. /package/dist/{compiler → core}/utils/projection.d.ts +0 -0
  96. /package/dist/{compiler → core}/utils/projection.js +0 -0
  97. /package/dist/{compiler → core}/utils/randomizer.d.ts +0 -0
  98. /package/dist/{compiler → core}/utils/randomizer.js +0 -0
  99. /package/dist/{compiler → core}/utils/worker-pool.d.ts +0 -0
  100. /package/dist/{compiler → core}/utils/worker-pool.js +0 -0
  101. /package/dist/{compiler → runtime}/aframe.d.ts +0 -0
  102. /package/dist/{compiler → runtime}/aframe.js +0 -0
  103. /package/dist/{compiler → runtime}/controller.worker.d.ts +0 -0
  104. /package/dist/{compiler → runtime}/simple-ar.d.ts +0 -0
  105. /package/dist/{compiler → runtime}/three.d.ts +0 -0
  106. /package/dist/{compiler → runtime}/three.js +0 -0
  107. /package/src/compiler/{index.js → offline-compiler-browsertest.js} +0 -0
  108. /package/src/{compiler → core}/detector/crop-detector.js +0 -0
  109. /package/src/{compiler → core}/detector/freak.js +0 -0
  110. /package/src/{compiler → core}/estimation/estimate.js +0 -0
  111. /package/src/{compiler → core}/estimation/estimator.js +0 -0
  112. /package/src/{compiler → core}/estimation/refine-estimate.js +0 -0
  113. /package/src/{compiler → core}/estimation/utils.js +0 -0
  114. /package/src/{compiler → core}/features/auto-rotation-feature.ts +0 -0
  115. /package/src/{compiler → core}/features/crop-detection-feature.ts +0 -0
  116. /package/src/{compiler → core}/features/feature-base.ts +0 -0
  117. /package/src/{compiler → core}/features/feature-manager.ts +0 -0
  118. /package/src/{compiler → core}/features/one-euro-filter-feature.ts +0 -0
  119. /package/src/{compiler → core}/features/temporal-filter-feature.ts +0 -0
  120. /package/src/{compiler → core}/image-list.js +0 -0
  121. /package/src/{compiler → core}/input-loader.js +0 -0
  122. /package/src/{compiler → core}/matching/hamming-distance.js +0 -0
  123. /package/src/{compiler → core}/matching/hierarchical-clustering.js +0 -0
  124. /package/src/{compiler → core}/matching/hough.js +0 -0
  125. /package/src/{compiler → core}/matching/matcher.js +0 -0
  126. /package/src/{compiler → core}/matching/ransacHomography.js +0 -0
  127. /package/src/{compiler → core}/tracker/extract-utils.js +0 -0
  128. /package/src/{compiler → core}/tracker/extract.js +0 -0
  129. /package/src/{compiler → core}/utils/cumsum.js +0 -0
  130. /package/src/{compiler → core}/utils/geometry.js +0 -0
  131. /package/src/{compiler → core}/utils/gpu-compute.js +0 -0
  132. /package/src/{compiler → core}/utils/homography.js +0 -0
  133. /package/src/{compiler → core}/utils/images.js +0 -0
  134. /package/src/{compiler → core}/utils/lsh-binarizer.js +0 -0
  135. /package/src/{compiler → core}/utils/lsh-direct.js +0 -0
  136. /package/src/{compiler → core}/utils/projection.js +0 -0
  137. /package/src/{compiler → core}/utils/randomizer.js +0 -0
  138. /package/src/{compiler → core}/utils/worker-pool.js +0 -0
  139. /package/src/{compiler → runtime}/aframe.js +0 -0
  140. /package/src/{compiler → runtime}/three.js +0 -0
@@ -1,11 +1,11 @@
1
- import { Tracker } from "./tracker/tracker.js";
2
- import { OfflineCompiler as Compiler } from "./offline-compiler.js";
3
- import { InputLoader } from "./input-loader.js";
4
- import { FeatureManager } from "./features/feature-manager.js";
5
- import { OneEuroFilterFeature } from "./features/one-euro-filter-feature.js";
6
- import { TemporalFilterFeature } from "./features/temporal-filter-feature.js";
7
- import { AutoRotationFeature } from "./features/auto-rotation-feature.js";
8
- import { DetectorLite } from "./detector/detector-lite.js";
1
+ import { Tracker } from "../core/tracker/tracker.js";
2
+ import { InputLoader } from "../core/input-loader.js";
3
+ import { FeatureManager } from "../core/features/feature-manager.js";
4
+ import { OneEuroFilterFeature } from "../core/features/one-euro-filter-feature.js";
5
+ import { TemporalFilterFeature } from "../core/features/temporal-filter-feature.js";
6
+ import { AutoRotationFeature } from "../core/features/auto-rotation-feature.js";
7
+ import { DetectorLite } from "../core/detector/detector-lite.js";
8
+ import * as protocol from "../core/protocol.js";
9
9
 
10
10
  let ControllerWorker: any;
11
11
 
@@ -61,6 +61,7 @@ class Controller {
61
61
  matchingDataList: any;
62
62
  workerMatchDone: ((data: any) => void) | null = null;
63
63
  workerTrackDone: ((data: any) => void) | null = null;
64
+ workerFullTrackDone: ((data: any) => void) | null = null;
64
65
  mainThreadMatcher: any;
65
66
  mainThreadEstimator: any;
66
67
  featureManager: FeatureManager;
@@ -143,6 +144,9 @@ class Controller {
143
144
  if (e.data.type === "matchDone" && this.workerMatchDone !== null) {
144
145
  this.workerMatchDone(e.data);
145
146
  }
147
+ if (e.data.type === "trackDone" && this.workerFullTrackDone !== null) {
148
+ this.workerFullTrackDone(e.data);
149
+ }
146
150
  if (e.data.type === "trackUpdateDone" && this.workerTrackDone !== null) {
147
151
  this.workerTrackDone(e.data);
148
152
  }
@@ -174,9 +178,8 @@ class Controller {
174
178
  const allDimensions: any[] = [];
175
179
 
176
180
  for (const buffer of buffers) {
177
- const compiler = new Compiler();
178
- const result = compiler.importData(buffer);
179
- const dataList = (result as any).dataList || [];
181
+ const result = protocol.decodeTaar(buffer);
182
+ const dataList = result.dataList || [];
180
183
 
181
184
  for (const item of dataList) {
182
185
  allMatchingData.push(item.matchingData);
@@ -194,6 +197,7 @@ class Controller {
194
197
  this.debugMode,
195
198
  );
196
199
 
200
+
197
201
  this._ensureWorker();
198
202
  if (this.worker) {
199
203
  this.worker.postMessage({
@@ -203,6 +207,8 @@ class Controller {
203
207
  projectionTransform: this.projectionTransform,
204
208
  debugMode: this.debugMode,
205
209
  matchingDataList: allMatchingData,
210
+ trackingDataList: allTrackingData,
211
+ markerDimensions: allDimensions
206
212
  });
207
213
  }
208
214
 
@@ -247,21 +253,25 @@ class Controller {
247
253
  }
248
254
 
249
255
  async _detectAndMatch(inputData: any, targetIndexes: number[]) {
250
- const { featurePoints } = this.fullDetector!.detect(inputData);
251
- const { targetIndex: matchedTargetIndex, modelViewTransform } = await this._workerMatch(
252
- featurePoints,
256
+ const { targetIndex, modelViewTransform, screenCoords, worldCoords, featurePoints } = await this._workerMatch(
257
+ null, // No feature points, worker will detect from inputData
253
258
  targetIndexes,
259
+ inputData
254
260
  );
255
- return { targetIndex: matchedTargetIndex, modelViewTransform, featurePoints };
261
+ return { targetIndex, modelViewTransform, screenCoords, worldCoords, featurePoints };
256
262
  }
257
263
 
258
264
  async _trackAndUpdate(inputData: any, lastModelViewTransform: number[][], targetIndex: number) {
259
- const { worldCoords, screenCoords, reliabilities, indices = [], octaveIndex = 0 } = this.tracker!.track(
265
+ const { worldCoords, screenCoords, reliabilities, indices = [], octaveIndex = 0 } = await this._workerTrack(
260
266
  inputData,
261
267
  lastModelViewTransform,
262
268
  targetIndex,
263
269
  );
264
270
 
271
+ if (!worldCoords || worldCoords.length === 0) {
272
+ return { modelViewTransform: null, screenCoords: [], reliabilities: [], stabilities: [] };
273
+ }
274
+
265
275
  const state = this.trackingStates[targetIndex];
266
276
  if (!state.pointStabilities) state.pointStabilities = [];
267
277
  if (!state.lastScreenCoords) state.lastScreenCoords = [];
@@ -296,7 +306,11 @@ class Controller {
296
306
  for (let i = 0; i < stabilities.length; i++) {
297
307
  if (stabilities[i] > 0) {
298
308
  const isCurrentlyTracked = indices.includes(i);
299
- finalScreenCoords.push(lastCoords[i]);
309
+ finalScreenCoords.push({
310
+ x: lastCoords[i].x,
311
+ y: lastCoords[i].y,
312
+ id: i // Unique index from tracker
313
+ });
300
314
  finalStabilities.push(stabilities[i]);
301
315
 
302
316
  if (isCurrentlyTracked) {
@@ -373,13 +387,17 @@ class Controller {
373
387
  matchingIndexes.push(i);
374
388
  }
375
389
 
376
- const { targetIndex: matchedTargetIndex, modelViewTransform } =
390
+ const { targetIndex: matchedTargetIndex, modelViewTransform, featurePoints } =
377
391
  await this._detectAndMatch(inputData, matchingIndexes);
378
392
 
379
393
  if (matchedTargetIndex !== -1) {
380
394
  this.trackingStates[matchedTargetIndex].isTracking = true;
381
395
  this.trackingStates[matchedTargetIndex].currentModelViewTransform = modelViewTransform;
382
396
  }
397
+
398
+ // If we have feature points, we can store them in a special "lastSeenFeatures"
399
+ // or just pass them in processDone for general visualization
400
+ this.onUpdate && this.onUpdate({ type: "featurePoints", featurePoints });
383
401
  }
384
402
 
385
403
  for (let i = 0; i < this.trackingStates.length; i++) {
@@ -491,10 +509,20 @@ class Controller {
491
509
  return this._workerTrackUpdate(modelViewTransform, trackFeatures);
492
510
  }
493
511
 
494
- _workerMatch(featurePoints: any, targetIndexes: number[]): Promise<any> {
512
+ _workerMatch(featurePoints: any, targetIndexes: number[], inputData: any = null): Promise<any> {
495
513
  return new Promise((resolve) => {
496
514
  if (!this.worker) {
497
- this._matchOnMainThread(featurePoints, targetIndexes).then(resolve).catch(() => resolve({ targetIndex: -1 }));
515
+ // If no feature points but we have input data, detect first
516
+ let fpPromise;
517
+ if (!featurePoints && inputData) {
518
+ fpPromise = Promise.resolve(this.fullDetector!.detect(inputData).featurePoints);
519
+ } else {
520
+ fpPromise = Promise.resolve(featurePoints);
521
+ }
522
+
523
+ fpPromise.then(fp => {
524
+ this._matchOnMainThread(fp, targetIndexes).then(resolve);
525
+ }).catch(() => resolve({ targetIndex: -1 }));
498
526
  return;
499
527
  }
500
528
 
@@ -511,17 +539,50 @@ class Controller {
511
539
  modelViewTransform: data.modelViewTransform,
512
540
  screenCoords: data.screenCoords,
513
541
  worldCoords: data.worldCoords,
542
+ featurePoints: data.featurePoints,
514
543
  debugExtra: data.debugExtra,
515
544
  });
516
545
  };
517
- this.worker.postMessage({ type: "match", featurePoints: featurePoints, targetIndexes });
546
+
547
+ if (inputData) {
548
+ this.worker.postMessage({ type: "match", inputData, targetIndexes });
549
+ } else {
550
+ this.worker.postMessage({ type: "match", featurePoints: featurePoints, targetIndexes });
551
+ }
552
+ });
553
+ }
554
+
555
+ _workerTrack(inputData: any, lastModelViewTransform: number[][], targetIndex: number): Promise<any> {
556
+ return new Promise((resolve) => {
557
+ if (!this.worker) {
558
+ resolve(this.tracker!.track(inputData, lastModelViewTransform, targetIndex));
559
+ return;
560
+ }
561
+
562
+ const timeout = setTimeout(() => {
563
+ this.workerFullTrackDone = null;
564
+ resolve({ worldCoords: [], screenCoords: [], reliabilities: [] });
565
+ }, WORKER_TIMEOUT_MS);
566
+
567
+ this.workerFullTrackDone = (data: any) => {
568
+ clearTimeout(timeout);
569
+ this.workerFullTrackDone = null;
570
+ resolve(data);
571
+ };
572
+
573
+ this.worker.postMessage({
574
+ type: "track",
575
+ inputData,
576
+ lastModelViewTransform,
577
+ targetIndex
578
+ });
518
579
  });
519
580
  }
520
581
 
521
582
  async _matchOnMainThread(featurePoints: any, targetIndexes: number[]) {
522
583
  if (!this.mainThreadMatcher) {
523
- const { Matcher } = await import("./matching/matcher.js");
524
- const { Estimator } = await import("./estimation/estimator.js");
584
+ const { Matcher } = await import("../core/matching/matcher.js");
585
+ const { Estimator } = await import("../core/estimation/estimator.js");
525
586
  this.mainThreadMatcher = new Matcher(this.inputWidth, this.inputHeight, this.debugMode);
526
587
  this.mainThreadEstimator = new Estimator(this.projectionTransform);
527
588
  }
@@ -591,7 +652,7 @@ class Controller {
591
652
 
592
653
  async _trackUpdateOnMainThread(modelViewTransform: number[][], trackingFeatures: any) {
593
654
  if (!this.mainThreadEstimator) {
594
- const { Estimator } = await import("./estimation/estimator.js");
655
+ const { Estimator } = await import("../core/estimation/estimator.js");
595
656
  this.mainThreadEstimator = new Estimator(this.projectionTransform);
596
657
  }
597
658
 
@@ -1,10 +1,14 @@
1
- import { Matcher } from "./matching/matcher.js";
2
- import { Estimator } from "./estimation/estimator.js";
1
+ import { Matcher } from "../core/matching/matcher.js";
2
+ import { Estimator } from "../core/estimation/estimator.js";
3
+ import { Tracker } from "../core/tracker/tracker.js";
4
+ import { DetectorLite } from "../core/detector/detector-lite.js";
3
5
 
4
6
  let matchingDataList = null;
5
7
  let debugMode = false;
6
8
  let matcher = null;
7
9
  let estimator = null;
10
+ let tracker = null;
11
+ let detector = null;
8
12
 
9
13
  onmessage = (msg) => {
10
14
  const { data } = msg;
@@ -15,6 +19,19 @@ onmessage = (msg) => {
15
19
  debugMode = data.debugMode;
16
20
  matcher = new Matcher(data.inputWidth, data.inputHeight, debugMode);
17
21
  estimator = new Estimator(data.projectionTransform);
22
+
23
+ if (data.trackingDataList && data.markerDimensions) {
24
+ tracker = new Tracker(
25
+ data.markerDimensions,
26
+ data.trackingDataList,
27
+ data.projectionTransform,
28
+ data.inputWidth,
29
+ data.inputHeight,
30
+ debugMode
31
+ );
32
+ }
33
+
34
+ detector = new DetectorLite(data.inputWidth, data.inputHeight, { useLSH: true });
18
35
  break;
19
36
 
20
37
  case "match":
@@ -22,14 +39,23 @@ onmessage = (msg) => {
22
39
 
23
40
  let matchedTargetIndex = -1;
24
41
  let matchedModelViewTransform = null;
42
+ let matchedScreenCoords = null;
43
+ let matchedWorldCoords = null;
25
44
  let matchedDebugExtra = null;
26
45
 
46
+ // New: If the worker received image data, run detector here too
47
+ let featurePoints = data.featurePoints;
48
+ if (data.inputData) {
49
+ const detectionResult = detector.detect(data.inputData);
50
+ featurePoints = detectionResult.featurePoints;
51
+ }
52
+
27
53
  for (let i = 0; i < interestedTargetIndexes.length; i++) {
28
54
  const matchingIndex = interestedTargetIndexes[i];
29
55
 
30
56
  const { keyframeIndex, screenCoords, worldCoords, debugExtra } = matcher.matchDetection(
31
57
  matchingDataList[matchingIndex],
32
- data.featurePoints,
58
+ featurePoints,
33
59
  );
34
60
  matchedDebugExtra = debugExtra;
35
61
 
@@ -39,6 +65,8 @@ onmessage = (msg) => {
39
65
  if (modelViewTransform) {
40
66
  matchedTargetIndex = matchingIndex;
41
67
  matchedModelViewTransform = modelViewTransform;
68
+ matchedScreenCoords = screenCoords;
69
+ matchedWorldCoords = worldCoords;
42
70
  }
43
71
  break;
44
72
  }
@@ -48,10 +76,24 @@ onmessage = (msg) => {
48
76
  type: "matchDone",
49
77
  targetIndex: matchedTargetIndex,
50
78
  modelViewTransform: matchedModelViewTransform,
79
+ screenCoords: matchedScreenCoords,
80
+ worldCoords: matchedWorldCoords,
81
+ featurePoints: featurePoints,
51
82
  debugExtra: matchedDebugExtra,
52
83
  });
53
84
  break;
54
85
 
86
+ case "track":
87
+ const { inputData: trackInput, lastModelViewTransform, targetIndex } = data;
88
+ const trackResult = tracker.track(trackInput, lastModelViewTransform, targetIndex);
89
+
90
+ postMessage({
91
+ type: "trackDone",
92
+ targetIndex,
93
+ ...trackResult
94
+ });
95
+ break;
96
+
55
97
  case "trackUpdate":
56
98
  const { modelViewTransform, worldCoords, screenCoords, stabilities } = data;
57
99
  const finalModelViewTransform = estimator.refineEstimate({
@@ -0,0 +1,4 @@
1
+ export * from "./controller.js";
2
+ export * from "./simple-ar.js";
3
+ export * from "./three.js";
4
+ export * from "./aframe.js";
@@ -1,6 +1,6 @@
1
1
  import { Controller } from "./controller.js";
2
2
  import { OneEuroFilter } from "../libs/one-euro-filter.js";
3
- import { projectToScreen } from "./utils/projection.js";
3
+ import { projectToScreen } from "../core/utils/projection.js";
4
4
 
5
5
  /**
6
6
  * 🍦 SimpleAR - Dead-simple vanilla AR for image overlays
@@ -1,25 +0,0 @@
1
- /**
2
- * 🚀 Moonshot: Fourier Positional Encoding
3
- *
4
- * Maps 2D coordinates (x, y) to a high-dimensional frequency space.
5
- * Used in Transformer Positional Encoding, NeRFs, and modern Generative AI.
6
- *
7
- * Theory: gamma(p) = [sin(2^0 * pi * p), cos(2^0 * pi * p), ..., sin(2^L-1 * pi * p), cos(2^L-1 * pi * p)]
8
- */
9
- export declare class FourierEncoder {
10
- private frequencies;
11
- private L;
12
- constructor(L?: number);
13
- /**
14
- * Encodes a normalized coordinate (0-1) into Fourier features
15
- * @param x Normalized X
16
- * @param y Normalized Y
17
- * @returns Float32Array of size 4 * L
18
- */
19
- encode(x: number, y: number): Float32Array;
20
- /**
21
- * Fast dot product between two fourier encodings
22
- * This measures "harmonic spatial similarity"
23
- */
24
- static similarity(v1: Float32Array, v2: Float32Array): number;
25
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * 🚀 Moonshot: Fourier Positional Encoding
3
- *
4
- * Maps 2D coordinates (x, y) to a high-dimensional frequency space.
5
- * Used in Transformer Positional Encoding, NeRFs, and modern Generative AI.
6
- *
7
- * Theory: gamma(p) = [sin(2^0 * pi * p), cos(2^0 * pi * p), ..., sin(2^L-1 * pi * p), cos(2^L-1 * pi * p)]
8
- */
9
- export class FourierEncoder {
10
- frequencies;
11
- L;
12
- constructor(L = 4) {
13
- this.L = L;
14
- this.frequencies = [];
15
- for (let i = 0; i < L; i++) {
16
- this.frequencies.push(Math.pow(2, i) * Math.PI);
17
- }
18
- }
19
- /**
20
- * Encodes a normalized coordinate (0-1) into Fourier features
21
- * @param x Normalized X
22
- * @param y Normalized Y
23
- * @returns Float32Array of size 4 * L
24
- */
25
- encode(x, y) {
26
- const result = new Float32Array(this.L * 4);
27
- let idx = 0;
28
- for (const freq of this.frequencies) {
29
- result[idx++] = Math.sin(freq * x);
30
- result[idx++] = Math.cos(freq * x);
31
- result[idx++] = Math.sin(freq * y);
32
- result[idx++] = Math.cos(freq * y);
33
- }
34
- return result;
35
- }
36
- /**
37
- * Fast dot product between two fourier encodings
38
- * This measures "harmonic spatial similarity"
39
- */
40
- static similarity(v1, v2) {
41
- let dot = 0;
42
- for (let i = 0; i < v1.length; i++) {
43
- dot += v1[i] * v2[i];
44
- }
45
- return dot / (v1.length / 2); // Normalize by number of components
46
- }
47
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * 🚀 Moonshot: Fourier Positional Encoding
3
- *
4
- * Maps 2D coordinates (x, y) to a high-dimensional frequency space.
5
- * Used in Transformer Positional Encoding, NeRFs, and modern Generative AI.
6
- *
7
- * Theory: gamma(p) = [sin(2^0 * pi * p), cos(2^0 * pi * p), ..., sin(2^L-1 * pi * p), cos(2^L-1 * pi * p)]
8
- */
9
-
10
- export class FourierEncoder {
11
- private frequencies: number[];
12
- private L: number;
13
-
14
- constructor(L: number = 4) {
15
- this.L = L;
16
- this.frequencies = [];
17
- for (let i = 0; i < L; i++) {
18
- this.frequencies.push(Math.pow(2, i) * Math.PI);
19
- }
20
- }
21
-
22
- /**
23
- * Encodes a normalized coordinate (0-1) into Fourier features
24
- * @param x Normalized X
25
- * @param y Normalized Y
26
- * @returns Float32Array of size 4 * L
27
- */
28
- encode(x: number, y: number): Float32Array {
29
- const result = new Float32Array(this.L * 4);
30
- let idx = 0;
31
-
32
- for (const freq of this.frequencies) {
33
- result[idx++] = Math.sin(freq * x);
34
- result[idx++] = Math.cos(freq * x);
35
- result[idx++] = Math.sin(freq * y);
36
- result[idx++] = Math.cos(freq * y);
37
- }
38
-
39
- return result;
40
- }
41
-
42
- /**
43
- * Fast dot product between two fourier encodings
44
- * This measures "harmonic spatial similarity"
45
- */
46
- static similarity(v1: Float32Array, v2: Float32Array): number {
47
- let dot = 0;
48
- for (let i = 0; i < v1.length; i++) {
49
- dot += v1[i] * v2[i];
50
- }
51
- return dot / (v1.length / 2); // Normalize by number of components
52
- }
53
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes