@gui-chat-plugin/avatar 0.0.1 → 0.0.3
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/dist/react.cjs +2 -2
- package/dist/react.js +106 -115
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +110 -125
- package/package.json +2 -2
package/dist/react.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("./three-vrm.module-FTOSkzpf.cjs"),B=require("./core.cjs"),a=require("react");var X={exports:{}},Y={};var K;function ie(){if(K)return Y;K=1;var d=Symbol.for("react.transitional.element"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("./three-vrm.module-FTOSkzpf.cjs"),B=require("./core.cjs"),a=require("react");var X={exports:{}},Y={};var K;function ie(){if(K)return Y;K=1;var d=Symbol.for("react.transitional.element"),R=Symbol.for("react.fragment");function l(P,u,g){var S=null;if(g!==void 0&&(S=""+g),u.key!==void 0&&(S=""+u.key),"key"in u){g={};for(var E in u)E!=="key"&&(g[E]=u[E])}else g=u;return u=g.ref,{$$typeof:d,type:P,key:S,ref:u!==void 0?u:null,props:g}}return Y.Fragment=R,Y.jsx=l,Y.jsxs=l,Y}var $={};var ee;function se(){return ee||(ee=1,process.env.NODE_ENV!=="production"&&(function(){function d(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case y:return"Fragment";case q:return"Profiler";case U:return"StrictMode";case h:return"Suspense";case C:return"SuspenseList";case o:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case W:return"Portal";case c:return e.displayName||"Context";case G:return(e._context.displayName||"Context")+".Consumer";case m:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case t:return r=e.displayName||null,r!==null?r:d(e.type)||"Memo";case j:r=e._payload,e=e._init;try{return d(e(r))}catch{}}return null}function R(e){return""+e}function l(e){try{R(e);var r=!1}catch{r=!0}if(r){r=console;var n=r.error,i=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",i),R(e)}}function P(e){if(e===y)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===j)return"<...>";try{var r=d(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function u(){var e=M.A;return e===null?null:e.getOwner()}function g(){return Error("react-stack-top-frame")}function S(e){if(b.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function E(e,r){function n(){N||(N=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function x(){var e=d(this.type);return _[e]||(_[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function f(e,r,n,i,J,H){var s=n.ref;return e={$$typeof:I,type:e,key:r,props:n,_owner:i},(s!==void 0?s:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:x}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:H}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function A(e,r,n,i,J,H){var s=r.children;if(s!==void 0)if(i)if(L(s)){for(i=0;i<s.length;i++)V(s[i]);Object.freeze&&Object.freeze(s)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else V(s);if(b.call(r,"key")){s=d(e);var D=Object.keys(r).filter(function(ae){return ae!=="key"});i=0<D.length?"{key: someKey, "+D.join(": ..., ")+": ...}":"{key: someKey}",F[s+i]||(D=0<D.length?"{"+D.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,i,s,
|
|
6
|
+
<%s key={someKey} {...props} />`,i,s,D,s),F[s+i]=!0)}if(s=null,n!==void 0&&(l(n),s=""+n),S(r)&&(l(r.key),s=""+r.key),"key"in r){n={};for(var Z in r)Z!=="key"&&(n[Z]=r[Z])}else n=r;return s&&E(n,typeof e=="function"?e.displayName||e.name||"Unknown":e),f(e,s,n,u(),J,H)}function V(e){z(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===j&&(e._payload.status==="fulfilled"?z(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function z(e){return typeof e=="object"&&e!==null&&e.$$typeof===I}var O=a,I=Symbol.for("react.transitional.element"),W=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),G=Symbol.for("react.consumer"),c=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),t=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),o=Symbol.for("react.activity"),Q=Symbol.for("react.client.reference"),M=O.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,b=Object.prototype.hasOwnProperty,L=Array.isArray,k=console.createTask?console.createTask:function(){return null};O={react_stack_bottom_frame:function(e){return e()}};var N,_={},w=O.react_stack_bottom_frame.bind(O,g)(),T=k(P(g)),F={};$.Fragment=y,$.jsx=function(e,r,n){var i=1e4>M.recentlyCreatedOwnerStacks++;return A(e,r,n,!1,i?Error("react-stack-top-frame"):w,i?k(P(e)):T)},$.jsxs=function(e,r,n){var i=1e4>M.recentlyCreatedOwnerStacks++;return A(e,r,n,!0,i?Error("react-stack-top-frame"):w,i?k(P(e)):T)}})()),$}var re;function le(){return re||(re=1,process.env.NODE_ENV==="production"?X.exports=ie():X.exports=se()),X.exports}var p=le();function te({selectedResult:d,isAudioPlaying:R}){const l=a.useRef(null),[P,u]=a.useState(!1),[g,S]=a.useState(null),E=a.useRef(null),x=a.useRef(null),f=a.useRef(null),A=a.useRef(null),V=a.useRef(null),z=a.useRef(null),O=a.useRef(0),I=a.useRef(R);a.useEffect(()=>{I.current=R},[R]);const W=a.useCallback(()=>{if(!l.current)return;const c=l.current,m=c.clientWidth,h=c.clientHeight;E.current=new v.Scene,x.current=new v.PerspectiveCamera(30,m/h,.1,100),x.current.position.set(0,1.3,1.5),x.current.lookAt(0,1.2,0),f.current=new v.WebGLRenderer({antialias:!0,alpha:!0}),f.current.setSize(m,h),f.current.setPixelRatio(window.devicePixelRatio),f.current.outputColorSpace=v.SRGBColorSpace,c.appendChild(f.current.domElement);const C=new v.AmbientLight(16777215,.6);E.current.add(C);const t=new v.DirectionalLight(16777215,.8);t.position.set(1,1,1),E.current.add(t),V.current=new v.Clock},[]),y=a.useCallback(()=>{if(!l.current||!x.current||!f.current)return;const c=l.current.clientWidth,m=l.current.clientHeight;x.current.aspect=c/m,x.current.updateProjectionMatrix(),f.current.setSize(c,m)},[]),U=a.useCallback(()=>{z.current=requestAnimationFrame(U);const c=V.current,m=f.current,h=E.current,C=x.current,t=A.current;if(!c||!m||!h||!C)return;const j=c.getDelta(),o=c.getElapsedTime();if(t){if(t.update(j),I.current){O.current+=j*10;const M=(Math.sin(O.current)+1)*.3;t.expressionManager?.setValue(v.VRMExpressionPresetName.Aa,M);const b=t.humanoid?.getNormalizedBoneNode("head"),L=t.humanoid?.getNormalizedBoneNode("neck"),k=t.humanoid?.getNormalizedBoneNode("spine");b&&(b.rotation.x=Math.sin(o*2)*.08,b.rotation.z=Math.sin(o*1.5)*.05),L&&(L.rotation.y=Math.sin(o*.8)*.05),k&&(k.rotation.z=Math.sin(o*.5)*.03);const N=t.humanoid?.getNormalizedBoneNode("leftShoulder"),_=t.humanoid?.getNormalizedBoneNode("rightShoulder"),w=t.humanoid?.getNormalizedBoneNode("leftUpperArm"),T=t.humanoid?.getNormalizedBoneNode("rightUpperArm"),F=t.humanoid?.getNormalizedBoneNode("leftLowerArm"),e=t.humanoid?.getNormalizedBoneNode("rightLowerArm");N&&(N.rotation.z=.1),_&&(_.rotation.z=-.1),w&&(w.rotation.z=-.8+Math.sin(o*1.2)*.1,w.rotation.x=.4+Math.sin(o*.9)*.15,w.rotation.y=Math.sin(o*.7)*.1),T&&(T.rotation.z=.8+Math.sin(o*1.3)*.1,T.rotation.x=.4+Math.sin(o*1)*.15,T.rotation.y=Math.sin(o*.8)*.1),F&&(F.rotation.y=-1-Math.sin(o*1.5)*.2,F.rotation.z=Math.sin(o*1.1)*.1),e&&(e.rotation.y=1+Math.sin(o*1.4)*.2,e.rotation.z=Math.sin(o*1.2)*.1)}else{O.current=0,t.expressionManager?.setValue(v.VRMExpressionPresetName.Aa,0);const M=t.humanoid?.getNormalizedBoneNode("spine"),b=t.humanoid?.getNormalizedBoneNode("head");M&&(M.rotation.x=Math.sin(o*.8)*.02),b&&(b.rotation.x=Math.sin(o*.3)*.03,b.rotation.z=Math.sin(o*.2)*.02);const L=t.humanoid?.getNormalizedBoneNode("leftShoulder"),k=t.humanoid?.getNormalizedBoneNode("rightShoulder"),N=t.humanoid?.getNormalizedBoneNode("leftUpperArm"),_=t.humanoid?.getNormalizedBoneNode("rightUpperArm"),w=t.humanoid?.getNormalizedBoneNode("leftLowerArm"),T=t.humanoid?.getNormalizedBoneNode("rightLowerArm");L&&(L.rotation.z=.1),k&&(k.rotation.z=-.1),N&&(N.rotation.z=-.9,N.rotation.x=.2,N.rotation.y=0),_&&(_.rotation.z=.9,_.rotation.x=.2,_.rotation.y=0),w&&(w.rotation.y=-.8),T&&(T.rotation.y=.8)}o%4<.1?t.expressionManager?.setValue(v.VRMExpressionPresetName.Blink,1):t.expressionManager?.setValue(v.VRMExpressionPresetName.Blink,0)}m.render(h,C)},[]),q=a.useCallback(async c=>{const m=E.current;if(m){u(!0),S(null),A.current&&(m.remove(A.current.scene),A.current=null);try{const h=new v.GLTFLoader;h.register(j=>new v.VRMLoaderPlugin(j));const t=(await h.loadAsync(c)).userData.vrm;if(!t)throw new Error("Failed to load VRM data");m.add(t.scene),A.current=t,u(!1)}catch(h){console.error("Failed to load VRM:",h),S(`Failed to load avatar: ${h instanceof Error?h.message:"Unknown error"}`),u(!1)}}},[]),G=a.useCallback(()=>{z.current!==null&&(cancelAnimationFrame(z.current),z.current=null),window.removeEventListener("resize",y),f.current&&l.current&&(l.current.removeChild(f.current.domElement),f.current.dispose(),f.current=null),A.current=null,E.current=null,x.current=null,V.current=null},[y]);return a.useEffect(()=>(W(),window.addEventListener("resize",y),U(),()=>{G()}),[W,y,U,G]),a.useEffect(()=>{if(d?.toolName===B.TOOL_NAME&&d.data){const c=d.data;c.avatarUrl&&q(c.avatarUrl)}},[d,q]),p.jsxs("div",{className:"w-full h-full bg-gradient-to-b from-slate-800 to-slate-900 relative",children:[p.jsx("div",{ref:l,className:"w-full h-full"}),P&&p.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-slate-900/80",children:p.jsx("div",{className:"text-white text-lg",children:"Loading Avatar..."})}),g&&p.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-slate-900/80",children:p.jsx("div",{className:"text-red-400 text-lg text-center p-4",children:g})}),R&&p.jsx("div",{className:"absolute top-4 right-4 px-3 py-1 bg-green-600 text-white text-sm rounded-full",children:"Speaking..."})]})}function ne({result:d}){const l=d.data?.emotion||"neutral";return p.jsx("div",{className:"p-3 bg-gradient-to-br from-slate-700 to-slate-800 rounded-md",children:p.jsxs("div",{className:"flex flex-col items-center gap-2",children:[p.jsx("div",{className:"w-12 h-12 bg-slate-600 rounded-full flex items-center justify-center",children:p.jsx("svg",{className:"w-8 h-8 text-slate-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}),p.jsx("div",{className:"text-sm font-semibold text-white text-center",children:"3D Avatar"}),l!=="neutral"&&p.jsx("div",{className:"text-xs px-2 py-0.5 bg-blue-500 text-white rounded-full",children:l})]})})}const oe={...B.pluginCore,ViewComponent:te,PreviewComponent:ne},ce={plugin:oe};exports.SAMPLES=B.SAMPLES;exports.TOOL_DEFINITION=B.TOOL_DEFINITION;exports.TOOL_NAME=B.TOOL_NAME;exports.executeAvatar=B.executeAvatar;exports.pluginCore=B.pluginCore;exports.Preview=ne;exports.View=te;exports.default=ce;exports.plugin=oe;
|
package/dist/react.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { S as ae, P as ie, W as se, a as le, A as ce, D as ue, C as de, b as J, G as fe, V as me } from "./three-vrm.module-DJ7DURJm.js";
|
|
2
2
|
import { TOOL_NAME as he, pluginCore as pe } from "./core.js";
|
|
3
3
|
import { SAMPLES as ye, TOOL_DEFINITION as je, executeAvatar as Oe } from "./core.js";
|
|
4
|
-
import ge, { useRef as
|
|
5
|
-
var X = { exports: {} },
|
|
4
|
+
import ge, { useRef as T, useState as ee, useEffect as Q, useCallback as V } from "react";
|
|
5
|
+
var X = { exports: {} }, Y = {};
|
|
6
6
|
var re;
|
|
7
7
|
function ve() {
|
|
8
|
-
if (re) return
|
|
8
|
+
if (re) return Y;
|
|
9
9
|
re = 1;
|
|
10
|
-
var u = /* @__PURE__ */ Symbol.for("react.transitional.element"),
|
|
10
|
+
var u = /* @__PURE__ */ Symbol.for("react.transitional.element"), v = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
11
11
|
function s(P, c, p) {
|
|
12
|
-
var
|
|
13
|
-
if (p !== void 0 && (
|
|
12
|
+
var k = null;
|
|
13
|
+
if (p !== void 0 && (k = "" + p), c.key !== void 0 && (k = "" + c.key), "key" in c) {
|
|
14
14
|
p = {};
|
|
15
15
|
for (var g in c)
|
|
16
16
|
g !== "key" && (p[g] = c[g]);
|
|
@@ -18,14 +18,14 @@ function ve() {
|
|
|
18
18
|
return c = p.ref, {
|
|
19
19
|
$$typeof: u,
|
|
20
20
|
type: P,
|
|
21
|
-
key:
|
|
21
|
+
key: k,
|
|
22
22
|
ref: c !== void 0 ? c : null,
|
|
23
23
|
props: p
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
return
|
|
26
|
+
return Y.Fragment = v, Y.jsx = s, Y.jsxs = s, Y;
|
|
27
27
|
}
|
|
28
|
-
var
|
|
28
|
+
var I = {};
|
|
29
29
|
var te;
|
|
30
30
|
function xe() {
|
|
31
31
|
return te || (te = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
@@ -35,7 +35,7 @@ function xe() {
|
|
|
35
35
|
return e.$$typeof === K ? null : e.displayName || e.name || null;
|
|
36
36
|
if (typeof e == "string") return e;
|
|
37
37
|
switch (e) {
|
|
38
|
-
case
|
|
38
|
+
case y:
|
|
39
39
|
return "Fragment";
|
|
40
40
|
case W:
|
|
41
41
|
return "Profiler";
|
|
@@ -43,9 +43,9 @@ function xe() {
|
|
|
43
43
|
return "StrictMode";
|
|
44
44
|
case m:
|
|
45
45
|
return "Suspense";
|
|
46
|
-
case
|
|
46
|
+
case z:
|
|
47
47
|
return "SuspenseList";
|
|
48
|
-
case
|
|
48
|
+
case o:
|
|
49
49
|
return "Activity";
|
|
50
50
|
}
|
|
51
51
|
if (typeof e == "object")
|
|
@@ -63,7 +63,7 @@ function xe() {
|
|
|
63
63
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
64
64
|
case t:
|
|
65
65
|
return r = e.displayName || null, r !== null ? r : u(e.type) || "Memo";
|
|
66
|
-
case
|
|
66
|
+
case j:
|
|
67
67
|
r = e._payload, e = e._init;
|
|
68
68
|
try {
|
|
69
69
|
return u(e(r));
|
|
@@ -72,29 +72,29 @@ function xe() {
|
|
|
72
72
|
}
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function v(e) {
|
|
76
76
|
return "" + e;
|
|
77
77
|
}
|
|
78
78
|
function s(e) {
|
|
79
79
|
try {
|
|
80
|
-
|
|
80
|
+
v(e);
|
|
81
81
|
var r = !1;
|
|
82
82
|
} catch {
|
|
83
83
|
r = !0;
|
|
84
84
|
}
|
|
85
85
|
if (r) {
|
|
86
86
|
r = console;
|
|
87
|
-
var
|
|
88
|
-
return
|
|
87
|
+
var n = r.error, a = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
88
|
+
return n.call(
|
|
89
89
|
r,
|
|
90
90
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
91
91
|
a
|
|
92
|
-
),
|
|
92
|
+
), v(e);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
function P(e) {
|
|
96
|
-
if (e ===
|
|
97
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
96
|
+
if (e === y) return "<>";
|
|
97
|
+
if (typeof e == "object" && e !== null && e.$$typeof === j)
|
|
98
98
|
return "<...>";
|
|
99
99
|
try {
|
|
100
100
|
var r = u(e);
|
|
@@ -104,48 +104,48 @@ function xe() {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
function c() {
|
|
107
|
-
var e =
|
|
107
|
+
var e = O.A;
|
|
108
108
|
return e === null ? null : e.getOwner();
|
|
109
109
|
}
|
|
110
110
|
function p() {
|
|
111
111
|
return Error("react-stack-top-frame");
|
|
112
112
|
}
|
|
113
|
-
function
|
|
114
|
-
if (
|
|
113
|
+
function k(e) {
|
|
114
|
+
if (E.call(e, "key")) {
|
|
115
115
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
116
116
|
if (r && r.isReactWarning) return !1;
|
|
117
117
|
}
|
|
118
118
|
return e.key !== void 0;
|
|
119
119
|
}
|
|
120
120
|
function g(e, r) {
|
|
121
|
-
function
|
|
122
|
-
|
|
121
|
+
function n() {
|
|
122
|
+
b || (b = !0, console.error(
|
|
123
123
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
124
124
|
r
|
|
125
125
|
));
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
get:
|
|
127
|
+
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
128
|
+
get: n,
|
|
129
129
|
configurable: !0
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function x() {
|
|
133
133
|
var e = u(this.type);
|
|
134
|
-
return
|
|
134
|
+
return R[e] || (R[e] = !0, console.error(
|
|
135
135
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
136
136
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
137
137
|
}
|
|
138
|
-
function d(e, r,
|
|
139
|
-
var i =
|
|
138
|
+
function d(e, r, n, a, q, H) {
|
|
139
|
+
var i = n.ref;
|
|
140
140
|
return e = {
|
|
141
141
|
$$typeof: F,
|
|
142
142
|
type: e,
|
|
143
143
|
key: r,
|
|
144
|
-
props:
|
|
144
|
+
props: n,
|
|
145
145
|
_owner: a
|
|
146
146
|
}, (i !== void 0 ? i : null) !== null ? Object.defineProperty(e, "ref", {
|
|
147
147
|
enumerable: !1,
|
|
148
|
-
get:
|
|
148
|
+
get: x
|
|
149
149
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
150
150
|
configurable: !1,
|
|
151
151
|
enumerable: !1,
|
|
@@ -168,11 +168,11 @@ function xe() {
|
|
|
168
168
|
value: H
|
|
169
169
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function w(e, r, n, a, q, H) {
|
|
172
172
|
var i = r.children;
|
|
173
173
|
if (i !== void 0)
|
|
174
174
|
if (a)
|
|
175
|
-
if (
|
|
175
|
+
if (C(i)) {
|
|
176
176
|
for (a = 0; a < i.length; a++)
|
|
177
177
|
L(i[a]);
|
|
178
178
|
Object.freeze && Object.freeze(i);
|
|
@@ -181,7 +181,7 @@ function xe() {
|
|
|
181
181
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
182
182
|
);
|
|
183
183
|
else L(i);
|
|
184
|
-
if (
|
|
184
|
+
if (E.call(r, "key")) {
|
|
185
185
|
i = u(e);
|
|
186
186
|
var D = Object.keys(r).filter(function(oe) {
|
|
187
187
|
return oe !== "key";
|
|
@@ -199,140 +199,131 @@ React keys must be passed directly to JSX without using spread:
|
|
|
199
199
|
i
|
|
200
200
|
), B[i + a] = !0);
|
|
201
201
|
}
|
|
202
|
-
if (i = null,
|
|
203
|
-
|
|
202
|
+
if (i = null, n !== void 0 && (s(n), i = "" + n), k(r) && (s(r.key), i = "" + r.key), "key" in r) {
|
|
203
|
+
n = {};
|
|
204
204
|
for (var Z in r)
|
|
205
|
-
Z !== "key" && (
|
|
206
|
-
} else
|
|
205
|
+
Z !== "key" && (n[Z] = r[Z]);
|
|
206
|
+
} else n = r;
|
|
207
207
|
return i && g(
|
|
208
|
-
|
|
208
|
+
n,
|
|
209
209
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
210
210
|
), d(
|
|
211
211
|
e,
|
|
212
212
|
i,
|
|
213
|
-
|
|
213
|
+
n,
|
|
214
214
|
c(),
|
|
215
215
|
q,
|
|
216
216
|
H
|
|
217
217
|
);
|
|
218
218
|
}
|
|
219
219
|
function L(e) {
|
|
220
|
-
|
|
220
|
+
M(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === j && (e._payload.status === "fulfilled" ? M(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function M(e) {
|
|
223
223
|
return typeof e == "object" && e !== null && e.$$typeof === F;
|
|
224
224
|
}
|
|
225
|
-
var
|
|
225
|
+
var S = ge, F = /* @__PURE__ */ Symbol.for("react.transitional.element"), $ = /* @__PURE__ */ Symbol.for("react.portal"), y = /* @__PURE__ */ Symbol.for("react.fragment"), U = /* @__PURE__ */ Symbol.for("react.strict_mode"), W = /* @__PURE__ */ Symbol.for("react.profiler"), G = /* @__PURE__ */ Symbol.for("react.consumer"), l = /* @__PURE__ */ Symbol.for("react.context"), f = /* @__PURE__ */ Symbol.for("react.forward_ref"), m = /* @__PURE__ */ Symbol.for("react.suspense"), z = /* @__PURE__ */ Symbol.for("react.suspense_list"), t = /* @__PURE__ */ Symbol.for("react.memo"), j = /* @__PURE__ */ Symbol.for("react.lazy"), o = /* @__PURE__ */ Symbol.for("react.activity"), K = /* @__PURE__ */ Symbol.for("react.client.reference"), O = S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, E = Object.prototype.hasOwnProperty, C = Array.isArray, A = console.createTask ? console.createTask : function() {
|
|
226
226
|
return null;
|
|
227
227
|
};
|
|
228
|
-
|
|
228
|
+
S = {
|
|
229
229
|
react_stack_bottom_frame: function(e) {
|
|
230
230
|
return e();
|
|
231
231
|
}
|
|
232
232
|
};
|
|
233
|
-
var
|
|
234
|
-
|
|
233
|
+
var b, R = {}, N = S.react_stack_bottom_frame.bind(
|
|
234
|
+
S,
|
|
235
235
|
p
|
|
236
|
-
)(),
|
|
237
|
-
|
|
238
|
-
var a = 1e4 >
|
|
239
|
-
return
|
|
236
|
+
)(), _ = A(P(p)), B = {};
|
|
237
|
+
I.Fragment = y, I.jsx = function(e, r, n) {
|
|
238
|
+
var a = 1e4 > O.recentlyCreatedOwnerStacks++;
|
|
239
|
+
return w(
|
|
240
240
|
e,
|
|
241
241
|
r,
|
|
242
|
-
|
|
242
|
+
n,
|
|
243
243
|
!1,
|
|
244
|
-
a ? Error("react-stack-top-frame") :
|
|
245
|
-
a ?
|
|
244
|
+
a ? Error("react-stack-top-frame") : N,
|
|
245
|
+
a ? A(P(e)) : _
|
|
246
246
|
);
|
|
247
|
-
},
|
|
248
|
-
var a = 1e4 >
|
|
249
|
-
return
|
|
247
|
+
}, I.jsxs = function(e, r, n) {
|
|
248
|
+
var a = 1e4 > O.recentlyCreatedOwnerStacks++;
|
|
249
|
+
return w(
|
|
250
250
|
e,
|
|
251
251
|
r,
|
|
252
|
-
|
|
252
|
+
n,
|
|
253
253
|
!0,
|
|
254
|
-
a ? Error("react-stack-top-frame") :
|
|
255
|
-
a ?
|
|
254
|
+
a ? Error("react-stack-top-frame") : N,
|
|
255
|
+
a ? A(P(e)) : _
|
|
256
256
|
);
|
|
257
257
|
};
|
|
258
|
-
})()),
|
|
258
|
+
})()), I;
|
|
259
259
|
}
|
|
260
260
|
var ne;
|
|
261
261
|
function Ee() {
|
|
262
262
|
return ne || (ne = 1, process.env.NODE_ENV === "production" ? X.exports = ve() : X.exports = xe()), X.exports;
|
|
263
263
|
}
|
|
264
264
|
var h = Ee();
|
|
265
|
-
function be({ selectedResult: u, isAudioPlaying:
|
|
266
|
-
const s =
|
|
265
|
+
function be({ selectedResult: u, isAudioPlaying: v }) {
|
|
266
|
+
const s = T(null), [P, c] = ee(!1), [p, k] = ee(null), g = T(null), x = T(null), d = T(null), w = T(null), L = T(null), M = T(null), S = T(0), F = T(v);
|
|
267
267
|
Q(() => {
|
|
268
|
-
F.current =
|
|
269
|
-
}, [
|
|
270
|
-
const $ =
|
|
268
|
+
F.current = v;
|
|
269
|
+
}, [v]);
|
|
270
|
+
const $ = V(() => {
|
|
271
271
|
if (!s.current) return;
|
|
272
272
|
const l = s.current, f = l.clientWidth, m = l.clientHeight;
|
|
273
|
-
g.current = new ae(),
|
|
274
|
-
const
|
|
275
|
-
g.current.add(
|
|
273
|
+
g.current = new ae(), x.current = new ie(30, f / m, 0.1, 100), x.current.position.set(0, 1.3, 1.5), x.current.lookAt(0, 1.2, 0), d.current = new se({ antialias: !0, alpha: !0 }), d.current.setSize(f, m), d.current.setPixelRatio(window.devicePixelRatio), d.current.outputColorSpace = le, l.appendChild(d.current.domElement);
|
|
274
|
+
const z = new ce(16777215, 0.6);
|
|
275
|
+
g.current.add(z);
|
|
276
276
|
const t = new ue(16777215, 0.8);
|
|
277
277
|
t.position.set(1, 1, 1), g.current.add(t), L.current = new de();
|
|
278
|
-
}, []),
|
|
279
|
-
if (!s.current || !
|
|
278
|
+
}, []), y = V(() => {
|
|
279
|
+
if (!s.current || !x.current || !d.current) return;
|
|
280
280
|
const l = s.current.clientWidth, f = s.current.clientHeight;
|
|
281
|
-
|
|
282
|
-
}, []), U =
|
|
283
|
-
|
|
284
|
-
const l = L.current, f = d.current, m = g.current,
|
|
285
|
-
if (!l || !f || !m || !
|
|
286
|
-
const
|
|
281
|
+
x.current.aspect = l / f, x.current.updateProjectionMatrix(), d.current.setSize(l, f);
|
|
282
|
+
}, []), U = V(() => {
|
|
283
|
+
M.current = requestAnimationFrame(U);
|
|
284
|
+
const l = L.current, f = d.current, m = g.current, z = x.current, t = w.current;
|
|
285
|
+
if (!l || !f || !m || !z) return;
|
|
286
|
+
const j = l.getDelta(), o = l.getElapsedTime();
|
|
287
287
|
if (t) {
|
|
288
|
-
if (t.update(
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
t.expressionManager?.setValue(J.Aa,
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
spine: !!b,
|
|
297
|
-
humanoid: !!t.humanoid
|
|
298
|
-
}), v && (v.rotation.x = Math.sin(n * 2) * 0.08, v.rotation.z = Math.sin(n * 1.5) * 0.05), M && (M.rotation.y = Math.sin(n * 0.8) * 0.05), b && (b.rotation.z = Math.sin(n * 0.5) * 0.03);
|
|
299
|
-
const R = t.humanoid?.getNormalizedBoneNode("leftShoulder"), N = t.humanoid?.getNormalizedBoneNode("rightShoulder"), _ = t.humanoid?.getNormalizedBoneNode("leftUpperArm"), w = t.humanoid?.getNormalizedBoneNode("rightUpperArm"), B = t.humanoid?.getNormalizedBoneNode("leftLowerArm"), e = t.humanoid?.getNormalizedBoneNode("rightLowerArm");
|
|
300
|
-
R && (R.rotation.z = 0.1), N && (N.rotation.z = -0.1), _ && (_.rotation.z = -0.8 + Math.sin(n * 1.2) * 0.1, _.rotation.x = 0.4 + Math.sin(n * 0.9) * 0.15, _.rotation.y = Math.sin(n * 0.7) * 0.1), w && (w.rotation.z = 0.8 + Math.sin(n * 1.3) * 0.1, w.rotation.x = 0.4 + Math.sin(n * 1) * 0.15, w.rotation.y = Math.sin(n * 0.8) * 0.1), B && (B.rotation.y = -1 - Math.sin(n * 1.5) * 0.2, B.rotation.z = Math.sin(n * 1.1) * 0.1), e && (e.rotation.y = 1 + Math.sin(n * 1.4) * 0.2, e.rotation.z = Math.sin(n * 1.2) * 0.1);
|
|
288
|
+
if (t.update(j), F.current) {
|
|
289
|
+
S.current += j * 10;
|
|
290
|
+
const O = (Math.sin(S.current) + 1) * 0.3;
|
|
291
|
+
t.expressionManager?.setValue(J.Aa, O);
|
|
292
|
+
const E = t.humanoid?.getNormalizedBoneNode("head"), C = t.humanoid?.getNormalizedBoneNode("neck"), A = t.humanoid?.getNormalizedBoneNode("spine");
|
|
293
|
+
E && (E.rotation.x = Math.sin(o * 2) * 0.08, E.rotation.z = Math.sin(o * 1.5) * 0.05), C && (C.rotation.y = Math.sin(o * 0.8) * 0.05), A && (A.rotation.z = Math.sin(o * 0.5) * 0.03);
|
|
294
|
+
const b = t.humanoid?.getNormalizedBoneNode("leftShoulder"), R = t.humanoid?.getNormalizedBoneNode("rightShoulder"), N = t.humanoid?.getNormalizedBoneNode("leftUpperArm"), _ = t.humanoid?.getNormalizedBoneNode("rightUpperArm"), B = t.humanoid?.getNormalizedBoneNode("leftLowerArm"), e = t.humanoid?.getNormalizedBoneNode("rightLowerArm");
|
|
295
|
+
b && (b.rotation.z = 0.1), R && (R.rotation.z = -0.1), N && (N.rotation.z = -0.8 + Math.sin(o * 1.2) * 0.1, N.rotation.x = 0.4 + Math.sin(o * 0.9) * 0.15, N.rotation.y = Math.sin(o * 0.7) * 0.1), _ && (_.rotation.z = 0.8 + Math.sin(o * 1.3) * 0.1, _.rotation.x = 0.4 + Math.sin(o * 1) * 0.15, _.rotation.y = Math.sin(o * 0.8) * 0.1), B && (B.rotation.y = -1 - Math.sin(o * 1.5) * 0.2, B.rotation.z = Math.sin(o * 1.1) * 0.1), e && (e.rotation.y = 1 + Math.sin(o * 1.4) * 0.2, e.rotation.z = Math.sin(o * 1.2) * 0.1);
|
|
301
296
|
} else {
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
Math.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
spine: !!S
|
|
308
|
-
}), S && (S.rotation.x = Math.sin(n * 0.8) * 0.02), v && (v.rotation.x = Math.sin(n * 0.3) * 0.03, v.rotation.z = Math.sin(n * 0.2) * 0.02);
|
|
309
|
-
const M = t.humanoid?.getNormalizedBoneNode("leftShoulder"), b = t.humanoid?.getNormalizedBoneNode("rightShoulder"), R = t.humanoid?.getNormalizedBoneNode("leftUpperArm"), N = t.humanoid?.getNormalizedBoneNode("rightUpperArm"), _ = t.humanoid?.getNormalizedBoneNode("leftLowerArm"), w = t.humanoid?.getNormalizedBoneNode("rightLowerArm");
|
|
310
|
-
M && (M.rotation.z = 0.1), b && (b.rotation.z = -0.1), R && (R.rotation.z = -0.9, R.rotation.x = 0.2, R.rotation.y = 0), N && (N.rotation.z = 0.9, N.rotation.x = 0.2, N.rotation.y = 0), _ && (_.rotation.y = -0.8), w && (w.rotation.y = 0.8);
|
|
297
|
+
S.current = 0, t.expressionManager?.setValue(J.Aa, 0);
|
|
298
|
+
const O = t.humanoid?.getNormalizedBoneNode("spine"), E = t.humanoid?.getNormalizedBoneNode("head");
|
|
299
|
+
O && (O.rotation.x = Math.sin(o * 0.8) * 0.02), E && (E.rotation.x = Math.sin(o * 0.3) * 0.03, E.rotation.z = Math.sin(o * 0.2) * 0.02);
|
|
300
|
+
const C = t.humanoid?.getNormalizedBoneNode("leftShoulder"), A = t.humanoid?.getNormalizedBoneNode("rightShoulder"), b = t.humanoid?.getNormalizedBoneNode("leftUpperArm"), R = t.humanoid?.getNormalizedBoneNode("rightUpperArm"), N = t.humanoid?.getNormalizedBoneNode("leftLowerArm"), _ = t.humanoid?.getNormalizedBoneNode("rightLowerArm");
|
|
301
|
+
C && (C.rotation.z = 0.1), A && (A.rotation.z = -0.1), b && (b.rotation.z = -0.9, b.rotation.x = 0.2, b.rotation.y = 0), R && (R.rotation.z = 0.9, R.rotation.x = 0.2, R.rotation.y = 0), N && (N.rotation.y = -0.8), _ && (_.rotation.y = 0.8);
|
|
311
302
|
}
|
|
312
|
-
|
|
303
|
+
o % 4 < 0.1 ? t.expressionManager?.setValue(J.Blink, 1) : t.expressionManager?.setValue(J.Blink, 0);
|
|
313
304
|
}
|
|
314
|
-
f.render(m,
|
|
315
|
-
}, []), W =
|
|
305
|
+
f.render(m, z);
|
|
306
|
+
}, []), W = V(async (l) => {
|
|
316
307
|
const f = g.current;
|
|
317
308
|
if (f) {
|
|
318
|
-
c(!0),
|
|
309
|
+
c(!0), k(null), w.current && (f.remove(w.current.scene), w.current = null);
|
|
319
310
|
try {
|
|
320
311
|
const m = new fe();
|
|
321
|
-
m.register((
|
|
312
|
+
m.register((j) => new me(j));
|
|
322
313
|
const t = (await m.loadAsync(l)).userData.vrm;
|
|
323
314
|
if (!t)
|
|
324
315
|
throw new Error("Failed to load VRM data");
|
|
325
|
-
f.add(t.scene),
|
|
316
|
+
f.add(t.scene), w.current = t, c(!1);
|
|
326
317
|
} catch (m) {
|
|
327
|
-
console.error("Failed to load VRM:", m),
|
|
318
|
+
console.error("Failed to load VRM:", m), k(`Failed to load avatar: ${m instanceof Error ? m.message : "Unknown error"}`), c(!1);
|
|
328
319
|
}
|
|
329
320
|
}
|
|
330
|
-
}, []), G =
|
|
331
|
-
|
|
332
|
-
}, [
|
|
333
|
-
return Q(() => ($(), window.addEventListener("resize",
|
|
321
|
+
}, []), G = V(() => {
|
|
322
|
+
M.current !== null && (cancelAnimationFrame(M.current), M.current = null), window.removeEventListener("resize", y), d.current && s.current && (s.current.removeChild(d.current.domElement), d.current.dispose(), d.current = null), w.current = null, g.current = null, x.current = null, L.current = null;
|
|
323
|
+
}, [y]);
|
|
324
|
+
return Q(() => ($(), window.addEventListener("resize", y), U(), () => {
|
|
334
325
|
G();
|
|
335
|
-
}), [$,
|
|
326
|
+
}), [$, y, U, G]), Q(() => {
|
|
336
327
|
if (u?.toolName === he && u.data) {
|
|
337
328
|
const l = u.data;
|
|
338
329
|
l.avatarUrl && W(l.avatarUrl);
|
|
@@ -341,7 +332,7 @@ function be({ selectedResult: u, isAudioPlaying: x }) {
|
|
|
341
332
|
/* @__PURE__ */ h.jsx("div", { ref: s, className: "w-full h-full" }),
|
|
342
333
|
P && /* @__PURE__ */ h.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-slate-900/80", children: /* @__PURE__ */ h.jsx("div", { className: "text-white text-lg", children: "Loading Avatar..." }) }),
|
|
343
334
|
p && /* @__PURE__ */ h.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-slate-900/80", children: /* @__PURE__ */ h.jsx("div", { className: "text-red-400 text-lg text-center p-4", children: p }) }),
|
|
344
|
-
|
|
335
|
+
v && /* @__PURE__ */ h.jsx("div", { className: "absolute top-4 right-4 px-3 py-1 bg-green-600 text-white text-sm rounded-full", children: "Speaking..." })
|
|
345
336
|
] });
|
|
346
337
|
}
|
|
347
338
|
function Re({ result: u }) {
|
|
@@ -373,14 +364,14 @@ const Ne = {
|
|
|
373
364
|
...pe,
|
|
374
365
|
ViewComponent: be,
|
|
375
366
|
PreviewComponent: Re
|
|
376
|
-
},
|
|
367
|
+
}, Te = { plugin: Ne };
|
|
377
368
|
export {
|
|
378
369
|
Re as Preview,
|
|
379
370
|
ye as SAMPLES,
|
|
380
371
|
je as TOOL_DEFINITION,
|
|
381
372
|
he as TOOL_NAME,
|
|
382
373
|
be as View,
|
|
383
|
-
|
|
374
|
+
Te as default,
|
|
384
375
|
Oe as executeAvatar,
|
|
385
376
|
Ne as plugin,
|
|
386
377
|
pe as pluginCore
|
package/dist/vue.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("./three-vrm.module-FTOSkzpf.cjs"),z=require("./core.cjs"),o=require("vue")
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("./three-vrm.module-FTOSkzpf.cjs"),z=require("./core.cjs"),o=require("vue"),$={class:"size-full bg-gradient-to-b from-slate-800 to-slate-900 relative"},q={key:0,class:"absolute inset-0 flex items-center justify-center bg-slate-900/80"},H={key:1,class:"absolute inset-0 flex items-center justify-center bg-slate-900/80"},G={class:"text-red-400 text-lg text-center p-4"},W={key:2,class:"absolute top-4 right-4 px-3 py-1 bg-green-600 text-white text-sm rounded-full"},U=o.defineComponent({__name:"View",props:{selectedResult:{},sendTextMessage:{type:Function},isAudioPlaying:{type:Boolean}},setup(y){const A=y,p=o.ref(null),N=o.ref(!1),B=o.ref(null);let r=null,f=null,l=null,t=null,w=null,V=null,S=0,k="neutral",L="none",b=0,P=0,_="";const F={neutral:null,happy:a.VRMExpressionPresetName.Happy,sad:a.VRMExpressionPresetName.Sad,angry:a.VRMExpressionPresetName.Angry,surprised:a.VRMExpressionPresetName.Surprised};function I(){if(!p.value)return;const n=p.value,e=n.clientWidth,E=n.clientHeight;r=new a.Scene,f=new a.PerspectiveCamera(30,e/E,.1,100),f.position.set(0,1.3,1.5),f.lookAt(0,1.2,0),l=new a.WebGLRenderer({antialias:!0,alpha:!0}),l.setSize(e,E),l.setPixelRatio(window.devicePixelRatio),l.outputColorSpace=a.SRGBColorSpace,n.appendChild(l.domElement);const v=new a.AmbientLight(16777215,.6);r.add(v);const c=new a.DirectionalLight(16777215,.8);c.position.set(1,1,1),r.add(c),w=new a.Clock,window.addEventListener("resize",R),T()}function R(){if(!p.value||!f||!l)return;const n=p.value.clientWidth,e=p.value.clientHeight;f.aspect=n/e,f.updateProjectionMatrix(),l.setSize(n,e)}async function C(n){if(r){N.value=!0,B.value=null,t&&(r.remove(t.scene),t=null);try{const e=new a.GLTFLoader;e.register(c=>new a.VRMLoaderPlugin(c));const v=(await e.loadAsync(n)).userData.vrm;if(!v)throw new Error("Failed to load VRM data");r.add(v.scene),t=v,N.value=!1}catch(e){console.error("Failed to load VRM:",e),B.value=`Failed to load avatar: ${e instanceof Error?e.message:"Unknown error"}`,N.value=!1}}}function T(){if(V=requestAnimationFrame(T),!w||!l||!r||!f)return;const n=w.getDelta(),e=w.getElapsedTime();if(t){if(t.update(n),A.isAudioPlaying){S+=n*10;const c=(Math.sin(S)+1)*.3;t.expressionManager?.setValue(a.VRMExpressionPresetName.Aa,c);const h=t.humanoid?.getNormalizedBoneNode("head"),u=t.humanoid?.getNormalizedBoneNode("neck"),i=t.humanoid?.getNormalizedBoneNode("spine");h&&(h.rotation.x=Math.sin(e*2)*.08,h.rotation.z=Math.sin(e*1.5)*.05),u&&(u.rotation.y=Math.sin(e*.8)*.05),i&&(i.rotation.z=Math.sin(e*.5)*.03);const s=t.humanoid?.getNormalizedBoneNode("leftShoulder"),m=t.humanoid?.getNormalizedBoneNode("rightShoulder"),g=t.humanoid?.getNormalizedBoneNode("leftUpperArm"),x=t.humanoid?.getNormalizedBoneNode("rightUpperArm"),d=t.humanoid?.getNormalizedBoneNode("leftLowerArm"),M=t.humanoid?.getNormalizedBoneNode("rightLowerArm");s&&(s.rotation.z=.1),m&&(m.rotation.z=-.1),g&&(g.rotation.z=-.8+Math.sin(e*1.2)*.1,g.rotation.x=.4+Math.sin(e*.9)*.15,g.rotation.y=Math.sin(e*.7)*.1),x&&(x.rotation.z=.8+Math.sin(e*1.3)*.1,x.rotation.x=.4+Math.sin(e*1)*.15,x.rotation.y=Math.sin(e*.8)*.1),d&&(d.rotation.y=-1-Math.sin(e*1.5)*.2,d.rotation.z=Math.sin(e*1.1)*.1),M&&(M.rotation.y=1+Math.sin(e*1.4)*.2,M.rotation.z=Math.sin(e*1.2)*.1)}else{S=0,t.expressionManager?.setValue(a.VRMExpressionPresetName.Aa,0);const c=t.humanoid?.getNormalizedBoneNode("spine"),h=t.humanoid?.getNormalizedBoneNode("head");c&&(c.rotation.x=Math.sin(e*.8)*.02),h&&(h.rotation.x=Math.sin(e*.3)*.03,h.rotation.z=Math.sin(e*.2)*.02);const u=t.humanoid?.getNormalizedBoneNode("leftShoulder"),i=t.humanoid?.getNormalizedBoneNode("rightShoulder"),s=t.humanoid?.getNormalizedBoneNode("leftUpperArm"),m=t.humanoid?.getNormalizedBoneNode("rightUpperArm"),g=t.humanoid?.getNormalizedBoneNode("leftLowerArm"),x=t.humanoid?.getNormalizedBoneNode("rightLowerArm");u&&(u.rotation.z=.1),i&&(i.rotation.z=-.1),s&&(s.rotation.z=-.9,s.rotation.x=.2,s.rotation.y=0),m&&(m.rotation.z=.9,m.rotation.x=.2,m.rotation.y=0),g&&(g.rotation.y=-.8),x&&(x.rotation.y=.8)}e%4<.1?t.expressionManager?.setValue(a.VRMExpressionPresetName.Blink,1):t.expressionManager?.setValue(a.VRMExpressionPresetName.Blink,0);const v=F[k];if(t.expressionManager?.setValue(a.VRMExpressionPresetName.Happy,0),t.expressionManager?.setValue(a.VRMExpressionPresetName.Sad,0),t.expressionManager?.setValue(a.VRMExpressionPresetName.Angry,0),t.expressionManager?.setValue(a.VRMExpressionPresetName.Surprised,0),v&&t.expressionManager?.setValue(v,.8),L!=="none"){const c=e-b,h=1.5;if(c<h){const u=c/h,i=t.humanoid?.getNormalizedBoneNode("head"),s=t.humanoid?.getNormalizedBoneNode("rightUpperArm"),m=t.humanoid?.getNormalizedBoneNode("rightLowerArm"),g=t.humanoid?.getNormalizedBoneNode("spine"),d=(M=>M<.5?2*M*M:1-Math.pow(-2*M+2,2)/2)(u<.5?u*2:(1-u)*2);switch(L){case"nod":i&&(i.rotation.x=Math.sin(u*Math.PI*3)*.2);break;case"shake":i&&(i.rotation.y=Math.sin(u*Math.PI*4)*.3);break;case"wave":s&&(s.rotation.z=1.5*d,s.rotation.x=-.3*d),m&&(m.rotation.y=.5+Math.sin(u*Math.PI*6)*.3);break;case"think":i&&(i.rotation.x=.1*d,i.rotation.z=.1*d),s&&(s.rotation.z=.3*d,s.rotation.x=.8*d),m&&(m.rotation.y=1.5*d);break;case"bow":g&&(g.rotation.x=.4*d),i&&(i.rotation.x=.2*d);break}}else L="none"}}l.render(r,f)}function j(){V!==null&&(cancelAnimationFrame(V),V=null),window.removeEventListener("resize",R),l&&p.value&&(p.value.removeChild(l.domElement),l.dispose(),l=null),t&&(t=null),r=null,f=null,w=null}return o.watch(()=>A.selectedResult,n=>{if(n?.toolName===z.TOOL_NAME&&n.data){const e=n.data;if(e.avatarUrl&&e.avatarUrl!==_&&(_=e.avatarUrl,C(e.avatarUrl)),e.emotion&&e.emotion!==k&&(console.log("[Avatar Debug] Emotion changed to:",e.emotion),k=e.emotion),e.action&&e.action!=="none"){const E=e.actionTimestamp||0;E>P&&(console.log("[Avatar Debug] Action triggered:",e.action),L=e.action,b=w?.getElapsedTime()||0,P=E)}}},{deep:!0}),o.onMounted(()=>{if(I(),A.selectedResult?.toolName===z.TOOL_NAME&&A.selectedResult.data){const n=A.selectedResult.data;n.avatarUrl&&(_=n.avatarUrl,C(n.avatarUrl)),n.emotion&&(k=n.emotion)}}),o.onUnmounted(()=>{j()}),(n,e)=>(o.openBlock(),o.createElementBlock("div",$,[o.createElementVNode("div",{ref_key:"containerRef",ref:p,class:"size-full"},null,512),N.value?(o.openBlock(),o.createElementBlock("div",q,[...e[0]||(e[0]=[o.createElementVNode("div",{class:"text-white text-lg"},"Loading Avatar...",-1)])])):o.createCommentVNode("",!0),B.value?(o.openBlock(),o.createElementBlock("div",H,[o.createElementVNode("div",G,o.toDisplayString(B.value),1)])):o.createCommentVNode("",!0),y.isAudioPlaying?(o.openBlock(),o.createElementBlock("div",W," Speaking... ")):o.createCommentVNode("",!0)]))}}),J={class:"p-3 bg-gradient-to-br from-slate-700 to-slate-800 rounded-md"},K={class:"flex flex-col items-center gap-2"},Q={key:0,class:"text-xs px-2 py-0.5 bg-blue-500 text-white rounded-full"},O=o.defineComponent({__name:"Preview",props:{result:{}},setup(y){const A=y,p=o.computed(()=>A.result.data),N=o.computed(()=>p.value?.emotion||"neutral");return(B,r)=>(o.openBlock(),o.createElementBlock("div",J,[o.createElementVNode("div",K,[r[0]||(r[0]=o.createElementVNode("div",{class:"size-12 bg-slate-600 rounded-full flex items-center justify-center"},[o.createElementVNode("svg",{class:"size-8 text-slate-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})])],-1)),r[1]||(r[1]=o.createElementVNode("div",{class:"text-sm font-semibold text-white text-center"}," 3D Avatar ",-1)),N.value&&N.value!=="neutral"?(o.openBlock(),o.createElementBlock("div",Q,o.toDisplayString(N.value),1)):o.createCommentVNode("",!0)])]))}}),D={...z.pluginCore,viewComponent:U,previewComponent:O},X={plugin:D};exports.SAMPLES=z.SAMPLES;exports.TOOL_DEFINITION=z.TOOL_DEFINITION;exports.TOOL_NAME=z.TOOL_NAME;exports.executeAvatar=z.executeAvatar;exports.pluginCore=z.pluginCore;exports.Preview=O;exports.View=U;exports.default=X;exports.plugin=D;
|
package/dist/vue.js
CHANGED
|
@@ -1,182 +1,167 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
import { TOOL_NAME as
|
|
3
|
-
import { SAMPLES as
|
|
4
|
-
import { defineComponent as
|
|
5
|
-
const
|
|
1
|
+
import { S as q, P as J, W as K, a as Q, A as X, D as Y, G as Z, V as ee, b as u, C as te } from "./three-vrm.module-DJ7DURJm.js";
|
|
2
|
+
import { TOOL_NAME as I, pluginCore as oe } from "./core.js";
|
|
3
|
+
import { SAMPLES as Ae, TOOL_DEFINITION as ye, executeAvatar as Be } from "./core.js";
|
|
4
|
+
import { defineComponent as j, ref as P, watch as ne, onMounted as ae, onUnmounted as ie, openBlock as y, createElementBlock as B, createElementVNode as z, createCommentVNode as U, toDisplayString as $, computed as O } from "vue";
|
|
5
|
+
const re = { class: "size-full bg-gradient-to-b from-slate-800 to-slate-900 relative" }, se = {
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "absolute inset-0 flex items-center justify-center bg-slate-900/80"
|
|
8
|
-
},
|
|
8
|
+
}, le = {
|
|
9
9
|
key: 1,
|
|
10
10
|
class: "absolute inset-0 flex items-center justify-center bg-slate-900/80"
|
|
11
|
-
},
|
|
11
|
+
}, de = { class: "text-red-400 text-lg text-center p-4" }, ce = {
|
|
12
12
|
key: 2,
|
|
13
13
|
class: "absolute top-4 right-4 px-3 py-1 bg-green-600 text-white text-sm rounded-full"
|
|
14
|
-
},
|
|
14
|
+
}, ue = /* @__PURE__ */ j({
|
|
15
15
|
__name: "View",
|
|
16
16
|
props: {
|
|
17
17
|
selectedResult: {},
|
|
18
18
|
sendTextMessage: { type: Function },
|
|
19
19
|
isAudioPlaying: { type: Boolean }
|
|
20
20
|
},
|
|
21
|
-
setup(
|
|
22
|
-
const
|
|
23
|
-
let a = null,
|
|
24
|
-
const
|
|
21
|
+
setup(b) {
|
|
22
|
+
const M = b, m = P(null), g = P(!1), k = P(null);
|
|
23
|
+
let a = null, f = null, r = null, t = null, A = null, L = null, V = 0, S = "neutral", _ = "none", C = 0, R = 0, E = "";
|
|
24
|
+
const G = {
|
|
25
25
|
neutral: null,
|
|
26
|
-
happy:
|
|
27
|
-
sad:
|
|
28
|
-
angry:
|
|
29
|
-
surprised:
|
|
26
|
+
happy: u.Happy,
|
|
27
|
+
sad: u.Sad,
|
|
28
|
+
angry: u.Angry,
|
|
29
|
+
surprised: u.Surprised
|
|
30
30
|
};
|
|
31
|
-
function
|
|
32
|
-
if (!
|
|
33
|
-
const o =
|
|
34
|
-
a = new
|
|
35
|
-
const
|
|
36
|
-
a.add(
|
|
37
|
-
const
|
|
38
|
-
|
|
31
|
+
function H() {
|
|
32
|
+
if (!m.value) return;
|
|
33
|
+
const o = m.value, e = o.clientWidth, w = o.clientHeight;
|
|
34
|
+
a = new q(), f = new J(30, e / w, 0.1, 100), f.position.set(0, 1.3, 1.5), f.lookAt(0, 1.2, 0), r = new K({ antialias: !0, alpha: !0 }), r.setSize(e, w), r.setPixelRatio(window.devicePixelRatio), r.outputColorSpace = Q, o.appendChild(r.domElement);
|
|
35
|
+
const v = new X(16777215, 0.6);
|
|
36
|
+
a.add(v);
|
|
37
|
+
const l = new Y(16777215, 0.8);
|
|
38
|
+
l.position.set(1, 1, 1), a.add(l), A = new te(), window.addEventListener("resize", T), F();
|
|
39
39
|
}
|
|
40
40
|
function T() {
|
|
41
|
-
if (!
|
|
42
|
-
const o =
|
|
43
|
-
|
|
41
|
+
if (!m.value || !f || !r) return;
|
|
42
|
+
const o = m.value.clientWidth, e = m.value.clientHeight;
|
|
43
|
+
f.aspect = o / e, f.updateProjectionMatrix(), r.setSize(o, e);
|
|
44
44
|
}
|
|
45
|
-
async function
|
|
45
|
+
async function D(o) {
|
|
46
46
|
if (a) {
|
|
47
|
-
|
|
47
|
+
g.value = !0, k.value = null, t && (a.remove(t.scene), t = null);
|
|
48
48
|
try {
|
|
49
|
-
const e = new
|
|
50
|
-
e.register((
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
49
|
+
const e = new Z();
|
|
50
|
+
e.register((l) => new ee(l));
|
|
51
|
+
const v = (await e.loadAsync(o)).userData.vrm;
|
|
52
|
+
if (!v)
|
|
53
53
|
throw new Error("Failed to load VRM data");
|
|
54
|
-
a.add(
|
|
54
|
+
a.add(v.scene), t = v, g.value = !1;
|
|
55
55
|
} catch (e) {
|
|
56
|
-
console.error("Failed to load VRM:", e),
|
|
56
|
+
console.error("Failed to load VRM:", e), k.value = `Failed to load avatar: ${e instanceof Error ? e.message : "Unknown error"}`, g.value = !1;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (t.update(o), f.isAudioPlaying) {
|
|
60
|
+
function F() {
|
|
61
|
+
if (L = requestAnimationFrame(F), !A || !r || !a || !f) return;
|
|
62
|
+
const o = A.getDelta(), e = A.getElapsedTime();
|
|
63
|
+
if (t) {
|
|
64
|
+
if (t.update(o), M.isAudioPlaying) {
|
|
66
65
|
V += o * 10;
|
|
67
|
-
const
|
|
68
|
-
t.expressionManager?.setValue(
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
spine: !!n,
|
|
74
|
-
humanoid: !!t.humanoid
|
|
75
|
-
}), c && (c.rotation.x = Math.sin(e * 2) * 0.08, c.rotation.z = Math.sin(e * 1.5) * 0.05), l && (l.rotation.y = Math.sin(e * 0.8) * 0.05), n && (n.rotation.z = Math.sin(e * 0.5) * 0.03);
|
|
76
|
-
const i = t.humanoid?.getNormalizedBoneNode("leftShoulder"), u = t.humanoid?.getNormalizedBoneNode("rightShoulder"), p = t.humanoid?.getNormalizedBoneNode("leftUpperArm"), A = t.humanoid?.getNormalizedBoneNode("rightUpperArm"), d = t.humanoid?.getNormalizedBoneNode("leftLowerArm"), M = t.humanoid?.getNormalizedBoneNode("rightLowerArm");
|
|
77
|
-
i && (i.rotation.z = 0.1), u && (u.rotation.z = -0.1), p && (p.rotation.z = -0.8 + Math.sin(e * 1.2) * 0.1, p.rotation.x = 0.4 + Math.sin(e * 0.9) * 0.15, p.rotation.y = Math.sin(e * 0.7) * 0.1), A && (A.rotation.z = 0.8 + Math.sin(e * 1.3) * 0.1, A.rotation.x = 0.4 + Math.sin(e * 1) * 0.15, A.rotation.y = Math.sin(e * 0.8) * 0.1), d && (d.rotation.y = -1 - Math.sin(e * 1.5) * 0.2, d.rotation.z = Math.sin(e * 1.1) * 0.1), M && (M.rotation.y = 1 + Math.sin(e * 1.4) * 0.2, M.rotation.z = Math.sin(e * 1.2) * 0.1);
|
|
66
|
+
const l = (Math.sin(V) + 1) * 0.3;
|
|
67
|
+
t.expressionManager?.setValue(u.Aa, l);
|
|
68
|
+
const h = t.humanoid?.getNormalizedBoneNode("head"), d = t.humanoid?.getNormalizedBoneNode("neck"), n = t.humanoid?.getNormalizedBoneNode("spine");
|
|
69
|
+
h && (h.rotation.x = Math.sin(e * 2) * 0.08, h.rotation.z = Math.sin(e * 1.5) * 0.05), d && (d.rotation.y = Math.sin(e * 0.8) * 0.05), n && (n.rotation.z = Math.sin(e * 0.5) * 0.03);
|
|
70
|
+
const i = t.humanoid?.getNormalizedBoneNode("leftShoulder"), c = t.humanoid?.getNormalizedBoneNode("rightShoulder"), p = t.humanoid?.getNormalizedBoneNode("leftUpperArm"), x = t.humanoid?.getNormalizedBoneNode("rightUpperArm"), s = t.humanoid?.getNormalizedBoneNode("leftLowerArm"), N = t.humanoid?.getNormalizedBoneNode("rightLowerArm");
|
|
71
|
+
i && (i.rotation.z = 0.1), c && (c.rotation.z = -0.1), p && (p.rotation.z = -0.8 + Math.sin(e * 1.2) * 0.1, p.rotation.x = 0.4 + Math.sin(e * 0.9) * 0.15, p.rotation.y = Math.sin(e * 0.7) * 0.1), x && (x.rotation.z = 0.8 + Math.sin(e * 1.3) * 0.1, x.rotation.x = 0.4 + Math.sin(e * 1) * 0.15, x.rotation.y = Math.sin(e * 0.8) * 0.1), s && (s.rotation.y = -1 - Math.sin(e * 1.5) * 0.2, s.rotation.z = Math.sin(e * 1.1) * 0.1), N && (N.rotation.y = 1 + Math.sin(e * 1.4) * 0.2, N.rotation.z = Math.sin(e * 1.2) * 0.1);
|
|
78
72
|
} else {
|
|
79
|
-
V = 0, t.expressionManager?.setValue(
|
|
80
|
-
const
|
|
81
|
-
Math.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
spine: !!s
|
|
85
|
-
}), s && (s.rotation.x = Math.sin(e * 0.8) * 0.02), c && (c.rotation.x = Math.sin(e * 0.3) * 0.03, c.rotation.z = Math.sin(e * 0.2) * 0.02);
|
|
86
|
-
const l = t.humanoid?.getNormalizedBoneNode("leftShoulder"), n = t.humanoid?.getNormalizedBoneNode("rightShoulder"), i = t.humanoid?.getNormalizedBoneNode("leftUpperArm"), u = t.humanoid?.getNormalizedBoneNode("rightUpperArm"), p = t.humanoid?.getNormalizedBoneNode("leftLowerArm"), A = t.humanoid?.getNormalizedBoneNode("rightLowerArm");
|
|
87
|
-
l && (l.rotation.z = 0.1), n && (n.rotation.z = -0.1), i && (i.rotation.z = -0.9, i.rotation.x = 0.2, i.rotation.y = 0), u && (u.rotation.z = 0.9, u.rotation.x = 0.2, u.rotation.y = 0), p && (p.rotation.y = -0.8), A && (A.rotation.y = 0.8);
|
|
73
|
+
V = 0, t.expressionManager?.setValue(u.Aa, 0);
|
|
74
|
+
const l = t.humanoid?.getNormalizedBoneNode("spine"), h = t.humanoid?.getNormalizedBoneNode("head");
|
|
75
|
+
l && (l.rotation.x = Math.sin(e * 0.8) * 0.02), h && (h.rotation.x = Math.sin(e * 0.3) * 0.03, h.rotation.z = Math.sin(e * 0.2) * 0.02);
|
|
76
|
+
const d = t.humanoid?.getNormalizedBoneNode("leftShoulder"), n = t.humanoid?.getNormalizedBoneNode("rightShoulder"), i = t.humanoid?.getNormalizedBoneNode("leftUpperArm"), c = t.humanoid?.getNormalizedBoneNode("rightUpperArm"), p = t.humanoid?.getNormalizedBoneNode("leftLowerArm"), x = t.humanoid?.getNormalizedBoneNode("rightLowerArm");
|
|
77
|
+
d && (d.rotation.z = 0.1), n && (n.rotation.z = -0.1), i && (i.rotation.z = -0.9, i.rotation.x = 0.2, i.rotation.y = 0), c && (c.rotation.z = 0.9, c.rotation.x = 0.2, c.rotation.y = 0), p && (p.rotation.y = -0.8), x && (x.rotation.y = 0.8);
|
|
88
78
|
}
|
|
89
|
-
e % 4 < 0.1 ? t.expressionManager?.setValue(
|
|
90
|
-
const
|
|
91
|
-
if (t.expressionManager?.setValue(
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
94
|
-
const
|
|
95
|
-
switch (
|
|
79
|
+
e % 4 < 0.1 ? t.expressionManager?.setValue(u.Blink, 1) : t.expressionManager?.setValue(u.Blink, 0);
|
|
80
|
+
const v = G[S];
|
|
81
|
+
if (t.expressionManager?.setValue(u.Happy, 0), t.expressionManager?.setValue(u.Sad, 0), t.expressionManager?.setValue(u.Angry, 0), t.expressionManager?.setValue(u.Surprised, 0), v && t.expressionManager?.setValue(v, 0.8), _ !== "none") {
|
|
82
|
+
const l = e - C, h = 1.5;
|
|
83
|
+
if (l < h) {
|
|
84
|
+
const d = l / h, n = t.humanoid?.getNormalizedBoneNode("head"), i = t.humanoid?.getNormalizedBoneNode("rightUpperArm"), c = t.humanoid?.getNormalizedBoneNode("rightLowerArm"), p = t.humanoid?.getNormalizedBoneNode("spine"), s = ((N) => N < 0.5 ? 2 * N * N : 1 - Math.pow(-2 * N + 2, 2) / 2)(d < 0.5 ? d * 2 : (1 - d) * 2);
|
|
85
|
+
switch (_) {
|
|
96
86
|
case "nod":
|
|
97
|
-
n && (n.rotation.x = Math.sin(
|
|
87
|
+
n && (n.rotation.x = Math.sin(d * Math.PI * 3) * 0.2);
|
|
98
88
|
break;
|
|
99
89
|
case "shake":
|
|
100
|
-
n && (n.rotation.y = Math.sin(
|
|
90
|
+
n && (n.rotation.y = Math.sin(d * Math.PI * 4) * 0.3);
|
|
101
91
|
break;
|
|
102
92
|
case "wave":
|
|
103
|
-
i && (i.rotation.z = 1.5 *
|
|
93
|
+
i && (i.rotation.z = 1.5 * s, i.rotation.x = -0.3 * s), c && (c.rotation.y = 0.5 + Math.sin(d * Math.PI * 6) * 0.3);
|
|
104
94
|
break;
|
|
105
95
|
case "think":
|
|
106
|
-
n && (n.rotation.x = 0.1 *
|
|
96
|
+
n && (n.rotation.x = 0.1 * s, n.rotation.z = 0.1 * s), i && (i.rotation.z = 0.3 * s, i.rotation.x = 0.8 * s), c && (c.rotation.y = 1.5 * s);
|
|
107
97
|
break;
|
|
108
98
|
case "bow":
|
|
109
|
-
p && (p.rotation.x = 0.4 *
|
|
99
|
+
p && (p.rotation.x = 0.4 * s), n && (n.rotation.x = 0.2 * s);
|
|
110
100
|
break;
|
|
111
101
|
}
|
|
112
102
|
} else
|
|
113
|
-
|
|
103
|
+
_ = "none";
|
|
114
104
|
}
|
|
115
105
|
}
|
|
116
|
-
r.render(a,
|
|
106
|
+
r.render(a, f);
|
|
117
107
|
}
|
|
118
|
-
function
|
|
119
|
-
L !== null && (cancelAnimationFrame(L), L = null), window.removeEventListener("resize", T), r &&
|
|
108
|
+
function W() {
|
|
109
|
+
L !== null && (cancelAnimationFrame(L), L = null), window.removeEventListener("resize", T), r && m.value && (m.value.removeChild(r.domElement), r.dispose(), r = null), t && (t = null), a = null, f = null, A = null;
|
|
120
110
|
}
|
|
121
|
-
return
|
|
122
|
-
() =>
|
|
111
|
+
return ne(
|
|
112
|
+
() => M.selectedResult,
|
|
123
113
|
(o) => {
|
|
124
|
-
if (o?.toolName ===
|
|
114
|
+
if (o?.toolName === I && o.data) {
|
|
125
115
|
const e = o.data;
|
|
126
|
-
if (e.avatarUrl && e.avatarUrl !==
|
|
127
|
-
const
|
|
128
|
-
|
|
116
|
+
if (e.avatarUrl && e.avatarUrl !== E && (E = e.avatarUrl, D(e.avatarUrl)), e.emotion && e.emotion !== S && (console.log("[Avatar Debug] Emotion changed to:", e.emotion), S = e.emotion), e.action && e.action !== "none") {
|
|
117
|
+
const w = e.actionTimestamp || 0;
|
|
118
|
+
w > R && (console.log("[Avatar Debug] Action triggered:", e.action), _ = e.action, C = A?.getElapsedTime() || 0, R = w);
|
|
129
119
|
}
|
|
130
120
|
}
|
|
131
121
|
},
|
|
132
122
|
{ deep: !0 }
|
|
133
|
-
),
|
|
134
|
-
()
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
), ie(() => {
|
|
139
|
-
if (console.log("[Avatar Debug] View component MOUNTED"), q(), f.selectedResult?.toolName === O && f.selectedResult.data) {
|
|
140
|
-
const o = f.selectedResult.data;
|
|
141
|
-
o.avatarUrl && (console.log("[Avatar Debug] Initial VRM load:", o.avatarUrl), _ = o.avatarUrl, F(o.avatarUrl)), o.emotion && (S = o.emotion);
|
|
123
|
+
), ae(() => {
|
|
124
|
+
if (H(), M.selectedResult?.toolName === I && M.selectedResult.data) {
|
|
125
|
+
const o = M.selectedResult.data;
|
|
126
|
+
o.avatarUrl && (E = o.avatarUrl, D(o.avatarUrl)), o.emotion && (S = o.emotion);
|
|
142
127
|
}
|
|
143
|
-
}),
|
|
144
|
-
|
|
145
|
-
}), (o, e) => (y(), B("div",
|
|
146
|
-
|
|
128
|
+
}), ie(() => {
|
|
129
|
+
W();
|
|
130
|
+
}), (o, e) => (y(), B("div", re, [
|
|
131
|
+
z("div", {
|
|
147
132
|
ref_key: "containerRef",
|
|
148
|
-
ref:
|
|
133
|
+
ref: m,
|
|
149
134
|
class: "size-full"
|
|
150
135
|
}, null, 512),
|
|
151
|
-
|
|
152
|
-
|
|
136
|
+
g.value ? (y(), B("div", se, [...e[0] || (e[0] = [
|
|
137
|
+
z("div", { class: "text-white text-lg" }, "Loading Avatar...", -1)
|
|
153
138
|
])])) : U("", !0),
|
|
154
|
-
|
|
155
|
-
|
|
139
|
+
k.value ? (y(), B("div", le, [
|
|
140
|
+
z("div", de, $(k.value), 1)
|
|
156
141
|
])) : U("", !0),
|
|
157
|
-
|
|
142
|
+
b.isAudioPlaying ? (y(), B("div", ce, " Speaking... ")) : U("", !0)
|
|
158
143
|
]));
|
|
159
144
|
}
|
|
160
|
-
}),
|
|
145
|
+
}), me = { class: "p-3 bg-gradient-to-br from-slate-700 to-slate-800 rounded-md" }, he = { class: "flex flex-col items-center gap-2" }, pe = {
|
|
161
146
|
key: 0,
|
|
162
147
|
class: "text-xs px-2 py-0.5 bg-blue-500 text-white rounded-full"
|
|
163
|
-
}, fe = /* @__PURE__ */
|
|
148
|
+
}, fe = /* @__PURE__ */ j({
|
|
164
149
|
__name: "Preview",
|
|
165
150
|
props: {
|
|
166
151
|
result: {}
|
|
167
152
|
},
|
|
168
|
-
setup(
|
|
169
|
-
const
|
|
170
|
-
return (
|
|
171
|
-
|
|
172
|
-
a[0] || (a[0] =
|
|
173
|
-
|
|
153
|
+
setup(b) {
|
|
154
|
+
const M = b, m = O(() => M.result.data), g = O(() => m.value?.emotion || "neutral");
|
|
155
|
+
return (k, a) => (y(), B("div", me, [
|
|
156
|
+
z("div", he, [
|
|
157
|
+
a[0] || (a[0] = z("div", { class: "size-12 bg-slate-600 rounded-full flex items-center justify-center" }, [
|
|
158
|
+
z("svg", {
|
|
174
159
|
class: "size-8 text-slate-300",
|
|
175
160
|
fill: "none",
|
|
176
161
|
stroke: "currentColor",
|
|
177
162
|
viewBox: "0 0 24 24"
|
|
178
163
|
}, [
|
|
179
|
-
|
|
164
|
+
z("path", {
|
|
180
165
|
"stroke-linecap": "round",
|
|
181
166
|
"stroke-linejoin": "round",
|
|
182
167
|
"stroke-width": "2",
|
|
@@ -184,24 +169,24 @@ const se = { class: "size-full bg-gradient-to-b from-slate-800 to-slate-900 rela
|
|
|
184
169
|
})
|
|
185
170
|
])
|
|
186
171
|
], -1)),
|
|
187
|
-
a[1] || (a[1] =
|
|
188
|
-
|
|
172
|
+
a[1] || (a[1] = z("div", { class: "text-sm font-semibold text-white text-center" }, " 3D Avatar ", -1)),
|
|
173
|
+
g.value && g.value !== "neutral" ? (y(), B("div", pe, $(g.value), 1)) : U("", !0)
|
|
189
174
|
])
|
|
190
175
|
]));
|
|
191
176
|
}
|
|
192
|
-
}),
|
|
193
|
-
...
|
|
194
|
-
viewComponent:
|
|
177
|
+
}), ge = {
|
|
178
|
+
...oe,
|
|
179
|
+
viewComponent: ue,
|
|
195
180
|
previewComponent: fe
|
|
196
|
-
},
|
|
181
|
+
}, ze = { plugin: ge };
|
|
197
182
|
export {
|
|
198
183
|
fe as Preview,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
184
|
+
Ae as SAMPLES,
|
|
185
|
+
ye as TOOL_DEFINITION,
|
|
186
|
+
I as TOOL_NAME,
|
|
187
|
+
ue as View,
|
|
188
|
+
ze as default,
|
|
189
|
+
Be as executeAvatar,
|
|
190
|
+
ge as plugin,
|
|
191
|
+
oe as pluginCore
|
|
207
192
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gui-chat-plugin/avatar",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "3D Avatar Plugin for GUIChat - VRM avatar with lip-sync",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"license": "MIT",
|
|
93
93
|
"dependencies": {
|
|
94
94
|
"@pixiv/three-vrm": "^3.3.3",
|
|
95
|
-
"gui-chat-protocol": "
|
|
95
|
+
"gui-chat-protocol": "^0.0.4",
|
|
96
96
|
"three": "^0.174.0"
|
|
97
97
|
}
|
|
98
98
|
}
|