@ikijs/editor 0.33.0 → 0.33.1
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.js +86 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3375,6 +3375,19 @@ function spin(x, y, ox, oy, a) {
|
|
|
3375
3375
|
];
|
|
3376
3376
|
}
|
|
3377
3377
|
function faceField(m) {
|
|
3378
|
+
const plate = plateField(m);
|
|
3379
|
+
const floor = foreheadFloor(m);
|
|
3380
|
+
let hold;
|
|
3381
|
+
return (x, y, ax, ay) => {
|
|
3382
|
+
const d = plate(x, y, ax, ay);
|
|
3383
|
+
if (ax === 0 || y <= floor) return d;
|
|
3384
|
+
if (hold === void 0) hold = foreheadHold(m, floor) ?? null;
|
|
3385
|
+
if (hold === null) return d;
|
|
3386
|
+
const s = Math.sign(ax);
|
|
3387
|
+
return [d[0] - s * Math.abs(ax) * hold(x, y, s) / 30, d[1]];
|
|
3388
|
+
};
|
|
3389
|
+
}
|
|
3390
|
+
function plateField(m) {
|
|
3378
3391
|
const f = m.frame;
|
|
3379
3392
|
return (x, y, ax, ay) => {
|
|
3380
3393
|
const s = Math.sign(ax);
|
|
@@ -3394,6 +3407,77 @@ function faceField(m) {
|
|
|
3394
3407
|
return [dx, nodDy(v, ay, f.hh)];
|
|
3395
3408
|
};
|
|
3396
3409
|
}
|
|
3410
|
+
function faceCellPx(frame) {
|
|
3411
|
+
return Math.min(FACE_CELL_PX, 2 * frame.wMax / 14);
|
|
3412
|
+
}
|
|
3413
|
+
var FACE_CELL_PX = 28;
|
|
3414
|
+
var FOREHEAD_FADE = 0.04;
|
|
3415
|
+
function foreheadFloor(m) {
|
|
3416
|
+
const f = m.frame;
|
|
3417
|
+
const eyes = [m.boxes.eye_L, m.boxes.eye_R].filter(
|
|
3418
|
+
(e) => e !== void 0
|
|
3419
|
+
);
|
|
3420
|
+
const eyeTop = eyes.length > 0 ? Math.max(...eyes.map((e) => e.y1)) : f.eyeY;
|
|
3421
|
+
return Math.max(eyeTop, f.ears === void 0 ? -Infinity : f.ears.top + 2);
|
|
3422
|
+
}
|
|
3423
|
+
function foreheadHold(m, floor) {
|
|
3424
|
+
const f = m.frame;
|
|
3425
|
+
const top = f.face.y1;
|
|
3426
|
+
const count = Math.floor(top - floor);
|
|
3427
|
+
if (count <= 0 || f.faceRuns(top - 0.5) === void 0 || f.hairRuns("hair_front", top - 0.5) === void 0) {
|
|
3428
|
+
return void 0;
|
|
3429
|
+
}
|
|
3430
|
+
const plate = plateField(m);
|
|
3431
|
+
const front = hairFrontField(m);
|
|
3432
|
+
const { inner } = hairFrontBends(f, m.boxes);
|
|
3433
|
+
const cell = faceCellPx(f);
|
|
3434
|
+
const fade = FOREHEAD_FADE * f.hh;
|
|
3435
|
+
const sides = [-1, 1];
|
|
3436
|
+
const hold = sides.map(() => new Float64Array(count));
|
|
3437
|
+
const whole = sides.map(() => new Float64Array(count));
|
|
3438
|
+
const span3 = sides.map(() => new Float64Array(count));
|
|
3439
|
+
let any = false;
|
|
3440
|
+
for (let i = 0; i < count; i++) {
|
|
3441
|
+
const y = top - i - 0.5;
|
|
3442
|
+
const faceRuns = f.faceRuns(y);
|
|
3443
|
+
const hairRuns = f.hairRuns("hair_front", y);
|
|
3444
|
+
sides.forEach((side, k) => {
|
|
3445
|
+
const edge = outerEdge(faceRuns, f.axisX, side);
|
|
3446
|
+
const hair = outerEdge(hairRuns, f.axisX, side);
|
|
3447
|
+
if (edge === void 0 || hair === void 0) return;
|
|
3448
|
+
const end = side * (edge - f.axisX) - cell;
|
|
3449
|
+
if (end <= 0) return;
|
|
3450
|
+
const cover = side * (hair - edge);
|
|
3451
|
+
const room = Math.max(0, cover);
|
|
3452
|
+
const goes = side * plate(edge - side * 0.5, y, 30 * side, 0)[0];
|
|
3453
|
+
const held = side * front(hair - side * 0.5, y, 30 * side, 0)[0];
|
|
3454
|
+
const need = clamp(1 + cover / fade, 0, 1) * Math.max(0, goes - held - room + Math.min(1, room));
|
|
3455
|
+
if (need <= 0) return;
|
|
3456
|
+
const over = Math.min(end, Math.max(2 * cell, end - inner, 2 * need));
|
|
3457
|
+
hold[k][i] = Math.min(need, over / 2);
|
|
3458
|
+
whole[k][i] = end;
|
|
3459
|
+
span3[k][i] = over;
|
|
3460
|
+
any = true;
|
|
3461
|
+
});
|
|
3462
|
+
}
|
|
3463
|
+
if (!any) return void 0;
|
|
3464
|
+
const reach = Math.ceil(cell);
|
|
3465
|
+
return (x, y, s) => {
|
|
3466
|
+
const u = s * (x - f.axisX);
|
|
3467
|
+
if (s === 0 || u <= 0 || y <= floor) return 0;
|
|
3468
|
+
const k = s < 0 ? 0 : 1;
|
|
3469
|
+
const i = clamp(Math.floor(top - y), 0, count - 1);
|
|
3470
|
+
let h = 0;
|
|
3471
|
+
const j1 = Math.min(count - 1, i + 3 * reach);
|
|
3472
|
+
for (let j = Math.max(0, i - 3 * reach); j <= j1; j++) {
|
|
3473
|
+
if (hold[k][j] === 0) continue;
|
|
3474
|
+
const near = clamp((3 * reach - Math.abs(i - j)) / (2 * reach), 0, 1);
|
|
3475
|
+
const across = clamp((u - (whole[k][j] - span3[k][j])) / span3[k][j], 0, 1);
|
|
3476
|
+
h = Math.max(h, hold[k][j] * near * across);
|
|
3477
|
+
}
|
|
3478
|
+
return h * clamp((y - floor) / (2 * cell), 0, 1);
|
|
3479
|
+
};
|
|
3480
|
+
}
|
|
3397
3481
|
function earField(m) {
|
|
3398
3482
|
const f = m.frame;
|
|
3399
3483
|
const ears = f.ears;
|
|
@@ -7338,7 +7422,7 @@ function writeOcclusion(customParts, built, parts) {
|
|
|
7338
7422
|
|
|
7339
7423
|
// src/auto-rig/generate.ts
|
|
7340
7424
|
var MESH_CELLS = {
|
|
7341
|
-
face: { px:
|
|
7425
|
+
face: { px: FACE_CELL_PX, min: 4, max: 24 },
|
|
7342
7426
|
// The front hair eases from riding the face to holding the outline.
|
|
7343
7427
|
hair_front: { px: 32, min: 3, max: 24 },
|
|
7344
7428
|
// A side lock's rows come from `sideLockGrid`: even ones, plus the root
|
|
@@ -7646,7 +7730,7 @@ function buildPart(spec, b, order, frame, byRole, plan, frontGrid, lips) {
|
|
|
7646
7730
|
let region;
|
|
7647
7731
|
let headStart = 0;
|
|
7648
7732
|
if (spec.role === "face") {
|
|
7649
|
-
const px =
|
|
7733
|
+
const px = faceCellPx(frame);
|
|
7650
7734
|
const fm = buildFaceMesh(frame, b, { ...MESH_CELLS.face, px }, NECK_CELLS);
|
|
7651
7735
|
mesh = fm.mesh;
|
|
7652
7736
|
region = fm.region;
|