@fabi-play/avatars 0.2.0 → 0.3.0
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/index.d.ts +4 -0
- package/dist/index.js +7 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -409,6 +409,10 @@ export declare const avatarIconDataUri: (def: AvatarDef | string, size: number,
|
|
|
409
409
|
* points (amount 0–1: how much of the new frame to take), and a point seen in the last frame stays visible until
|
|
410
410
|
* its visibility drops well below the threshold. Keep the result per player and pass it back as prev.
|
|
411
411
|
*
|
|
412
|
+
* The easing follows the speed: a point that barely moves (a still arm, where the camera's points only tremble)
|
|
413
|
+
* takes a small share of amount, down to STILL_SHARE, so a resting arm stays still instead of wobbling; a point that
|
|
414
|
+
* moves STILL_FULL or more in a frame takes all of amount, so real movements are not delayed.
|
|
415
|
+
*
|
|
412
416
|
* The face (nose, eyes, ears, mouth: what places and tilts the head) is smoothed much more, and relative to the
|
|
413
417
|
* shoulders: the head follows the body at once when the child moves, but face-point noise and small nods barely
|
|
414
418
|
* move it.
|
package/dist/index.js
CHANGED
|
@@ -2078,9 +2078,11 @@ function smoothBody(prev, next, amount = 0.5) {
|
|
|
2078
2078
|
const wasSeen = pv >= 0.5;
|
|
2079
2079
|
const isSeen = nv >= 0.5;
|
|
2080
2080
|
if (wasSeen && nv >= 0.3) out[i + 2] = Math.max(nv, 0.5);
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2081
|
+
const step = Math.hypot(next[i] - prev[i], next[i + 1] - prev[i + 1]);
|
|
2082
|
+
if (wasSeen && isSeen && step < 0.15) {
|
|
2083
|
+
const k = amount * Math.min(1, STILL_SHARE + (1 - STILL_SHARE) * step / STILL_FULL);
|
|
2084
|
+
out[i] = prev[i] + (next[i] - prev[i]) * k;
|
|
2085
|
+
out[i + 1] = prev[i + 1] + (next[i + 1] - prev[i + 1]) * k;
|
|
2084
2086
|
} else if (wasSeen && !isSeen && out[i + 2] >= 0.5) {
|
|
2085
2087
|
out[i] = prev[i];
|
|
2086
2088
|
out[i + 1] = prev[i + 1];
|
|
@@ -2089,6 +2091,8 @@ function smoothBody(prev, next, amount = 0.5) {
|
|
|
2089
2091
|
smoothFace(prev, next, out, amount * FACE_SMOOTHING);
|
|
2090
2092
|
return out;
|
|
2091
2093
|
}
|
|
2094
|
+
var STILL_SHARE = 0.1;
|
|
2095
|
+
var STILL_FULL = 0.03;
|
|
2092
2096
|
var FACE_SMOOTHING = 0.35;
|
|
2093
2097
|
var FACE_POINTS = 11;
|
|
2094
2098
|
function smoothFace(prev, next, out, amount) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabi-play/avatars",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "37 child-friendly avatars: Fabi the fox in every age band and 12 per band, drawn from a body pose, on canvas or as SVG portraits for the pickers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fabi-play",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@fabi-play/protocol": "^0.
|
|
35
|
+
"@fabi-play/protocol": "^0.3.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "24.10.1",
|