@ikijs/engine 0.3.0 → 0.3.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 CHANGED
@@ -1073,7 +1073,10 @@ var FixedStepClock = class {
1073
1073
  // src/idle-motion.ts
1074
1074
  var BLINK_INTERVAL_MIN_MS = 1500;
1075
1075
  var BLINK_INTERVAL_MAX_MS = 6e3;
1076
- var BLINK_DURATION_MS = 120;
1076
+ var BLINK_CLOSE_MS = 60;
1077
+ var BLINK_HOLD_MS = 20;
1078
+ var BLINK_OPEN_MS = 100;
1079
+ var BLINK_DURATION_MS = BLINK_CLOSE_MS + BLINK_HOLD_MS + BLINK_OPEN_MS;
1077
1080
  var BREATH_PERIOD_MS = 3500;
1078
1081
  var GAZE_RADIUS = 0.3;
1079
1082
  var GAZE_RETARGET_MIN_MS = 1200;
@@ -1091,7 +1094,18 @@ function lerp(a, b, t) {
1091
1094
  return a + (b - a) * t;
1092
1095
  }
1093
1096
  function blinkEnvelope(phase) {
1094
- return 2 * Math.abs(phase - 0.5);
1097
+ const ms = phase * BLINK_DURATION_MS;
1098
+ if (ms <= 0) return 1;
1099
+ if (ms < BLINK_CLOSE_MS) {
1100
+ const t = ms / BLINK_CLOSE_MS;
1101
+ return 1 - t * t * (3 - 2 * t);
1102
+ }
1103
+ if (ms <= BLINK_CLOSE_MS + BLINK_HOLD_MS) return 0;
1104
+ if (ms < BLINK_DURATION_MS) {
1105
+ const t = (ms - BLINK_CLOSE_MS - BLINK_HOLD_MS) / BLINK_OPEN_MS;
1106
+ return 1 - (1 - t) * (1 - t);
1107
+ }
1108
+ return 1;
1095
1109
  }
1096
1110
  function randomInDisk(rng, radius) {
1097
1111
  const r = Math.sqrt(rng()) * radius;