@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
|
|
29724
|
-
const o = useRef(null), d = useRef(null), h = l.type === "character", [f, u] = useState(!1),
|
|
29725
|
-
var y, w, C, D, N, P
|
|
29726
|
-
return h ? l.animationId && ((
|
|
29727
|
-
}, [l.emotion, l == null ? void 0 : l.animationId, l == null ? void 0 : l.animation, (
|
|
29728
|
-
if (
|
|
29729
|
-
const
|
|
29730
|
-
|
|
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
|
|
29735
|
-
if (n)
|
|
29734
|
+
var b, R, y, w, C, D;
|
|
29735
|
+
if (n && f)
|
|
29736
29736
|
if (e) {
|
|
29737
|
-
const
|
|
29738
|
-
if (
|
|
29739
|
-
const
|
|
29740
|
-
|
|
29741
|
-
if (!
|
|
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
|
|
29744
|
-
|
|
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
|
-
|
|
29749
|
-
|
|
29750
|
-
|
|
29751
|
-
|
|
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
|
|
29756
|
-
|
|
29757
|
-
const
|
|
29758
|
-
|
|
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
|
-
|
|
29758
|
+
b.addEventListener("update_bounds", y);
|
|
29761
29759
|
} else
|
|
29762
|
-
cameraFitAnyObject(
|
|
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:
|
|
29765
|
+
return useFrame(({ gl: b, scene: R }) => {
|
|
29768
29766
|
if (o.current && d.current) {
|
|
29769
|
-
const
|
|
29770
|
-
if (
|
|
29771
|
-
const
|
|
29772
|
-
if (o.current.aspect =
|
|
29773
|
-
box.setFromObject(
|
|
29774
|
-
const
|
|
29775
|
-
|
|
29776
|
-
}
|
|
29777
|
-
const
|
|
29778
|
-
top:
|
|
29779
|
-
right:
|
|
29780
|
-
left:
|
|
29781
|
-
bottom:
|
|
29782
|
-
},
|
|
29783
|
-
|
|
29784
|
-
}
|
|
29785
|
-
}
|
|
29786
|
-
}, 1), !((
|
|
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:
|
|
29788
|
+
ref: p,
|
|
29791
29789
|
name: `char_${l.uid}`,
|
|
29792
29790
|
url: l.resource.url,
|
|
29793
|
-
animationStates: { idle:
|
|
29791
|
+
animationStates: { idle: x.url },
|
|
29794
29792
|
type: l.type,
|
|
29795
|
-
onRender:
|
|
29793
|
+
onRender: _,
|
|
29796
29794
|
texturable: !0,
|
|
29797
29795
|
interactive: !1,
|
|
29798
29796
|
generate: !1,
|
|
29799
29797
|
merge: l.type !== "character",
|
|
29800
|
-
visible:
|
|
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: (
|
|
29811
|
-
|
|
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}`);
|