@memori.ai/memori-react 7.7.1 → 7.8.0-rc.0
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/CHANGELOG.md +22 -0
- package/dist/components/Avatar/Avatar.js +2 -2
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.d.ts +6 -3
- package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js +10 -6
- package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.d.ts +13 -17
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js +110 -111
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.d.ts +3 -4
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js +77 -52
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/index.d.ts +7 -3
- package/dist/components/Avatar/AvatarView/index.js +2 -2
- package/dist/components/Avatar/AvatarView/index.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +34 -22
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/layouts/ZoomedFullBody.js +1 -8
- package/dist/components/layouts/ZoomedFullBody.js.map +1 -1
- package/dist/components/layouts/zoomed-full-body.css +5 -1
- package/dist/context/visemeContext.d.ts +9 -15
- package/dist/context/visemeContext.js +73 -190
- package/dist/context/visemeContext.js.map +1 -1
- package/esm/components/Avatar/Avatar.js +2 -2
- package/esm/components/Avatar/Avatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.d.ts +6 -3
- package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js +10 -6
- package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.d.ts +13 -17
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js +112 -113
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.d.ts +3 -4
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js +81 -55
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/index.d.ts +7 -3
- package/esm/components/Avatar/AvatarView/index.js +2 -2
- package/esm/components/Avatar/AvatarView/index.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +34 -22
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/layouts/ZoomedFullBody.js +1 -8
- package/esm/components/layouts/ZoomedFullBody.js.map +1 -1
- package/esm/components/layouts/zoomed-full-body.css +5 -1
- package/esm/context/visemeContext.d.ts +9 -15
- package/esm/context/visemeContext.js +74 -191
- package/esm/context/visemeContext.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Avatar/Avatar.tsx +5 -5
- package/src/components/Avatar/AvatarView/AvatarComponent/avatarComponent.tsx +33 -19
- package/src/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.tsx +181 -158
- package/src/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.tsx +116 -71
- package/src/components/Avatar/AvatarView/AvatarView.stories.tsx +12 -24
- package/src/components/Avatar/AvatarView/index.tsx +9 -8
- package/src/components/MemoriWidget/MemoriWidget.tsx +45 -38
- package/src/components/layouts/ZoomedFullBody.tsx +6 -11
- package/src/components/layouts/zoomed-full-body.css +5 -1
- package/src/context/visemeContext.tsx +130 -283
- package/dist/components/AttachmentMediaModal/AttachmentMediaModal.d.ts +0 -14
- package/dist/components/AttachmentMediaModal/AttachmentMediaModal.js +0 -66
- package/dist/components/AttachmentMediaModal/AttachmentMediaModal.js.map +0 -1
- package/dist/components/Avatar/AvatarView/components/controls.d.ts +0 -23
- package/dist/components/Avatar/AvatarView/components/controls.js +0 -55
- package/dist/components/Avatar/AvatarView/components/controls.js.map +0 -1
- package/dist/components/Avatar/AvatarView/components/fullbodyAvatar.d.ts +0 -19
- package/dist/components/Avatar/AvatarView/components/fullbodyAvatar.js +0 -61
- package/dist/components/Avatar/AvatarView/components/fullbodyAvatar.js.map +0 -1
- package/dist/components/Avatar/AvatarView/components/halfbodyAvatar.d.ts +0 -9
- package/dist/components/Avatar/AvatarView/components/halfbodyAvatar.js +0 -39
- package/dist/components/Avatar/AvatarView/components/halfbodyAvatar.js.map +0 -1
- package/dist/components/Avatar/AvatarView/components/loader.d.ts +0 -5
- package/dist/components/Avatar/AvatarView/components/loader.js +0 -12
- package/dist/components/Avatar/AvatarView/components/loader.js.map +0 -1
- package/dist/components/Avatar/AvatarView/utils/useMouthSpeaking.d.ts +0 -2
- package/dist/components/Avatar/AvatarView/utils/useMouthSpeaking.js +0 -68
- package/dist/components/Avatar/AvatarView/utils/useMouthSpeaking.js.map +0 -1
- package/dist/components/AvatarView/components/avatar.d.ts +0 -9
- package/dist/components/AvatarView/components/avatar.js +0 -35
- package/dist/components/AvatarView/components/avatar.js.map +0 -1
- package/dist/components/AvatarView/components/fullbodyAvatar.d.ts +0 -10
- package/dist/components/AvatarView/components/fullbodyAvatar.js +0 -62
- package/dist/components/AvatarView/components/fullbodyAvatar.js.map +0 -1
- package/dist/components/AvatarView/components/loader.d.ts +0 -5
- package/dist/components/AvatarView/components/loader.js +0 -12
- package/dist/components/AvatarView/components/loader.js.map +0 -1
- package/dist/components/AvatarView/index.d.ts +0 -17
- package/dist/components/AvatarView/index.js +0 -35
- package/dist/components/AvatarView/index.js.map +0 -1
- package/dist/components/AvatarView/utils/useEyeBlink.d.ts +0 -2
- package/dist/components/AvatarView/utils/useEyeBlink.js +0 -40
- package/dist/components/AvatarView/utils/useEyeBlink.js.map +0 -1
- package/dist/components/AvatarView/utils/useHeadMovement.d.ts +0 -2
- package/dist/components/AvatarView/utils/useHeadMovement.js +0 -53
- package/dist/components/AvatarView/utils/useHeadMovement.js.map +0 -1
- package/dist/components/AvatarView/utils/useLoadingMorphAnim.d.ts +0 -2
- package/dist/components/AvatarView/utils/useLoadingMorphAnim.js +0 -34
- package/dist/components/AvatarView/utils/useLoadingMorphAnim.js.map +0 -1
- package/dist/components/AvatarView/utils/useMouthSpeaking.d.ts +0 -2
- package/dist/components/AvatarView/utils/useMouthSpeaking.js +0 -60
- package/dist/components/AvatarView/utils/useMouthSpeaking.js.map +0 -1
- package/dist/components/AvatarView/utils/useSmile.d.ts +0 -2
- package/dist/components/AvatarView/utils/useSmile.js +0 -30
- package/dist/components/AvatarView/utils/useSmile.js.map +0 -1
- package/dist/components/AvatarView/utils/utils.d.ts +0 -13
- package/dist/components/AvatarView/utils/utils.js +0 -42
- package/dist/components/AvatarView/utils/utils.js.map +0 -1
- package/dist/components/ImageUpload/ImageUpload.css +0 -168
- package/dist/components/ImageUpload/ImageUpload.d.ts +0 -28
- package/dist/components/ImageUpload/ImageUpload.js +0 -163
- package/dist/components/ImageUpload/ImageUpload.js.map +0 -1
- package/dist/components/layouts/Default.d.ts +0 -17
- package/dist/components/layouts/Default.js +0 -8
- package/dist/components/layouts/Default.js.map +0 -1
- package/dist/components/ui/Message.d.ts +0 -17
- package/dist/components/ui/Message.js +0 -13
- package/dist/components/ui/Message.js.map +0 -1
- package/esm/components/AttachmentMediaModal/AttachmentMediaModal.d.ts +0 -14
- package/esm/components/AttachmentMediaModal/AttachmentMediaModal.js +0 -63
- package/esm/components/AttachmentMediaModal/AttachmentMediaModal.js.map +0 -1
- package/esm/components/Avatar/AvatarView/components/controls.d.ts +0 -23
- package/esm/components/Avatar/AvatarView/components/controls.js +0 -52
- package/esm/components/Avatar/AvatarView/components/controls.js.map +0 -1
- package/esm/components/Avatar/AvatarView/components/fullbodyAvatar.d.ts +0 -19
- package/esm/components/Avatar/AvatarView/components/fullbodyAvatar.js +0 -57
- package/esm/components/Avatar/AvatarView/components/fullbodyAvatar.js.map +0 -1
- package/esm/components/Avatar/AvatarView/components/halfbodyAvatar.d.ts +0 -9
- package/esm/components/Avatar/AvatarView/components/halfbodyAvatar.js +0 -35
- package/esm/components/Avatar/AvatarView/components/halfbodyAvatar.js.map +0 -1
- package/esm/components/Avatar/AvatarView/components/loader.d.ts +0 -5
- package/esm/components/Avatar/AvatarView/components/loader.js +0 -9
- package/esm/components/Avatar/AvatarView/components/loader.js.map +0 -1
- package/esm/components/Avatar/AvatarView/utils/useMouthSpeaking.d.ts +0 -2
- package/esm/components/Avatar/AvatarView/utils/useMouthSpeaking.js +0 -65
- package/esm/components/Avatar/AvatarView/utils/useMouthSpeaking.js.map +0 -1
- package/esm/components/AvatarView/components/avatar.d.ts +0 -9
- package/esm/components/AvatarView/components/avatar.js +0 -31
- package/esm/components/AvatarView/components/avatar.js.map +0 -1
- package/esm/components/AvatarView/components/fullbodyAvatar.d.ts +0 -10
- package/esm/components/AvatarView/components/fullbodyAvatar.js +0 -58
- package/esm/components/AvatarView/components/fullbodyAvatar.js.map +0 -1
- package/esm/components/AvatarView/components/loader.d.ts +0 -5
- package/esm/components/AvatarView/components/loader.js +0 -9
- package/esm/components/AvatarView/components/loader.js.map +0 -1
- package/esm/components/AvatarView/index.d.ts +0 -17
- package/esm/components/AvatarView/index.js +0 -31
- package/esm/components/AvatarView/index.js.map +0 -1
- package/esm/components/AvatarView/utils/useEyeBlink.d.ts +0 -2
- package/esm/components/AvatarView/utils/useEyeBlink.js +0 -37
- package/esm/components/AvatarView/utils/useEyeBlink.js.map +0 -1
- package/esm/components/AvatarView/utils/useHeadMovement.d.ts +0 -2
- package/esm/components/AvatarView/utils/useHeadMovement.js +0 -50
- package/esm/components/AvatarView/utils/useHeadMovement.js.map +0 -1
- package/esm/components/AvatarView/utils/useLoadingMorphAnim.d.ts +0 -2
- package/esm/components/AvatarView/utils/useLoadingMorphAnim.js +0 -31
- package/esm/components/AvatarView/utils/useLoadingMorphAnim.js.map +0 -1
- package/esm/components/AvatarView/utils/useMouthSpeaking.d.ts +0 -2
- package/esm/components/AvatarView/utils/useMouthSpeaking.js +0 -57
- package/esm/components/AvatarView/utils/useMouthSpeaking.js.map +0 -1
- package/esm/components/AvatarView/utils/useSmile.d.ts +0 -2
- package/esm/components/AvatarView/utils/useSmile.js +0 -27
- package/esm/components/AvatarView/utils/useSmile.js.map +0 -1
- package/esm/components/AvatarView/utils/utils.d.ts +0 -13
- package/esm/components/AvatarView/utils/utils.js +0 -33
- package/esm/components/AvatarView/utils/utils.js.map +0 -1
- package/esm/components/ImageUpload/ImageUpload.css +0 -168
- package/esm/components/ImageUpload/ImageUpload.d.ts +0 -28
- package/esm/components/ImageUpload/ImageUpload.js +0 -160
- package/esm/components/ImageUpload/ImageUpload.js.map +0 -1
- package/esm/components/layouts/Default.d.ts +0 -17
- package/esm/components/layouts/Default.js +0 -5
- package/esm/components/layouts/Default.js.map +0 -1
- package/esm/components/ui/Message.d.ts +0 -17
- package/esm/components/ui/Message.js +0 -10
- package/esm/components/ui/Message.js.map +0 -1
|
@@ -1,332 +1,179 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
createContext,
|
|
3
3
|
useContext,
|
|
4
|
-
useState,
|
|
5
|
-
useCallback,
|
|
6
4
|
useRef,
|
|
5
|
+
useCallback,
|
|
6
|
+
useState,
|
|
7
7
|
useEffect,
|
|
8
8
|
} from 'react';
|
|
9
|
-
import { MathUtils, SkinnedMesh } from 'three';
|
|
10
9
|
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
type ProcessedViseme = {
|
|
10
|
+
type Viseme = {
|
|
14
11
|
name: string;
|
|
15
|
-
duration: number;
|
|
16
12
|
weight: number;
|
|
17
13
|
startTime: number;
|
|
14
|
+
endTime: number;
|
|
18
15
|
};
|
|
19
16
|
|
|
20
17
|
interface VisemeContextType {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
getAzureStyleForEmotion: (emotion: string) => string;
|
|
18
|
+
addViseme: (visemeId: number, audioOffset: number) => void;
|
|
19
|
+
updateCurrentViseme: (currentTime: number) => Viseme | null;
|
|
20
|
+
startProcessing: () => void;
|
|
21
|
+
stopProcessing: () => void;
|
|
22
|
+
resetVisemeQueue: () => void;
|
|
23
|
+
resetAndStartProcessing: () => void;
|
|
24
|
+
isProcessing: boolean;
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
const VisemeContext = createContext<VisemeContextType | undefined>(undefined);
|
|
32
28
|
|
|
33
|
-
const VISEME_SMOOTHING = 0.3;
|
|
34
|
-
const DEFAULT_VISEME_DURATION = 0.1;
|
|
35
|
-
const MINIMUM_ELAPSED_TIME = 0.01;
|
|
36
|
-
const VISEME_SPEED_FACTOR = 1;
|
|
37
|
-
const AUDIO_PLAYBACK_RATE = 1;
|
|
38
|
-
const VISEME_BASE_SPEED = 1;
|
|
39
|
-
|
|
40
29
|
const VISEME_MAP: { [key: number]: string } = {
|
|
41
|
-
0: 'viseme_sil',
|
|
42
|
-
1: 'viseme_PP',
|
|
43
|
-
2: 'viseme_FF',
|
|
44
|
-
3: 'viseme_TH',
|
|
45
|
-
4: 'viseme_DD',
|
|
46
|
-
5: 'viseme_kk',
|
|
47
|
-
6: 'viseme_CH',
|
|
48
|
-
7: 'viseme_SS',
|
|
49
|
-
8: 'viseme_nn',
|
|
50
|
-
9: 'viseme_RR',
|
|
51
|
-
10: 'viseme_aa',
|
|
52
|
-
11: 'viseme_E',
|
|
53
|
-
12: 'viseme_I',
|
|
54
|
-
13: 'viseme_O',
|
|
55
|
-
14: 'viseme_U',
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
30
|
+
0: 'viseme_sil', // silence
|
|
31
|
+
1: 'viseme_PP', // p, b, m
|
|
32
|
+
2: 'viseme_FF', // f, v
|
|
33
|
+
3: 'viseme_TH', // th, dh
|
|
34
|
+
4: 'viseme_DD', // t, d, n, l
|
|
35
|
+
5: 'viseme_kk', // k, g, ng
|
|
36
|
+
6: 'viseme_CH', // tS, dZ, S, Z
|
|
37
|
+
7: 'viseme_SS', // s, z
|
|
38
|
+
8: 'viseme_nn', // Not explicitly defined in Azure mapping, keeping for compatibility
|
|
39
|
+
9: 'viseme_RR', // r
|
|
40
|
+
10: 'viseme_aa', // A:
|
|
41
|
+
11: 'viseme_E', // e
|
|
42
|
+
12: 'viseme_I', // I
|
|
43
|
+
13: 'viseme_O', // O
|
|
44
|
+
14: 'viseme_U', // u
|
|
45
|
+
// Mapping the rest based on closest matches or keeping them as in the original mapping
|
|
46
|
+
15: 'viseme_kk', // g, k (same as 5)
|
|
47
|
+
16: 'viseme_CH', // ch, j, sh, zh (same as 6)
|
|
48
|
+
17: 'viseme_SS', // s, z (same as 7)
|
|
49
|
+
18: 'viseme_TH', // th, dh (same as 3)
|
|
50
|
+
19: 'viseme_RR', // r (same as 9)
|
|
51
|
+
20: 'viseme_kk', // w (closest match, could be debated)
|
|
52
|
+
21: 'viseme_PP', // y (closest match, could be debated)
|
|
63
53
|
};
|
|
64
54
|
|
|
55
|
+
const DEFAULT_VISEME_DURATION = 0.04; //0; // Reduced from 0.4 for smoother transitions
|
|
56
|
+
const VISEME_OVERLAP = 0.15; // Slightly increased from 0.04 for more overlap
|
|
57
|
+
const SMOOTHING_FACTOR = 0.35; // New constant for weight smoothing
|
|
58
|
+
const TIME_OFFSET = -0.04; // Adjust this value as needed (in seconds)
|
|
59
|
+
const PRELOAD_TIME = 1; // Preload visemes 0.5 seconds in advance
|
|
60
|
+
|
|
65
61
|
export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
66
62
|
children,
|
|
67
63
|
}) => {
|
|
68
|
-
const
|
|
69
|
-
const [emotion, setEmotion] = useState('Neutral');
|
|
70
|
-
const isAnimatingRef = useRef(false);
|
|
71
|
-
const currentVisemesRef = useRef<ProcessedViseme[]>([]);
|
|
72
|
-
const visemeQueueRef = useRef<AzureViseme[]>([]);
|
|
73
|
-
const animationFrameRef = useRef<number | null>(null);
|
|
64
|
+
const visemeQueueRef = useRef<Viseme[]>([]);
|
|
74
65
|
const startTimeRef = useRef<number | null>(null);
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
66
|
+
const [isProcessing, setIsProcessing] = useState(false);
|
|
67
|
+
const lastVisemeRef = useRef<Viseme | null>(null);
|
|
68
|
+
|
|
69
|
+
const addViseme = useCallback(
|
|
70
|
+
(visemeId: number, audioOffset: number) => {
|
|
71
|
+
const visemeName = VISEME_MAP[visemeId] || 'viseme_sil';
|
|
72
|
+
const startTime = audioOffset / 10000000 + TIME_OFFSET;
|
|
73
|
+
const endTime = startTime + DEFAULT_VISEME_DURATION;
|
|
74
|
+
const newViseme: Viseme = {
|
|
75
|
+
name: visemeName,
|
|
76
|
+
weight: 0,
|
|
77
|
+
startTime,
|
|
78
|
+
endTime,
|
|
79
|
+
};
|
|
80
|
+
visemeQueueRef.current.push(newViseme);
|
|
81
|
+
|
|
82
|
+
if (!isProcessing) {
|
|
83
|
+
startProcessing();
|
|
93
84
|
}
|
|
94
85
|
},
|
|
95
|
-
[
|
|
86
|
+
[isProcessing]
|
|
96
87
|
);
|
|
97
88
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (elapsedTime < MINIMUM_ELAPSED_TIME) return null;
|
|
104
|
-
|
|
105
|
-
return currentVisemesRef.current.find((viseme, index) => {
|
|
106
|
-
const nextViseme = currentVisemesRef.current[index + 1];
|
|
107
|
-
return (
|
|
108
|
-
elapsedTime >= viseme.startTime &&
|
|
109
|
-
(!nextViseme || elapsedTime < nextViseme.startTime)
|
|
110
|
-
);
|
|
111
|
-
});
|
|
112
|
-
}, []);
|
|
113
|
-
|
|
114
|
-
const getDynamicSpeedFactor = (visemeDuration: number): number => {
|
|
115
|
-
const baseDuration = 0.1;
|
|
116
|
-
return (
|
|
117
|
-
VISEME_BASE_SPEED * (baseDuration / visemeDuration) * AUDIO_PLAYBACK_RATE
|
|
118
|
-
);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const applyViseme = useCallback(
|
|
122
|
-
(viseme: ProcessedViseme, elapsedTime: number) => {
|
|
123
|
-
if (!meshRef.current) {
|
|
124
|
-
console.error('Mesh not set');
|
|
125
|
-
return;
|
|
89
|
+
const updateCurrentViseme = useCallback(
|
|
90
|
+
(currentTime: number): Viseme | null => {
|
|
91
|
+
if (!isProcessing || startTimeRef.current === null) {
|
|
92
|
+
console.log('StartTimeRef not set');
|
|
93
|
+
return null;
|
|
126
94
|
}
|
|
127
95
|
|
|
128
|
-
const
|
|
129
|
-
(elapsedTime - viseme.startTime) / viseme.duration,
|
|
130
|
-
1
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
const dynamicSpeedFactor = getDynamicSpeedFactor(viseme.duration);
|
|
134
|
-
const adjustedProgress = visemeProgress * dynamicSpeedFactor;
|
|
96
|
+
const elapsedTime = currentTime - startTimeRef.current + PRELOAD_TIME;
|
|
135
97
|
|
|
136
|
-
|
|
137
|
-
|
|
98
|
+
// Remove expired visemes
|
|
99
|
+
visemeQueueRef.current = visemeQueueRef.current.filter(
|
|
100
|
+
v => v.endTime > elapsedTime
|
|
101
|
+
);
|
|
138
102
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
VISEME_SMOOTHING
|
|
103
|
+
const currentViseme = visemeQueueRef.current.find(
|
|
104
|
+
v =>
|
|
105
|
+
v.startTime <= elapsedTime && v.endTime > elapsedTime - VISEME_OVERLAP
|
|
143
106
|
);
|
|
144
107
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
108
|
+
if (currentViseme) {
|
|
109
|
+
console.log('CurrentViseme Found!');
|
|
110
|
+
const visemeProgress =
|
|
111
|
+
(elapsedTime - currentViseme.startTime) /
|
|
112
|
+
(currentViseme.endTime - currentViseme.startTime);
|
|
113
|
+
const targetWeight = Math.sin(Math.PI * Math.min(visemeProgress, 1));
|
|
114
|
+
|
|
115
|
+
// Smooth the weight transition
|
|
116
|
+
const smoothedWeight = lastVisemeRef.current
|
|
117
|
+
? lastVisemeRef.current.weight +
|
|
118
|
+
(targetWeight - lastVisemeRef.current.weight) * SMOOTHING_FACTOR
|
|
119
|
+
: targetWeight;
|
|
120
|
+
|
|
121
|
+
const updatedViseme = { ...currentViseme, weight: smoothedWeight };
|
|
122
|
+
lastVisemeRef.current = updatedViseme;
|
|
123
|
+
return updatedViseme;
|
|
156
124
|
}
|
|
157
125
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
meshRef.current!.morphTargetInfluences[index] = currentVisemeWeightRef.current[visemeName];
|
|
169
|
-
}
|
|
126
|
+
// Gradually reduce weight when no viseme is active
|
|
127
|
+
if (lastVisemeRef.current) {
|
|
128
|
+
const reducedWeight =
|
|
129
|
+
lastVisemeRef.current.weight * (1 - SMOOTHING_FACTOR);
|
|
130
|
+
if (reducedWeight > 0.01) {
|
|
131
|
+
lastVisemeRef.current = {
|
|
132
|
+
...lastVisemeRef.current,
|
|
133
|
+
weight: reducedWeight,
|
|
134
|
+
};
|
|
135
|
+
return lastVisemeRef.current;
|
|
170
136
|
}
|
|
171
|
-
});
|
|
172
|
-
},
|
|
173
|
-
[]
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
const animate = useCallback(
|
|
177
|
-
(time: number) => {
|
|
178
|
-
if (startTimeRef.current === null) {
|
|
179
|
-
startTimeRef.current = time;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const elapsedTime =
|
|
183
|
-
((time - startTimeRef.current) / 1000) * VISEME_SPEED_FACTOR;
|
|
184
|
-
|
|
185
|
-
const currentViseme = getCurrentViseme(elapsedTime);
|
|
186
|
-
|
|
187
|
-
if (currentViseme) {
|
|
188
|
-
applyViseme(currentViseme, elapsedTime);
|
|
189
137
|
}
|
|
190
138
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
elapsedTime <
|
|
194
|
-
currentVisemesRef.current[currentVisemesRef.current.length - 1]
|
|
195
|
-
.startTime +
|
|
196
|
-
currentVisemesRef.current[currentVisemesRef.current.length - 1]
|
|
197
|
-
.duration
|
|
198
|
-
) {
|
|
199
|
-
animationFrameRef.current = requestAnimationFrame(animate);
|
|
200
|
-
} else {
|
|
201
|
-
clearVisemes();
|
|
202
|
-
}
|
|
139
|
+
lastVisemeRef.current = null;
|
|
140
|
+
return null;
|
|
203
141
|
},
|
|
204
|
-
[
|
|
142
|
+
[isProcessing]
|
|
205
143
|
);
|
|
206
144
|
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return [];
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const processedVisemes: ProcessedViseme[] = azureVisemes.map(
|
|
216
|
-
(currentViseme, i) => {
|
|
217
|
-
const nextViseme = azureVisemes[i + 1];
|
|
218
|
-
const duration = nextViseme
|
|
219
|
-
? (nextViseme.audioOffset - currentViseme.audioOffset) / 10000000
|
|
220
|
-
: DEFAULT_VISEME_DURATION;
|
|
221
|
-
|
|
222
|
-
const processedViseme = {
|
|
223
|
-
name: VISEME_MAP[currentViseme.visemeId] || 'viseme_sil',
|
|
224
|
-
duration,
|
|
225
|
-
weight: 1,
|
|
226
|
-
startTime: currentViseme.audioOffset / 10000000,
|
|
227
|
-
};
|
|
228
|
-
return processedViseme;
|
|
229
|
-
}
|
|
230
|
-
);
|
|
231
|
-
|
|
232
|
-
const interpolatedVisemes: ProcessedViseme[] = [];
|
|
233
|
-
for (let i = 0; i < processedVisemes.length - 1; i++) {
|
|
234
|
-
const currentViseme = processedVisemes[i];
|
|
235
|
-
const nextViseme = processedVisemes[i + 1];
|
|
236
|
-
|
|
237
|
-
interpolatedVisemes.push(currentViseme);
|
|
238
|
-
|
|
239
|
-
const intermediateDuration = (nextViseme.startTime - currentViseme.startTime) * 0.5;
|
|
240
|
-
interpolatedVisemes.push({
|
|
241
|
-
name: 'viseme_sil',
|
|
242
|
-
duration: intermediateDuration,
|
|
243
|
-
weight: 0.5,
|
|
244
|
-
startTime: currentViseme.startTime + intermediateDuration,
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
interpolatedVisemes.push(processedVisemes[processedVisemes.length - 1]);
|
|
248
|
-
|
|
249
|
-
currentVisemesRef.current = interpolatedVisemes;
|
|
250
|
-
|
|
251
|
-
if (!isAnimatingRef.current) {
|
|
252
|
-
isAnimatingRef.current = true;
|
|
253
|
-
startTimeRef.current = performance.now();
|
|
254
|
-
animationFrameRef.current = requestAnimationFrame(animate);
|
|
255
|
-
} else {
|
|
256
|
-
if (startTimeRef.current !== null) {
|
|
257
|
-
const currentTime = performance.now();
|
|
258
|
-
const elapsedTime =
|
|
259
|
-
((currentTime - startTimeRef.current) / 1000) * VISEME_SPEED_FACTOR;
|
|
260
|
-
startTimeRef.current =
|
|
261
|
-
currentTime - (elapsedTime / VISEME_SPEED_FACTOR) * 1000;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
return interpolatedVisemes;
|
|
266
|
-
}, [animate]);
|
|
145
|
+
const startProcessing = useCallback(() => {
|
|
146
|
+
// if (isProcessing) return;
|
|
147
|
+
startTimeRef.current = performance.now() / 1000;
|
|
148
|
+
setIsProcessing(true);
|
|
149
|
+
}, [isProcessing]);
|
|
267
150
|
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
visemeQueueRef.current = [];
|
|
271
|
-
|
|
272
|
-
if (animationFrameRef.current !== null) {
|
|
273
|
-
cancelAnimationFrame(animationFrameRef.current);
|
|
274
|
-
animationFrameRef.current = null;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (
|
|
278
|
-
meshRef.current?.morphTargetDictionary &&
|
|
279
|
-
meshRef.current?.morphTargetInfluences
|
|
280
|
-
) {
|
|
281
|
-
Object.values(meshRef.current.morphTargetDictionary).forEach(index => {
|
|
282
|
-
if (typeof index === 'number') {
|
|
283
|
-
meshRef.current!.morphTargetInfluences![index] = 0;
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
currentVisemeWeightRef.current = {};
|
|
151
|
+
const stopProcessing = useCallback(() => {
|
|
152
|
+
setIsProcessing(false);
|
|
289
153
|
startTimeRef.current = null;
|
|
290
|
-
|
|
154
|
+
lastVisemeRef.current = null;
|
|
291
155
|
}, []);
|
|
292
156
|
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
Sorpresa: { Sorpresa: 1 },
|
|
297
|
-
Tristezza: { Tristezza: 1 },
|
|
298
|
-
Timore: { Timore: 1 },
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
const emotionToAzureStyleMap: Record<string, string> = {
|
|
302
|
-
Gioia: 'cheerful',
|
|
303
|
-
Rabbia: 'angry',
|
|
304
|
-
Sorpresa: 'excited',
|
|
305
|
-
Tristezza: 'sad',
|
|
306
|
-
Timore: 'terrified',
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
function getAzureStyleForEmotion(emotion: string): string {
|
|
310
|
-
return emotionToAzureStyleMap[emotion] || 'neutral';
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
useEffect(() => {
|
|
314
|
-
return () => {
|
|
315
|
-
if (animationFrameRef.current !== null) {
|
|
316
|
-
cancelAnimationFrame(animationFrameRef.current);
|
|
317
|
-
}
|
|
318
|
-
};
|
|
157
|
+
const resetVisemeQueue = useCallback(() => {
|
|
158
|
+
visemeQueueRef.current = [];
|
|
159
|
+
lastVisemeRef.current = null;
|
|
319
160
|
}, []);
|
|
320
161
|
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
162
|
+
const resetAndStartProcessing = useCallback(() => {
|
|
163
|
+
stopProcessing();
|
|
164
|
+
resetVisemeQueue();
|
|
165
|
+
startTimeRef.current = performance.now() / 1000;
|
|
166
|
+
setIsProcessing(true);
|
|
167
|
+
}, [stopProcessing, resetVisemeQueue]);
|
|
168
|
+
|
|
169
|
+
const contextValue = {
|
|
170
|
+
addViseme,
|
|
171
|
+
updateCurrentViseme,
|
|
172
|
+
startProcessing,
|
|
173
|
+
stopProcessing,
|
|
174
|
+
resetAndStartProcessing,
|
|
175
|
+
resetVisemeQueue,
|
|
176
|
+
isProcessing,
|
|
330
177
|
};
|
|
331
178
|
|
|
332
179
|
return (
|
|
@@ -338,8 +185,8 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
338
185
|
|
|
339
186
|
export const useViseme = (): VisemeContextType => {
|
|
340
187
|
const context = useContext(VisemeContext);
|
|
341
|
-
if (context
|
|
188
|
+
if (!context) {
|
|
342
189
|
throw new Error('useViseme must be used within a VisemeProvider');
|
|
343
190
|
}
|
|
344
191
|
return context;
|
|
345
|
-
};
|
|
192
|
+
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Asset, ResponseSpec } from '@memori.ai/memori-api-client/dist/types';
|
|
2
|
-
export interface Props {
|
|
3
|
-
visible: boolean;
|
|
4
|
-
authToken: string;
|
|
5
|
-
sessionID: string;
|
|
6
|
-
tenantID: string;
|
|
7
|
-
uploadAssetURL: string;
|
|
8
|
-
deleteAsset: (token: string, assetURL: string) => Promise<ResponseSpec>;
|
|
9
|
-
onCancel?: () => void;
|
|
10
|
-
onOk: (asset: Asset) => Promise<void>;
|
|
11
|
-
apiURL?: string;
|
|
12
|
-
}
|
|
13
|
-
declare const AttachmentMediaModal: ({ visible, authToken, sessionID, tenantID, uploadAssetURL, deleteAsset, onCancel, onOk, apiURL, }: Props) => JSX.Element;
|
|
14
|
-
export default AttachmentMediaModal;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const react_i18next_1 = require("react-i18next");
|
|
7
|
-
const error_1 = require("../../helpers/error");
|
|
8
|
-
const constants_1 = require("../../helpers/constants");
|
|
9
|
-
const media_1 = require("../../helpers/media");
|
|
10
|
-
const Modal_1 = tslib_1.__importDefault(require("../ui/Modal"));
|
|
11
|
-
const Message_1 = tslib_1.__importDefault(require("../ui/Message"));
|
|
12
|
-
const Button_1 = tslib_1.__importDefault(require("../ui/Button"));
|
|
13
|
-
const ImageUpload_1 = tslib_1.__importDefault(require("../ImageUpload/ImageUpload"));
|
|
14
|
-
const AttachmentMediaModal = ({ visible, authToken, sessionID, tenantID, uploadAssetURL, deleteAsset, onCancel, onOk, apiURL, }) => {
|
|
15
|
-
const { t } = (0, react_i18next_1.useTranslation)();
|
|
16
|
-
const [asset, setAsset] = (0, react_1.useState)();
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)(Modal_1.default, { open: visible, title: t('media.addMediaLabel'), className: "attachment-media-modal", closable: true, width: "100%", widthMd: "100%", onClose: () => {
|
|
18
|
-
if (onCancel)
|
|
19
|
-
onCancel();
|
|
20
|
-
}, footer: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default, { onClick: onCancel, children: t('cancel') }), (0, jsx_runtime_1.jsx)(Button_1.default, { primary: true, onClick: () => {
|
|
21
|
-
if (asset)
|
|
22
|
-
onOk(asset);
|
|
23
|
-
setAsset(undefined);
|
|
24
|
-
}, disabled: !asset, children: t('confirm') })] }), children: (0, jsx_runtime_1.jsx)(ImageUpload_1.default, { tenantID: tenantID, apiUrl: apiURL, uploadMultipleImages: false, maxNumberOfVisualizedUploads: 1, maxFileSizeInMB: 100, uploadUrl: uploadAssetURL, useImageCrop: false, allowedMimeTypes: constants_1.allowedMediaTypes, fileList: asset
|
|
25
|
-
? [
|
|
26
|
-
{
|
|
27
|
-
uid: `-1`,
|
|
28
|
-
name: asset.assetID,
|
|
29
|
-
status: 'done',
|
|
30
|
-
thumbUrl: (0, media_1.getResourceUrl)({
|
|
31
|
-
resourceURI: asset.assetURL,
|
|
32
|
-
tenantID,
|
|
33
|
-
apiURL,
|
|
34
|
-
sessionID,
|
|
35
|
-
}),
|
|
36
|
-
},
|
|
37
|
-
]
|
|
38
|
-
: [], uploadMessage: t('media.mediaUploadMessage'), imageProportions: 1, onUploadFinished: (file) => {
|
|
39
|
-
let newAsset = file.response.asset;
|
|
40
|
-
let response = file.response;
|
|
41
|
-
if (response.resultCode === 0) {
|
|
42
|
-
setAsset(newAsset);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
console.error(response, file);
|
|
46
|
-
Message_1.default.error(t((0, error_1.getErrori18nKey)(response.resultCode)));
|
|
47
|
-
}
|
|
48
|
-
}, onFileChanged: (_assetID, asset) => {
|
|
49
|
-
setAsset(a => ({
|
|
50
|
-
...(a || {}),
|
|
51
|
-
...asset,
|
|
52
|
-
}));
|
|
53
|
-
}, onRemove: async (file) => {
|
|
54
|
-
const resp = await deleteAsset(authToken, file.thumbUrl);
|
|
55
|
-
if (resp.resultCode === 0) {
|
|
56
|
-
setAsset(undefined);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
console.error(resp, file);
|
|
60
|
-
Message_1.default.error(t((0, error_1.getErrori18nKey)(resp.resultCode)));
|
|
61
|
-
}
|
|
62
|
-
return resp.resultCode === 0;
|
|
63
|
-
} }) }));
|
|
64
|
-
};
|
|
65
|
-
exports.default = AttachmentMediaModal;
|
|
66
|
-
//# sourceMappingURL=AttachmentMediaModal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentMediaModal.js","sourceRoot":"","sources":["../../../src/components/AttachmentMediaModal/AttachmentMediaModal.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface BaseAction {
|
|
3
|
-
weight: number;
|
|
4
|
-
action?: string;
|
|
5
|
-
}
|
|
6
|
-
interface AdditiveAction {
|
|
7
|
-
weight: number;
|
|
8
|
-
action?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface AnimationControlPanelProps {
|
|
11
|
-
baseActions: Record<string, BaseAction>;
|
|
12
|
-
additiveActions: Record<string, AdditiveAction>;
|
|
13
|
-
onBaseActionChange: (action: string) => void;
|
|
14
|
-
onAdditiveActionChange?: (action: string, weight: number) => void;
|
|
15
|
-
currentBaseAction: {
|
|
16
|
-
action: string;
|
|
17
|
-
weight: number;
|
|
18
|
-
};
|
|
19
|
-
modifyTimeScale: (value: number) => void;
|
|
20
|
-
timeScale: number;
|
|
21
|
-
}
|
|
22
|
-
declare const AnimationControlPanel: React.FC<AnimationControlPanelProps>;
|
|
23
|
-
export default AnimationControlPanel;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const lil_gui_1 = tslib_1.__importDefault(require("lil-gui"));
|
|
6
|
-
const AnimationControlPanel = ({ onBaseActionChange, onAdditiveActionChange, baseActions, additiveActions, modifyTimeScale, timeScale, }) => {
|
|
7
|
-
const guiRef = (0, react_1.useRef)(null);
|
|
8
|
-
const panelSettingsRef = (0, react_1.useRef)({
|
|
9
|
-
'modify time scale': timeScale,
|
|
10
|
-
});
|
|
11
|
-
const crossFadeControlsRef = (0, react_1.useRef)([]);
|
|
12
|
-
(0, react_1.useEffect)(() => {
|
|
13
|
-
const gui = new lil_gui_1.default({ width: 310 });
|
|
14
|
-
guiRef.current = gui;
|
|
15
|
-
const folder1 = gui.addFolder('Base Actions');
|
|
16
|
-
const folder2 = gui.addFolder('Additive Action Weights');
|
|
17
|
-
const folder3 = gui.addFolder('General Speed');
|
|
18
|
-
const baseNames = ['None', ...Object.keys(baseActions)];
|
|
19
|
-
baseNames.forEach(name => {
|
|
20
|
-
const settings = baseActions[name];
|
|
21
|
-
panelSettingsRef.current[name] = () => {
|
|
22
|
-
onBaseActionChange(name);
|
|
23
|
-
};
|
|
24
|
-
const control = folder1.add(panelSettingsRef.current, name);
|
|
25
|
-
crossFadeControlsRef.current.push(control);
|
|
26
|
-
});
|
|
27
|
-
Object.entries(additiveActions).forEach(([name, settings]) => {
|
|
28
|
-
panelSettingsRef.current[name] = settings.weight;
|
|
29
|
-
folder2
|
|
30
|
-
.add(panelSettingsRef.current, name, 0.0, 1.0, 0.01)
|
|
31
|
-
.listen()
|
|
32
|
-
.onChange((weight) => {
|
|
33
|
-
settings.weight = weight;
|
|
34
|
-
onAdditiveActionChange === null || onAdditiveActionChange === void 0 ? void 0 : onAdditiveActionChange(name, weight);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
folder3
|
|
38
|
-
.add(panelSettingsRef.current, 'modify time scale', 0.0, 1.5, 0.01)
|
|
39
|
-
.onChange((value) => {
|
|
40
|
-
modifyTimeScale(value);
|
|
41
|
-
});
|
|
42
|
-
folder1.open();
|
|
43
|
-
folder2.open();
|
|
44
|
-
folder3.open();
|
|
45
|
-
return () => {
|
|
46
|
-
gui.destroy();
|
|
47
|
-
};
|
|
48
|
-
}, [
|
|
49
|
-
onBaseActionChange,
|
|
50
|
-
onAdditiveActionChange,
|
|
51
|
-
]);
|
|
52
|
-
return null;
|
|
53
|
-
};
|
|
54
|
-
exports.default = AnimationControlPanel;
|
|
55
|
-
//# sourceMappingURL=controls.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../../../../src/components/Avatar/AvatarView/components/controls.tsx"],"names":[],"mappings":";;;AAAA,iCAA2D;AAC3D,8DAA0B;AAyB1B,MAAM,qBAAqB,GAAyC,CAAC,EACnE,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,eAAe,EACf,eAAe,EACf,SAAS,GACV,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,IAAA,cAAM,EAAa,IAAI,CAAC,CAAC;IACxC,MAAM,gBAAgB,GAAG,IAAA,cAAM,EAAsB;QACnD,mBAAmB,EAAE,SAAS;KAC/B,CAAC,CAAC;IACH,MAAM,oBAAoB,GAAG,IAAA,cAAM,EAAQ,EAAE,CAAC,CAAC;IAE/C,IAAA,iBAAS,EAAC,GAAG,EAAE;QAEb,MAAM,GAAG,GAAG,IAAI,iBAAG,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACpC,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC;QAErB,MAAM,OAAO,GAAG,GAAG,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAG,GAAG,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,GAAG,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QAE/C,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAExD,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACvB,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;YACnC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE;gBACpC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC,CAAC;YAEF,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC5D,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE;YAC3D,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC;YACjD,OAAO;iBACJ,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC;iBACnD,MAAM,EAAE;iBACR,QAAQ,CAAC,CAAC,MAAc,EAAE,EAAE;gBAC3B,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;gBACzB,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAG,IAAI,EAAE,MAAM,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,OAAO;aACJ,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC;aAClE,QAAQ,CAAC,CAAC,KAAa,EAAE,EAAE;YAC1B,eAAe,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEL,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,EAAE,CAAC;QAEf,OAAO,GAAG,EAAE;YACV,GAAG,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,kBAAkB;QAClB,sBAAsB;KACvB,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,kBAAe,qBAAqB,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface FullbodyAvatarProps {
|
|
2
|
-
url: string;
|
|
3
|
-
sex: 'MALE' | 'FEMALE';
|
|
4
|
-
onLoaded?: () => void;
|
|
5
|
-
currentBaseAction: {
|
|
6
|
-
action: string;
|
|
7
|
-
weight: number;
|
|
8
|
-
};
|
|
9
|
-
additiveActions: {
|
|
10
|
-
[key: string]: {
|
|
11
|
-
weight: number;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
timeScale: number;
|
|
15
|
-
loading?: boolean;
|
|
16
|
-
speaking?: boolean;
|
|
17
|
-
isZoomed?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export default function FullbodyAvatar({ url, sex, onLoaded, currentBaseAction, additiveActions, timeScale, isZoomed, }: FullbodyAvatarProps): JSX.Element;
|