@srsergio/taptapp-ar 1.0.75 → 1.0.76

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.
@@ -20,8 +20,8 @@ const getControllerWorker = async () => {
20
20
  ControllerWorker = await getControllerWorker();
21
21
  const DEFAULT_FILTER_CUTOFF = 0.5;
22
22
  const DEFAULT_FILTER_BETA = 0.1;
23
- const DEFAULT_WARMUP_TOLERANCE = 8;
24
- const DEFAULT_MISS_TOLERANCE = 2;
23
+ const DEFAULT_WARMUP_TOLERANCE = 2; // Instant detection
24
+ const DEFAULT_MISS_TOLERANCE = 5; // More grace when partially hidden
25
25
  class Controller {
26
26
  inputWidth;
27
27
  inputHeight;
@@ -22,9 +22,6 @@ export class CropDetector {
22
22
  projectedImage?: undefined;
23
23
  };
24
24
  };
25
- /**
26
- * Scans the ENTIRE frame by downsampling it to cropSize
27
- */
28
25
  _detectGlobal(imageData: any): {
29
26
  featurePoints: any[];
30
27
  debugExtra: {
@@ -24,16 +24,16 @@ class CropDetector {
24
24
  }
25
25
  detectMoving(input) {
26
26
  const imageData = input;
27
- // 🚀 MOONSHOT: Alternate between local crops and GLOBAL scan
28
- // This solves the "not reading the whole screen" issue.
29
- // Every 3 frames, we do a full screen downsampled scan.
30
- if (this.lastRandomIndex % 3 === 0) {
27
+ // 🚀 MOONSHOT: High Frequency Global Scan
28
+ // Scan full screen every 2 frames when searching to guarantee instant recovery
29
+ if (this.lastRandomIndex % 2 === 0) {
31
30
  this.lastRandomIndex = (this.lastRandomIndex + 1) % 25;
32
31
  return this._detectGlobal(imageData);
33
32
  }
34
- // Original moving crop logic for high-detail local detection
33
+ // Local crops (25 grid)
35
34
  const gridSize = 5;
36
35
  const idx = (this.lastRandomIndex - 1) % (gridSize * gridSize);
36
+ // ... rest of logic remains but we hit it less often because global scan is more successful
37
37
  const dx = idx % gridSize;
38
38
  const dy = Math.floor(idx / gridSize);
39
39
  const stepX = this.cropSize / 3;
@@ -45,19 +45,18 @@ class CropDetector {
45
45
  this.lastRandomIndex = (this.lastRandomIndex + 1) % 25;
46
46
  return this._detect(imageData, startX, startY);
47
47
  }
48
- /**
49
- * Scans the ENTIRE frame by downsampling it to cropSize
50
- */
51
48
  _detectGlobal(imageData) {
52
49
  const croppedData = new Float32Array(this.cropSize * this.cropSize);
53
50
  const scaleX = this.width / this.cropSize;
54
51
  const scaleY = this.height / this.cropSize;
55
- // Fast downsample (nearest neighbor is enough for initial feature detection)
52
+ // Better sampling: avoid missing edges by jumping too much
56
53
  for (let y = 0; y < this.cropSize; y++) {
57
54
  const srcY = Math.floor(y * scaleY) * this.width;
58
55
  const dstY = y * this.cropSize;
59
56
  for (let x = 0; x < this.cropSize; x++) {
60
- croppedData[dstY + x] = imageData[srcY + Math.floor(x * scaleX)];
57
+ // Average slightly to preserve gradients
58
+ const sx = Math.floor(x * scaleX);
59
+ croppedData[dstY + x] = (imageData[srcY + sx] + imageData[srcY + sx + 1]) * 0.5;
61
60
  }
62
61
  }
63
62
  const { featurePoints } = this.detector.detect(croppedData);
@@ -92,9 +92,6 @@ export const TaptappAR = ({ config, className = "", showScanningOverlay = true,
92
92
  display: block;
93
93
  width: 100%;
94
94
  height: auto;
95
- will-change: transform;
96
- /* Visual interpolation to smooth out frame gaps */
97
- transition: transform 0.1s linear, opacity 0.3s ease;
98
95
  }
99
96
  ` })] }));
100
97
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srsergio/taptapp-ar",
3
- "version": "1.0.75",
3
+ "version": "1.0.76",
4
4
  "description": "AR Compiler for Node.js and Browser",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@ ControllerWorker = await getControllerWorker();
21
21
 
22
22
  const DEFAULT_FILTER_CUTOFF = 0.5;
23
23
  const DEFAULT_FILTER_BETA = 0.1;
24
- const DEFAULT_WARMUP_TOLERANCE = 8;
25
- const DEFAULT_MISS_TOLERANCE = 2;
24
+ const DEFAULT_WARMUP_TOLERANCE = 2; // Instant detection
25
+ const DEFAULT_MISS_TOLERANCE = 5; // More grace when partially hidden
26
26
 
27
27
  export interface ControllerOptions {
28
28
  inputWidth: number;
@@ -33,20 +33,19 @@ class CropDetector {
33
33
  detectMoving(input) {
34
34
  const imageData = input;
35
35
 
36
- // 🚀 MOONSHOT: Alternate between local crops and GLOBAL scan
37
- // This solves the "not reading the whole screen" issue.
38
- // Every 3 frames, we do a full screen downsampled scan.
39
- if (this.lastRandomIndex % 3 === 0) {
36
+ // 🚀 MOONSHOT: High Frequency Global Scan
37
+ // Scan full screen every 2 frames when searching to guarantee instant recovery
38
+ if (this.lastRandomIndex % 2 === 0) {
40
39
  this.lastRandomIndex = (this.lastRandomIndex + 1) % 25;
41
40
  return this._detectGlobal(imageData);
42
41
  }
43
42
 
44
- // Original moving crop logic for high-detail local detection
43
+ // Local crops (25 grid)
45
44
  const gridSize = 5;
46
45
  const idx = (this.lastRandomIndex - 1) % (gridSize * gridSize);
46
+ // ... rest of logic remains but we hit it less often because global scan is more successful
47
47
  const dx = idx % gridSize;
48
48
  const dy = Math.floor(idx / gridSize);
49
-
50
49
  const stepX = this.cropSize / 3;
51
50
  const stepY = this.cropSize / 3;
52
51
 
@@ -57,29 +56,26 @@ class CropDetector {
57
56
  startY = Math.max(0, Math.min(this.height - this.cropSize - 1, startY));
58
57
 
59
58
  this.lastRandomIndex = (this.lastRandomIndex + 1) % 25;
60
-
61
59
  return this._detect(imageData, startX, startY);
62
60
  }
63
61
 
64
- /**
65
- * Scans the ENTIRE frame by downsampling it to cropSize
66
- */
67
62
  _detectGlobal(imageData) {
68
63
  const croppedData = new Float32Array(this.cropSize * this.cropSize);
69
64
  const scaleX = this.width / this.cropSize;
70
65
  const scaleY = this.height / this.cropSize;
71
66
 
72
- // Fast downsample (nearest neighbor is enough for initial feature detection)
67
+ // Better sampling: avoid missing edges by jumping too much
73
68
  for (let y = 0; y < this.cropSize; y++) {
74
69
  const srcY = Math.floor(y * scaleY) * this.width;
75
70
  const dstY = y * this.cropSize;
76
71
  for (let x = 0; x < this.cropSize; x++) {
77
- croppedData[dstY + x] = imageData[srcY + Math.floor(x * scaleX)];
72
+ // Average slightly to preserve gradients
73
+ const sx = Math.floor(x * scaleX);
74
+ croppedData[dstY + x] = (imageData[srcY + sx] + imageData[srcY + sx + 1]) * 0.5;
78
75
  }
79
76
  }
80
77
 
81
78
  const { featurePoints } = this.detector.detect(croppedData);
82
-
83
79
  featurePoints.forEach((p) => {
84
80
  p.x *= scaleX;
85
81
  p.y *= scaleY;
@@ -169,9 +169,6 @@ export const TaptappAR: React.FC<TaptappARProps> = ({
169
169
  display: block;
170
170
  width: 100%;
171
171
  height: auto;
172
- will-change: transform;
173
- /* Visual interpolation to smooth out frame gaps */
174
- transition: transform 0.1s linear, opacity 0.3s ease;
175
172
  }
176
173
  `}</style>
177
174
  </div>