@gamelearn/arcade-components 3.32.1 → 3.32.2
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.
|
@@ -19,8 +19,8 @@ var Nc = (l, e, n, t) => ({
|
|
|
19
19
|
}), Ue = (l, e, n) => (Am(l, e, "access private method"), n);
|
|
20
20
|
import * as React$2 from "react";
|
|
21
21
|
import React__default, { useRef, useEffect, useCallback, createContext, useReducer, forwardRef, useImperativeHandle, useMemo, useContext, useLayoutEffect, useState } from "react";
|
|
22
|
-
import { OrbitControls, PerspectiveCamera as PerspectiveCamera$1 } from "@react-three/drei";
|
|
23
|
-
import { Renderer, SceneResource, CameraControls, SettingsController,
|
|
22
|
+
import { OrbitControls, PerspectiveCamera as PerspectiveCamera$1, Environment } from "@react-three/drei";
|
|
23
|
+
import { Renderer, SceneResource, CameraControls, SettingsController, QualityManager, HtmlPro, ProgressManager, AssetLoader } from "@gamelearn/arcade-three-core";
|
|
24
24
|
import { useThree, useFrame } from "@react-three/fiber";
|
|
25
25
|
import { Vector3, Box3, TrianglesDrawMode, TriangleFanDrawMode, TriangleStripDrawMode, Loader, LoaderUtils, FileLoader, Color, LinearSRGBColorSpace, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, SRGBColorSpace, MeshPhysicalMaterial, Vector2, Matrix4, Quaternion, InstancedMesh, InstancedBufferAttribute, Object3D, TextureLoader, ImageBitmapLoader, BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, LinearFilter, LinearMipmapLinearFilter, RepeatWrapping, PointsMaterial, Material, LineBasicMaterial, MeshStandardMaterial, DoubleSide, PropertyBinding, BufferGeometry, SkinnedMesh, Mesh, LineSegments, Line as Line$3, LineLoop, Points, Group as Group$3, PerspectiveCamera, MathUtils, OrthographicCamera, Skeleton, AnimationClip, Bone, InterpolateLinear, ColorManagement, NearestFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, InterpolateDiscrete, FrontSide, Texture, VectorKeyframeTrack, NumberKeyframeTrack, QuaternionKeyframeTrack, Sphere, Interpolant, Raycaster, LoopRepeat } from "three";
|
|
26
26
|
import require$$0 from "react-dom";
|
|
@@ -29730,92 +29730,92 @@ function addPrimitiveAttributes(l, e, n) {
|
|
|
29730
29730
|
});
|
|
29731
29731
|
}
|
|
29732
29732
|
const defaultCamPos = [0, 14.63, 16], isMobile = DeviceDetection(), loader$1 = new GLTFLoader(), box = new Box3(), worldPos = new Vector3(), size = new Vector3();
|
|
29733
|
-
function Panel({ character: l, ttsStarted: e, active: n, visible: t }) {
|
|
29734
|
-
var
|
|
29735
|
-
const
|
|
29736
|
-
var
|
|
29737
|
-
return
|
|
29738
|
-
}, [l.emotion, l == null ? void 0 : l.animationId, l == null ? void 0 : l.animation, (
|
|
29739
|
-
if (
|
|
29740
|
-
const
|
|
29741
|
-
|
|
29733
|
+
function Panel({ character: l, ttsStarted: e, active: n, visible: t, onLoad: s }) {
|
|
29734
|
+
var S, g, v;
|
|
29735
|
+
const o = useRef(null), d = useRef(null), h = l.type === "character", [f, u] = useState(!1), p = useRef(), _ = useMemo(() => {
|
|
29736
|
+
var b, R, y, w, C, N, D, P;
|
|
29737
|
+
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 ? (N = (C = l == null ? void 0 : l.resource) == null ? void 0 : C.animations) == null ? void 0 : N[l.emotion] : (P = (D = l == null ? void 0 : l.resource) == null ? void 0 : D.animations) == null ? void 0 : P.neutral : {};
|
|
29738
|
+
}, [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(() => {
|
|
29739
|
+
if (p.current) {
|
|
29740
|
+
const b = p.current.userData.animator;
|
|
29741
|
+
b.getAction("idle") && b.mix("idle", 0.1);
|
|
29742
29742
|
}
|
|
29743
29743
|
}, []);
|
|
29744
29744
|
useEffect(() => {
|
|
29745
|
-
var
|
|
29746
|
-
if (
|
|
29747
|
-
if (
|
|
29748
|
-
|
|
29749
|
-
|
|
29750
|
-
|
|
29751
|
-
|
|
29752
|
-
|
|
29753
|
-
|
|
29754
|
-
|
|
29755
|
-
|
|
29756
|
-
|
|
29757
|
-
|
|
29758
|
-
|
|
29759
|
-
|
|
29760
|
-
|
|
29761
|
-
|
|
29762
|
-
|
|
29763
|
-
|
|
29764
|
-
|
|
29765
|
-
(v) => {
|
|
29745
|
+
var b, R, y, w, C, N;
|
|
29746
|
+
if (n)
|
|
29747
|
+
if (e) {
|
|
29748
|
+
const D = (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 = ((N = (C = (w = l == null ? void 0 : l.resource) == null ? void 0 : w.animations) == null ? void 0 : C["talking-short"]) == null ? void 0 : N.url) || D;
|
|
29749
|
+
if (k && p.current) {
|
|
29750
|
+
const F = p.current.userData.animator, M = `${k}_talking`;
|
|
29751
|
+
F.getAction(M) ? (F.mix(M, 0.1), u(!0)) : loader$1.load(k, ({ animations: j }) => {
|
|
29752
|
+
if (!p.current)
|
|
29753
|
+
return;
|
|
29754
|
+
const B = F.getAction("idle").getClip();
|
|
29755
|
+
F.register(M, mixWithTalkingClip(j[0], B)), F.mix(M, 0.1), u(!0);
|
|
29756
|
+
});
|
|
29757
|
+
}
|
|
29758
|
+
} else
|
|
29759
|
+
T();
|
|
29760
|
+
else
|
|
29761
|
+
f && T();
|
|
29762
|
+
}, [e, n, T, f, (g = l == null ? void 0 : l.resource) == null ? void 0 : g.animations]);
|
|
29763
|
+
const x = useCallback(
|
|
29764
|
+
(b) => {
|
|
29766
29765
|
if (l.type === "character") {
|
|
29767
|
-
const
|
|
29768
|
-
|
|
29766
|
+
const R = b.getObjectByName("Head_M", !0);
|
|
29767
|
+
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;
|
|
29769
29768
|
} else
|
|
29770
|
-
cameraFitAnyObject(
|
|
29771
|
-
|
|
29769
|
+
cameraFitAnyObject(b, o.current), o.current.zoom = 1;
|
|
29770
|
+
o.current.updateProjectionMatrix(), s();
|
|
29772
29771
|
},
|
|
29773
|
-
[l]
|
|
29772
|
+
[l, s]
|
|
29774
29773
|
);
|
|
29775
|
-
return useFrame(({ gl:
|
|
29776
|
-
if (
|
|
29777
|
-
const
|
|
29778
|
-
if (
|
|
29779
|
-
const
|
|
29780
|
-
if (
|
|
29781
|
-
box.setFromObject(
|
|
29782
|
-
const
|
|
29783
|
-
|
|
29784
|
-
}
|
|
29785
|
-
const
|
|
29786
|
-
top:
|
|
29787
|
-
right:
|
|
29788
|
-
left:
|
|
29789
|
-
bottom:
|
|
29790
|
-
},
|
|
29791
|
-
|
|
29792
|
-
}
|
|
29793
|
-
}
|
|
29794
|
-
}, 1), l.type === "image" ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("scene", { ref:
|
|
29795
|
-
|
|
29774
|
+
return useFrame(({ gl: b, scene: R }) => {
|
|
29775
|
+
if (o.current && d.current) {
|
|
29776
|
+
const y = document.querySelectorAll(".conversation--character__item")[l.slot];
|
|
29777
|
+
if (y) {
|
|
29778
|
+
const w = y.getBoundingClientRect(), C = y.parentNode.getBoundingClientRect(), [N, D] = [w.right - w.left, w.bottom - w.top];
|
|
29779
|
+
if (o.current.aspect = N / D, o.current.updateProjectionMatrix(), h && p.current) {
|
|
29780
|
+
box.setFromObject(p.current), box.getSize(size);
|
|
29781
|
+
const F = p.current.getObjectByName("Head_M", !0);
|
|
29782
|
+
F ? (F.getWorldPosition(worldPos), o.current.lookAt(worldPos)) : o.current.position.setY(size.y - 1.5 * 1.3), o.current.zoom = 1.5;
|
|
29783
|
+
}
|
|
29784
|
+
const P = {
|
|
29785
|
+
top: w.top - C.top,
|
|
29786
|
+
right: w.right - C.right,
|
|
29787
|
+
left: w.left - C.left,
|
|
29788
|
+
bottom: w.bottom - C.bottom
|
|
29789
|
+
}, k = isMobile ? 24 : 40;
|
|
29790
|
+
P.bottom += n ? -k : k, b.setViewport(P.left, P.bottom, N, D), b.setScissor(P.left, P.bottom, N, D), d.current.environment = R.environment, b.render(d.current, o.current);
|
|
29791
|
+
}
|
|
29792
|
+
}
|
|
29793
|
+
}, 1), !((v = l.resource) != null && v.url) || l.type === "image" ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("scene", { ref: d, children: [
|
|
29794
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
29796
29795
|
SceneResource,
|
|
29797
29796
|
{
|
|
29798
|
-
ref:
|
|
29797
|
+
ref: p,
|
|
29799
29798
|
name: `char_${l.uid}`,
|
|
29800
29799
|
url: l.resource.url,
|
|
29801
|
-
|
|
29800
|
+
animationStates: { idle: _.url },
|
|
29802
29801
|
type: l.type,
|
|
29803
|
-
onRender:
|
|
29802
|
+
onRender: x,
|
|
29804
29803
|
texturable: !0,
|
|
29805
|
-
interactive: !
|
|
29804
|
+
interactive: !1,
|
|
29805
|
+
generate: !1,
|
|
29806
29806
|
merge: l.type !== "character",
|
|
29807
29807
|
visible: t
|
|
29808
29808
|
}
|
|
29809
|
-
)
|
|
29809
|
+
),
|
|
29810
29810
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
29811
29811
|
PerspectiveCamera$1,
|
|
29812
29812
|
{
|
|
29813
|
-
ref:
|
|
29813
|
+
ref: o,
|
|
29814
29814
|
fov: 35,
|
|
29815
29815
|
position: defaultCamPos,
|
|
29816
29816
|
rotation: [0, 0, 0],
|
|
29817
|
-
onUpdate: (
|
|
29818
|
-
|
|
29817
|
+
onUpdate: (b) => {
|
|
29818
|
+
b.layers.enableAll();
|
|
29819
29819
|
},
|
|
29820
29820
|
manual: !0
|
|
29821
29821
|
}
|
|
@@ -29827,14 +29827,7 @@ function PanelsWrapper({ characters: l, slots: e, ttsStarted: n, flex: t, curren
|
|
|
29827
29827
|
const [d, h] = useState(!1);
|
|
29828
29828
|
return useFrame(({ gl: f }) => {
|
|
29829
29829
|
f.setScissorTest(!1), f.clear(!0, !0), f.setScissorTest(!0);
|
|
29830
|
-
}),
|
|
29831
|
-
const f = () => {
|
|
29832
|
-
h(!0);
|
|
29833
|
-
};
|
|
29834
|
-
return ProgressManager.addEventListener("loaded", f), () => {
|
|
29835
|
-
ProgressManager.removeEventListener("loaded", f);
|
|
29836
|
-
};
|
|
29837
|
-
}, []), /* @__PURE__ */ jsxRuntimeExports.jsx(QualityManager, { lod: o, active: !0, children: e.map((f, u) => {
|
|
29830
|
+
}), /* @__PURE__ */ jsxRuntimeExports.jsx(QualityManager, { lod: d ? o : "divideby64", active: d, children: e.map((f, u) => {
|
|
29838
29831
|
let p = null;
|
|
29839
29832
|
const _ = l.findIndex((T) => T && T.uid === f.uid);
|
|
29840
29833
|
if (_ >= 0) {
|
|
@@ -29845,7 +29838,7 @@ function PanelsWrapper({ characters: l, slots: e, ttsStarted: n, flex: t, curren
|
|
|
29845
29838
|
character: p,
|
|
29846
29839
|
active: s.position === T,
|
|
29847
29840
|
ttsStarted: n,
|
|
29848
|
-
|
|
29841
|
+
onLoad: () => h(!0)
|
|
29849
29842
|
},
|
|
29850
29843
|
`${`${p.uid}_${u}`}_${_}`
|
|
29851
29844
|
);
|
|
@@ -29870,7 +29863,7 @@ function Scene(l) {
|
|
|
29870
29863
|
},
|
|
29871
29864
|
children: [
|
|
29872
29865
|
/* @__PURE__ */ jsxRuntimeExports.jsx(SettingsController, { current: { animate: l.pause } }),
|
|
29873
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
29866
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Environment, { files: "https://min.gamelearn.io/statics/envs/envmap_1k.hdr" }),
|
|
29874
29867
|
/* @__PURE__ */ jsxRuntimeExports.jsx(PanelsWrapper, { ...l })
|
|
29875
29868
|
]
|
|
29876
29869
|
}
|