@srsergio/taptapp-ar 1.0.72 → 1.0.73

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.
@@ -173,8 +173,8 @@ class Controller {
173
173
  }
174
174
  async _trackAndUpdate(inputData, lastModelViewTransform, targetIndex) {
175
175
  const { worldCoords, screenCoords } = this.tracker.track(inputData, lastModelViewTransform, targetIndex);
176
- if (worldCoords.length < 6)
177
- return null;
176
+ if (worldCoords.length < 10)
177
+ return null; // Increased from 6 to 10 for better noise rejection
178
178
  const modelViewTransform = await this._workerTrackUpdate(lastModelViewTransform, {
179
179
  worldCoords,
180
180
  screenCoords,
@@ -94,6 +94,25 @@ class Tracker {
94
94
  });
95
95
  }
96
96
  }
97
+ // 2.1 Spatial distribution check: Avoid getting stuck in corners/noise
98
+ if (screenCoords.length >= 10) {
99
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
100
+ for (const p of screenCoords) {
101
+ if (p.x < minX)
102
+ minX = p.x;
103
+ if (p.y < minY)
104
+ minY = p.y;
105
+ if (p.x > maxX)
106
+ maxX = p.x;
107
+ if (p.y > maxY)
108
+ maxY = p.y;
109
+ }
110
+ const detectedDiagonal = Math.sqrt((maxX - minX) ** 2 + (maxY - minY) ** 2);
111
+ // If the points cover too little space compared to the screen size of the marker, it's a glitch
112
+ if (detectedDiagonal < screenW * 0.15) {
113
+ return { worldCoords: [], screenCoords: [], debugExtra };
114
+ }
115
+ }
97
116
  if (this.debugMode) {
98
117
  debugExtra = {
99
118
  octaveIndex,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srsergio/taptapp-ar",
3
- "version": "1.0.72",
3
+ "version": "1.0.73",
4
4
  "description": "AR Compiler for Node.js and Browser",
5
5
  "repository": {
6
6
  "type": "git",
@@ -233,7 +233,7 @@ class Controller {
233
233
  lastModelViewTransform,
234
234
  targetIndex,
235
235
  );
236
- if (worldCoords.length < 6) return null;
236
+ if (worldCoords.length < 10) return null; // Increased from 6 to 10 for better noise rejection
237
237
  const modelViewTransform = await this._workerTrackUpdate(lastModelViewTransform, {
238
238
  worldCoords,
239
239
  screenCoords,
@@ -136,6 +136,20 @@ class Tracker {
136
136
  }
137
137
  }
138
138
 
139
+ // 2.1 Spatial distribution check: Avoid getting stuck in corners/noise
140
+ if (screenCoords.length >= 10) {
141
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
142
+ for (const p of screenCoords) {
143
+ if (p.x < minX) minX = p.x; if (p.y < minY) minY = p.y;
144
+ if (p.x > maxX) maxX = p.x; if (p.y > maxY) maxY = p.y;
145
+ }
146
+ const detectedDiagonal = Math.sqrt((maxX - minX) ** 2 + (maxY - minY) ** 2);
147
+
148
+ // If the points cover too little space compared to the screen size of the marker, it's a glitch
149
+ if (detectedDiagonal < screenW * 0.15) {
150
+ return { worldCoords: [], screenCoords: [], debugExtra };
151
+ }
152
+ }
139
153
  if (this.debugMode) {
140
154
  debugExtra = {
141
155
  octaveIndex,