@gamelearn/arcade-components 3.34.2 → 3.34.4

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.
@@ -29720,84 +29720,82 @@ function addPrimitiveAttributes(l, e, n) {
29720
29720
  }
29721
29721
  const defaultCamPos = [0, 14.63, 16], isMobile = DeviceDetection(), loader$1 = new GLTFLoader(), box = new Box3(), worldPos = new Vector3(), size = new Vector3();
29722
29722
  function Panel({ character: l, ttsStarted: e, active: n, visible: t = !0, onLoad: s }) {
29723
- var v, b, R;
29724
- const o = useRef(null), d = useRef(null), h = l.type === "character", [f, u] = useState(!1), [p, x] = useState(!1), T = useRef(), _ = useMemo(() => {
29725
- var y, w, C, D, N, P, k, F;
29726
- return h ? l.animationId && ((y = l.animation) != null && y.url) ? l.animation : (D = (C = (w = l == null ? void 0 : l.resource) == null ? void 0 : w.animations) == null ? void 0 : C[l.emotion]) != null && D.url ? (P = (N = l == null ? void 0 : l.resource) == null ? void 0 : N.animations) == null ? void 0 : P[l.emotion] : (F = (k = l == null ? void 0 : l.resource) == null ? void 0 : k.animations) == null ? void 0 : F.neutral : {};
29727
- }, [l.emotion, l == null ? void 0 : l.animationId, l == null ? void 0 : l.animation, (v = l == null ? void 0 : l.resource) == null ? void 0 : v.animations, h]), S = useCallback(() => {
29728
- if (T.current) {
29729
- const y = T.current.userData.animator;
29730
- y.getAction("idle") && y.mix("idle", 0.1);
29723
+ var S, g, v;
29724
+ const o = useRef(null), d = useRef(null), h = l.type === "character", [f, u] = useState(!1), p = useRef(), x = useMemo(() => {
29725
+ var b, R, y, w, C, D, N, P;
29726
+ return h ? l.animationId && ((b = l.animation) != null && b.url) ? l.animation : (w = (y = (R = l == null ? void 0 : l.resource) == null ? void 0 : R.animations) == null ? void 0 : y[l.emotion]) != null && w.url ? (D = (C = l == null ? void 0 : l.resource) == null ? void 0 : C.animations) == null ? void 0 : D[l.emotion] : (P = (N = l == null ? void 0 : l.resource) == null ? void 0 : N.animations) == null ? void 0 : P.neutral : {};
29727
+ }, [l.emotion, l == null ? void 0 : l.animationId, l == null ? void 0 : l.animation, (S = l == null ? void 0 : l.resource) == null ? void 0 : S.animations, h]), T = useCallback(() => {
29728
+ if (p.current) {
29729
+ const b = p.current.userData.animator;
29730
+ b.getAction("idle") && b.mix("idle", 0.1);
29731
29731
  }
29732
29732
  }, []);
29733
29733
  useEffect(() => {
29734
- var y, w, C, D, N, P;
29735
- if (n)
29734
+ var b, R, y, w, C, D;
29735
+ if (n && f)
29736
29736
  if (e) {
29737
- const k = (C = (w = (y = l == null ? void 0 : l.resource) == null ? void 0 : y.animations) == null ? void 0 : w.talking) == null ? void 0 : C.url, M = ((P = (N = (D = l == null ? void 0 : l.resource) == null ? void 0 : D.animations) == null ? void 0 : N["talking-short"]) == null ? void 0 : P.url) || k;
29738
- if (M && T.current) {
29739
- const j = T.current.userData.animator, B = `${M}_talking`;
29740
- j.getAction(B) ? (j.mix(B, 0.1), u(!0)) : loader$1.load(M, ({ animations: z }) => {
29741
- if (!T.current)
29737
+ const N = (y = (R = (b = l == null ? void 0 : l.resource) == null ? void 0 : b.animations) == null ? void 0 : R.talking) == null ? void 0 : y.url, k = ((D = (C = (w = l == null ? void 0 : l.resource) == null ? void 0 : w.animations) == null ? void 0 : C["talking-short"]) == null ? void 0 : D.url) || N;
29738
+ if (k && p.current) {
29739
+ const F = p.current.userData.animator, M = `${k}_talking`;
29740
+ F.getAction(M) ? F.mix(M, 0.1) : loader$1.load(k, ({ animations: j }) => {
29741
+ if (!p.current)
29742
29742
  return;
29743
- const X = j.getAction("idle").getClip();
29744
- j.register(B, mixWithTalkingClip(z[0], X)), j.mix(B, 0.1), u(!0);
29743
+ const B = F.getAction("idle").getClip();
29744
+ F.register(M, mixWithTalkingClip(j[0], B)), F.mix(M, 0.1);
29745
29745
  });
29746
29746
  }
29747
29747
  } else
29748
- S();
29749
- else
29750
- f && S();
29751
- }, [e, n, S, f, (b = l == null ? void 0 : l.resource) == null ? void 0 : b.animations]);
29752
- const g = useCallback(
29753
- (y) => {
29748
+ T();
29749
+ }, [e, n, T, (g = l == null ? void 0 : l.resource) == null ? void 0 : g.animations, f]);
29750
+ const _ = useCallback(
29751
+ (b) => {
29754
29752
  if (l.type === "character") {
29755
- const w = y.getObjectByName("Head_M", !0);
29756
- w ? (w.updateMatrixWorld(!0), box.setFromObject(y), box.getSize(size), w.getWorldPosition(worldPos), o.current.lookAt(worldPos)) : o.current.position.setY(size.y - 1.5 * 1.3), o.current.zoom = 1.5;
29757
- const C = () => {
29758
- x(!0), s == null || s(), y.removeEventListener("update_bounds", C);
29753
+ const R = b.getObjectByName("Head_M", !0);
29754
+ R ? (R.updateMatrixWorld(!0), box.setFromObject(b), box.getSize(size), R.getWorldPosition(worldPos), o.current.lookAt(worldPos)) : o.current.position.setY(size.y - 1.5 * 1.3), o.current.zoom = 1.5;
29755
+ const y = () => {
29756
+ u(!0), s == null || s(), b.removeEventListener("update_bounds", y);
29759
29757
  };
29760
- y.addEventListener("update_bounds", C);
29758
+ b.addEventListener("update_bounds", y);
29761
29759
  } else
29762
- cameraFitAnyObject(y, o.current), o.current.zoom = 1, x(!0);
29760
+ cameraFitAnyObject(b, o.current), o.current.zoom = 1, u(!0);
29763
29761
  o.current.updateProjectionMatrix();
29764
29762
  },
29765
29763
  [l, s]
29766
29764
  );
29767
- return useFrame(({ gl: y, scene: w }) => {
29765
+ return useFrame(({ gl: b, scene: R }) => {
29768
29766
  if (o.current && d.current) {
29769
- const C = document.querySelectorAll(".conversation--character__item")[l.slot];
29770
- if (C) {
29771
- const D = C.getBoundingClientRect(), N = C.parentNode.getBoundingClientRect(), [P, k] = [D.right - D.left, D.bottom - D.top];
29772
- if (o.current.aspect = P / k, o.current.updateProjectionMatrix(), h && T.current) {
29773
- box.setFromObject(T.current), box.getSize(size);
29774
- const j = T.current.getObjectByName("Head_M", !0);
29775
- j ? (j.getWorldPosition(worldPos), o.current.lookAt(worldPos)) : o.current.position.setY(size.y - 1.5 * 1.3), o.current.zoom = 1.5;
29776
- }
29777
- const F = {
29778
- top: D.top - N.top,
29779
- right: D.right - N.right,
29780
- left: D.left - N.left,
29781
- bottom: D.bottom - N.bottom
29782
- }, M = isMobile ? 24 : 40;
29783
- F.bottom += n ? -M : M, y.setViewport(F.left, F.bottom, P, k), y.setScissor(F.left, F.bottom, P, k), d.current.environment = w.environment, y.render(d.current, o.current);
29784
- }
29785
- }
29786
- }, 1), !((R = l.resource) != null && R.url) || l.type === "image" ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("scene", { ref: d, children: [
29767
+ const y = document.querySelectorAll(".conversation--character__item")[l.slot];
29768
+ if (y) {
29769
+ const w = y.getBoundingClientRect(), C = y.parentNode.getBoundingClientRect(), [D, N] = [w.right - w.left, w.bottom - w.top];
29770
+ if (o.current.aspect = D / N, o.current.updateProjectionMatrix(), h && p.current) {
29771
+ box.setFromObject(p.current), box.getSize(size);
29772
+ const F = p.current.getObjectByName("Head_M", !0);
29773
+ F ? (F.getWorldPosition(worldPos), o.current.lookAt(worldPos)) : o.current.position.setY(size.y - 1.5 * 1.3), o.current.zoom = 1.5;
29774
+ }
29775
+ const P = {
29776
+ top: w.top - C.top,
29777
+ right: w.right - C.right,
29778
+ left: w.left - C.left,
29779
+ bottom: w.bottom - C.bottom
29780
+ }, k = isMobile ? 24 : 40;
29781
+ P.bottom += n ? -k : k, b.setViewport(P.left, P.bottom, D, N), b.setScissor(P.left, P.bottom, D, N), d.current.environment = R.environment, b.render(d.current, o.current);
29782
+ }
29783
+ }
29784
+ }, 1), !((v = l.resource) != null && v.url) || l.type === "image" ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("scene", { ref: d, children: [
29787
29785
  /* @__PURE__ */ jsxRuntimeExports.jsx(
29788
29786
  SceneResource,
29789
29787
  {
29790
- ref: T,
29788
+ ref: p,
29791
29789
  name: `char_${l.uid}`,
29792
29790
  url: l.resource.url,
29793
- animationStates: { idle: _.url },
29791
+ animationStates: { idle: x.url },
29794
29792
  type: l.type,
29795
- onRender: g,
29793
+ onRender: _,
29796
29794
  texturable: !0,
29797
29795
  interactive: !1,
29798
29796
  generate: !1,
29799
29797
  merge: l.type !== "character",
29800
- visible: p && t
29798
+ visible: f && t
29801
29799
  }
29802
29800
  ),
29803
29801
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -29807,8 +29805,8 @@ function Panel({ character: l, ttsStarted: e, active: n, visible: t = !0, onLoad
29807
29805
  fov: 35,
29808
29806
  position: defaultCamPos,
29809
29807
  rotation: [0, 0, 0],
29810
- onUpdate: (y) => {
29811
- y.layers.enableAll();
29808
+ onUpdate: (b) => {
29809
+ b.layers.enableAll();
29812
29810
  },
29813
29811
  manual: !0
29814
29812
  }
@@ -62212,7 +62210,7 @@ function SortPuzzleComponent({
62212
62210
  const Re = document.querySelector(`#${Ze.id}`), at = Re.getBoundingClientRect();
62213
62211
  ue.current.find((ve) => !(at.left >= ve.right || at.right <= ve.left || at.top >= ve.bottom || at.bottom <= ve.top)) && (Ge = !0, Re.classList.add("sort-draggable-item--error"), le(Ze, Re));
62214
62212
  }
62215
- }), Ge ? (M("fail"), G()) : (M("score"), W());
62213
+ }), Ge ? (M("fail"), G()) : (M("score"), P(!0), W());
62216
62214
  }, Le = () => {
62217
62215
  f.forEach((Ge) => {
62218
62216
  const Ze = document.querySelector(`#${Ge.id}`);