Spaces:
Running
Running
Update index.html
Browse files- index.html +12 -14
index.html
CHANGED
|
@@ -72,16 +72,14 @@
|
|
| 72 |
transform: scaleX(-1);
|
| 73 |
}
|
| 74 |
|
| 75 |
-
/* PERBAIKAN CSS: Animasi GIF Transisi Halus (Anti-Blink) */
|
| 76 |
.pose1-anim {
|
| 77 |
position: absolute;
|
| 78 |
-
opacity: 0;
|
| 79 |
border-radius: 8px;
|
| 80 |
z-index: 10;
|
| 81 |
border: 2px solid #eab308;
|
| 82 |
box-shadow: 0 0 15px rgba(234, 179, 8, 0.8);
|
| 83 |
pointer-events: none;
|
| 84 |
-
/* Transisi opacity ditambahkan agar memudar perlahan saat AI berkedip */
|
| 85 |
transition: opacity 0.2s ease-in-out, left 0.1s linear, top 0.1s linear;
|
| 86 |
transform: scaleX(-1);
|
| 87 |
}
|
|
@@ -157,7 +155,7 @@
|
|
| 157 |
document.getElementById('audio5')
|
| 158 |
];
|
| 159 |
|
| 160 |
-
|
| 161 |
let memoryActivePoses = [];
|
| 162 |
let memoryTimer = 0;
|
| 163 |
let currentFaceLandmarks = null;
|
|
@@ -221,7 +219,7 @@
|
|
| 221 |
|
| 222 |
const hands = new Hands({locateFile: (file) => { return `https://cdn.jsdelivr.net/npm/@mediapipe/hands/${file}`; }});
|
| 223 |
|
| 224 |
-
|
| 225 |
hands.setOptions({ maxNumHands: 2, modelComplexity: 0, minDetectionConfidence: 0.7, minTrackingConfidence: 0.7 });
|
| 226 |
|
| 227 |
hands.onResults((results) => {
|
|
@@ -240,7 +238,7 @@
|
|
| 240 |
}
|
| 241 |
|
| 242 |
let detectedPosesThisFrame = [];
|
| 243 |
-
|
| 244 |
anims.forEach(a => a.style.opacity = '0');
|
| 245 |
|
| 246 |
if (results.multiHandLandmarks && results.multiHandLandmarks.length > 0) {
|
|
@@ -255,7 +253,7 @@
|
|
| 255 |
}
|
| 256 |
canvasCtx.restore();
|
| 257 |
|
| 258 |
-
|
| 259 |
if (currentFaceLandmarks) {
|
| 260 |
let bio = analyzeFaceBiometrics(currentFaceLandmarks);
|
| 261 |
let isPositivePose = detectedPosesThisFrame.some(p => p.id === 1 || p.id === 2 || p.id === 3);
|
|
@@ -271,7 +269,7 @@
|
|
| 271 |
biometricContainer.style.borderColor = "#334155";
|
| 272 |
}
|
| 273 |
|
| 274 |
-
|
| 275 |
let currentIds = detectedPosesThisFrame.map(p => p.id);
|
| 276 |
|
| 277 |
if (currentIds.length > 0) {
|
|
@@ -279,21 +277,21 @@
|
|
| 279 |
statusPose.textContent = uniquePoseNames.join(" & ");
|
| 280 |
statusPose.style.color = detectedPosesThisFrame[0].color;
|
| 281 |
|
| 282 |
-
|
| 283 |
detectedPosesThisFrame.forEach((pose, i) => {
|
| 284 |
if (pose.id === 1 && anims[i]) {
|
| 285 |
const wrist = pose.wrist;
|
| 286 |
const leftPos = ((1 - wrist.x) * canvasElement.width) - 75;
|
| 287 |
const topPos = (wrist.y * canvasElement.height) + 30;
|
| 288 |
|
| 289 |
-
anims[i].style.opacity = '1';
|
| 290 |
anims[i].style.left = `${leftPos}px`;
|
| 291 |
anims[i].style.top = `${topPos}px`;
|
| 292 |
anims[i].style.width = `150px`;
|
| 293 |
}
|
| 294 |
});
|
| 295 |
|
| 296 |
-
|
| 297 |
let newPoses = currentIds.filter(id => !memoryActivePoses.includes(id));
|
| 298 |
|
| 299 |
if (newPoses.length > 0) {
|
|
@@ -303,11 +301,11 @@
|
|
| 303 |
if (soundToPlay) soundToPlay.play();
|
| 304 |
}
|
| 305 |
|
| 306 |
-
memoryActivePoses = currentIds;
|
| 307 |
-
memoryTimer = Date.now();
|
| 308 |
|
| 309 |
} else {
|
| 310 |
-
|
| 311 |
if (Date.now() - memoryTimer > 500) {
|
| 312 |
if (memoryActivePoses.length > 0) {
|
| 313 |
statusPose.textContent = "Menunggu formasi jari...";
|
|
|
|
| 72 |
transform: scaleX(-1);
|
| 73 |
}
|
| 74 |
|
|
|
|
| 75 |
.pose1-anim {
|
| 76 |
position: absolute;
|
| 77 |
+
opacity: 0;
|
| 78 |
border-radius: 8px;
|
| 79 |
z-index: 10;
|
| 80 |
border: 2px solid #eab308;
|
| 81 |
box-shadow: 0 0 15px rgba(234, 179, 8, 0.8);
|
| 82 |
pointer-events: none;
|
|
|
|
| 83 |
transition: opacity 0.2s ease-in-out, left 0.1s linear, top 0.1s linear;
|
| 84 |
transform: scaleX(-1);
|
| 85 |
}
|
|
|
|
| 155 |
document.getElementById('audio5')
|
| 156 |
];
|
| 157 |
|
| 158 |
+
|
| 159 |
let memoryActivePoses = [];
|
| 160 |
let memoryTimer = 0;
|
| 161 |
let currentFaceLandmarks = null;
|
|
|
|
| 219 |
|
| 220 |
const hands = new Hands({locateFile: (file) => { return `https://cdn.jsdelivr.net/npm/@mediapipe/hands/${file}`; }});
|
| 221 |
|
| 222 |
+
|
| 223 |
hands.setOptions({ maxNumHands: 2, modelComplexity: 0, minDetectionConfidence: 0.7, minTrackingConfidence: 0.7 });
|
| 224 |
|
| 225 |
hands.onResults((results) => {
|
|
|
|
| 238 |
}
|
| 239 |
|
| 240 |
let detectedPosesThisFrame = [];
|
| 241 |
+
|
| 242 |
anims.forEach(a => a.style.opacity = '0');
|
| 243 |
|
| 244 |
if (results.multiHandLandmarks && results.multiHandLandmarks.length > 0) {
|
|
|
|
| 253 |
}
|
| 254 |
canvasCtx.restore();
|
| 255 |
|
| 256 |
+
|
| 257 |
if (currentFaceLandmarks) {
|
| 258 |
let bio = analyzeFaceBiometrics(currentFaceLandmarks);
|
| 259 |
let isPositivePose = detectedPosesThisFrame.some(p => p.id === 1 || p.id === 2 || p.id === 3);
|
|
|
|
| 269 |
biometricContainer.style.borderColor = "#334155";
|
| 270 |
}
|
| 271 |
|
| 272 |
+
|
| 273 |
let currentIds = detectedPosesThisFrame.map(p => p.id);
|
| 274 |
|
| 275 |
if (currentIds.length > 0) {
|
|
|
|
| 277 |
statusPose.textContent = uniquePoseNames.join(" & ");
|
| 278 |
statusPose.style.color = detectedPosesThisFrame[0].color;
|
| 279 |
|
| 280 |
+
|
| 281 |
detectedPosesThisFrame.forEach((pose, i) => {
|
| 282 |
if (pose.id === 1 && anims[i]) {
|
| 283 |
const wrist = pose.wrist;
|
| 284 |
const leftPos = ((1 - wrist.x) * canvasElement.width) - 75;
|
| 285 |
const topPos = (wrist.y * canvasElement.height) + 30;
|
| 286 |
|
| 287 |
+
anims[i].style.opacity = '1';
|
| 288 |
anims[i].style.left = `${leftPos}px`;
|
| 289 |
anims[i].style.top = `${topPos}px`;
|
| 290 |
anims[i].style.width = `150px`;
|
| 291 |
}
|
| 292 |
});
|
| 293 |
|
| 294 |
+
|
| 295 |
let newPoses = currentIds.filter(id => !memoryActivePoses.includes(id));
|
| 296 |
|
| 297 |
if (newPoses.length > 0) {
|
|
|
|
| 301 |
if (soundToPlay) soundToPlay.play();
|
| 302 |
}
|
| 303 |
|
| 304 |
+
memoryActivePoses = currentIds;
|
| 305 |
+
memoryTimer = Date.now();
|
| 306 |
|
| 307 |
} else {
|
| 308 |
+
|
| 309 |
if (Date.now() - memoryTimer > 500) {
|
| 310 |
if (memoryActivePoses.length > 0) {
|
| 311 |
statusPose.textContent = "Menunggu formasi jari...";
|