@memori.ai/memori-react 7.13.1 → 7.13.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/AnimationController.d.ts +38 -0
  3. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/AnimationController.js +181 -0
  4. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/AnimationController.js.map +1 -0
  5. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarPositionController.d.ts +19 -0
  6. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarPositionController.js +60 -0
  7. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarPositionController.js.map +1 -0
  8. package/dist/components/Avatar/AvatarView/AvatarComponent/components/{FullbodyAvatar/MorhTargetController.js → controllers/MorphTargetController.js} +6 -4
  9. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js.map +1 -0
  10. package/dist/components/Chat/Chat.d.ts +2 -2
  11. package/dist/components/Chat/Chat.js.map +1 -1
  12. package/dist/components/MemoriWidget/MemoriWidget.js +4 -4
  13. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  14. package/dist/components/layouts/totem.css +9 -0
  15. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/AnimationController.d.ts +38 -0
  16. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/AnimationController.js +177 -0
  17. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/AnimationController.js.map +1 -0
  18. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarPositionController.d.ts +19 -0
  19. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarPositionController.js +56 -0
  20. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarPositionController.js.map +1 -0
  21. package/esm/components/Avatar/AvatarView/AvatarComponent/components/{FullbodyAvatar/MorhTargetController.js → controllers/MorphTargetController.js} +6 -4
  22. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js.map +1 -0
  23. package/esm/components/Chat/Chat.d.ts +2 -2
  24. package/esm/components/Chat/Chat.js.map +1 -1
  25. package/esm/components/MemoriWidget/MemoriWidget.js +4 -4
  26. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  27. package/esm/components/layouts/totem.css +9 -0
  28. package/package.json +2 -2
  29. package/src/components/Chat/Chat.tsx +2 -3
  30. package/src/components/MemoriWidget/MemoriWidget.tsx +5 -5
  31. package/src/components/layouts/totem.css +9 -0
  32. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/MorhTargetController.js.map +0 -1
  33. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.d.ts +0 -17
  34. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.js +0 -25
  35. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.js.map +0 -1
  36. package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.d.ts +0 -26
  37. package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js +0 -166
  38. package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js.map +0 -1
  39. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/MorhTargetController.js.map +0 -1
  40. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.d.ts +0 -17
  41. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.js +0 -22
  42. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.js.map +0 -1
  43. package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.d.ts +0 -26
  44. package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js +0 -163
  45. package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js.map +0 -1
  46. /package/dist/components/Avatar/AvatarView/AvatarComponent/components/{FullbodyAvatar/MorhTargetController.d.ts → controllers/MorphTargetController.d.ts} +0 -0
  47. /package/esm/components/Avatar/AvatarView/AvatarComponent/components/{FullbodyAvatar/MorhTargetController.d.ts → controllers/MorphTargetController.d.ts} +0 -0
@@ -121,9 +121,18 @@
121
121
  .memori-totem-layout--controls .memori--start-panel,
122
122
  .memori-totem-layout--controls .memori-chat--history,
123
123
  .memori-totem-layout--controls .memori-chat--content {
124
+ z-index: 100;
124
125
  background: transparent;
125
126
  }
126
127
 
128
+ .memori-totem-layout--controls .memori-chat--history .memori-chat--content {
129
+ max-height: 400px;
130
+ }
131
+
132
+ .memori-totem-layout--controls {
133
+ z-index: 100;
134
+ }
135
+
127
136
  .memori-totem-layout--controls .memori--start-panel,
128
137
  .memori-totem-layout--controls .memori-chat--wrapper {
129
138
  width: 80vw;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.13.1",
2
+ "version": "7.13.3",
3
3
  "name": "@memori.ai/memori-react",
4
4
  "author": "Memori Srl",
5
5
  "main": "dist/index.js",
@@ -292,7 +292,7 @@
292
292
  },
293
293
  "dependencies": {
294
294
  "@headlessui/react": "1.7.4",
295
- "@memori.ai/memori-api-client": "^5.2.1",
295
+ "@memori.ai/memori-api-client": "^5.4.2",
296
296
  "@react-three/drei": "8.20.2",
297
297
  "@react-three/fiber": "7.0.25",
298
298
  "classnames": "2.5.1",
@@ -14,7 +14,6 @@ import ChatBubble from '../ChatBubble/ChatBubble';
14
14
  import MediaWidget, {
15
15
  Props as MediaWidgetProps,
16
16
  } from '../MediaWidget/MediaWidget';
17
- import Button from '../ui/Button';
18
17
  import { Props as MemoriProps } from '../MemoriWidget/MemoriWidget';
19
18
  import memoriApiClient from '@memori.ai/memori-api-client';
20
19
  import ChatInputs from '../ChatInputs/ChatInputs';
@@ -43,7 +42,7 @@ export interface Props {
43
42
  showAIicon?: boolean;
44
43
  showTranslationOriginal?: boolean;
45
44
  showWhyThisAnswer?: boolean;
46
- client: ReturnType<typeof memoriApiClient>;
45
+ client?: ReturnType<typeof memoriApiClient>;
47
46
  preview?: boolean;
48
47
  microphoneMode?: 'CONTINUOUS' | 'HOLD_TO_TALK';
49
48
  sendOnEnter?: 'keypress' | 'click';
@@ -74,7 +73,7 @@ export interface Props {
74
73
  stopListening: () => void;
75
74
  resetTranscript: () => void;
76
75
  customMediaRenderer?: MediaWidgetProps['customMediaRenderer'];
77
- layout: MemoriProps['layout'];
76
+ layout?: MemoriProps['layout'];
78
77
  userAvatar?: MemoriProps['userAvatar'];
79
78
  user?: User;
80
79
  experts?: ExpertReference[];
@@ -430,7 +430,7 @@ const MemoriWidget = ({
430
430
  showTypingText = false,
431
431
  showClear = false,
432
432
  showLogin = false,
433
- showUpload = false,
433
+ showUpload,
434
434
  showOnlyLastMessages,
435
435
  height = '100vh',
436
436
  secret,
@@ -898,7 +898,7 @@ const MemoriWidget = ({
898
898
  userLang: string,
899
899
  msg?: string
900
900
  ) => {
901
- const emission = state.emission ?? currentDialogState?.emission;
901
+ const emission = state?.emission ?? currentDialogState?.emission;
902
902
 
903
903
  let translatedState = { ...state };
904
904
  let translatedMsg = null;
@@ -1922,11 +1922,10 @@ const MemoriWidget = ({
1922
1922
  return;
1923
1923
  }
1924
1924
  stopListening();
1925
- // stopAudio();
1926
1925
 
1927
1926
  if (preview) return;
1928
1927
 
1929
- if (muteSpeaker || speakerMuted) {
1928
+ if (speakerMuted) {
1930
1929
  memoriSpeaking = false;
1931
1930
  setMemoriTyping(false);
1932
1931
 
@@ -1945,6 +1944,7 @@ const MemoriWidget = ({
1945
1944
  window.navigator.userAgent.includes('Safari') &&
1946
1945
  !window.navigator.userAgent.includes('Chrome');
1947
1946
  let isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
1947
+
1948
1948
  if ((audioContext.state as string) === 'interrupted') {
1949
1949
  audioContext.resume().then(() => speak(text));
1950
1950
  return;
@@ -2432,7 +2432,7 @@ const MemoriWidget = ({
2432
2432
  ? true
2433
2433
  : integrationConfig?.showAIicon;
2434
2434
 
2435
- const enableUpload = showUpload || !!integrationConfig?.showUpload;
2435
+ const enableUpload = !!(showUpload ?? integrationConfig?.showUpload);
2436
2436
 
2437
2437
  const showWhyThisAnswer =
2438
2438
  integrationConfig?.showWhyThisAnswer === undefined
@@ -121,9 +121,18 @@
121
121
  .memori-totem-layout--controls .memori--start-panel,
122
122
  .memori-totem-layout--controls .memori-chat--history,
123
123
  .memori-totem-layout--controls .memori-chat--content {
124
+ z-index: 100;
124
125
  background: transparent;
125
126
  }
126
127
 
128
+ .memori-totem-layout--controls .memori-chat--history .memori-chat--content {
129
+ max-height: 400px;
130
+ }
131
+
132
+ .memori-totem-layout--controls {
133
+ z-index: 100;
134
+ }
135
+
127
136
  .memori-totem-layout--controls .memori--start-panel,
128
137
  .memori-totem-layout--controls .memori-chat--wrapper {
129
138
  width: 80vw;
@@ -1 +0,0 @@
1
- {"version":3,"file":"MorhTargetController.js","sourceRoot":"","sources":["../../../../../../../src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/MorhTargetController.ts"],"names":[],"mappings":";;;AACA,iCAAkC;AAClC,2CAAgF;AAEhF,MAAa,qBAAqB;IAKhC,YAAY,QAAqB;QAHzB,yBAAoB,GAA2B,EAAE,CAAC;QAClD,wBAAmB,GAAgB,IAAI,GAAG,EAAE,CAAC;QAGnD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,kBAAkB,CAChB,WAAmB,EACnB,mBAA2C,EAC3C,aAAsD,EACtD,QAAiB,EACjB,UAKC;QAED,IACE,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB;YACpC,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,EACpC;YACA,OAAO;SACR;QAED,MAAM,UAAU,GAAG,IAAI,CAA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_POSITION: Vector3;
4
- export declare const AVATAR_ROTATION: Euler;
5
- export declare const AVATAR_POSITION_ZOOMED: Vector3;
6
- export declare const ANIMATION_URLS: {
7
- MALE: string;
8
- FEMALE: string;
9
- };
10
- export declare const BLINK_CONFIG: {
11
- minInterval: number;
12
- maxInterval: number;
13
- blinkDuration: number;
14
- };
15
- export declare const DEFAULT_CONFIG: AnimationConfig;
16
- export declare const EMOTION_SMOOTHING = 0.3;
17
- export declare const VISEME_SMOOTHING = 0.5;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VISEME_SMOOTHING = exports.EMOTION_SMOOTHING = exports.DEFAULT_CONFIG = exports.BLINK_CONFIG = exports.ANIMATION_URLS = exports.AVATAR_POSITION_ZOOMED = exports.AVATAR_ROTATION = exports.AVATAR_POSITION = void 0;
4
- const three_1 = require("three");
5
- exports.AVATAR_POSITION = new three_1.Vector3(0, -1, 0);
6
- exports.AVATAR_ROTATION = new three_1.Euler(0.175, 0, 0);
7
- exports.AVATAR_POSITION_ZOOMED = new three_1.Vector3(0, -1.45, 0);
8
- exports.ANIMATION_URLS = {
9
- MALE: 'https://assets.memori.ai/api/v2/asset/2c5e88a4-cf62-408b-9ef0-518b099dfcb2.glb',
10
- FEMALE: 'https://assets.memori.ai/api/v2/asset/2adc934b-24b2-45bd-94ad-ffec58d3cb32.glb',
11
- };
12
- exports.BLINK_CONFIG = {
13
- minInterval: 1000,
14
- maxInterval: 5000,
15
- blinkDuration: 150,
16
- };
17
- exports.DEFAULT_CONFIG = {
18
- fadeInDuration: 0.8,
19
- fadeOutDuration: 0.8,
20
- idleCount: 5,
21
- timeScale: 1.0,
22
- };
23
- exports.EMOTION_SMOOTHING = 0.3;
24
- exports.VISEME_SMOOTHING = 0.5;
25
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.ts"],"names":[],"mappings":";;;AAAA,iCAAuC;AAG1B,QAAA,eAAe,GAAG,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACxC,QAAA,eAAe,GAAG,IAAI,aAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACzC,QAAA,sBAAsB,GAAG,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAElD,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gFAAgF;IACtF,MAAM,EACJ,gFAAgF;CACnF,CAAC;AAEW,QAAA,YAAY,GAAG;IAC1B,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,GAAG;CACnB,CAAC;AAEW,QAAA,cAAc,GAAoB;IAC7C,cAAc,EAAE,GAAG;IACnB,eAAe,EAAE,GAAG;IACpB,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,GAAG;CACf,CAAC;AAEW,QAAA,iBAAiB,GAAG,GAAG,CAAC;AACxB,QAAA,gBAAgB,GAAG,GAAG,CAAC"}
@@ -1,26 +0,0 @@
1
- interface FullbodyAvatarProps {
2
- url: string;
3
- sex: 'MALE' | 'FEMALE';
4
- onLoaded?: () => void;
5
- currentBaseAction: {
6
- action: string;
7
- weight: number;
8
- };
9
- timeScale: number;
10
- isZoomed?: boolean;
11
- eyeBlink?: boolean;
12
- stopProcessing: () => void;
13
- resetVisemeQueue: () => void;
14
- updateCurrentViseme: (currentTime: number) => {
15
- name: string;
16
- weight: number;
17
- } | null;
18
- smoothMorphTarget?: boolean;
19
- morphTargetSmoothing?: number;
20
- morphTargetInfluences: Record<string, number>;
21
- setMorphTargetDictionary: (morphTargetDictionary: Record<string, number>) => void;
22
- setMorphTargetInfluences: (morphTargetInfluences: Record<string, number>) => void;
23
- emotionMorphTargets: Record<string, number>;
24
- }
25
- export default function FullbodyAvatar({ url, sex, currentBaseAction, timeScale, isZoomed, eyeBlink, updateCurrentViseme, setMorphTargetDictionary, setMorphTargetInfluences, emotionMorphTargets, }: FullbodyAvatarProps): JSX.Element;
26
- export {};
@@ -1,166 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
- const react_1 = require("react");
5
- const three_1 = require("three");
6
- const drei_1 = require("@react-three/drei");
7
- const fiber_1 = require("@react-three/fiber");
8
- const AVATAR_POSITION = new three_1.Vector3(0, -1, 0);
9
- const AVATAR_ROTATION = new three_1.Euler(0.175, 0, 0);
10
- const AVATAR_POSITION_ZOOMED = new three_1.Vector3(0, -1.45, 0);
11
- const ANIMATION_URLS = {
12
- MALE: 'https://assets.memori.ai/api/v2/asset/2c5e88a4-cf62-408b-9ef0-518b099dfcb2.glb',
13
- FEMALE: 'https://assets.memori.ai/api/v2/asset/8d1a5853-f05a-4a34-9f99-6eff64986081.glb',
14
- };
15
- const BLINK_CONFIG = {
16
- minInterval: 1000,
17
- maxInterval: 5000,
18
- blinkDuration: 150,
19
- };
20
- const EMOTION_SMOOTHING = 0.3;
21
- const VISME_SMOOTHING = 0.5;
22
- function FullbodyAvatar({ url, sex, currentBaseAction, timeScale, isZoomed, eyeBlink, updateCurrentViseme, setMorphTargetDictionary, setMorphTargetInfluences, emotionMorphTargets, }) {
23
- const { scene } = (0, drei_1.useGLTF)(url);
24
- const { animations } = (0, drei_1.useGLTF)(ANIMATION_URLS[sex]);
25
- const { actions } = (0, drei_1.useAnimations)(animations, scene);
26
- const mixerRef = (0, react_1.useRef)();
27
- const headMeshRef = (0, react_1.useRef)();
28
- const currentActionRef = (0, react_1.useRef)(null);
29
- const isTransitioningToIdleRef = (0, react_1.useRef)(false);
30
- const lastBlinkTimeRef = (0, react_1.useRef)(0);
31
- const nextBlinkTimeRef = (0, react_1.useRef)(0);
32
- const isBlinkingRef = (0, react_1.useRef)(false);
33
- const blinkStartTimeRef = (0, react_1.useRef)(0);
34
- const currentEmotionRef = (0, react_1.useRef)({});
35
- const previousEmotionKeysRef = (0, react_1.useRef)(new Set());
36
- const headMesh = (0, react_1.useMemo)(() => {
37
- let foundMesh;
38
- scene.traverse((object) => {
39
- if (object instanceof three_1.SkinnedMesh &&
40
- (object.name === 'GBNL__Head' || object.name === 'Wolf3D_Avatar')) {
41
- foundMesh = object;
42
- }
43
- });
44
- return foundMesh;
45
- }, [scene]);
46
- (0, react_1.useEffect)(() => {
47
- if (headMesh) {
48
- headMeshRef.current = headMesh;
49
- if (headMesh.morphTargetDictionary && headMesh.morphTargetInfluences) {
50
- setMorphTargetDictionary(headMesh.morphTargetDictionary);
51
- const initialInfluences = Object.keys(headMesh.morphTargetDictionary).reduce((acc, key) => ({ ...acc, [key]: 0 }), {});
52
- setMorphTargetInfluences(initialInfluences);
53
- }
54
- }
55
- mixerRef.current = new three_1.AnimationMixer(scene);
56
- }, [headMesh, scene, setMorphTargetDictionary, setMorphTargetInfluences]);
57
- const handleAnimationChange = (0, react_1.useCallback)(() => {
58
- if (!actions || !currentBaseAction.action)
59
- return;
60
- const newAction = actions[currentBaseAction.action];
61
- if (!newAction) {
62
- console.warn(`Animation "${currentBaseAction.action}" not found in actions.`);
63
- return;
64
- }
65
- const fadeOutDuration = 0.8;
66
- const fadeInDuration = 0.8;
67
- if (currentActionRef.current) {
68
- currentActionRef.current.fadeOut(fadeOutDuration);
69
- }
70
- newAction.reset().fadeIn(fadeInDuration).play();
71
- currentActionRef.current = newAction;
72
- newAction.timeScale = timeScale;
73
- if (currentBaseAction.action.startsWith('Gioia') ||
74
- currentBaseAction.action.startsWith('Rabbia') ||
75
- currentBaseAction.action.startsWith('Sorpresa') ||
76
- currentBaseAction.action.startsWith('Timore') ||
77
- currentBaseAction.action.startsWith('Tristezza')) {
78
- newAction.setLoop(three_1.LoopOnce, 1);
79
- newAction.clampWhenFinished = true;
80
- isTransitioningToIdleRef.current = true;
81
- }
82
- }, [actions, currentBaseAction, timeScale]);
83
- (0, react_1.useEffect)(() => {
84
- handleAnimationChange();
85
- }, [handleAnimationChange]);
86
- const updateFrame = (0, react_1.useCallback)((currentTime) => {
87
- var _a;
88
- if (!headMeshRef.current ||
89
- !headMeshRef.current.morphTargetDictionary ||
90
- !headMeshRef.current.morphTargetInfluences)
91
- return;
92
- let blinkValue = 0;
93
- if (eyeBlink) {
94
- if (currentTime >= nextBlinkTimeRef.current && !isBlinkingRef.current) {
95
- isBlinkingRef.current = true;
96
- blinkStartTimeRef.current = currentTime;
97
- lastBlinkTimeRef.current = currentTime;
98
- nextBlinkTimeRef.current =
99
- currentTime +
100
- Math.random() *
101
- (BLINK_CONFIG.maxInterval - BLINK_CONFIG.minInterval) +
102
- BLINK_CONFIG.minInterval;
103
- }
104
- if (isBlinkingRef.current) {
105
- const blinkProgress = (currentTime - blinkStartTimeRef.current) /
106
- BLINK_CONFIG.blinkDuration;
107
- if (blinkProgress <= 0.5) {
108
- blinkValue = blinkProgress * 2;
109
- }
110
- else if (blinkProgress <= 1) {
111
- blinkValue = 2 - blinkProgress * 2;
112
- }
113
- else {
114
- isBlinkingRef.current = false;
115
- blinkValue = 0;
116
- }
117
- }
118
- }
119
- const currentViseme = updateCurrentViseme(currentTime / 1000);
120
- const currentEmotionKeys = new Set(Object.keys(emotionMorphTargets));
121
- Object.entries(headMeshRef.current.morphTargetDictionary).forEach(([key, index]) => {
122
- if (typeof index === 'number') {
123
- let targetValue = 0;
124
- if (currentEmotionKeys.has(key)) {
125
- const targetEmotionValue = emotionMorphTargets[key];
126
- const currentEmotionValue = currentEmotionRef.current[key] || 0;
127
- const newEmotionValue = three_1.MathUtils.lerp(currentEmotionValue, targetEmotionValue * 2.5, EMOTION_SMOOTHING);
128
- currentEmotionRef.current[key] = newEmotionValue;
129
- targetValue += newEmotionValue;
130
- }
131
- if (currentViseme && key === currentViseme.name) {
132
- targetValue += currentViseme.weight;
133
- }
134
- if (key === 'eyesClosed' && eyeBlink) {
135
- targetValue += blinkValue;
136
- }
137
- targetValue = three_1.MathUtils.clamp(targetValue, 0, 1);
138
- if (headMeshRef.current &&
139
- headMeshRef.current.morphTargetInfluences) {
140
- headMeshRef.current.morphTargetInfluences[index] = three_1.MathUtils.lerp(headMeshRef.current.morphTargetInfluences[index], targetValue, VISME_SMOOTHING);
141
- }
142
- }
143
- });
144
- previousEmotionKeysRef.current = currentEmotionKeys;
145
- if (isTransitioningToIdleRef.current && currentActionRef.current) {
146
- if (currentActionRef.current.time >=
147
- currentActionRef.current.getClip().duration) {
148
- const idleNumber = Math.floor(Math.random() * 5) + 1;
149
- const idleAction = actions[`Idle${idleNumber === 3 ? 4 : idleNumber}`];
150
- if (idleAction) {
151
- currentActionRef.current.fadeOut(0.5);
152
- idleAction.reset().fadeIn(0.5).play();
153
- currentActionRef.current = idleAction;
154
- isTransitioningToIdleRef.current = false;
155
- }
156
- }
157
- }
158
- (_a = mixerRef.current) === null || _a === void 0 ? void 0 : _a.update(0.01);
159
- }, [actions, emotionMorphTargets, eyeBlink, updateCurrentViseme]);
160
- (0, fiber_1.useFrame)(state => {
161
- updateFrame(state.clock.elapsedTime * 1000);
162
- });
163
- return ((0, jsx_runtime_1.jsx)("group", { position: isZoomed ? AVATAR_POSITION_ZOOMED : AVATAR_POSITION, rotation: AVATAR_ROTATION, children: (0, jsx_runtime_1.jsx)("primitive", { object: scene }) }));
164
- }
165
- exports.default = FullbodyAvatar;
166
- //# sourceMappingURL=fullbodyAvatar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fullbodyAvatar.js","sourceRoot":"","sources":["../../../../../../src/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.tsx"],"names":[],"mappings":";;;AAAA,iCAAuE;AACvE,iCASe;AACf,4CAA2D;AAC3D,8CAAwD;AA8BxD,MAAM,eAAe,GAAG,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9C,MAAM,eAAe,GAAG,IAAI,aAAK,C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CAAC,CAAC,CAAC,eAAe,EAC7D,QAAQ,EAAE,eAAe,YAEzB,sCAAW,MAAM,EAAE,KAAK,GAAI,GACtB,CACT,CAAC;AACJ,CAAC;AA3ND,iCA2NC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MorhTargetController.js","sourceRoot":"","sources":["../../../../../../../src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/MorhTargetController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhF,MAAM,OAAO,qBAAqB;IAKhC,YAAY,QAAqB;QAHzB,yBAAoB,GAA2B,EAAE,CAAC;QAClD,wBAAmB,GAAgB,IAAI,GAAG,EAAE,CAAC;QAGnD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,kBAAkB,CAChB,WAAmB,EACnB,mBAA2C,EAC3C,aAAsD,EACtD,QAAiB,EACjB,UAKC;QAED,IACE,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB;YACpC,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,EACpC;YACA,OAAO;SACR;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CACzC,WAAW,EACX,UAAU,EACV,QAAQ,CACT,CAAC;QACF,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAErE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC,OAAO,CACzD,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACf,IAAI,OAAO,KAAK,KAAK,QAAQ;gBAAE,OAAO;YAEtC,IAAI,WAAW,GAAG,CAAC,CAAC;YAGpB,IAAI,kBAAkB,CAAC,GAAG,CAAC,GAA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AI,CAAC;YAC7B,UAAU,CAAC,cAAc,GAAG,WAAW,CAAC;YACxC,UAAU,CAAC,aAAa,GAAG,WAAW,CAAC;YACvC,UAAU,CAAC,aAAa;gBACtB,WAAW;oBACX,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC;oBACrE,YAAY,CAAC,WAAW,CAAC;SAC5B;QAED,IAAI,UAAU,CAAC,UAAU,EAAE;YACzB,MAAM,aAAa,GACjB,CAAC,WAAW,GAAG,UAAU,CAAC,cAAc,CAAC,GAAG,YAAY,CAAC,aAAa,CAAC;YACzE,IAAI,aAAa,IAAI,GAAG,EAAE;gBACxB,UAAU,GAAG,aAAa,GAAG,CAAC,CAAC;aAChC;iBAAM,IAAI,aAAa,IAAI,CAAC,EAAE;gBAC7B,UAAU,GAAG,CAAC,GAAG,aAAa,GAAG,CAAC,CAAC;aACpC;iBAAM;gBACL,UAAU,CAAC,UAAU,GAAG,KAAK,CAAC;gBAC9B,UAAU,GAAG,CAAC,CAAC;aAChB;SACF;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF"}
@@ -1,17 +0,0 @@
1
- import { Vector3, Euler } from 'three';
2
- import { AnimationConfig } from './types';
3
- export declare const AVATAR_POSITION: Vector3;
4
- export declare const AVATAR_ROTATION: Euler;
5
- export declare const AVATAR_POSITION_ZOOMED: Vector3;
6
- export declare const ANIMATION_URLS: {
7
- MALE: string;
8
- FEMALE: string;
9
- };
10
- export declare const BLINK_CONFIG: {
11
- minInterval: number;
12
- maxInterval: number;
13
- blinkDuration: number;
14
- };
15
- export declare const DEFAULT_CONFIG: AnimationConfig;
16
- export declare const EMOTION_SMOOTHING = 0.3;
17
- export declare const VISEME_SMOOTHING = 0.5;
@@ -1,22 +0,0 @@
1
- import { Vector3, Euler } from 'three';
2
- export const AVATAR_POSITION = new Vector3(0, -1, 0);
3
- export const AVATAR_ROTATION = new Euler(0.175, 0, 0);
4
- export const AVATAR_POSITION_ZOOMED = new Vector3(0, -1.45, 0);
5
- export const ANIMATION_URLS = {
6
- MALE: 'https://assets.memori.ai/api/v2/asset/2c5e88a4-cf62-408b-9ef0-518b099dfcb2.glb',
7
- FEMALE: 'https://assets.memori.ai/api/v2/asset/2adc934b-24b2-45bd-94ad-ffec58d3cb32.glb',
8
- };
9
- export const BLINK_CONFIG = {
10
- minInterval: 1000,
11
- maxInterval: 5000,
12
- blinkDuration: 150,
13
- };
14
- export const DEFAULT_CONFIG = {
15
- fadeInDuration: 0.8,
16
- fadeOutDuration: 0.8,
17
- idleCount: 5,
18
- timeScale: 1.0,
19
- };
20
- export const EMOTION_SMOOTHING = 0.3;
21
- export const VISEME_SMOOTHING = 0.5;
22
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gFAAgF;IACtF,MAAM,EACJ,gFAAgF;CACnF,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,GAAG;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAoB;IAC7C,cAAc,EAAE,GAAG;IACnB,eAAe,EAAE,GAAG;IACpB,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,GAAG;CACf,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC"}
@@ -1,26 +0,0 @@
1
- interface FullbodyAvatarProps {
2
- url: string;
3
- sex: 'MALE' | 'FEMALE';
4
- onLoaded?: () => void;
5
- currentBaseAction: {
6
- action: string;
7
- weight: number;
8
- };
9
- timeScale: number;
10
- isZoomed?: boolean;
11
- eyeBlink?: boolean;
12
- stopProcessing: () => void;
13
- resetVisemeQueue: () => void;
14
- updateCurrentViseme: (currentTime: number) => {
15
- name: string;
16
- weight: number;
17
- } | null;
18
- smoothMorphTarget?: boolean;
19
- morphTargetSmoothing?: number;
20
- morphTargetInfluences: Record<string, number>;
21
- setMorphTargetDictionary: (morphTargetDictionary: Record<string, number>) => void;
22
- setMorphTargetInfluences: (morphTargetInfluences: Record<string, number>) => void;
23
- emotionMorphTargets: Record<string, number>;
24
- }
25
- export default function FullbodyAvatar({ url, sex, currentBaseAction, timeScale, isZoomed, eyeBlink, updateCurrentViseme, setMorphTargetDictionary, setMorphTargetInfluences, emotionMorphTargets, }: FullbodyAvatarProps): JSX.Element;
26
- export {};
@@ -1,163 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useRef, useMemo, useCallback } from 'react';
3
- import { Vector3, Euler, AnimationMixer, SkinnedMesh, MathUtils, LoopOnce, } from 'three';
4
- import { useAnimations, useGLTF } from '@react-three/drei';
5
- import { useFrame } from '@react-three/fiber';
6
- const AVATAR_POSITION = new Vector3(0, -1, 0);
7
- const AVATAR_ROTATION = new Euler(0.175, 0, 0);
8
- const AVATAR_POSITION_ZOOMED = new Vector3(0, -1.45, 0);
9
- const ANIMATION_URLS = {
10
- MALE: 'https://assets.memori.ai/api/v2/asset/2c5e88a4-cf62-408b-9ef0-518b099dfcb2.glb',
11
- FEMALE: 'https://assets.memori.ai/api/v2/asset/8d1a5853-f05a-4a34-9f99-6eff64986081.glb',
12
- };
13
- const BLINK_CONFIG = {
14
- minInterval: 1000,
15
- maxInterval: 5000,
16
- blinkDuration: 150,
17
- };
18
- const EMOTION_SMOOTHING = 0.3;
19
- const VISME_SMOOTHING = 0.5;
20
- export default function FullbodyAvatar({ url, sex, currentBaseAction, timeScale, isZoomed, eyeBlink, updateCurrentViseme, setMorphTargetDictionary, setMorphTargetInfluences, emotionMorphTargets, }) {
21
- const { scene } = useGLTF(url);
22
- const { animations } = useGLTF(ANIMATION_URLS[sex]);
23
- const { actions } = useAnimations(animations, scene);
24
- const mixerRef = useRef();
25
- const headMeshRef = useRef();
26
- const currentActionRef = useRef(null);
27
- const isTransitioningToIdleRef = useRef(false);
28
- const lastBlinkTimeRef = useRef(0);
29
- const nextBlinkTimeRef = useRef(0);
30
- const isBlinkingRef = useRef(false);
31
- const blinkStartTimeRef = useRef(0);
32
- const currentEmotionRef = useRef({});
33
- const previousEmotionKeysRef = useRef(new Set());
34
- const headMesh = useMemo(() => {
35
- let foundMesh;
36
- scene.traverse((object) => {
37
- if (object instanceof SkinnedMesh &&
38
- (object.name === 'GBNL__Head' || object.name === 'Wolf3D_Avatar')) {
39
- foundMesh = object;
40
- }
41
- });
42
- return foundMesh;
43
- }, [scene]);
44
- useEffect(() => {
45
- if (headMesh) {
46
- headMeshRef.current = headMesh;
47
- if (headMesh.morphTargetDictionary && headMesh.morphTargetInfluences) {
48
- setMorphTargetDictionary(headMesh.morphTargetDictionary);
49
- const initialInfluences = Object.keys(headMesh.morphTargetDictionary).reduce((acc, key) => ({ ...acc, [key]: 0 }), {});
50
- setMorphTargetInfluences(initialInfluences);
51
- }
52
- }
53
- mixerRef.current = new AnimationMixer(scene);
54
- }, [headMesh, scene, setMorphTargetDictionary, setMorphTargetInfluences]);
55
- const handleAnimationChange = useCallback(() => {
56
- if (!actions || !currentBaseAction.action)
57
- return;
58
- const newAction = actions[currentBaseAction.action];
59
- if (!newAction) {
60
- console.warn(`Animation "${currentBaseAction.action}" not found in actions.`);
61
- return;
62
- }
63
- const fadeOutDuration = 0.8;
64
- const fadeInDuration = 0.8;
65
- if (currentActionRef.current) {
66
- currentActionRef.current.fadeOut(fadeOutDuration);
67
- }
68
- newAction.reset().fadeIn(fadeInDuration).play();
69
- currentActionRef.current = newAction;
70
- newAction.timeScale = timeScale;
71
- if (currentBaseAction.action.startsWith('Gioia') ||
72
- currentBaseAction.action.startsWith('Rabbia') ||
73
- currentBaseAction.action.startsWith('Sorpresa') ||
74
- currentBaseAction.action.startsWith('Timore') ||
75
- currentBaseAction.action.startsWith('Tristezza')) {
76
- newAction.setLoop(LoopOnce, 1);
77
- newAction.clampWhenFinished = true;
78
- isTransitioningToIdleRef.current = true;
79
- }
80
- }, [actions, currentBaseAction, timeScale]);
81
- useEffect(() => {
82
- handleAnimationChange();
83
- }, [handleAnimationChange]);
84
- const updateFrame = useCallback((currentTime) => {
85
- var _a;
86
- if (!headMeshRef.current ||
87
- !headMeshRef.current.morphTargetDictionary ||
88
- !headMeshRef.current.morphTargetInfluences)
89
- return;
90
- let blinkValue = 0;
91
- if (eyeBlink) {
92
- if (currentTime >= nextBlinkTimeRef.current && !isBlinkingRef.current) {
93
- isBlinkingRef.current = true;
94
- blinkStartTimeRef.current = currentTime;
95
- lastBlinkTimeRef.current = currentTime;
96
- nextBlinkTimeRef.current =
97
- currentTime +
98
- Math.random() *
99
- (BLINK_CONFIG.maxInterval - BLINK_CONFIG.minInterval) +
100
- BLINK_CONFIG.minInterval;
101
- }
102
- if (isBlinkingRef.current) {
103
- const blinkProgress = (currentTime - blinkStartTimeRef.current) /
104
- BLINK_CONFIG.blinkDuration;
105
- if (blinkProgress <= 0.5) {
106
- blinkValue = blinkProgress * 2;
107
- }
108
- else if (blinkProgress <= 1) {
109
- blinkValue = 2 - blinkProgress * 2;
110
- }
111
- else {
112
- isBlinkingRef.current = false;
113
- blinkValue = 0;
114
- }
115
- }
116
- }
117
- const currentViseme = updateCurrentViseme(currentTime / 1000);
118
- const currentEmotionKeys = new Set(Object.keys(emotionMorphTargets));
119
- Object.entries(headMeshRef.current.morphTargetDictionary).forEach(([key, index]) => {
120
- if (typeof index === 'number') {
121
- let targetValue = 0;
122
- if (currentEmotionKeys.has(key)) {
123
- const targetEmotionValue = emotionMorphTargets[key];
124
- const currentEmotionValue = currentEmotionRef.current[key] || 0;
125
- const newEmotionValue = MathUtils.lerp(currentEmotionValue, targetEmotionValue * 2.5, EMOTION_SMOOTHING);
126
- currentEmotionRef.current[key] = newEmotionValue;
127
- targetValue += newEmotionValue;
128
- }
129
- if (currentViseme && key === currentViseme.name) {
130
- targetValue += currentViseme.weight;
131
- }
132
- if (key === 'eyesClosed' && eyeBlink) {
133
- targetValue += blinkValue;
134
- }
135
- targetValue = MathUtils.clamp(targetValue, 0, 1);
136
- if (headMeshRef.current &&
137
- headMeshRef.current.morphTargetInfluences) {
138
- headMeshRef.current.morphTargetInfluences[index] = MathUtils.lerp(headMeshRef.current.morphTargetInfluences[index], targetValue, VISME_SMOOTHING);
139
- }
140
- }
141
- });
142
- previousEmotionKeysRef.current = currentEmotionKeys;
143
- if (isTransitioningToIdleRef.current && currentActionRef.current) {
144
- if (currentActionRef.current.time >=
145
- currentActionRef.current.getClip().duration) {
146
- const idleNumber = Math.floor(Math.random() * 5) + 1;
147
- const idleAction = actions[`Idle${idleNumber === 3 ? 4 : idleNumber}`];
148
- if (idleAction) {
149
- currentActionRef.current.fadeOut(0.5);
150
- idleAction.reset().fadeIn(0.5).play();
151
- currentActionRef.current = idleAction;
152
- isTransitioningToIdleRef.current = false;
153
- }
154
- }
155
- }
156
- (_a = mixerRef.current) === null || _a === void 0 ? void 0 : _a.update(0.01);
157
- }, [actions, emotionMorphTargets, eyeBlink, updateCurrentViseme]);
158
- useFrame(state => {
159
- updateFrame(state.clock.elapsedTime * 1000);
160
- });
161
- return (_jsx("group", { position: isZoomed ? AVATAR_POSITION_ZOOMED : AVATAR_POSITION, rotation: AVATAR_ROTATION, children: _jsx("primitive", { object: scene }) }));
162
- }
163
- //# sourceMappingURL=fullbodyAvatar.js.map