react-ai-avatar 0.1.0 → 0.1.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.
- package/README.md +22 -9
- package/dist/lib/GlbArkitAvatar-CIHx_Kop.cjs +1 -0
- package/dist/lib/GlbArkitAvatar-CjfIOQ2P.js +233 -0
- package/dist/lib/VrmAvatar-Dw0gf27E.js +245 -0
- package/dist/lib/VrmAvatar-g_9JGG0m.cjs +1 -0
- package/dist/lib/components/AvatarCaption.d.ts +36 -0
- package/dist/lib/index.cjs +4 -2
- package/dist/lib/index.js +446 -400
- package/dist/lib/lib/captionText.d.ts +33 -0
- package/dist/lib/lib/index.d.ts +4 -0
- package/dist/lib/react-ai-avatar.css +1 -1
- package/dist/lib/vrm.cjs +1 -1
- package/dist/lib/vrm.js +1 -1
- package/package.json +2 -14
- package/dist/lib/GlbArkitAvatar-CcPWCsQV.cjs +0 -1
- package/dist/lib/GlbArkitAvatar-Dm9STiyR.js +0 -232
- package/dist/lib/VrmAvatar-CehRzj0J.js +0 -224
- package/dist/lib/VrmAvatar-D_jr2TOG.cjs +0 -1
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import { jsxs as w, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import te, { useState as Q, useEffect as C, Suspense as ne, useRef as c } from "react";
|
|
3
|
-
import { Canvas as ae, useLoader as ie, useFrame as oe } from "@react-three/fiber";
|
|
4
|
-
import { GLTFLoader as se } from "three/addons/loaders/GLTFLoader.js";
|
|
5
|
-
import { VRMLoaderPlugin as ce } from "@pixiv/three-vrm";
|
|
6
|
-
import { OrbitControls as le } from "@react-three/drei";
|
|
7
|
-
import * as n from "three";
|
|
8
|
-
import { u as ue, c as de } from "./useReducedMotion-BDcEizfP.js";
|
|
9
|
-
class pe extends te.Component {
|
|
10
|
-
constructor(t) {
|
|
11
|
-
super(t), this.state = { hasError: !1 };
|
|
12
|
-
}
|
|
13
|
-
static getDerivedStateFromError() {
|
|
14
|
-
return { hasError: !0 };
|
|
15
|
-
}
|
|
16
|
-
componentDidCatch(t) {
|
|
17
|
-
this.props.onError((t == null ? void 0 : t.message) || String(t));
|
|
18
|
-
}
|
|
19
|
-
render() {
|
|
20
|
-
return this.state.hasError ? null : this.props.children;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function d(l, t, p) {
|
|
24
|
-
if (!l.expressionManager) return;
|
|
25
|
-
const k = l.expressionManager.expressionMap || {}, U = Object.keys(k);
|
|
26
|
-
let i = [];
|
|
27
|
-
switch (t) {
|
|
28
|
-
case "blink":
|
|
29
|
-
i = ["blink", "Blink", "BLINK"];
|
|
30
|
-
break;
|
|
31
|
-
case "aa":
|
|
32
|
-
i = ["aa", "Aa", "a", "A", "AA", "mouth_a", "mouth_A"];
|
|
33
|
-
break;
|
|
34
|
-
case "ee":
|
|
35
|
-
i = ["ee", "Ee", "e", "E", "EE", "mouth_e", "mouth_E"];
|
|
36
|
-
break;
|
|
37
|
-
case "oo":
|
|
38
|
-
i = ["oh", "Oh", "oo", "Oo", "o", "O", "OO", "mouth_o", "mouth_O"];
|
|
39
|
-
break;
|
|
40
|
-
case "happy":
|
|
41
|
-
i = ["happy", "Happy", "joy", "Joy", "JOY", "fun", "Fun", "FUN", "HAPPY"];
|
|
42
|
-
break;
|
|
43
|
-
case "sad":
|
|
44
|
-
i = ["sad", "Sad", "sorrow", "Sorrow", "SORROW", "sadness", "SAD"];
|
|
45
|
-
break;
|
|
46
|
-
case "relaxed":
|
|
47
|
-
i = ["relaxed", "Relaxed", "fun", "Fun", "FUN", "neutral", "Neutral", "RELAXED"];
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
const E = i.find((g) => k[g] !== void 0 || U.includes(g));
|
|
51
|
-
if (E)
|
|
52
|
-
l.expressionManager.setValue(E, p);
|
|
53
|
-
else
|
|
54
|
-
try {
|
|
55
|
-
l.expressionManager.setValue(i[0], p);
|
|
56
|
-
} catch {
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function me({
|
|
60
|
-
url: l,
|
|
61
|
-
state: t,
|
|
62
|
-
analyser: p,
|
|
63
|
-
maxMouthOpening: k = 30,
|
|
64
|
-
mouseTrackingIntensity: U = 1,
|
|
65
|
-
blinkIntervalMin: i = 2e3,
|
|
66
|
-
blinkIntervalMax: E = 6e3,
|
|
67
|
-
blinkDuration: g = 100,
|
|
68
|
-
reducedMotion: L = !1,
|
|
69
|
-
onLoaded: O
|
|
70
|
-
}) {
|
|
71
|
-
const e = ie(se, l, (f) => {
|
|
72
|
-
f.register((h) => new ce(h));
|
|
73
|
-
}).userData.vrm;
|
|
74
|
-
C(() => {
|
|
75
|
-
var f, h;
|
|
76
|
-
if (e) {
|
|
77
|
-
O(!0), console.log(
|
|
78
|
-
"[VRM] Model loaded successfully. Available expressions:",
|
|
79
|
-
Object.keys(((f = e.expressionManager) == null ? void 0 : f.expressionMap) || {})
|
|
80
|
-
), e.scene.traverse((y) => {
|
|
81
|
-
y.frustumCulled = !1;
|
|
82
|
-
});
|
|
83
|
-
const o = ((h = e.meta) == null ? void 0 : h.metaVersion) === "0";
|
|
84
|
-
e.scene.rotation.y = o ? Math.PI : 0;
|
|
85
|
-
}
|
|
86
|
-
}, [e, O]);
|
|
87
|
-
const x = c(0), m = c(0), u = c(0), A = c(0), z = c(0), v = c(0), M = c(Math.random() * 3 + 2), b = c(0), V = c(!1), P = c(null), S = c(null);
|
|
88
|
-
return oe((f, h) => {
|
|
89
|
-
var D, _, H, K, Y, T, X, G, J;
|
|
90
|
-
if (!e) return;
|
|
91
|
-
e.update(h);
|
|
92
|
-
const o = (D = e.humanoid) == null ? void 0 : D.getNormalizedBoneNode("neck"), y = (_ = e.humanoid) == null ? void 0 : _.getNormalizedBoneNode("head");
|
|
93
|
-
if (((H = e.meta) == null ? void 0 : H.metaVersion) === "0") {
|
|
94
|
-
const s = (K = e.humanoid) == null ? void 0 : K.getNormalizedBoneNode("leftUpperArm"), N = (Y = e.humanoid) == null ? void 0 : Y.getNormalizedBoneNode("rightUpperArm");
|
|
95
|
-
s && (s.rotation.z = Math.PI / 2.6), N && (N.rotation.z = -Math.PI / 2.6);
|
|
96
|
-
}
|
|
97
|
-
const ee = ((T = f.pointer) == null ? void 0 : T.x) ?? ((X = f.mouse) == null ? void 0 : X.x) ?? 0, re = ((G = f.pointer) == null ? void 0 : G.y) ?? ((J = f.mouse) == null ? void 0 : J.y) ?? 0, B = L ? 0 : U, I = ee * 0.35 * B, F = -re * 0.2 * B;
|
|
98
|
-
if (o && (o.rotation.y = n.MathUtils.lerp(o.rotation.y, I, 0.1), o.rotation.x = n.MathUtils.lerp(o.rotation.x, F, 0.1)), y && (y.rotation.y = n.MathUtils.lerp(y.rotation.y, I * 0.2, 0.1), y.rotation.x = n.MathUtils.lerp(y.rotation.x, F * 0.2, 0.1)), !L)
|
|
99
|
-
if (!V.current)
|
|
100
|
-
M.current -= h, M.current <= 0 && (V.current = !0);
|
|
101
|
-
else {
|
|
102
|
-
const s = 1e3 / (g || 100);
|
|
103
|
-
b.current += h * s * 2, b.current >= 1 && (b.current = 1, V.current = !1, M.current = Math.random() * ((E - i) / 1e3) + i / 1e3);
|
|
104
|
-
}
|
|
105
|
-
if (!V.current && b.current > 0) {
|
|
106
|
-
const s = 1e3 / (g || 100);
|
|
107
|
-
b.current -= h * s * 2, b.current < 0 && (b.current = 0);
|
|
108
|
-
}
|
|
109
|
-
if (e.expressionManager) {
|
|
110
|
-
d(e, "blink", b.current);
|
|
111
|
-
let s = 0, N = 0, W = 0;
|
|
112
|
-
if (t === "listening" ? (s = 0.35, N = 0.2) : t === "thinking" ? (W = 0.25, N = 0.15, o && (o.rotation.y = n.MathUtils.lerp(o.rotation.y, -0.18, 0.05), o.rotation.x = n.MathUtils.lerp(o.rotation.x, 0.12, 0.05))) : t === "speaking" ? s = 0.15 : s = 0.05, A.current = n.MathUtils.lerp(A.current, s, 0.1), z.current = n.MathUtils.lerp(z.current, N, 0.1), v.current = n.MathUtils.lerp(v.current, W, 0.1), d(e, "happy", A.current), d(e, "relaxed", z.current), d(e, "sad", v.current), t === "speaking") {
|
|
113
|
-
(!P.current || S.current !== p) && (P.current = de(p), S.current = p);
|
|
114
|
-
const R = P.current.read(), j = k / 30;
|
|
115
|
-
let Z = 0, $ = 0, q = 0;
|
|
116
|
-
R.shape === "e" ? $ = R.level * 0.8 * j : R.shape === "o" ? q = R.level * 0.8 * j : R.shape === "a" && (Z = R.level * 0.95 * j), x.current = n.MathUtils.lerp(x.current, Z, 0.25), m.current = n.MathUtils.lerp(m.current, $, 0.25), u.current = n.MathUtils.lerp(u.current, q, 0.25), d(e, "aa", x.current), d(e, "ee", m.current), d(e, "oo", u.current);
|
|
117
|
-
} else
|
|
118
|
-
x.current = n.MathUtils.lerp(x.current, 0, 0.2), m.current = n.MathUtils.lerp(m.current, 0, 0.2), u.current = n.MathUtils.lerp(u.current, 0, 0.2), d(e, "aa", x.current), d(e, "ee", m.current), d(e, "oo", u.current);
|
|
119
|
-
e.expressionManager.update();
|
|
120
|
-
}
|
|
121
|
-
}), e ? /* @__PURE__ */ a("primitive", { object: e.scene }) : null;
|
|
122
|
-
}
|
|
123
|
-
function Ee({
|
|
124
|
-
state: l,
|
|
125
|
-
analyser: t,
|
|
126
|
-
size: p = 300,
|
|
127
|
-
className: k = "",
|
|
128
|
-
style: U,
|
|
129
|
-
maxMouthOpening: i,
|
|
130
|
-
blinkIntervalMin: E,
|
|
131
|
-
blinkIntervalMax: g,
|
|
132
|
-
blinkDuration: L,
|
|
133
|
-
mouseTrackingIntensity: O,
|
|
134
|
-
stateColors: r,
|
|
135
|
-
vrmUrl: e
|
|
136
|
-
}) {
|
|
137
|
-
const [x, m] = Q(!1), [u, A] = Q(null), z = ue();
|
|
138
|
-
C(() => {
|
|
139
|
-
m(!1), A(null);
|
|
140
|
-
}, [e]);
|
|
141
|
-
const v = {
|
|
142
|
-
idle: (r == null ? void 0 : r.idle) ?? "#4b5563",
|
|
143
|
-
listening: (r == null ? void 0 : r.listening) ?? "#3b82f6",
|
|
144
|
-
thinking: (r == null ? void 0 : r.thinking) ?? "#8b5cf6",
|
|
145
|
-
speaking: (r == null ? void 0 : r.speaking) ?? "#10b981",
|
|
146
|
-
working: (r == null ? void 0 : r.working) ?? "#f59e0b"
|
|
147
|
-
};
|
|
148
|
-
return /* @__PURE__ */ w(
|
|
149
|
-
"div",
|
|
150
|
-
{
|
|
151
|
-
className: `relative flex items-center justify-center rounded-3xl overflow-hidden border border-zinc-800/40 bg-zinc-950/40 ${k}`,
|
|
152
|
-
style: { width: p, height: p, ...U },
|
|
153
|
-
children: [
|
|
154
|
-
/* @__PURE__ */ w(
|
|
155
|
-
ae,
|
|
156
|
-
{
|
|
157
|
-
camera: { position: [0, 1.43, 0.88], fov: 44 },
|
|
158
|
-
shadows: !0,
|
|
159
|
-
gl: { antialias: !0, alpha: !0, preserveDrawingBuffer: !0 },
|
|
160
|
-
style: { width: "100%", height: "100%", background: "transparent" },
|
|
161
|
-
children: [
|
|
162
|
-
/* @__PURE__ */ a("ambientLight", { intensity: 1.5 }),
|
|
163
|
-
/* @__PURE__ */ a(
|
|
164
|
-
"spotLight",
|
|
165
|
-
{
|
|
166
|
-
position: [0, 3, 2],
|
|
167
|
-
angle: 0.6,
|
|
168
|
-
penumbra: 1,
|
|
169
|
-
intensity: 3,
|
|
170
|
-
color: v[l],
|
|
171
|
-
castShadow: !0
|
|
172
|
-
}
|
|
173
|
-
),
|
|
174
|
-
/* @__PURE__ */ a("directionalLight", { position: [-2, 2, -2], intensity: 1.8, color: "#ffffff" }),
|
|
175
|
-
/* @__PURE__ */ a("directionalLight", { position: [2, 2, 2], intensity: 2.2, color: "#ffffff" }),
|
|
176
|
-
/* @__PURE__ */ a(pe, { onError: (M) => A(M), children: e && /* @__PURE__ */ a(ne, { fallback: null, children: /* @__PURE__ */ a(
|
|
177
|
-
me,
|
|
178
|
-
{
|
|
179
|
-
url: e,
|
|
180
|
-
state: l,
|
|
181
|
-
analyser: t,
|
|
182
|
-
maxMouthOpening: i,
|
|
183
|
-
mouseTrackingIntensity: O,
|
|
184
|
-
blinkIntervalMin: E,
|
|
185
|
-
blinkIntervalMax: g,
|
|
186
|
-
blinkDuration: L,
|
|
187
|
-
reducedMotion: z,
|
|
188
|
-
onLoaded: (M) => m(M)
|
|
189
|
-
}
|
|
190
|
-
) }) }),
|
|
191
|
-
/* @__PURE__ */ a(
|
|
192
|
-
le,
|
|
193
|
-
{
|
|
194
|
-
enableZoom: !1,
|
|
195
|
-
enablePan: !1,
|
|
196
|
-
minPolarAngle: Math.PI / 2.6,
|
|
197
|
-
maxPolarAngle: Math.PI / 1.7,
|
|
198
|
-
minAzimuthAngle: -Math.PI / 4,
|
|
199
|
-
maxAzimuthAngle: Math.PI / 4,
|
|
200
|
-
target: [0, 1.38, 0]
|
|
201
|
-
}
|
|
202
|
-
)
|
|
203
|
-
]
|
|
204
|
-
}
|
|
205
|
-
),
|
|
206
|
-
!e && /* @__PURE__ */ w("div", { className: "absolute inset-0 flex flex-col items-center justify-center bg-zinc-950/90 backdrop-blur-md z-20 p-4 text-center", children: [
|
|
207
|
-
/* @__PURE__ */ a("span", { className: "text-xs font-mono font-bold text-amber-400 uppercase tracking-wider mb-2", children: "Missing vrmUrl" }),
|
|
208
|
-
/* @__PURE__ */ a("p", { className: "text-[10px] text-zinc-500 max-w-[200px] leading-relaxed", children: "Pass a CORS-enabled .vrm URL via the vrmUrl prop." })
|
|
209
|
-
] }),
|
|
210
|
-
e && !x && !u && /* @__PURE__ */ w("div", { className: "absolute inset-0 flex flex-col items-center justify-center bg-zinc-950/80 backdrop-blur-md z-20", children: [
|
|
211
|
-
/* @__PURE__ */ a("div", { className: "w-10 h-10 border-4 border-t-emerald-500 border-emerald-500/20 rounded-full animate-spin mb-3" }),
|
|
212
|
-
/* @__PURE__ */ a("span", { className: "text-[10px] font-mono font-bold tracking-widest text-zinc-400 animate-pulse", children: "LOADING NEURAL VRM MODEL..." })
|
|
213
|
-
] }),
|
|
214
|
-
u && /* @__PURE__ */ w("div", { className: "absolute inset-0 flex flex-col items-center justify-center bg-zinc-950/90 backdrop-blur-md z-20 p-4 text-center", children: [
|
|
215
|
-
/* @__PURE__ */ a("span", { className: "text-xs font-mono font-bold text-red-400 uppercase tracking-wider mb-2", children: "Failed to load VRM" }),
|
|
216
|
-
/* @__PURE__ */ a("p", { className: "text-[10px] text-zinc-500 max-w-[200px] leading-relaxed break-all", children: u })
|
|
217
|
-
] })
|
|
218
|
-
]
|
|
219
|
-
}
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
export {
|
|
223
|
-
Ee as VrmAvatar
|
|
224
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),n=require("react"),P=require("@react-three/fiber"),te=require("three/addons/loaders/GLTFLoader.js"),re=require("@pixiv/three-vrm"),ne=require("@react-three/drei"),ae=require("three"),Q=require("./useReducedMotion-BRDEmRNI.cjs");function ie(a){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const o in a)if(o!=="default"){const p=Object.getOwnPropertyDescriptor(a,o);Object.defineProperty(r,o,p.get?p:{enumerable:!0,get:()=>a[o]})}}return r.default=a,Object.freeze(r)}const s=ie(ae);class se extends n.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(r){this.props.onError((r==null?void 0:r.message)||String(r))}render(){return this.state.hasError?null:this.props.children}}function f(a,r,o){if(!a.expressionManager)return;const p=a.expressionManager.expressionMap||{},N=Object.keys(p);let c=[];switch(r){case"blink":c=["blink","Blink","BLINK"];break;case"aa":c=["aa","Aa","a","A","AA","mouth_a","mouth_A"];break;case"ee":c=["ee","Ee","e","E","EE","mouth_e","mouth_E"];break;case"oo":c=["oh","Oh","oo","Oo","o","O","OO","mouth_o","mouth_O"];break;case"happy":c=["happy","Happy","joy","Joy","JOY","fun","Fun","FUN","HAPPY"];break;case"sad":c=["sad","Sad","sorrow","Sorrow","SORROW","sadness","SAD"];break;case"relaxed":c=["relaxed","Relaxed","fun","Fun","FUN","neutral","Neutral","RELAXED"];break}const R=c.find(g=>p[g]!==void 0||N.includes(g));if(R)a.expressionManager.setValue(R,o);else try{a.expressionManager.setValue(c[0],o)}catch{}}function oe({url:a,state:r,analyser:o,maxMouthOpening:p=30,mouseTrackingIntensity:N=1,blinkIntervalMin:c=2e3,blinkIntervalMax:R=6e3,blinkDuration:g=100,reducedMotion:U=!1,onLoaded:z}){const e=P.useLoader(te.GLTFLoader,a,m=>{m.register(x=>new re.VRMLoaderPlugin(x))}).userData.vrm;n.useEffect(()=>{var m,x;if(e){z(!0),console.log("[VRM] Model loaded successfully. Available expressions:",Object.keys(((m=e.expressionManager)==null?void 0:m.expressionMap)||{})),e.scene.traverse(j=>{j.frustumCulled=!1});const l=((x=e.meta)==null?void 0:x.metaVersion)==="0";e.scene.rotation.y=l?Math.PI:0}},[e,z]);const b=n.useRef(0),h=n.useRef(0),d=n.useRef(0),k=n.useRef(0),O=n.useRef(0),v=n.useRef(0),y=n.useRef(Math.random()*3+2),M=n.useRef(0),w=n.useRef(!1),L=n.useRef(null),S=n.useRef(null);return P.useFrame((m,x)=>{var F,I,q,T,H,K,Y,G,X;if(!e)return;e.update(x);const l=(F=e.humanoid)==null?void 0:F.getNormalizedBoneNode("neck"),j=(I=e.humanoid)==null?void 0:I.getNormalizedBoneNode("head");if(((q=e.meta)==null?void 0:q.metaVersion)==="0"){const u=(T=e.humanoid)==null?void 0:T.getNormalizedBoneNode("leftUpperArm"),E=(H=e.humanoid)==null?void 0:H.getNormalizedBoneNode("rightUpperArm");u&&(u.rotation.z=Math.PI/2.6),E&&(E.rotation.z=-Math.PI/2.6)}const C=((K=m.pointer)==null?void 0:K.x)??((Y=m.mouse)==null?void 0:Y.x)??0,ee=((G=m.pointer)==null?void 0:G.y)??((X=m.mouse)==null?void 0:X.y)??0,_=U?0:N,B=C*.35*_,D=-ee*.2*_;if(l&&(l.rotation.y=s.MathUtils.lerp(l.rotation.y,B,.1),l.rotation.x=s.MathUtils.lerp(l.rotation.x,D,.1)),j&&(j.rotation.y=s.MathUtils.lerp(j.rotation.y,B*.2,.1),j.rotation.x=s.MathUtils.lerp(j.rotation.x,D*.2,.1)),!U)if(!w.current)y.current-=x,y.current<=0&&(w.current=!0);else{const u=1e3/(g||100);M.current+=x*u*2,M.current>=1&&(M.current=1,w.current=!1,y.current=Math.random()*((R-c)/1e3)+c/1e3)}if(!w.current&&M.current>0){const u=1e3/(g||100);M.current-=x*u*2,M.current<0&&(M.current=0)}if(e.expressionManager){f(e,"blink",M.current);let u=0,E=0,J=0;if(r==="listening"?(u=.35,E=.2):r==="thinking"?(J=.25,E=.15,l&&(l.rotation.y=s.MathUtils.lerp(l.rotation.y,-.18,.05),l.rotation.x=s.MathUtils.lerp(l.rotation.x,.12,.05))):r==="speaking"?u=.15:u=.05,k.current=s.MathUtils.lerp(k.current,u,.1),O.current=s.MathUtils.lerp(O.current,E,.1),v.current=s.MathUtils.lerp(v.current,J,.1),f(e,"happy",k.current),f(e,"relaxed",O.current),f(e,"sad",v.current),r==="speaking"){(!L.current||S.current!==o)&&(L.current=Q.createMouthEngine(o),S.current=o);const A=L.current.read(),V=p/30;let W=0,Z=0,$=0;A.shape==="e"?Z=A.level*.8*V:A.shape==="o"?$=A.level*.8*V:A.shape==="a"&&(W=A.level*.95*V),b.current=s.MathUtils.lerp(b.current,W,.25),h.current=s.MathUtils.lerp(h.current,Z,.25),d.current=s.MathUtils.lerp(d.current,$,.25),f(e,"aa",b.current),f(e,"ee",h.current),f(e,"oo",d.current)}else b.current=s.MathUtils.lerp(b.current,0,.2),h.current=s.MathUtils.lerp(h.current,0,.2),d.current=s.MathUtils.lerp(d.current,0,.2),f(e,"aa",b.current),f(e,"ee",h.current),f(e,"oo",d.current);e.expressionManager.update()}}),e?t.jsx("primitive",{object:e.scene}):null}function ce({state:a,analyser:r,size:o=300,className:p="",style:N,maxMouthOpening:c,blinkIntervalMin:R,blinkIntervalMax:g,blinkDuration:U,mouseTrackingIntensity:z,stateColors:i,vrmUrl:e}){const[b,h]=n.useState(!1),[d,k]=n.useState(null),O=Q.useReducedMotion();n.useEffect(()=>{h(!1),k(null)},[e]);const v={idle:(i==null?void 0:i.idle)??"#4b5563",listening:(i==null?void 0:i.listening)??"#3b82f6",thinking:(i==null?void 0:i.thinking)??"#8b5cf6",speaking:(i==null?void 0:i.speaking)??"#10b981",working:(i==null?void 0:i.working)??"#f59e0b"};return t.jsxs("div",{className:`relative flex items-center justify-center rounded-3xl overflow-hidden border border-zinc-800/40 bg-zinc-950/40 ${p}`,style:{width:o,height:o,...N},children:[t.jsxs(P.Canvas,{camera:{position:[0,1.43,.88],fov:44},shadows:!0,gl:{antialias:!0,alpha:!0,preserveDrawingBuffer:!0},style:{width:"100%",height:"100%",background:"transparent"},children:[t.jsx("ambientLight",{intensity:1.5}),t.jsx("spotLight",{position:[0,3,2],angle:.6,penumbra:1,intensity:3,color:v[a],castShadow:!0}),t.jsx("directionalLight",{position:[-2,2,-2],intensity:1.8,color:"#ffffff"}),t.jsx("directionalLight",{position:[2,2,2],intensity:2.2,color:"#ffffff"}),t.jsx(se,{onError:y=>k(y),children:e&&t.jsx(n.Suspense,{fallback:null,children:t.jsx(oe,{url:e,state:a,analyser:r,maxMouthOpening:c,mouseTrackingIntensity:z,blinkIntervalMin:R,blinkIntervalMax:g,blinkDuration:U,reducedMotion:O,onLoaded:y=>h(y)})})}),t.jsx(ne.OrbitControls,{enableZoom:!1,enablePan:!1,minPolarAngle:Math.PI/2.6,maxPolarAngle:Math.PI/1.7,minAzimuthAngle:-Math.PI/4,maxAzimuthAngle:Math.PI/4,target:[0,1.38,0]})]}),!e&&t.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-zinc-950/90 backdrop-blur-md z-20 p-4 text-center",children:[t.jsx("span",{className:"text-xs font-mono font-bold text-amber-400 uppercase tracking-wider mb-2",children:"Missing vrmUrl"}),t.jsx("p",{className:"text-[10px] text-zinc-500 max-w-[200px] leading-relaxed",children:"Pass a CORS-enabled .vrm URL via the vrmUrl prop."})]}),e&&!b&&!d&&t.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-zinc-950/80 backdrop-blur-md z-20",children:[t.jsx("div",{className:"w-10 h-10 border-4 border-t-emerald-500 border-emerald-500/20 rounded-full animate-spin mb-3"}),t.jsx("span",{className:"text-[10px] font-mono font-bold tracking-widest text-zinc-400 animate-pulse",children:"LOADING NEURAL VRM MODEL..."})]}),d&&t.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-zinc-950/90 backdrop-blur-md z-20 p-4 text-center",children:[t.jsx("span",{className:"text-xs font-mono font-bold text-red-400 uppercase tracking-wider mb-2",children:"Failed to load VRM"}),t.jsx("p",{className:"text-[10px] text-zinc-500 max-w-[200px] leading-relaxed break-all",children:d})]})]})}exports.VrmAvatar=ce;
|