Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 3x 92x 36x 36x 36x 36x 36x 36x 36x 7x 29x 20x 20x 20x 20x 9x 9x | // Generated by ReScript, PLEASE EDIT WITH CARE
import * as Quaternion$WsteinRegripCore from "./Quaternion.res.mjs";
let defaults = {
radiusDeg: 35,
snapDeg: 4,
velocityMax: 2.5
};
function radians(degrees) {
return degrees * Math.PI / 180;
}
function apply(raw, target, velocityOpt, configOpt) {
let velocity = velocityOpt !== undefined ? velocityOpt : 0;
let config = configOpt !== undefined ? configOpt : defaults;
let angle = Quaternion$WsteinRegripCore.angle(raw, target);
let radius = radians(config.radiusDeg);
let snap = radians(config.snapDeg);
let gate = 1 - Math.min(1, Math.abs(velocity) / config.velocityMax);
if (angle >= radius || gate <= 0) {
return raw;
}
if (angle <= snap) {
let core = radians(1);
let outerPull = Math.sqrt(1 - snap / radius * (snap / radius));
let pull = angle <= snap - core ? 1 : outerPull + (1 - outerPull) * (snap - angle) / core;
return Quaternion$WsteinRegripCore.slerp(raw, target, pull * gate);
}
let n = angle / radius;
return Quaternion$WsteinRegripCore.slerp(raw, target, Math.sqrt(1 - n * n) * gate);
}
export {
defaults,
apply,
}
/* No side effect */
|