@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.mjs
CHANGED
|
@@ -1779,23 +1779,22 @@ var HEAD_TURN_MAX_DEG = 30;
|
|
|
1779
1779
|
function headTurnParallaxUnit(gridHalfWidth) {
|
|
1780
1780
|
return gridHalfWidth * HEAD_CYLINDER_RADIUS_FACTOR * Math.sin(HEAD_TURN_MAX_DEG * (Math.PI / 180));
|
|
1781
1781
|
}
|
|
1782
|
+
function gridReach(grid, axis, center) {
|
|
1783
|
+
let reach = 0;
|
|
1784
|
+
for (let i = axis; i < grid.points.length; i += 2) {
|
|
1785
|
+
reach = Math.max(reach, Math.abs(grid.points[i] - center));
|
|
1786
|
+
}
|
|
1787
|
+
return reach;
|
|
1788
|
+
}
|
|
1782
1789
|
function pinnedCylinderBend(local, radius, theta) {
|
|
1783
1790
|
const alpha = Math.asin(Math.max(-1, Math.min(1, local / radius)));
|
|
1784
1791
|
return radius * Math.sin(alpha + theta) - local - radius * Math.sin(theta);
|
|
1785
1792
|
}
|
|
1786
1793
|
function bakeHeadTurnGridWarp2DCentered(grid, parameterX, parameterY, centerX, centerY) {
|
|
1787
1794
|
const STOPS = [-HEAD_TURN_MAX_DEG, 0, HEAD_TURN_MAX_DEG];
|
|
1788
|
-
const
|
|
1789
|
-
const
|
|
1795
|
+
const RADIUS_X = gridReach(grid, 0, centerX) * HEAD_CYLINDER_RADIUS_FACTOR;
|
|
1796
|
+
const RADIUS_Y = gridReach(grid, 1, centerY) * HEAD_CYLINDER_RADIUS_FACTOR;
|
|
1790
1797
|
const pointCount = grid.points.length / 2;
|
|
1791
|
-
let halfHeight = 0;
|
|
1792
|
-
for (let i = 0; i < pointCount; i++) {
|
|
1793
|
-
halfHeight = Math.max(
|
|
1794
|
-
halfHeight,
|
|
1795
|
-
Math.abs(grid.points[i * 2 + 1] - centerY)
|
|
1796
|
-
);
|
|
1797
|
-
}
|
|
1798
|
-
const RADIUS_Y = halfHeight * HEAD_CYLINDER_RADIUS_FACTOR;
|
|
1799
1798
|
const DEG_TO_RAD = Math.PI / 180;
|
|
1800
1799
|
const keyforms2d = [];
|
|
1801
1800
|
for (const angleY of STOPS) {
|
|
@@ -2004,6 +2003,7 @@ function bakeHairBackTurnWarp(mesh, parameter) {
|
|
|
2004
2003
|
var HAIR_SWAY_TIP_FRACTION = 0.09;
|
|
2005
2004
|
var HAIR_SWAY_CURL = 1.5;
|
|
2006
2005
|
var HAIR_SWAY_RANGE = 20;
|
|
2006
|
+
var HAIR_SWAY_PEAK_FRACTION = 0.56;
|
|
2007
2007
|
function bakeHairSwayWarp(mesh, parameter, tipShift, range) {
|
|
2008
2008
|
let top = -Infinity;
|
|
2009
2009
|
let bottom = Infinity;
|
|
@@ -2320,7 +2320,18 @@ function generateIkiFromLayerSet(layers, canvas) {
|
|
|
2320
2320
|
part.bindings = roleBindings;
|
|
2321
2321
|
}
|
|
2322
2322
|
if ((role === "hair_front" || role === "hair_back") && hasHair) {
|
|
2323
|
-
|
|
2323
|
+
let tipShift = HAIR_SWAY_TIP_FRACTION * cropH;
|
|
2324
|
+
if (role === "hair_front") {
|
|
2325
|
+
const shift = HAIR_FRONT_DEPTH * parallaxUnit;
|
|
2326
|
+
const headroom = Math.min(
|
|
2327
|
+
faceGridMaxX - (t.x + cropW / 2),
|
|
2328
|
+
t.x - cropW / 2 - faceGridMinX
|
|
2329
|
+
) - shift;
|
|
2330
|
+
tipShift = Math.min(
|
|
2331
|
+
tipShift,
|
|
2332
|
+
Math.max(0, headroom) / HAIR_SWAY_PEAK_FRACTION
|
|
2333
|
+
);
|
|
2334
|
+
}
|
|
2324
2335
|
part.warps = [
|
|
2325
2336
|
bakeHairSwayWarp(
|
|
2326
2337
|
mesh,
|