@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.
- package/dist/compiler/controller.js +2 -2
- package/dist/compiler/detector/crop-detector.d.ts +0 -3
- package/dist/compiler/detector/crop-detector.js +9 -10
- package/dist/react/TaptappAR.js +0 -3
- package/package.json +1 -1
- package/src/compiler/controller.ts +2 -2
- package/src/compiler/detector/crop-detector.js +9 -13
- package/src/react/TaptappAR.tsx +0 -3
|
@@ -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 =
|
|
24
|
-
const DEFAULT_MISS_TOLERANCE =
|
|
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;
|
|
@@ -24,16 +24,16 @@ class CropDetector {
|
|
|
24
24
|
}
|
|
25
25
|
detectMoving(input) {
|
|
26
26
|
const imageData = input;
|
|
27
|
-
// 🚀 MOONSHOT:
|
|
28
|
-
//
|
|
29
|
-
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
|
|
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);
|
package/dist/react/TaptappAR.js
CHANGED
|
@@ -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
|
@@ -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 =
|
|
25
|
-
const DEFAULT_MISS_TOLERANCE =
|
|
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:
|
|
37
|
-
//
|
|
38
|
-
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
|
|
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;
|
package/src/react/TaptappAR.tsx
CHANGED
|
@@ -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>
|