import { V as d, M as s } from "../../three.module-BPupfU8l.js";
function* l(o) {
  if (!o)
    return;
  const e = [o], t = [0];
  for (yield o; e.length; ) {
    const r = e.pop(), n = t.pop();
    r.children.length <= n || (e.push(r, r.children[n]), t.push(n + 1, 0), yield r.children[n]);
  }
}
function f(o) {
  const e = new d(), t = new d();
  let r = 0;
  for (const n of l(o)) {
    t.copy(n.position);
    let { parent: c } = n.parent;
    for (; c && (t.applyQuaternion(c.quaternion).add(c.position), c !== o); )
      c = c.parent;
    e.add(t), r++;
  }
  return e.divideScalar(r);
}
const u = Math.PI * 2;
function h(o, e, t) {
  return o.set(
    i(o.x, e == null ? void 0 : e.x, t == null ? void 0 : t.x),
    i(o.y, e == null ? void 0 : e.y, t == null ? void 0 : t.y),
    i(o.z, e == null ? void 0 : e.z, t == null ? void 0 : t.z)
  );
}
function i(o, e = Number.NEGATIVE_INFINITY, t = Number.POSITIVE_INFINITY) {
  const r = Number.isFinite(e), n = Number.isFinite(t);
  return r && n && e === t ? e : (r && (e = s.euclideanModulo(e, u)), n && (t = s.euclideanModulo(t, u)), o = s.euclideanModulo(o, u), r && n && e >= t && (t += u, o < Math.PI && (o += u)), n && o > t ? o = t : r && o < e && (o = e), s.euclideanModulo(o, u));
}
export {
  f as centerOfDescendant,
  i as clampByRadian,
  h as clampVector3ByRadian,
  l as transverse
};
