@memori.ai/memori-react 7.5.1 → 7.6.1
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 +51 -0
- package/README.md +10 -2
- package/dist/components/Avatar/Avatar.d.ts +2 -0
- package/dist/components/Avatar/Avatar.js +11 -6
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.d.ts +20 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js +107 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js.map +1 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controls.d.ts +26 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controls.js +59 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controls.js.map +1 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.d.ts +30 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js +148 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js.map +1 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.d.ts +15 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js +77 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js.map +1 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/loader.d.ts +5 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/loader.js +12 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/loader.js.map +1 -0
- package/dist/components/Avatar/AvatarView/components/avatar.d.ts +9 -0
- package/dist/components/Avatar/AvatarView/components/avatar.js +39 -0
- package/dist/components/Avatar/AvatarView/components/avatar.js.map +1 -0
- package/dist/components/Avatar/AvatarView/components/fullbodyAvatar.d.ts +2 -1
- package/dist/components/Avatar/AvatarView/components/fullbodyAvatar.js +8 -9
- package/dist/components/Avatar/AvatarView/components/fullbodyAvatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/index.d.ts +6 -1
- package/dist/components/Avatar/AvatarView/index.js +14 -84
- package/dist/components/Avatar/AvatarView/index.js.map +1 -1
- package/dist/components/Avatar/AvatarView/utils/useEyeBlink.d.ts +16 -2
- package/dist/components/Avatar/AvatarView/utils/useEyeBlink.js +62 -38
- package/dist/components/Avatar/AvatarView/utils/useEyeBlink.js.map +1 -1
- package/dist/components/Avatar/AvatarView/utils/useMouthAnimation.d.ts +16 -0
- package/dist/components/Avatar/AvatarView/utils/useMouthAnimation.js +59 -0
- package/dist/components/Avatar/AvatarView/utils/useMouthAnimation.js.map +1 -0
- package/dist/components/Avatar/AvatarView/utils/useMouthSpeaking.js +1 -1
- package/dist/components/Avatar/AvatarView/utils/useMouthSpeaking.js.map +1 -1
- package/dist/components/Avatar/AvatarView/utils/useSmile.js +1 -1
- package/dist/components/Avatar/AvatarView/utils/useSmile.js.map +1 -1
- package/dist/components/Avatar/AvatarView/utils/useViseme.d.ts +18 -0
- package/dist/components/Avatar/AvatarView/utils/useViseme.js +141 -0
- package/dist/components/Avatar/AvatarView/utils/useViseme.js.map +1 -0
- package/dist/components/Avatar/AvatarView/utils/visemeContext.d.ts +24 -0
- package/dist/components/Avatar/AvatarView/utils/visemeContext.js +157 -0
- package/dist/components/Avatar/AvatarView/utils/visemeContext.js.map +1 -0
- package/dist/components/ChatBubble/ChatBubble.js +2 -3
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.d.ts +1 -1
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js +24 -3
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.d.ts +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +25 -3
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/MemoriWidget/enhanceSSML/enhanceSSML.d.ts +4 -0
- package/dist/components/MemoriWidget/enhanceSSML/enhanceSSML.js +157 -0
- package/dist/components/MemoriWidget/enhanceSSML/enhanceSSML.js.map +1 -0
- package/dist/components/StartPanel/StartPanel.js +1 -1
- package/dist/components/StartPanel/StartPanel.js.map +1 -1
- package/dist/components/layouts/HiddenChat.d.ts +4 -0
- package/dist/components/layouts/HiddenChat.js +50 -0
- package/dist/components/layouts/HiddenChat.js.map +1 -0
- package/dist/components/layouts/ZoomedFullBody.d.ts +4 -0
- package/dist/components/layouts/ZoomedFullBody.js +8 -0
- package/dist/components/layouts/ZoomedFullBody.js.map +1 -0
- package/dist/components/layouts/ZoomedHalfBody.d.ts +4 -0
- package/dist/components/layouts/ZoomedHalfBody.js +8 -0
- package/dist/components/layouts/ZoomedHalfBody.js.map +1 -0
- package/dist/components/layouts/hidden-chat.css +184 -0
- package/dist/components/layouts/zoomed-half-body.css +3 -0
- package/dist/context/visemeContext.d.ts +27 -0
- package/dist/context/visemeContext.js +221 -0
- package/dist/context/visemeContext.js.map +1 -0
- package/dist/helpers/utils.d.ts +7 -0
- package/dist/helpers/utils.js +51 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/index.js +20 -16
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -0
- package/esm/components/Avatar/Avatar.d.ts +2 -0
- package/esm/components/Avatar/Avatar.js +11 -6
- package/esm/components/Avatar/Avatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.d.ts +20 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js +102 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js.map +1 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controls.d.ts +26 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controls.js +56 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controls.js.map +1 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.d.ts +30 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js +145 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js.map +1 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.d.ts +15 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js +73 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js.map +1 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/loader.d.ts +5 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/loader.js +9 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/loader.js.map +1 -0
- package/esm/components/Avatar/AvatarView/components/avatar.d.ts +9 -0
- package/esm/components/Avatar/AvatarView/components/avatar.js +35 -0
- package/esm/components/Avatar/AvatarView/components/avatar.js.map +1 -0
- package/esm/components/Avatar/AvatarView/components/fullbodyAvatar.d.ts +2 -1
- package/esm/components/Avatar/AvatarView/components/fullbodyAvatar.js +8 -9
- package/esm/components/Avatar/AvatarView/components/fullbodyAvatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/index.d.ts +6 -1
- package/esm/components/Avatar/AvatarView/index.js +15 -85
- package/esm/components/Avatar/AvatarView/index.js.map +1 -1
- package/esm/components/Avatar/AvatarView/utils/useEyeBlink.d.ts +16 -2
- package/esm/components/Avatar/AvatarView/utils/useEyeBlink.js +61 -38
- package/esm/components/Avatar/AvatarView/utils/useEyeBlink.js.map +1 -1
- package/esm/components/Avatar/AvatarView/utils/useMouthAnimation.d.ts +16 -0
- package/esm/components/Avatar/AvatarView/utils/useMouthAnimation.js +55 -0
- package/esm/components/Avatar/AvatarView/utils/useMouthAnimation.js.map +1 -0
- package/esm/components/Avatar/AvatarView/utils/useMouthSpeaking.js +1 -1
- package/esm/components/Avatar/AvatarView/utils/useMouthSpeaking.js.map +1 -1
- package/esm/components/Avatar/AvatarView/utils/useSmile.js +1 -1
- package/esm/components/Avatar/AvatarView/utils/useSmile.js.map +1 -1
- package/esm/components/Avatar/AvatarView/utils/useViseme.d.ts +18 -0
- package/esm/components/Avatar/AvatarView/utils/useViseme.js +137 -0
- package/esm/components/Avatar/AvatarView/utils/useViseme.js.map +1 -0
- package/esm/components/Avatar/AvatarView/utils/visemeContext.d.ts +24 -0
- package/esm/components/Avatar/AvatarView/utils/visemeContext.js +152 -0
- package/esm/components/Avatar/AvatarView/utils/visemeContext.js.map +1 -0
- package/esm/components/ChatBubble/ChatBubble.js +2 -3
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.d.ts +1 -1
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js +24 -3
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.d.ts +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +26 -4
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/MemoriWidget/enhanceSSML/enhanceSSML.d.ts +4 -0
- package/esm/components/MemoriWidget/enhanceSSML/enhanceSSML.js +152 -0
- package/esm/components/MemoriWidget/enhanceSSML/enhanceSSML.js.map +1 -0
- package/esm/components/StartPanel/StartPanel.js +1 -1
- package/esm/components/StartPanel/StartPanel.js.map +1 -1
- package/esm/components/layouts/HiddenChat.d.ts +4 -0
- package/esm/components/layouts/HiddenChat.js +47 -0
- package/esm/components/layouts/HiddenChat.js.map +1 -0
- package/esm/components/layouts/ZoomedFullBody.d.ts +4 -0
- package/esm/components/layouts/ZoomedFullBody.js +5 -0
- package/esm/components/layouts/ZoomedFullBody.js.map +1 -0
- package/esm/components/layouts/ZoomedHalfBody.d.ts +4 -0
- package/esm/components/layouts/ZoomedHalfBody.js +5 -0
- package/esm/components/layouts/ZoomedHalfBody.js.map +1 -0
- package/esm/components/layouts/hidden-chat.css +184 -0
- package/esm/components/layouts/zoomed-half-body.css +3 -0
- package/esm/context/visemeContext.d.ts +27 -0
- package/esm/context/visemeContext.js +216 -0
- package/esm/context/visemeContext.js.map +1 -0
- package/esm/helpers/utils.d.ts +7 -0
- package/esm/helpers/utils.js +45 -0
- package/esm/helpers/utils.js.map +1 -1
- package/esm/index.js +20 -16
- package/esm/index.js.map +1 -1
- package/esm/styles.css +1 -0
- package/package.json +2 -2
- package/src/components/Avatar/Avatar.test.tsx +28 -20
- package/src/components/Avatar/Avatar.tsx +19 -5
- package/src/components/Avatar/AvatarView/AvatarComponent/avatarComponent.tsx +222 -0
- package/src/components/Avatar/AvatarView/{components → AvatarComponent/components}/controls.tsx +16 -10
- package/src/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.tsx +234 -0
- package/src/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.tsx +123 -0
- package/src/components/Avatar/AvatarView/{components → AvatarComponent/components}/loader.tsx +1 -1
- package/src/components/Avatar/AvatarView/AvatarView.stories.tsx +47 -8
- package/src/components/Avatar/AvatarView/index.tsx +35 -167
- package/src/components/Avatar/AvatarView/utils/useEyeBlink.ts +89 -48
- package/src/components/Avatar/AvatarView/utils/useMouthAnimation.ts +93 -0
- package/src/components/Avatar/AvatarView/utils/useSmile.ts +1 -1
- package/src/components/ChatBubble/ChatBubble.tsx +3 -4
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx +33 -3
- package/src/components/CompletionProviderStatus/__snapshots__/CompletionProviderStatus.test.tsx.snap +18 -0
- package/src/components/MemoriWidget/MemoriWidget.tsx +60 -5
- package/src/components/StartPanel/StartPanel.tsx +1 -1
- package/src/components/layouts/Chat.test.tsx +7 -5
- package/src/components/layouts/FullPage.test.tsx +11 -8
- package/src/components/layouts/HiddenChat.test.tsx +37 -0
- package/src/components/layouts/HiddenChat.tsx +107 -0
- package/src/components/layouts/Totem.test.tsx +6 -4
- package/src/components/layouts/WebsiteAssistant.test.tsx +7 -5
- package/src/components/layouts/ZoomedFullBody.test.tsx +37 -0
- package/src/components/layouts/ZoomedFullBody.tsx +55 -0
- package/src/components/layouts/__snapshots__/HiddenChat.test.tsx.snap +210 -0
- package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +444 -0
- package/src/components/layouts/hidden-chat.css +184 -0
- package/src/components/layouts/layouts.stories.tsx +135 -19
- package/src/context/visemeContext.tsx +328 -0
- package/src/helpers/utils.ts +73 -0
- package/src/index.stories.tsx +40 -17
- package/src/index.tsx +82 -78
- package/src/styles.css +1 -0
- 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/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/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
- package/src/components/Avatar/AvatarView/components/fullbodyAvatar.tsx +0 -120
- package/src/components/Avatar/AvatarView/components/halfbodyAvatar.tsx +0 -69
- package/src/components/Avatar/AvatarView/utils/useMouthSpeaking.ts +0 -87
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import message from '../ui/Message';
|
|
4
|
-
import Button from '../ui/Button';
|
|
5
|
-
import Tooltip from '../ui/Tooltip';
|
|
6
|
-
import Modal from '../ui/Modal';
|
|
7
|
-
import Spin from '../ui/Spin';
|
|
8
|
-
import Upload from 'antd/lib/upload/Upload';
|
|
9
|
-
import ImgCrop from 'antd-img-crop';
|
|
10
|
-
import { useTranslation } from 'react-i18next';
|
|
11
|
-
import Edit from '../icons/Edit';
|
|
12
|
-
import Delete from '../icons/Delete';
|
|
13
|
-
import { RenderMediaItem } from '../MediaWidget/MediaItemWidget';
|
|
14
|
-
import { getResourceUrl } from '../../helpers/media';
|
|
15
|
-
const imgMimeTypes = ['image/jpeg', 'image/png', 'image/jpg', 'image/gif'];
|
|
16
|
-
const UploadListItem = ({ originNode, file, tenantID, apiUrl, actions, resourceType, }) => {
|
|
17
|
-
var _a, _b, _c, _d;
|
|
18
|
-
const { t } = useTranslation();
|
|
19
|
-
return (_jsxs("div", { className: `memori--list-item-wrapper${file.status === 'uploading' ? ` listItemUploading` : ''}`, children: [_jsx(Spin, { spinning: file.status === 'uploading', children: file.status === 'error' ? (_jsx(Tooltip, { content: t('media.uploadError'), children: originNode.props.children })) : (_jsx(RenderMediaItem, { item: {
|
|
20
|
-
mediumID: file.uid,
|
|
21
|
-
mimeType: file.status === 'uploading'
|
|
22
|
-
? 'image/png'
|
|
23
|
-
: ((_a = file.name) === null || _a === void 0 ? void 0 : _a.endsWith('.glb'))
|
|
24
|
-
? 'model/gltf-binary'
|
|
25
|
-
: file.type || 'image/png',
|
|
26
|
-
title: (_b = file.name) !== null && _b !== void 0 ? _b : '',
|
|
27
|
-
url: file.status === 'uploading'
|
|
28
|
-
? ''
|
|
29
|
-
: ((_d = (_c = file.response) === null || _c === void 0 ? void 0 : _c.asset) === null || _d === void 0 ? void 0 : _d.assetURL)
|
|
30
|
-
? file.response.asset.assetURL
|
|
31
|
-
: getResourceUrl({
|
|
32
|
-
type: resourceType,
|
|
33
|
-
resourceURI: file.thumbUrl,
|
|
34
|
-
tenantID,
|
|
35
|
-
apiURL: apiUrl,
|
|
36
|
-
}),
|
|
37
|
-
content: `${getResourceUrl({
|
|
38
|
-
resourceURI: file.thumbUrl,
|
|
39
|
-
type: resourceType,
|
|
40
|
-
apiURL: apiUrl,
|
|
41
|
-
})}`,
|
|
42
|
-
}, preview: false })) }), (file.status === 'success' || file.status === 'done') && (_jsxs("div", { className: "list-item-actions", children: [_jsx(Button, { outlined: true, shape: "circle", icon: _jsx(Edit, {}), className: "action-button", title: t('edit') || 'Edit', onClick: () => actions === null || actions === void 0 ? void 0 : actions.download(file) }), _jsx(Button, { outlined: true, shape: "circle", icon: _jsx(Delete, {}), className: "action-button", title: t('delete') || 'Delete', onClick: () => actions === null || actions === void 0 ? void 0 : actions.remove(file) })] }))] }));
|
|
43
|
-
};
|
|
44
|
-
const ImageUpload = ({ uploadMultipleImages, maxNumberOfVisualizedUploads, uploadUrl, apiUrl, tenantID, fileList, maxFileSizeInMB = 2, fileResolution, useImageCrop, uploadMessage, imageProportions = 1, imageProportionsHelper, allowedMimeTypes, onRemove, onFileChanged, onUploadFinished, onFileNotValid, disabled, showHelper, additionalHelper, resourceType, }) => {
|
|
45
|
-
var _a;
|
|
46
|
-
const { t } = useTranslation();
|
|
47
|
-
const [internalFileList, setInternalFileList] = useState((fileList !== null && fileList !== void 0 ? fileList : []));
|
|
48
|
-
const onChange = (info) => {
|
|
49
|
-
setInternalFileList(info.fileList.map(f => { var _a; return ({ ...f, status: (_a = f.status) !== null && _a !== void 0 ? _a : 'error' }); }));
|
|
50
|
-
if (info.file.status === 'done') {
|
|
51
|
-
onUploadFinished && onUploadFinished(info.file);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const beforeUpload = (file) => {
|
|
55
|
-
const isAllowed = (allowedMimeTypes !== null && allowedMimeTypes !== void 0 ? allowedMimeTypes : imgMimeTypes).find(x => x === file.type);
|
|
56
|
-
if (!isAllowed && file.type) {
|
|
57
|
-
console.debug('File not allowed', file, allowedMimeTypes !== null && allowedMimeTypes !== void 0 ? allowedMimeTypes : imgMimeTypes);
|
|
58
|
-
message.error(t('media.uploadMimeTypeNotAllowed'));
|
|
59
|
-
onFileNotValid && onFileNotValid();
|
|
60
|
-
return Promise.reject(t('media.uploadMimeTypeNotAllowed'));
|
|
61
|
-
}
|
|
62
|
-
const isLimitedSize = file.size / 1024 / 1024 < (maxFileSizeInMB !== null && maxFileSizeInMB !== void 0 ? maxFileSizeInMB : 2);
|
|
63
|
-
if (!isLimitedSize) {
|
|
64
|
-
message.error(t('media.uploadSizeLimitMessage', { size: maxFileSizeInMB }));
|
|
65
|
-
onFileNotValid && onFileNotValid();
|
|
66
|
-
return Promise.reject(t('media.uploadSizeLimitMessage', { size: maxFileSizeInMB }));
|
|
67
|
-
}
|
|
68
|
-
if (fileResolution && fileResolution.length) {
|
|
69
|
-
const reader = new FileReader();
|
|
70
|
-
reader.readAsDataURL(file);
|
|
71
|
-
return new Promise((resolve, reject) => {
|
|
72
|
-
reader.addEventListener('load', event => {
|
|
73
|
-
var _a, _b, _c;
|
|
74
|
-
var newImg = new Image();
|
|
75
|
-
newImg.style.padding = '0px';
|
|
76
|
-
newImg.style.margin = '0px';
|
|
77
|
-
newImg.onload = () => {
|
|
78
|
-
let ok = newImg.width === fileResolution[0] &&
|
|
79
|
-
newImg.height === fileResolution[1];
|
|
80
|
-
if (!ok) {
|
|
81
|
-
message.error(t('media.uploadWrongResolutionMessage', {
|
|
82
|
-
width: fileResolution[0],
|
|
83
|
-
height: fileResolution[1],
|
|
84
|
-
}));
|
|
85
|
-
reject();
|
|
86
|
-
if (onFileNotValid)
|
|
87
|
-
onFileNotValid();
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
resolve(file);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
newImg.src = (_c = (_b = (_a = event.target) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : '';
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
else
|
|
98
|
-
return Promise.resolve(file);
|
|
99
|
-
};
|
|
100
|
-
const [fileTitleModal, setFileTitleModal] = useState();
|
|
101
|
-
const upload = (_jsx(Upload, { className: "memori--upload", disabled: disabled !== null && disabled !== void 0 ? disabled : false, accept: ((_a = (allowedMimeTypes !== null && allowedMimeTypes !== void 0 ? allowedMimeTypes : imgMimeTypes)) === null || _a === void 0 ? void 0 : _a.join(',')) +
|
|
102
|
-
';capture=camera,camcorder', action: uploadUrl, listType: "picture-card", showUploadList: {
|
|
103
|
-
showPreviewIcon: true,
|
|
104
|
-
showRemoveIcon: true,
|
|
105
|
-
showDownloadIcon: true,
|
|
106
|
-
downloadIcon: _jsx(Edit, { title: t('edit') || 'Edit' }),
|
|
107
|
-
}, beforeUpload: beforeUpload, supportServerRender: true, fileList: internalFileList, multiple: uploadMultipleImages, maxCount: maxNumberOfVisualizedUploads || (uploadMultipleImages ? 100 : 1), onChange: onChange, onRemove: onRemove, onDownload: file => {
|
|
108
|
-
var _a, _b;
|
|
109
|
-
let asset = (_a = file.response) === null || _a === void 0 ? void 0 : _a.asset;
|
|
110
|
-
if (asset) {
|
|
111
|
-
let title = asset.originalFileName && file.name.includes(asset.originalFileName)
|
|
112
|
-
? asset.originalFileName
|
|
113
|
-
: file.name;
|
|
114
|
-
setFileTitleModal({
|
|
115
|
-
...asset,
|
|
116
|
-
title: title !== null && title !== void 0 ? title : asset.title,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
setFileTitleModal({
|
|
121
|
-
assetID: file.uid,
|
|
122
|
-
title: (_b = file.name) !== null && _b !== void 0 ? _b : file.fileName,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}, itemRender: (originNode, file, currFileList, actions) => (_jsx(UploadListItem, { resourceType: resourceType, originNode: originNode, file: file, fileList: internalFileList || currFileList, actions: actions, tenantID: tenantID, apiUrl: apiUrl })), children: uploadMessage }));
|
|
126
|
-
return (_jsxs("div", { "aria-live": "polite", children: [!!useImageCrop ? (_jsx(ImgCrop, { rotate: true, aspect: imageProportions, fillColor: 'transparent', modalCancel: t('cancel') || 'Cancel', modalMaskTransitionName: "none", modalTransitionName: "none", children: upload })) : (upload), _jsxs(Modal, { open: !!fileTitleModal, title: t('media.editAttributes'), onClose: () => {
|
|
127
|
-
setFileTitleModal(undefined);
|
|
128
|
-
}, footer: _jsx(_Fragment, {}), width: "100%", children: [_jsx("label", { htmlFor: "media-title-input", className: "media-title-label", children: t('media.title') }), _jsx("input", { id: "media-title-input", className: "media-title-input", type: "text", name: "title", defaultValue: (fileTitleModal === null || fileTitleModal === void 0 ? void 0 : fileTitleModal.title) || '', onChange: e => {
|
|
129
|
-
setFileTitleModal({
|
|
130
|
-
...fileTitleModal,
|
|
131
|
-
title: e.target.value,
|
|
132
|
-
});
|
|
133
|
-
} }), _jsxs("div", { className: "memori-modal--footer", children: [_jsx(Button, { onClick: () => {
|
|
134
|
-
setFileTitleModal(undefined);
|
|
135
|
-
}, children: t('cancel') }), _jsx(Button, { primary: true, onClick: () => {
|
|
136
|
-
onFileChanged &&
|
|
137
|
-
(fileTitleModal === null || fileTitleModal === void 0 ? void 0 : fileTitleModal.assetID) &&
|
|
138
|
-
onFileChanged(fileTitleModal.assetID, {
|
|
139
|
-
...fileTitleModal,
|
|
140
|
-
});
|
|
141
|
-
setInternalFileList(fl => fl.map(f => {
|
|
142
|
-
var _a, _b;
|
|
143
|
-
return f.uid === (fileTitleModal === null || fileTitleModal === void 0 ? void 0 : fileTitleModal.assetID) ||
|
|
144
|
-
((_b = (_a = f.response) === null || _a === void 0 ? void 0 : _a.asset) === null || _b === void 0 ? void 0 : _b.assetID) === (fileTitleModal === null || fileTitleModal === void 0 ? void 0 : fileTitleModal.assetID)
|
|
145
|
-
? {
|
|
146
|
-
...f,
|
|
147
|
-
title: fileTitleModal === null || fileTitleModal === void 0 ? void 0 : fileTitleModal.title,
|
|
148
|
-
name: fileTitleModal === null || fileTitleModal === void 0 ? void 0 : fileTitleModal.title,
|
|
149
|
-
}
|
|
150
|
-
: f;
|
|
151
|
-
}));
|
|
152
|
-
setFileTitleModal(undefined);
|
|
153
|
-
}, children: t('confirm') })] })] }), showHelper && (_jsxs("legend", { className: "helper", children: [_jsx("p", { children: t(allowedMimeTypes
|
|
154
|
-
? 'media.uploadHelper'
|
|
155
|
-
: 'media.uploadHelperImages', {
|
|
156
|
-
size: maxFileSizeInMB !== null && maxFileSizeInMB !== void 0 ? maxFileSizeInMB : 2,
|
|
157
|
-
}) }), imageProportionsHelper && useImageCrop && (_jsxs("p", { children: [t('media.scaleRatio'), ": ", imageProportionsHelper] })), additionalHelper && _jsx("p", { children: additionalHelper })] }))] }));
|
|
158
|
-
};
|
|
159
|
-
export default ImageUpload;
|
|
160
|
-
//# sourceMappingURL=ImageUpload.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUpload.js","sourceRoot":"","sources":["../../../src/components/ImageUpload/ImageUpload.tsx"],"names":[],"mappings":";AAEA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,MAAM,MAAM,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AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface Props {
|
|
3
|
-
header?: JSX.Element | null;
|
|
4
|
-
avatar: JSX.Element;
|
|
5
|
-
chat?: JSX.Element | null;
|
|
6
|
-
startPanel: JSX.Element;
|
|
7
|
-
integrationStyle?: JSX.Element | null;
|
|
8
|
-
integrationBackground?: JSX.Element | null;
|
|
9
|
-
changeMode?: JSX.Element | null;
|
|
10
|
-
poweredBy?: JSX.Element | null;
|
|
11
|
-
sessionId?: string;
|
|
12
|
-
hasUserActivatedSpeak?: boolean;
|
|
13
|
-
showInstruct?: boolean;
|
|
14
|
-
loading?: boolean;
|
|
15
|
-
}
|
|
16
|
-
declare const Default: React.FC<Props>;
|
|
17
|
-
export default Default;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import Spin from '../ui/Spin';
|
|
3
|
-
const Default = ({ header, avatar, chat, startPanel, integrationStyle, integrationBackground, changeMode, sessionId, hasUserActivatedSpeak, showInstruct = false, loading = false, poweredBy, }) => (_jsxs(_Fragment, { children: [integrationStyle, integrationBackground, _jsxs(Spin, { spinning: loading, children: [showInstruct && changeMode, header, _jsxs("div", { className: "memori--grid", children: [_jsx("div", { className: "memori--grid-column memori--grid-column-left", children: avatar }), _jsx("div", { className: "memori--grid-column memori--grid-column-right", children: sessionId && hasUserActivatedSpeak ? chat : startPanel }), poweredBy] })] })] }));
|
|
4
|
-
export default Default;
|
|
5
|
-
//# sourceMappingURL=Default.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Default.js","sourceRoot":"","sources":["../../../src/components/layouts/Default.tsx"],"names":[],"mappings":";AACA,OAAO,IAAI,MAAM,YAAY,CAAC;AAiB9B,MAAM,OAAO,GAAoB,CAAC,EAChC,MAAM,EACN,MAAM,EACN,IAAI,EACJ,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,YAAY,GAAG,KAAK,EACpB,OAAO,GAAG,KAAK,EACf,SAAS,GACV,EAAE,EAAE,CAAC,CACJ,8BACG,gBAAgB,EAChB,qBAAqB,EAEtB,MAAC,IAAI,IAAC,QAAQ,EAAE,OAAO,aACpB,YAAY,IAAI,UAAU,EAE1B,MAAM,EAEP,eAAK,SAAS,EAAC,cAAc,aAC3B,cAAK,SAAS,EAAC,8CAA8C,YAC1D,MAAM,GACH,EACN,cAAK,SAAS,EAAC,+CAA+C,YAC3D,SAAS,IAAI,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,GACnD,EAEL,SAAS,IACN,IACD,IACN,CACJ,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
declare const Message: () => JSX.Element;
|
|
2
|
-
declare const message: {
|
|
3
|
-
error: {
|
|
4
|
-
(...data: any[]): void;
|
|
5
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
6
|
-
};
|
|
7
|
-
info: {
|
|
8
|
-
(...data: any[]): void;
|
|
9
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
10
|
-
};
|
|
11
|
-
success: {
|
|
12
|
-
(...data: any[]): void;
|
|
13
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export { Message };
|
|
17
|
-
export default message;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
const Message = () => _jsx("div", { children: "Message" });
|
|
3
|
-
const message = {
|
|
4
|
-
error: console.error,
|
|
5
|
-
info: console.info,
|
|
6
|
-
success: console.log,
|
|
7
|
-
};
|
|
8
|
-
export { Message };
|
|
9
|
-
export default message;
|
|
10
|
-
//# sourceMappingURL=Message.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../src/components/ui/Message.tsx"],"names":[],"mappings":";AAEA,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,oCAAkB,CAAC;AAEzC,MAAM,OAAO,GAAG;IACd,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,IAAI,EAAE,OAAO,CAAC,IAAI;IAClB,OAAO,EAAE,OAAO,CAAC,GAAG;CACrB,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,eAAe,OAAO,CAAC"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Vector3,
|
|
4
|
-
Euler,
|
|
5
|
-
AnimationMixer,
|
|
6
|
-
AnimationAction,
|
|
7
|
-
AnimationClip,
|
|
8
|
-
} from 'three';
|
|
9
|
-
import { useAnimations, useGLTF } from '@react-three/drei';
|
|
10
|
-
import { useGraph, dispose, useFrame } from '@react-three/fiber';
|
|
11
|
-
import { correctMaterials, isSkinnedMesh } from '../utils/utils';
|
|
12
|
-
import useEyeBlink from '../utils/useEyeBlink';
|
|
13
|
-
import useMouthSpeaking from '../utils/useMouthSpeaking';
|
|
14
|
-
import useHeadMovement from '../utils/useHeadMovement';
|
|
15
|
-
import useSmile from '../utils/useSmile';
|
|
16
|
-
|
|
17
|
-
export interface FullbodyAvatarProps {
|
|
18
|
-
url: string;
|
|
19
|
-
sex: 'MALE' | 'FEMALE';
|
|
20
|
-
onLoaded?: () => void;
|
|
21
|
-
currentBaseAction: {
|
|
22
|
-
action: string;
|
|
23
|
-
weight: number;
|
|
24
|
-
};
|
|
25
|
-
additiveActions: {
|
|
26
|
-
[key: string]: {
|
|
27
|
-
weight: number;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
timeScale: number;
|
|
31
|
-
loading?: boolean;
|
|
32
|
-
speaking?: boolean;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const AVATAR_POSITION = new Vector3(0, -1, 0);
|
|
36
|
-
const AVATAR_ROTATION = new Euler(0.175, 0, 0);
|
|
37
|
-
const ANIMATION_URLS = {
|
|
38
|
-
MALE: 'https://assets.memori.ai/api/v2/asset/5de7456f-0cd8-4e29-95a7-0cd0045a5325.glb',
|
|
39
|
-
FEMALE:
|
|
40
|
-
'https://assets.memori.ai/api/v2/asset/84487a2b-377c-4565-800a-51459d580ec8.glb',
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default function FullbodyAvatar({
|
|
44
|
-
url,
|
|
45
|
-
sex,
|
|
46
|
-
onLoaded,
|
|
47
|
-
currentBaseAction,
|
|
48
|
-
additiveActions,
|
|
49
|
-
timeScale
|
|
50
|
-
}: FullbodyAvatarProps) {
|
|
51
|
-
const { scene } = useGLTF(url);
|
|
52
|
-
const { animations } = useGLTF(ANIMATION_URLS[sex]);
|
|
53
|
-
const { nodes, materials } = useGraph(scene);
|
|
54
|
-
const { actions } = useAnimations(animations, scene);
|
|
55
|
-
const [mixer] = useState(() => new AnimationMixer(scene));
|
|
56
|
-
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
correctMaterials(materials);
|
|
59
|
-
onLoaded?.();
|
|
60
|
-
|
|
61
|
-
return () => {
|
|
62
|
-
Object.values(materials).forEach(dispose);
|
|
63
|
-
Object.values(nodes).filter(isSkinnedMesh).forEach(dispose);
|
|
64
|
-
};
|
|
65
|
-
}, [materials, nodes, url, onLoaded]);
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
if (!actions || !currentBaseAction.action) return;
|
|
69
|
-
|
|
70
|
-
const newAction = actions[currentBaseAction.action];
|
|
71
|
-
|
|
72
|
-
if (!newAction) {
|
|
73
|
-
console.warn(
|
|
74
|
-
`Animation "${currentBaseAction.action}" not found in actions.`
|
|
75
|
-
);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const fadeOutDuration = 0.8;
|
|
80
|
-
const fadeInDuration = 0.8;
|
|
81
|
-
|
|
82
|
-
newAction.timeScale = timeScale;
|
|
83
|
-
newAction.reset().fadeIn(fadeInDuration).play();
|
|
84
|
-
|
|
85
|
-
return () => {
|
|
86
|
-
newAction.fadeOut(fadeOutDuration);
|
|
87
|
-
};
|
|
88
|
-
}, [currentBaseAction, timeScale]);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// useEffect(() => {
|
|
94
|
-
// if (speaking && actions['Talk 1'] && actions['Talk 2']) {
|
|
95
|
-
// const talk1 = actions['Talk 1'].getClip();
|
|
96
|
-
// const talk2 = actions['Talk 2'].getClip();
|
|
97
|
-
// const talk = new AnimationClip(
|
|
98
|
-
// 'Talk',
|
|
99
|
-
// talk1.duration + talk2.duration,
|
|
100
|
-
// );
|
|
101
|
-
// mixer.clipAction(talk, scene).play();
|
|
102
|
-
// }
|
|
103
|
-
// }, [speaking]);
|
|
104
|
-
|
|
105
|
-
// Additive actions
|
|
106
|
-
useEyeBlink(additiveActions.blink.weight > 0, nodes);
|
|
107
|
-
useMouthSpeaking(additiveActions.speak.weight > 0, nodes);
|
|
108
|
-
useHeadMovement(additiveActions.headMovement.weight > 0, nodes);
|
|
109
|
-
useSmile(additiveActions.smile.weight > 0, nodes);
|
|
110
|
-
|
|
111
|
-
useFrame((_, delta) => {
|
|
112
|
-
mixer.update(delta * 0.001);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<group position={AVATAR_POSITION} rotation={AVATAR_ROTATION}>
|
|
117
|
-
<primitive object={scene} />
|
|
118
|
-
</group>
|
|
119
|
-
);
|
|
120
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo } from 'react';
|
|
2
|
-
import { Object3D, Vector3 } from 'three';
|
|
3
|
-
import { useGLTF } from '@react-three/drei';
|
|
4
|
-
import useEyeBlink from '../utils/useEyeBlink';
|
|
5
|
-
import useHeadMovement from '../utils/useHeadMovement';
|
|
6
|
-
import useMouthSpeaking from '../utils/useMouthSpeaking';
|
|
7
|
-
import { dispose, useGraph } from '@react-three/fiber';
|
|
8
|
-
import { correctMaterials, hideHands, isSkinnedMesh } from '../utils/utils';
|
|
9
|
-
|
|
10
|
-
interface HalfBodyAvatarProps {
|
|
11
|
-
url: string;
|
|
12
|
-
eyeBlink?: boolean;
|
|
13
|
-
headMovement?: boolean;
|
|
14
|
-
speaking?: boolean;
|
|
15
|
-
onLoaded?: () => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const AVATAR_POSITION = new Vector3(0, -0.6, 0);
|
|
19
|
-
|
|
20
|
-
export default function HalfBodyAvatar({
|
|
21
|
-
url,
|
|
22
|
-
eyeBlink,
|
|
23
|
-
headMovement,
|
|
24
|
-
speaking,
|
|
25
|
-
onLoaded,
|
|
26
|
-
}: HalfBodyAvatarProps) {
|
|
27
|
-
const { scene } = useGLTF(url);
|
|
28
|
-
const { nodes, materials } = useGraph(scene);
|
|
29
|
-
|
|
30
|
-
useEyeBlink(eyeBlink, nodes);
|
|
31
|
-
useHeadMovement(headMovement, nodes);
|
|
32
|
-
useMouthSpeaking(!!speaking, nodes);
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const setupAvatar = () => {
|
|
36
|
-
hideHands(nodes);
|
|
37
|
-
correctMaterials(materials);
|
|
38
|
-
onLoaded?.();
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
setupAvatar();
|
|
42
|
-
|
|
43
|
-
return () => {
|
|
44
|
-
const disposeObjects = () => {
|
|
45
|
-
Object.values(materials).forEach(dispose);
|
|
46
|
-
Object.values(nodes).filter(isSkinnedMesh).forEach(dispose);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
disposeObjects();
|
|
50
|
-
};
|
|
51
|
-
}, [materials, nodes, url, onLoaded]);
|
|
52
|
-
|
|
53
|
-
const skinnedMeshes = useMemo(
|
|
54
|
-
() => Object.values(nodes).filter(isSkinnedMesh),
|
|
55
|
-
[nodes]
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<group position={AVATAR_POSITION}>
|
|
60
|
-
{nodes.Hips && <primitive key="armature" object={nodes.Hips} />}
|
|
61
|
-
{skinnedMeshes.map(
|
|
62
|
-
(node: Object3D) =>
|
|
63
|
-
node && (
|
|
64
|
-
<primitive key={node.name} object={node} receiveShadow castShadow />
|
|
65
|
-
)
|
|
66
|
-
)}
|
|
67
|
-
</group>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { Nodes } from './utils';
|
|
2
|
-
import { SkinnedMesh } from 'three';
|
|
3
|
-
import { useEffect, useRef, useCallback } from 'react';
|
|
4
|
-
import { useFrame } from '@react-three/fiber';
|
|
5
|
-
|
|
6
|
-
interface MouthState {
|
|
7
|
-
moveTime: number;
|
|
8
|
-
mesh: SkinnedMesh | null;
|
|
9
|
-
morphIndices: {
|
|
10
|
-
open: number;
|
|
11
|
-
smile: number;
|
|
12
|
-
funner: number;
|
|
13
|
-
pucker: number;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const MOUTH_MOVE_DURATION = 2;
|
|
18
|
-
const MOUTH_MOVE_INTERVAL_MIN = 100;
|
|
19
|
-
const MOUTH_MOVE_INTERVAL_MAX = 500;
|
|
20
|
-
|
|
21
|
-
export default function useMouthSpeaking(speaking: boolean | undefined, nodes: Nodes) {
|
|
22
|
-
const mouthStateRef = useRef<MouthState>({
|
|
23
|
-
moveTime: 999,
|
|
24
|
-
mesh: null,
|
|
25
|
-
morphIndices: { open: 0, smile: 0, funner: 0, pucker: 0 },
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const setNextMouthMove = useCallback(() => {
|
|
29
|
-
mouthStateRef.current.moveTime = 0;
|
|
30
|
-
const nextMoveDelay = Math.random() * (MOUTH_MOVE_INTERVAL_MAX - MOUTH_MOVE_INTERVAL_MIN) + MOUTH_MOVE_INTERVAL_MIN;
|
|
31
|
-
setTimeout(setNextMouthMove, nextMoveDelay);
|
|
32
|
-
}, []);
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (!speaking) return;
|
|
36
|
-
|
|
37
|
-
const mouthMesh = (nodes.Wolf3D_Head || nodes.Wolf3D_Avatar || nodes.Wolf3D_Avatar001) as SkinnedMesh;
|
|
38
|
-
mouthStateRef.current.mesh = mouthMesh;
|
|
39
|
-
|
|
40
|
-
if (mouthMesh?.morphTargetDictionary && mouthMesh?.morphTargetInfluences) {
|
|
41
|
-
mouthStateRef.current.morphIndices = {
|
|
42
|
-
open: mouthMesh.morphTargetDictionary.mouthOpen,
|
|
43
|
-
smile: mouthMesh.morphTargetDictionary.mouthSmile,
|
|
44
|
-
funner: mouthMesh.morphTargetDictionary.mouthFunner,
|
|
45
|
-
pucker: mouthMesh.morphTargetDictionary.mouthPucker,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const initialMoveDelay = setTimeout(setNextMouthMove, 200);
|
|
50
|
-
|
|
51
|
-
return () => {
|
|
52
|
-
clearTimeout(initialMoveDelay);
|
|
53
|
-
};
|
|
54
|
-
}, [nodes, speaking, setNextMouthMove]);
|
|
55
|
-
|
|
56
|
-
useFrame((_, delta) => {
|
|
57
|
-
const { moveTime, mesh, morphIndices } = mouthStateRef.current;
|
|
58
|
-
|
|
59
|
-
if (!speaking || !mesh?.morphTargetInfluences) {
|
|
60
|
-
resetMouthShape(mesh, morphIndices);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (moveTime < MOUTH_MOVE_DURATION) {
|
|
65
|
-
const value = Math.abs(Math.sin((moveTime * Math.PI) / 2));
|
|
66
|
-
mouthStateRef.current.moveTime += delta * 10;
|
|
67
|
-
updateMouthShape(mesh, morphIndices, value);
|
|
68
|
-
} else {
|
|
69
|
-
resetMouthShape(mesh, morphIndices);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function updateMouthShape(mesh: SkinnedMesh, morphIndices: MouthState['morphIndices'], value: number) {
|
|
75
|
-
mesh.morphTargetInfluences![morphIndices.open] = value / 3;
|
|
76
|
-
mesh.morphTargetInfluences![morphIndices.smile] = value / 10;
|
|
77
|
-
mesh.morphTargetInfluences![morphIndices.funner] = value / 7;
|
|
78
|
-
mesh.morphTargetInfluences![morphIndices.pucker] = value / 5;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function resetMouthShape(mesh: SkinnedMesh | null, morphIndices: MouthState['morphIndices']) {
|
|
82
|
-
if (!mesh?.morphTargetInfluences) return;
|
|
83
|
-
mesh.morphTargetInfluences[morphIndices.open] = 0;
|
|
84
|
-
mesh.morphTargetInfluences[morphIndices.smile] = 0;
|
|
85
|
-
mesh.morphTargetInfluences[morphIndices.funner] = 0;
|
|
86
|
-
mesh.morphTargetInfluences[morphIndices.pucker] = 0;
|
|
87
|
-
}
|