@ikijs/editor 0.2.0 → 0.2.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 +22 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1838,23 +1838,22 @@ var HEAD_TURN_MAX_DEG = 30;
|
|
|
1838
1838
|
function headTurnParallaxUnit(gridHalfWidth) {
|
|
1839
1839
|
return gridHalfWidth * HEAD_CYLINDER_RADIUS_FACTOR * Math.sin(HEAD_TURN_MAX_DEG * (Math.PI / 180));
|
|
1840
1840
|
}
|
|
1841
|
+
function gridReach(grid, axis, center) {
|
|
1842
|
+
let reach = 0;
|
|
1843
|
+
for (let i = axis; i < grid.points.length; i += 2) {
|
|
1844
|
+
reach = Math.max(reach, Math.abs(grid.points[i] - center));
|
|
1845
|
+
}
|
|
1846
|
+
return reach;
|
|
1847
|
+
}
|
|
1841
1848
|
function pinnedCylinderBend(local, radius, theta) {
|
|
1842
1849
|
const alpha = Math.asin(Math.max(-1, Math.min(1, local / radius)));
|
|
1843
1850
|
return radius * Math.sin(alpha + theta) - local - radius * Math.sin(theta);
|
|
1844
1851
|
}
|
|
1845
1852
|
function bakeHeadTurnGridWarp2DCentered(grid, parameterX, parameterY, centerX, centerY) {
|
|
1846
1853
|
const STOPS = [-HEAD_TURN_MAX_DEG, 0, HEAD_TURN_MAX_DEG];
|
|
1847
|
-
const
|
|
1848
|
-
const
|
|
1854
|
+
const RADIUS_X = gridReach(grid, 0, centerX) * HEAD_CYLINDER_RADIUS_FACTOR;
|
|
1855
|
+
const RADIUS_Y = gridReach(grid, 1, centerY) * HEAD_CYLINDER_RADIUS_FACTOR;
|
|
1849
1856
|
const pointCount = grid.points.length / 2;
|
|
1850
|
-
let halfHeight = 0;
|
|
1851
|
-
for (let i = 0; i < pointCount; i++) {
|
|
1852
|
-
halfHeight = Math.max(
|
|
1853
|
-
halfHeight,
|
|
1854
|
-
Math.abs(grid.points[i * 2 + 1] - centerY)
|
|
1855
|
-
);
|
|
1856
|
-
}
|
|
1857
|
-
const RADIUS_Y = halfHeight * HEAD_CYLINDER_RADIUS_FACTOR;
|
|
1858
1857
|
const DEG_TO_RAD = Math.PI / 180;
|
|
1859
1858
|
const keyforms2d = [];
|
|
1860
1859
|
for (const angleY of STOPS) {
|
|
@@ -2063,6 +2062,7 @@ function bakeHairBackTurnWarp(mesh, parameter) {
|
|
|
2063
2062
|
var HAIR_SWAY_TIP_FRACTION = 0.09;
|
|
2064
2063
|
var HAIR_SWAY_CURL = 1.5;
|
|
2065
2064
|
var HAIR_SWAY_RANGE = 20;
|
|
2065
|
+
var HAIR_SWAY_PEAK_FRACTION = 0.56;
|
|
2066
2066
|
function bakeHairSwayWarp(mesh, parameter, tipShift, range) {
|
|
2067
2067
|
let top = -Infinity;
|
|
2068
2068
|
let bottom = Infinity;
|
|
@@ -2379,7 +2379,18 @@ function generateIkiFromLayerSet(layers, canvas) {
|
|
|
2379
2379
|
part.bindings = roleBindings;
|
|
2380
2380
|
}
|
|
2381
2381
|
if ((role === "hair_front" || role === "hair_back") && hasHair) {
|
|
2382
|
-
|
|
2382
|
+
let tipShift = HAIR_SWAY_TIP_FRACTION * cropH;
|
|
2383
|
+
if (role === "hair_front") {
|
|
2384
|
+
const shift = HAIR_FRONT_DEPTH * parallaxUnit;
|
|
2385
|
+
const headroom = Math.min(
|
|
2386
|
+
faceGridMaxX - (t.x + cropW / 2),
|
|
2387
|
+
t.x - cropW / 2 - faceGridMinX
|
|
2388
|
+
) - shift;
|
|
2389
|
+
tipShift = Math.min(
|
|
2390
|
+
tipShift,
|
|
2391
|
+
Math.max(0, headroom) / HAIR_SWAY_PEAK_FRACTION
|
|
2392
|
+
);
|
|
2393
|
+
}
|
|
2383
2394
|
part.warps = [
|
|
2384
2395
|
bakeHairSwayWarp(
|
|
2385
2396
|
mesh,
|