@oxy.so/bloom 19.10.3 → 20.0.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/docs/adoption-matrix.mdx +8 -7
- package/docs/agent-avatar.mdx +42 -0
- package/docs/agent-creator.mdx +20 -14
- package/docs/empty-state.mdx +20 -1
- package/docs/multi-agent-chat.mdx +5 -0
- package/docs/task-catalog.json +1 -1
- package/docs/task-catalog.mdx +1 -1
- package/lib/commonjs/agent-avatar/VectorCharacterAvatar.js +36 -17
- package/lib/commonjs/agent-avatar/VectorCharacterAvatar.js.map +1 -1
- package/lib/commonjs/agent-avatar/character.js +27 -0
- package/lib/commonjs/agent-avatar/character.js.map +1 -1
- package/lib/commonjs/agent-avatar/index.js +6 -0
- package/lib/commonjs/agent-avatar/index.js.map +1 -1
- package/lib/commonjs/agent-avatar/vector-mood.js +129 -0
- package/lib/commonjs/agent-avatar/vector-mood.js.map +1 -0
- package/lib/commonjs/agent-creator/AgentCreator.js +0 -4
- package/lib/commonjs/agent-creator/AgentCreator.js.map +1 -1
- package/lib/commonjs/agent-creator/AgentCreator.web.js +8 -12
- package/lib/commonjs/agent-creator/AgentCreator.web.js.map +1 -1
- package/lib/commonjs/agent-creator/AgentCreatorBase.js +61 -99
- package/lib/commonjs/agent-creator/AgentCreatorBase.js.map +1 -1
- package/lib/commonjs/agent-creator/context.js.map +1 -1
- package/lib/commonjs/agent-creator/messages.js +1 -22
- package/lib/commonjs/agent-creator/messages.js.map +1 -1
- package/lib/commonjs/agent-creator/paint.js +47 -0
- package/lib/commonjs/agent-creator/paint.js.map +1 -0
- package/lib/commonjs/agent-creator/shared.js +0 -28
- package/lib/commonjs/agent-creator/shared.js.map +1 -1
- package/lib/commonjs/agent-creator/use-character-history.js +12 -9
- package/lib/commonjs/agent-creator/use-character-history.js.map +1 -1
- package/lib/commonjs/avatar/Avatar.js +12 -4
- package/lib/commonjs/avatar/Avatar.js.map +1 -1
- package/lib/commonjs/avatar/account.js +9 -3
- package/lib/commonjs/avatar/account.js.map +1 -1
- package/lib/commonjs/empty-state/constants.js +2 -0
- package/lib/commonjs/empty-state/constants.js.map +1 -1
- package/lib/commonjs/locale/translations/ar.js +1 -22
- package/lib/commonjs/locale/translations/ar.js.map +1 -1
- package/lib/commonjs/locale/translations/bn.js +1 -22
- package/lib/commonjs/locale/translations/bn.js.map +1 -1
- package/lib/commonjs/locale/translations/ca.js +1 -22
- package/lib/commonjs/locale/translations/ca.js.map +1 -1
- package/lib/commonjs/locale/translations/de.js +1 -22
- package/lib/commonjs/locale/translations/de.js.map +1 -1
- package/lib/commonjs/locale/translations/es.js +1 -22
- package/lib/commonjs/locale/translations/es.js.map +1 -1
- package/lib/commonjs/locale/translations/fr.js +1 -22
- package/lib/commonjs/locale/translations/fr.js.map +1 -1
- package/lib/commonjs/locale/translations/hi.js +1 -22
- package/lib/commonjs/locale/translations/hi.js.map +1 -1
- package/lib/commonjs/locale/translations/id.js +1 -22
- package/lib/commonjs/locale/translations/id.js.map +1 -1
- package/lib/commonjs/locale/translations/it.js +1 -22
- package/lib/commonjs/locale/translations/it.js.map +1 -1
- package/lib/commonjs/locale/translations/ja.js +1 -22
- package/lib/commonjs/locale/translations/ja.js.map +1 -1
- package/lib/commonjs/locale/translations/pt.js +1 -22
- package/lib/commonjs/locale/translations/pt.js.map +1 -1
- package/lib/commonjs/locale/translations/ru.js +1 -22
- package/lib/commonjs/locale/translations/ru.js.map +1 -1
- package/lib/commonjs/locale/translations/tr.js +1 -22
- package/lib/commonjs/locale/translations/tr.js.map +1 -1
- package/lib/commonjs/locale/translations/zh.js +1 -22
- package/lib/commonjs/locale/translations/zh.js.map +1 -1
- package/lib/commonjs/multi-agent-chat/Marketplace.js +1 -1
- package/lib/commonjs/multi-agent-chat/Marketplace.js.map +1 -1
- package/lib/commonjs/multi-agent-chat/MultiAgentChatBase.js +6 -6
- package/lib/commonjs/multi-agent-chat/MultiAgentChatBase.js.map +1 -1
- package/lib/commonjs/multi-agent-chat/SelectedAgentPreview.js +2 -1
- package/lib/commonjs/multi-agent-chat/SelectedAgentPreview.js.map +1 -1
- package/lib/commonjs/multi-agent-chat/data.js +58 -39
- package/lib/commonjs/multi-agent-chat/data.js.map +1 -1
- package/lib/commonjs/multi-agent-chat/marketplace-data.js +21 -27
- package/lib/commonjs/multi-agent-chat/marketplace-data.js.map +1 -1
- package/lib/module/agent-avatar/VectorCharacterAvatar.js +36 -17
- package/lib/module/agent-avatar/VectorCharacterAvatar.js.map +1 -1
- package/lib/module/agent-avatar/character.js +26 -0
- package/lib/module/agent-avatar/character.js.map +1 -1
- package/lib/module/agent-avatar/index.js +1 -1
- package/lib/module/agent-avatar/index.js.map +1 -1
- package/lib/module/agent-avatar/vector-mood.js +117 -0
- package/lib/module/agent-avatar/vector-mood.js.map +1 -0
- package/lib/module/agent-creator/AgentCreator.js +0 -4
- package/lib/module/agent-creator/AgentCreator.js.map +1 -1
- package/lib/module/agent-creator/AgentCreator.web.js +0 -4
- package/lib/module/agent-creator/AgentCreator.web.js.map +1 -1
- package/lib/module/agent-creator/AgentCreatorBase.js +56 -94
- package/lib/module/agent-creator/AgentCreatorBase.js.map +1 -1
- package/lib/module/agent-creator/context.js.map +1 -1
- package/lib/module/agent-creator/messages.js +1 -22
- package/lib/module/agent-creator/messages.js.map +1 -1
- package/lib/module/agent-creator/paint.js +42 -0
- package/lib/module/agent-creator/paint.js.map +1 -0
- package/lib/module/agent-creator/shared.js +0 -26
- package/lib/module/agent-creator/shared.js.map +1 -1
- package/lib/module/agent-creator/use-character-history.js +7 -4
- package/lib/module/agent-creator/use-character-history.js.map +1 -1
- package/lib/module/avatar/Avatar.js +12 -4
- package/lib/module/avatar/Avatar.js.map +1 -1
- package/lib/module/avatar/account.js +9 -3
- package/lib/module/avatar/account.js.map +1 -1
- package/lib/module/empty-state/constants.js +2 -0
- package/lib/module/empty-state/constants.js.map +1 -1
- package/lib/module/locale/translations/ar.js +1 -22
- package/lib/module/locale/translations/ar.js.map +1 -1
- package/lib/module/locale/translations/bn.js +1 -22
- package/lib/module/locale/translations/bn.js.map +1 -1
- package/lib/module/locale/translations/ca.js +1 -22
- package/lib/module/locale/translations/ca.js.map +1 -1
- package/lib/module/locale/translations/de.js +1 -22
- package/lib/module/locale/translations/de.js.map +1 -1
- package/lib/module/locale/translations/es.js +1 -22
- package/lib/module/locale/translations/es.js.map +1 -1
- package/lib/module/locale/translations/fr.js +1 -22
- package/lib/module/locale/translations/fr.js.map +1 -1
- package/lib/module/locale/translations/hi.js +1 -22
- package/lib/module/locale/translations/hi.js.map +1 -1
- package/lib/module/locale/translations/id.js +1 -22
- package/lib/module/locale/translations/id.js.map +1 -1
- package/lib/module/locale/translations/it.js +1 -22
- package/lib/module/locale/translations/it.js.map +1 -1
- package/lib/module/locale/translations/ja.js +1 -22
- package/lib/module/locale/translations/ja.js.map +1 -1
- package/lib/module/locale/translations/pt.js +1 -22
- package/lib/module/locale/translations/pt.js.map +1 -1
- package/lib/module/locale/translations/ru.js +1 -22
- package/lib/module/locale/translations/ru.js.map +1 -1
- package/lib/module/locale/translations/tr.js +1 -22
- package/lib/module/locale/translations/tr.js.map +1 -1
- package/lib/module/locale/translations/zh.js +1 -22
- package/lib/module/locale/translations/zh.js.map +1 -1
- package/lib/module/multi-agent-chat/Marketplace.js +2 -2
- package/lib/module/multi-agent-chat/Marketplace.js.map +1 -1
- package/lib/module/multi-agent-chat/MultiAgentChatBase.js +7 -7
- package/lib/module/multi-agent-chat/MultiAgentChatBase.js.map +1 -1
- package/lib/module/multi-agent-chat/SelectedAgentPreview.js +2 -1
- package/lib/module/multi-agent-chat/SelectedAgentPreview.js.map +1 -1
- package/lib/module/multi-agent-chat/data.js +58 -40
- package/lib/module/multi-agent-chat/data.js.map +1 -1
- package/lib/module/multi-agent-chat/marketplace-data.js +21 -27
- package/lib/module/multi-agent-chat/marketplace-data.js.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/VectorCharacterAvatar.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/character.d.ts +14 -0
- package/lib/typescript/commonjs/agent-avatar/character.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/index.d.ts +2 -2
- package/lib/typescript/commonjs/agent-avatar/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/types.d.ts +14 -0
- package/lib/typescript/commonjs/agent-avatar/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/vector-mood.d.ts +61 -0
- package/lib/typescript/commonjs/agent-avatar/vector-mood.d.ts.map +1 -0
- package/lib/typescript/commonjs/agent-creator/AgentCreator.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/AgentCreator.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/AgentCreatorBase.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/context.d.ts +1 -13
- package/lib/typescript/commonjs/agent-creator/context.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/messages.d.ts +0 -11
- package/lib/typescript/commonjs/agent-creator/messages.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/paint.d.ts +20 -0
- package/lib/typescript/commonjs/agent-creator/paint.d.ts.map +1 -0
- package/lib/typescript/commonjs/agent-creator/shared.d.ts +0 -7
- package/lib/typescript/commonjs/agent-creator/shared.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/types.d.ts +14 -0
- package/lib/typescript/commonjs/agent-creator/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/use-character-history.d.ts +6 -2
- package/lib/typescript/commonjs/agent-creator/use-character-history.d.ts.map +1 -1
- package/lib/typescript/commonjs/avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/commonjs/avatar/account.d.ts +4 -2
- package/lib/typescript/commonjs/avatar/account.d.ts.map +1 -1
- package/lib/typescript/commonjs/avatar/types.d.ts +6 -0
- package/lib/typescript/commonjs/avatar/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/empty-state/constants.d.ts +5 -0
- package/lib/typescript/commonjs/empty-state/constants.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/ar.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/bn.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/ca.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/de.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/es.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/fr.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/hi.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/id.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/it.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/ja.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/pt.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/ru.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/tr.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/zh.d.ts.map +1 -1
- package/lib/typescript/commonjs/multi-agent-chat/Marketplace.d.ts.map +1 -1
- package/lib/typescript/commonjs/multi-agent-chat/MultiAgentChatBase.d.ts.map +1 -1
- package/lib/typescript/commonjs/multi-agent-chat/SelectedAgentPreview.d.ts +1 -1
- package/lib/typescript/commonjs/multi-agent-chat/SelectedAgentPreview.d.ts.map +1 -1
- package/lib/typescript/commonjs/multi-agent-chat/data.d.ts +4 -1
- package/lib/typescript/commonjs/multi-agent-chat/data.d.ts.map +1 -1
- package/lib/typescript/commonjs/multi-agent-chat/marketplace-data.d.ts +3 -0
- package/lib/typescript/commonjs/multi-agent-chat/marketplace-data.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/VectorCharacterAvatar.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/character.d.ts +14 -0
- package/lib/typescript/module/agent-avatar/character.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/index.d.ts +2 -2
- package/lib/typescript/module/agent-avatar/index.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/types.d.ts +14 -0
- package/lib/typescript/module/agent-avatar/types.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/vector-mood.d.ts +61 -0
- package/lib/typescript/module/agent-avatar/vector-mood.d.ts.map +1 -0
- package/lib/typescript/module/agent-creator/AgentCreator.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/AgentCreator.web.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/AgentCreatorBase.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/context.d.ts +1 -13
- package/lib/typescript/module/agent-creator/context.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/messages.d.ts +0 -11
- package/lib/typescript/module/agent-creator/messages.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/paint.d.ts +20 -0
- package/lib/typescript/module/agent-creator/paint.d.ts.map +1 -0
- package/lib/typescript/module/agent-creator/shared.d.ts +0 -7
- package/lib/typescript/module/agent-creator/shared.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/types.d.ts +14 -0
- package/lib/typescript/module/agent-creator/types.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/use-character-history.d.ts +6 -2
- package/lib/typescript/module/agent-creator/use-character-history.d.ts.map +1 -1
- package/lib/typescript/module/avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/module/avatar/account.d.ts +4 -2
- package/lib/typescript/module/avatar/account.d.ts.map +1 -1
- package/lib/typescript/module/avatar/types.d.ts +6 -0
- package/lib/typescript/module/avatar/types.d.ts.map +1 -1
- package/lib/typescript/module/empty-state/constants.d.ts +5 -0
- package/lib/typescript/module/empty-state/constants.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/ar.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/bn.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/ca.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/de.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/es.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/fr.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/hi.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/id.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/it.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/ja.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/pt.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/ru.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/tr.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/zh.d.ts.map +1 -1
- package/lib/typescript/module/multi-agent-chat/Marketplace.d.ts.map +1 -1
- package/lib/typescript/module/multi-agent-chat/MultiAgentChatBase.d.ts.map +1 -1
- package/lib/typescript/module/multi-agent-chat/SelectedAgentPreview.d.ts +1 -1
- package/lib/typescript/module/multi-agent-chat/SelectedAgentPreview.d.ts.map +1 -1
- package/lib/typescript/module/multi-agent-chat/data.d.ts +4 -1
- package/lib/typescript/module/multi-agent-chat/data.d.ts.map +1 -1
- package/lib/typescript/module/multi-agent-chat/marketplace-data.d.ts +3 -0
- package/lib/typescript/module/multi-agent-chat/marketplace-data.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/support/adoption-matrix.ts +5 -0
- package/src/agent-avatar/VectorCharacterAvatar.tsx +39 -10
- package/src/agent-avatar/character.ts +30 -0
- package/src/agent-avatar/index.ts +2 -1
- package/src/agent-avatar/types.ts +15 -0
- package/src/agent-avatar/vector-mood.ts +140 -0
- package/src/agent-creator/AgentCreator.tsx +0 -4
- package/src/agent-creator/AgentCreator.web.tsx +0 -4
- package/src/agent-creator/AgentCreatorBase.tsx +51 -89
- package/src/agent-creator/context.ts +0 -2
- package/src/agent-creator/messages.ts +1 -37
- package/src/agent-creator/paint.ts +48 -0
- package/src/agent-creator/shared.ts +0 -27
- package/src/agent-creator/types.ts +14 -0
- package/src/agent-creator/use-character-history.ts +8 -4
- package/src/avatar/Avatar.tsx +13 -3
- package/src/avatar/account.ts +9 -3
- package/src/avatar/types.ts +6 -0
- package/src/empty-state/constants.ts +7 -0
- package/src/locale/translations/ar.ts +1 -23
- package/src/locale/translations/bn.ts +1 -23
- package/src/locale/translations/ca.ts +1 -23
- package/src/locale/translations/de.ts +1 -23
- package/src/locale/translations/es.ts +1 -23
- package/src/locale/translations/fr.ts +1 -23
- package/src/locale/translations/hi.ts +1 -23
- package/src/locale/translations/id.ts +1 -23
- package/src/locale/translations/it.ts +1 -23
- package/src/locale/translations/ja.ts +1 -23
- package/src/locale/translations/pt.ts +1 -23
- package/src/locale/translations/ru.ts +1 -23
- package/src/locale/translations/tr.ts +1 -23
- package/src/locale/translations/zh.ts +1 -23
- package/src/multi-agent-chat/Marketplace.tsx +6 -2
- package/src/multi-agent-chat/MultiAgentChatBase.tsx +7 -6
- package/src/multi-agent-chat/SelectedAgentPreview.tsx +2 -2
- package/src/multi-agent-chat/data.ts +58 -27
- package/src/multi-agent-chat/marketplace-data.ts +28 -9
- package/lib/commonjs/agent-creator/CustomColorPicker.js +0 -431
- package/lib/commonjs/agent-creator/CustomColorPicker.js.map +0 -1
- package/lib/commonjs/agent-creator/GlossArt.js +0 -212
- package/lib/commonjs/agent-creator/GlossArt.js.map +0 -1
- package/lib/commonjs/agent-creator/rainbow-artwork.js +0 -10
- package/lib/commonjs/agent-creator/rainbow-artwork.js.map +0 -1
- package/lib/module/agent-creator/CustomColorPicker.js +0 -426
- package/lib/module/agent-creator/CustomColorPicker.js.map +0 -1
- package/lib/module/agent-creator/GlossArt.js +0 -207
- package/lib/module/agent-creator/GlossArt.js.map +0 -1
- package/lib/module/agent-creator/rainbow-artwork.js +0 -6
- package/lib/module/agent-creator/rainbow-artwork.js.map +0 -1
- package/lib/typescript/commonjs/agent-creator/CustomColorPicker.d.ts +0 -9
- package/lib/typescript/commonjs/agent-creator/CustomColorPicker.d.ts.map +0 -1
- package/lib/typescript/commonjs/agent-creator/GlossArt.d.ts +0 -9
- package/lib/typescript/commonjs/agent-creator/GlossArt.d.ts.map +0 -1
- package/lib/typescript/commonjs/agent-creator/rainbow-artwork.d.ts +0 -3
- package/lib/typescript/commonjs/agent-creator/rainbow-artwork.d.ts.map +0 -1
- package/lib/typescript/module/agent-creator/CustomColorPicker.d.ts +0 -9
- package/lib/typescript/module/agent-creator/CustomColorPicker.d.ts.map +0 -1
- package/lib/typescript/module/agent-creator/GlossArt.d.ts +0 -9
- package/lib/typescript/module/agent-creator/GlossArt.d.ts.map +0 -1
- package/lib/typescript/module/agent-creator/rainbow-artwork.d.ts +0 -3
- package/lib/typescript/module/agent-creator/rainbow-artwork.d.ts.map +0 -1
- package/src/agent-creator/CustomColorPicker.tsx +0 -443
- package/src/agent-creator/GlossArt.tsx +0 -160
- package/src/agent-creator/rainbow-artwork.ts +0 -5
|
@@ -18,6 +18,14 @@ import { CHARACTER_COLORS } from './character-colors';
|
|
|
18
18
|
import { vectorWorkLook } from './vector-work-look';
|
|
19
19
|
import { sampleVectorPose, blendVectorPose, type VectorPose } from './vector-pose';
|
|
20
20
|
import { sampleVectorMotion, referenceWorkTime, type VectorMotionPose } from './vector-motion';
|
|
21
|
+
import {
|
|
22
|
+
advanceVectorMood,
|
|
23
|
+
initialVectorMood,
|
|
24
|
+
setVectorMood,
|
|
25
|
+
settleVectorMood,
|
|
26
|
+
vectorMoodActive,
|
|
27
|
+
vectorMoodFrame,
|
|
28
|
+
} from './vector-mood';
|
|
21
29
|
import {
|
|
22
30
|
useCallback,
|
|
23
31
|
useContext,
|
|
@@ -83,7 +91,7 @@ export function VectorCharacterAvatar(props: Props) {
|
|
|
83
91
|
return <AnimatedVectorCharacterAvatar {...props} />;
|
|
84
92
|
}
|
|
85
93
|
function AnimatedVectorCharacterAvatar(props: Props) {
|
|
86
|
-
const { character, size = 64, paused, portrait, interactive, previewPart } = props;
|
|
94
|
+
const { character, size = 64, paused, portrait, interactive, previewPart, mood } = props;
|
|
87
95
|
const { messages } = useMessages(AGENT_AVATAR_MESSAGES, props.locale);
|
|
88
96
|
const catalog = useVectorAssetLoader(props.catalog);
|
|
89
97
|
const reduced = usePrefersReducedMotion(),
|
|
@@ -166,13 +174,17 @@ function AnimatedVectorCharacterAvatar(props: Props) {
|
|
|
166
174
|
motionFrom: undefined as VectorMotionPose | undefined,
|
|
167
175
|
transitionStarted: 0,
|
|
168
176
|
transitionDuration: VECTOR_TRANSITION_SECONDS,
|
|
177
|
+
mood: initialVectorMood(mood),
|
|
169
178
|
});
|
|
170
179
|
const previous = useRef({
|
|
171
180
|
idle: props.idleKey,
|
|
172
181
|
reaction: props.reactionKey,
|
|
173
182
|
work: props.workingKey,
|
|
174
183
|
entrance: props.entranceKey,
|
|
184
|
+
mood,
|
|
175
185
|
});
|
|
186
|
+
const latestMood = useRef(mood);
|
|
187
|
+
latestMood.current = mood;
|
|
176
188
|
const cycles = useRef(props.workingCycles);
|
|
177
189
|
cycles.current = props.workingCycles;
|
|
178
190
|
const play = useCallback((action: VectorAction) => {
|
|
@@ -253,6 +265,13 @@ function AnimatedVectorCharacterAvatar(props: Props) {
|
|
|
253
265
|
play('idle');
|
|
254
266
|
}
|
|
255
267
|
}, [props.idleKey, props.reactionKey, props.workingKey, props.entranceKey, play]);
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
if (mood === previous.current.mood) return;
|
|
270
|
+
setVectorMood(state.current.mood, mood, previous.current.mood);
|
|
271
|
+
previous.current.mood = mood;
|
|
272
|
+
// A still character repaints into the new mood; a running one restarts its frame loop.
|
|
273
|
+
setRevision((value) => value + 1);
|
|
274
|
+
}, [mood]);
|
|
256
275
|
useEffect(() => {
|
|
257
276
|
if (Platform.OS !== 'web' || typeof IntersectionObserver === 'undefined' || !host.current)
|
|
258
277
|
return;
|
|
@@ -289,7 +308,8 @@ function AnimatedVectorCharacterAvatar(props: Props) {
|
|
|
289
308
|
motion.yaw += (motion.targetYaw - motion.yaw) * follow;
|
|
290
309
|
motion.pitch += (motion.targetPitch - motion.pitch) * follow;
|
|
291
310
|
motion.lookMix += ((motion.pointerActive ? 1 : 0) - motion.lookMix) * follow;
|
|
292
|
-
|
|
311
|
+
advanceVectorMood(motion.mood, latestMood.current, delta);
|
|
312
|
+
} else settleVectorMood(motion.mood, latestMood.current);
|
|
293
313
|
if (!painted || stopped || now - painted >= 1000 / 30) {
|
|
294
314
|
painted = painted ? now - ((now - painted) % (1000 / 30)) : now;
|
|
295
315
|
const action = portrait ? 'idle' : motion.action,
|
|
@@ -299,6 +319,7 @@ function AnimatedVectorCharacterAvatar(props: Props) {
|
|
|
299
319
|
Math.max(0, (motion.clock - motion.transitionStarted) / motion.transitionDuration),
|
|
300
320
|
);
|
|
301
321
|
const eased = transition * transition * (3 - 2 * transition);
|
|
322
|
+
const feeling = !portrait && vectorMoodActive(motion.mood) ? { ...motion.mood } : undefined;
|
|
302
323
|
const sharedKey = JSON.stringify([
|
|
303
324
|
latestFrameRecipe.current,
|
|
304
325
|
action,
|
|
@@ -312,10 +333,12 @@ function AnimatedVectorCharacterAvatar(props: Props) {
|
|
|
312
333
|
motion.transitionDuration,
|
|
313
334
|
vectorStateIdentity(motion.poseFrom),
|
|
314
335
|
vectorStateIdentity(motion.motionFrom),
|
|
336
|
+
feeling?.sadness,
|
|
337
|
+
feeling?.declineTime,
|
|
315
338
|
portrait,
|
|
316
339
|
previewPart,
|
|
317
340
|
]);
|
|
318
|
-
const { pose, procedural, drawing } = shareVectorFrame(sharedKey, () => {
|
|
341
|
+
const { pose, procedural, gaze, drawing } = shareVectorFrame(sharedKey, () => {
|
|
319
342
|
const poseTime =
|
|
320
343
|
asset.referenceFace && action === 'work' ? referenceWorkTime(time) : time;
|
|
321
344
|
const targetPose = sampleVectorPose(asset, action, poseTime);
|
|
@@ -346,17 +369,22 @@ function AnimatedVectorCharacterAvatar(props: Props) {
|
|
|
346
369
|
: undefined,
|
|
347
370
|
})
|
|
348
371
|
: undefined;
|
|
372
|
+
// The mood goes over the blended motion, never into it: a transition captures the
|
|
373
|
+
// motion without the mood, which carries on through the transition on its own clock.
|
|
374
|
+
const framed = vectorMoodFrame(
|
|
375
|
+
asset,
|
|
376
|
+
procedural,
|
|
377
|
+
{ yaw: portrait ? 0 : motion.yaw, pitch: portrait ? 0 : motion.pitch },
|
|
378
|
+
feeling,
|
|
379
|
+
);
|
|
349
380
|
const drawing = renderVectorFrame(asset, {
|
|
350
381
|
action,
|
|
351
382
|
time,
|
|
352
|
-
|
|
353
|
-
pitch: portrait ? 0 : motion.pitch,
|
|
383
|
+
...framed,
|
|
354
384
|
eyesOnly: previewPart === 'eyes',
|
|
355
385
|
pose,
|
|
356
|
-
motion: procedural,
|
|
357
|
-
look: procedural ? { yaw: procedural.yaw, pitch: procedural.pitch, mix: 1 } : undefined,
|
|
358
386
|
});
|
|
359
|
-
return { pose, procedural, drawing };
|
|
387
|
+
return { pose, procedural, gaze: framed.look ?? framed, drawing };
|
|
360
388
|
});
|
|
361
389
|
motion.lastPose = pose;
|
|
362
390
|
motion.lastMotion = procedural;
|
|
@@ -372,8 +400,8 @@ function AnimatedVectorCharacterAvatar(props: Props) {
|
|
|
372
400
|
time,
|
|
373
401
|
count: motion.count,
|
|
374
402
|
entrance: stopped ? 1 : motion.entrance,
|
|
375
|
-
gazeYaw:
|
|
376
|
-
gazePitch:
|
|
403
|
+
gazeYaw: gaze.yaw,
|
|
404
|
+
gazePitch: gaze.pitch,
|
|
377
405
|
tracking: motion.lookMix,
|
|
378
406
|
});
|
|
379
407
|
}
|
|
@@ -424,6 +452,7 @@ function AnimatedVectorCharacterAvatar(props: Props) {
|
|
|
424
452
|
gazeYaw: String(display?.gazeYaw ?? 0),
|
|
425
453
|
gazePitch: String(display?.gazePitch ?? 0),
|
|
426
454
|
tracking: String(display?.tracking ?? 0),
|
|
455
|
+
mood: mood ?? 'neutral',
|
|
427
456
|
},
|
|
428
457
|
}
|
|
429
458
|
: {})}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from './catalog-ids';
|
|
15
15
|
import { CHARACTER_COLORS } from './character-colors';
|
|
16
16
|
import { normalizeAvatarSkinColor } from './skin-color';
|
|
17
|
+
import { APP_COLOR_PRESETS, resolveProfileColor } from '../theme/color-presets';
|
|
17
18
|
import { CHARACTER_PRESET_DEFAULTS } from './character-preset-defaults';
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -203,6 +204,35 @@ export function updateAvatarCharacter(
|
|
|
203
204
|
return next;
|
|
204
205
|
}
|
|
205
206
|
|
|
207
|
+
/**
|
|
208
|
+
* A character painted in its account's colour.
|
|
209
|
+
*
|
|
210
|
+
* `color` is the colour of the account the character stands for, as Oxy stores `User.color`: a
|
|
211
|
+
* Bloom colour preset key (`'lagoon'`), or a legacy `#rgb`/`#rrggbb`. The body takes the preset's
|
|
212
|
+
* identity seed (or the legacy colour), lifted to the avatar skin floor, so an agent is drawn in
|
|
213
|
+
* the same colour its profile is themed with. This is the one place a colour preset becomes an
|
|
214
|
+
* avatar paint.
|
|
215
|
+
*
|
|
216
|
+
* The result carries `bodyColor` and no `color`; every part is kept. A colour that does not resolve
|
|
217
|
+
* (`null`, `undefined`, an unknown key) returns the character unchanged, so its own paint (or its
|
|
218
|
+
* preset's) applies.
|
|
219
|
+
*/
|
|
220
|
+
export function avatarCharacterInColor(
|
|
221
|
+
character: AvatarCharacter,
|
|
222
|
+
color: string | null | undefined,
|
|
223
|
+
): AvatarCharacter {
|
|
224
|
+
const resolved = resolveProfileColor(color);
|
|
225
|
+
if (resolved === undefined) return character;
|
|
226
|
+
const seed =
|
|
227
|
+
resolved.colorPreset === undefined
|
|
228
|
+
? resolved.seed
|
|
229
|
+
: APP_COLOR_PRESETS[resolved.colorPreset].hex;
|
|
230
|
+
const painted: AvatarCharacter = { ...character };
|
|
231
|
+
delete painted.color;
|
|
232
|
+
painted.bodyColor = normalizeAvatarSkinColor(seed);
|
|
233
|
+
return painted;
|
|
234
|
+
}
|
|
235
|
+
|
|
206
236
|
/** The body paint as `#rrggbb`, whichever way it was named. */
|
|
207
237
|
export function avatarBodyHex(resolved: ResolvedAvatarCharacter): string {
|
|
208
238
|
return 'bodyColor' in resolved.paint
|
|
@@ -2,12 +2,13 @@ export { AgentAvatar } from './AgentAvatar';
|
|
|
2
2
|
export { AgentAvatarProvider } from './AgentAvatarProvider';
|
|
3
3
|
export { BLOOM_CHARACTER_RUNTIME_URL } from './context';
|
|
4
4
|
export { useAvatarRendererCapabilities } from './use-avatar-renderer-capabilities';
|
|
5
|
-
export type { AgentAvatarProps, AgentAvatarProviderProps } from './types';
|
|
5
|
+
export type { AgentAvatarMood, AgentAvatarProps, AgentAvatarProviderProps } from './types';
|
|
6
6
|
|
|
7
7
|
// One model: a character. `resolveAvatarCharacter` fills it in, `parseAvatarCharacter`
|
|
8
8
|
// checks saved JSON, `characterFromLegacy` migrates an avatar saved before 10.
|
|
9
9
|
export {
|
|
10
10
|
avatarBodyHex,
|
|
11
|
+
avatarCharacterInColor,
|
|
11
12
|
avatarCharacterOf,
|
|
12
13
|
parseAvatarCharacter,
|
|
13
14
|
resolveAvatarCharacter,
|
|
@@ -4,6 +4,14 @@ import type { BloomThemeStorage } from '../theme/persistence';
|
|
|
4
4
|
import type { AvatarCharacter } from './character';
|
|
5
5
|
import type { VectorAssetLoader } from './vector-types';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* How the character feels, held for as long as it is set. `neutral` is its usual idle. `sad` is
|
|
9
|
+
* for an empty or not-found state, a refusal, something that could not be done: the character
|
|
10
|
+
* shakes its head "no" once as the mood starts, then stays dejected (looking down, drooping, lids
|
|
11
|
+
* heavy) on top of its idle until the mood changes.
|
|
12
|
+
*/
|
|
13
|
+
export type AgentAvatarMood = 'neutral' | 'sad';
|
|
14
|
+
|
|
7
15
|
export type AgentAvatarProps = {
|
|
8
16
|
/** @deprecated All characters use SVG. The legacy selector is accepted but has no effect. */
|
|
9
17
|
renderer?: 'svg' | 'webgl';
|
|
@@ -24,6 +32,13 @@ export type AgentAvatarProps = {
|
|
|
24
32
|
entranceKey?: number;
|
|
25
33
|
workingKey?: number;
|
|
26
34
|
workingCycles?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Default `neutral`. Becoming `sad` (or mounting sad) shakes the head "no" once, then holds a
|
|
37
|
+
* dejected idle; back to `neutral` the droop eases out. Reactions, work and pointer gaze still
|
|
38
|
+
* play on top. Reduced motion and `paused` show the settled pose with no shake; a `portrait`
|
|
39
|
+
* still is always neutral.
|
|
40
|
+
*/
|
|
41
|
+
mood?: AgentAvatarMood;
|
|
27
42
|
/** The first picture of the character has been painted. Fires once per mounted renderer. */
|
|
28
43
|
onReady?: () => void;
|
|
29
44
|
/** Reports selected geometry preparation; paint-only changes do not reload. */
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { VectorLook } from './vector-face';
|
|
2
|
+
import type { VectorMotionPose } from './vector-motion';
|
|
3
|
+
import type { VectorData } from './vector-types';
|
|
4
|
+
import type { AgentAvatarMood } from './types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How a mood is laid over whatever the character is doing. It is procedural, like gaze and
|
|
8
|
+
* blinking: every body, preset or edited, has its authored clips and none of them a "no", so the
|
|
9
|
+
* mood moves the pose those clips produce rather than adding a clip that only some bodies would
|
|
10
|
+
* have.
|
|
11
|
+
*/
|
|
12
|
+
export type VectorMoodState = {
|
|
13
|
+
/** How far into its mood the character is: 0 neutral, 1 fully sad. Eases, never jumps. */
|
|
14
|
+
sadness: number;
|
|
15
|
+
/** Seconds into the head shake that starts a sad mood. Past `VECTOR_DECLINE_SECONDS`, none. */
|
|
16
|
+
declineTime: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** The shake that says "no": three turns, the first the widest, coming to rest. */
|
|
20
|
+
export const VECTOR_DECLINE_SECONDS = 1.4;
|
|
21
|
+
/** How quickly the dejected pose sets in and lifts, per second. Settled in about a second. */
|
|
22
|
+
const SADNESS_RATE = 2.5;
|
|
23
|
+
const DECLINE_YAW = 0.6;
|
|
24
|
+
|
|
25
|
+
/** A neutral pose that a mood can be laid on: no turn, no droop, eyes open. */
|
|
26
|
+
export const VECTOR_REST_MOTION: Readonly<VectorMotionPose> = {
|
|
27
|
+
yaw: 0,
|
|
28
|
+
pitch: 0,
|
|
29
|
+
roll: 0,
|
|
30
|
+
bob: 0,
|
|
31
|
+
scale: 1,
|
|
32
|
+
lid: 1,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const unit = (value: number) => (Number.isFinite(value) ? Math.max(0, Math.min(1, value)) : 0);
|
|
36
|
+
const ease = (value: number) => {
|
|
37
|
+
const t = unit(value);
|
|
38
|
+
return t * t * (3 - 2 * t);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** The state a character starts in, with or without the mood. Starting sad shakes the head. */
|
|
42
|
+
export function initialVectorMood(mood: AgentAvatarMood | undefined): VectorMoodState {
|
|
43
|
+
return { sadness: 0, declineTime: mood === 'sad' ? 0 : Number.POSITIVE_INFINITY };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The mood the character is now asked for. Becoming sad shakes the head once. */
|
|
47
|
+
export function setVectorMood(
|
|
48
|
+
state: VectorMoodState,
|
|
49
|
+
mood: AgentAvatarMood | undefined,
|
|
50
|
+
previous: AgentAvatarMood | undefined,
|
|
51
|
+
) {
|
|
52
|
+
if (mood === 'sad' && previous !== 'sad') state.declineTime = 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** One frame of a running character: the shake moves on and the droop eases towards the mood. */
|
|
56
|
+
export function advanceVectorMood(
|
|
57
|
+
state: VectorMoodState,
|
|
58
|
+
mood: AgentAvatarMood | undefined,
|
|
59
|
+
delta: number,
|
|
60
|
+
) {
|
|
61
|
+
const target = mood === 'sad' ? 1 : 0;
|
|
62
|
+
state.declineTime += delta;
|
|
63
|
+
state.sadness += (target - state.sadness) * (1 - Math.exp(-delta * SADNESS_RATE));
|
|
64
|
+
if (Math.abs(target - state.sadness) < 0.001) state.sadness = target;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** A still character (paused, reduced motion) shows the mood's settled pose and never shakes. */
|
|
68
|
+
export function settleVectorMood(state: VectorMoodState, mood: AgentAvatarMood | undefined) {
|
|
69
|
+
state.sadness = mood === 'sad' ? 1 : 0;
|
|
70
|
+
state.declineTime = Number.POSITIVE_INFINITY;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Whether the mood moves the pose at all; a neutral character draws exactly as it did without one. */
|
|
74
|
+
export function vectorMoodActive(state: VectorMoodState): boolean {
|
|
75
|
+
return state.sadness > 0 || state.declineTime < VECTOR_DECLINE_SECONDS;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The head turn of the shake, in radians, at `time` seconds into it: zero before and after, and
|
|
80
|
+
* it starts and ends at rest with no jump in speed. The swings shrink as the head gives up.
|
|
81
|
+
*/
|
|
82
|
+
export function sampleVectorDecline(time: number): number {
|
|
83
|
+
if (!(time > 0 && time < VECTOR_DECLINE_SECONDS)) return 0;
|
|
84
|
+
const u = time / VECTOR_DECLINE_SECONDS;
|
|
85
|
+
return DECLINE_YAW * ease(u / 0.12) * (1 - u) ** 2 * Math.sin(Math.PI * 6 * u);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* `pose` with the mood laid over it. Sad looks down and a little aside, sinks and deflates
|
|
90
|
+
* slightly, tilts the head and lets the lids fall; the shake turns the head and rocks it a little
|
|
91
|
+
* with each turn. Blinks and breathing carry on underneath.
|
|
92
|
+
*/
|
|
93
|
+
export function applyVectorMood(pose: VectorMotionPose, state: VectorMoodState): VectorMotionPose {
|
|
94
|
+
const sad = unit(state.sadness),
|
|
95
|
+
shake = sampleVectorDecline(state.declineTime);
|
|
96
|
+
return {
|
|
97
|
+
yaw: pose.yaw + shake - sad * 0.1,
|
|
98
|
+
pitch: pose.pitch + sad * 0.3,
|
|
99
|
+
roll: pose.roll + shake * 0.12 + sad * 0.06,
|
|
100
|
+
bob: pose.bob - sad * 0.04,
|
|
101
|
+
scale: pose.scale * (1 - sad * 0.03),
|
|
102
|
+
lid: unit(pose.lid * (1 - sad * 0.4)),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type VectorMoodFrame = {
|
|
107
|
+
/** The turn of the whole drawing (and of a reference face without a rest basis). */
|
|
108
|
+
yaw: number;
|
|
109
|
+
pitch: number;
|
|
110
|
+
motion?: VectorMotionPose;
|
|
111
|
+
/** A reference face's head direction. */
|
|
112
|
+
look?: VectorLook;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* What `renderVectorFrame` draws a character with, the mood laid on. `procedural` is a reference
|
|
117
|
+
* face's sampled motion (undefined for other bodies) and `turn` the pointer's turn. The mood's
|
|
118
|
+
* turn goes everywhere a head can turn: a reference face's `look`, and the frame's own turn, which
|
|
119
|
+
* is how a body with no head of its own (and a face fitted without a rest basis) shakes. A neutral
|
|
120
|
+
* character draws exactly as it did without a mood.
|
|
121
|
+
*/
|
|
122
|
+
export function vectorMoodFrame(
|
|
123
|
+
asset: VectorData,
|
|
124
|
+
procedural: VectorMotionPose | undefined,
|
|
125
|
+
turn: { yaw: number; pitch: number },
|
|
126
|
+
mood: VectorMoodState | undefined,
|
|
127
|
+
): VectorMoodFrame {
|
|
128
|
+
const look = (motion: VectorMotionPose | undefined) =>
|
|
129
|
+
asset.referenceFace && motion ? { yaw: motion.yaw, pitch: motion.pitch, mix: 1 } : undefined;
|
|
130
|
+
if (!mood || !vectorMoodActive(mood))
|
|
131
|
+
return { ...turn, motion: procedural, look: look(procedural) };
|
|
132
|
+
const base = procedural ?? VECTOR_REST_MOTION,
|
|
133
|
+
motion = applyVectorMood(base, mood);
|
|
134
|
+
return {
|
|
135
|
+
yaw: turn.yaw + motion.yaw - base.yaw,
|
|
136
|
+
pitch: turn.pitch + motion.pitch - base.pitch,
|
|
137
|
+
motion,
|
|
138
|
+
look: look(motion),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Screen, ScreenScrollView } from '../screen/index';
|
|
2
|
-
import { Popover, PopoverContent, PopoverTrigger } from '../popover';
|
|
3
2
|
import {
|
|
4
3
|
Select,
|
|
5
4
|
SelectContent,
|
|
@@ -23,9 +22,6 @@ const bindings = {
|
|
|
23
22
|
SelectContent,
|
|
24
23
|
SelectItem,
|
|
25
24
|
SelectItemText,
|
|
26
|
-
Popover,
|
|
27
|
-
PopoverTrigger,
|
|
28
|
-
PopoverContent,
|
|
29
25
|
SettingsSelect,
|
|
30
26
|
};
|
|
31
27
|
export function AgentCreator(props: AgentCreatorProps) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Screen, ScreenScrollView } from '../screen/index.web';
|
|
2
|
-
import { Popover, PopoverContent, PopoverTrigger } from '../popover/index.web';
|
|
3
2
|
import {
|
|
4
3
|
Select,
|
|
5
4
|
SelectContent,
|
|
@@ -23,9 +22,6 @@ const bindings = {
|
|
|
23
22
|
SelectContent,
|
|
24
23
|
SelectItem,
|
|
25
24
|
SelectItemText,
|
|
26
|
-
Popover,
|
|
27
|
-
PopoverTrigger,
|
|
28
|
-
PopoverContent,
|
|
29
25
|
SettingsSelect,
|
|
30
26
|
};
|
|
31
27
|
export function AgentCreator(props: AgentCreatorProps) {
|
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
resolveAvatarCharacter,
|
|
9
9
|
updateAvatarCharacter,
|
|
10
10
|
} from '../agent-avatar';
|
|
11
|
+
import { ColorSwatchPicker } from '../color-swatch-picker';
|
|
12
|
+
import { APP_COLOR_PRESETS, COLOR_PRESET_REGISTRY, FREE_COLOR_NAMES } from '../theme/color-presets';
|
|
13
|
+
import { drawnCharacter } from './paint';
|
|
11
14
|
import { editorShapeId } from './shape-choices';
|
|
12
15
|
import { ButtonGroup, ButtonGroupItem } from '../button-group';
|
|
13
16
|
import { RiArrowGoBackLine } from '../icons/remix/RiArrowGoBackLine';
|
|
@@ -22,15 +25,13 @@ import { Text } from '../typography';
|
|
|
22
25
|
import { AgentCreatorField } from './AgentCreatorField';
|
|
23
26
|
import { AgentPreferencesPanel } from './AgentPreferencesPanel';
|
|
24
27
|
import { CharacterControls } from './CharacterControls';
|
|
25
|
-
import { CustomColorPicker } from './CustomColorPicker';
|
|
26
28
|
import { EmotionPicker } from './EmotionPicker';
|
|
27
|
-
import { GlossArt } from './GlossArt';
|
|
28
29
|
import { PageHeader } from '../page-header/PageHeader';
|
|
29
30
|
import { useDialogContext } from '../dialog/context';
|
|
30
31
|
import { SurfaceLevelProvider } from '../styles/surface-levels';
|
|
31
32
|
import { useSurfaceBacking } from '../surface/use-surface-backing';
|
|
32
33
|
import { ShapeArc } from './ShapeArc';
|
|
33
|
-
import {
|
|
34
|
+
import { CHARACTER_OPTIONS } from './constants';
|
|
34
35
|
import {
|
|
35
36
|
AgentCreatorCopyContext,
|
|
36
37
|
useAgentCreatorBindings,
|
|
@@ -46,8 +47,7 @@ export function AgentCreatorBase(props: AgentCreatorProps) {
|
|
|
46
47
|
const { isWithinDialog } = useDialogContext();
|
|
47
48
|
const { colors } = useTheme();
|
|
48
49
|
const backing = useSurfaceBacking(colors.background, style);
|
|
49
|
-
const { Screen, ScreenScrollView
|
|
50
|
-
useAgentCreatorBindings();
|
|
50
|
+
const { Screen, ScreenScrollView } = useAgentCreatorBindings();
|
|
51
51
|
const latest = useRef({ agent, onChange });
|
|
52
52
|
latest.current = { agent, onChange };
|
|
53
53
|
const copy = useMemo(
|
|
@@ -103,13 +103,34 @@ export function AgentCreatorBase(props: AgentCreatorProps) {
|
|
|
103
103
|
node?.addEventListener('keydown', keydown);
|
|
104
104
|
return () => node?.removeEventListener('keydown', keydown);
|
|
105
105
|
}, []);
|
|
106
|
-
//
|
|
107
|
-
const
|
|
106
|
+
// The colours offered are the host's, and only those Bloom can draw.
|
|
107
|
+
const offered = useMemo(
|
|
108
|
+
() => (props.colors ?? FREE_COLOR_NAMES).filter((key) => key in APP_COLOR_PRESETS),
|
|
109
|
+
[props.colors],
|
|
110
|
+
);
|
|
111
|
+
const swatches = useMemo(() => {
|
|
112
|
+
const keyOf: Record<string, string> = {};
|
|
113
|
+
const names: Record<string, string> = {};
|
|
114
|
+
const hexes = offered.map((key) => {
|
|
115
|
+
const preset = COLOR_PRESET_REGISTRY.find(({ name }) => name === key)!;
|
|
116
|
+
keyOf[preset.hex] = key;
|
|
117
|
+
names[preset.hex] = preset.displayName;
|
|
118
|
+
return preset.hex;
|
|
119
|
+
});
|
|
120
|
+
return { hexes, keyOf, names };
|
|
121
|
+
}, [offered]);
|
|
122
|
+
// Every control draws the character in the agent's colour and writes one edit to the saved
|
|
123
|
+
// one; the history keeps the parts and drops the paint.
|
|
124
|
+
const painted = useMemo(
|
|
125
|
+
() => drawnCharacter(avatar, agent.color, offered),
|
|
126
|
+
[avatar, agent.color, offered],
|
|
127
|
+
);
|
|
128
|
+
const character = useMemo(() => resolveAvatarCharacter(painted), [painted]);
|
|
108
129
|
const edit = (patch: Parameters<typeof updateAvatarCharacter>[1]) =>
|
|
109
|
-
history.change(updateAvatarCharacter(
|
|
110
|
-
const paintColor = 'color' in character.paint ? character.paint.color : undefined;
|
|
111
|
-
const customHex = 'bodyColor' in character.paint ? character.paint.bodyColor : undefined;
|
|
130
|
+
history.change(updateAvatarCharacter(painted, patch));
|
|
112
131
|
const bodyHex = avatarBodyHex(character);
|
|
132
|
+
const chosenHex = (APP_COLOR_PRESETS as Record<string, { hex: string } | undefined>)[agent.color]
|
|
133
|
+
?.hex;
|
|
113
134
|
const shapeChoices = useMemo(
|
|
114
135
|
() =>
|
|
115
136
|
CHARACTER_OPTIONS.shape.map(([id, title]) => ({
|
|
@@ -118,9 +139,9 @@ export function AgentCreatorBase(props: AgentCreatorProps) {
|
|
|
118
139
|
id in messages.shapes
|
|
119
140
|
? messages.shapes[id as keyof typeof messages.shapes]
|
|
120
141
|
: messages.characterOption('shape', id, title),
|
|
121
|
-
character: updateAvatarCharacter(
|
|
142
|
+
character: updateAvatarCharacter(painted, { shape: id }),
|
|
122
143
|
})),
|
|
123
|
-
[
|
|
144
|
+
[painted, messages],
|
|
124
145
|
);
|
|
125
146
|
const nearby = useMemo(() => {
|
|
126
147
|
const index = CHARACTER_OPTIONS.shape.findIndex(
|
|
@@ -128,19 +149,19 @@ export function AgentCreatorBase(props: AgentCreatorProps) {
|
|
|
128
149
|
);
|
|
129
150
|
return [index - 1, index + 1].flatMap((i) => {
|
|
130
151
|
const next = CHARACTER_OPTIONS.shape[i];
|
|
131
|
-
return next ? [updateAvatarCharacter(
|
|
152
|
+
return next ? [updateAvatarCharacter(painted, { shape: next[0] })] : [];
|
|
132
153
|
});
|
|
133
|
-
}, [
|
|
154
|
+
}, [painted, character.shape]);
|
|
134
155
|
useVectorGeometryPreparation(nearby);
|
|
135
156
|
const eyeChoices = useMemo(
|
|
136
157
|
() =>
|
|
137
158
|
CHARACTER_OPTIONS.eyes.map(([id, title]) => ({
|
|
138
159
|
id,
|
|
139
160
|
label: messages.characterOption('eyes', id, title),
|
|
140
|
-
character: updateAvatarCharacter(
|
|
161
|
+
character: updateAvatarCharacter(painted, { eyes: id }),
|
|
141
162
|
disabled: false,
|
|
142
163
|
})),
|
|
143
|
-
[
|
|
164
|
+
[painted, messages],
|
|
144
165
|
);
|
|
145
166
|
return (
|
|
146
167
|
<AgentCreatorCopyContext.Provider value={copy}>
|
|
@@ -238,7 +259,7 @@ export function AgentCreatorBase(props: AgentCreatorProps) {
|
|
|
238
259
|
}}
|
|
239
260
|
>
|
|
240
261
|
<AgentAvatar
|
|
241
|
-
character={
|
|
262
|
+
character={painted}
|
|
242
263
|
size={162}
|
|
243
264
|
interactive
|
|
244
265
|
renderer="svg"
|
|
@@ -270,80 +291,21 @@ export function AgentCreatorBase(props: AgentCreatorProps) {
|
|
|
270
291
|
{preparing ? messages.preparingAvatar : ''}
|
|
271
292
|
</Text>
|
|
272
293
|
</StyledView>
|
|
273
|
-
<StyledView
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
accessibilityLabel={messages.color}
|
|
281
|
-
testID="agent-avatar-color-selector"
|
|
282
|
-
className="flex h-[38px] shrink-0 items-center gap-1 rounded-full border border-border-button-default bg-background-primary-default p-[5px] shadow-xs flex-row"
|
|
283
|
-
style={{
|
|
284
|
-
backgroundColor: colors.card,
|
|
285
|
-
borderColor: colors.border,
|
|
286
|
-
boxShadow: '0 1px 2px rgba(0,0,0,.05)',
|
|
294
|
+
<StyledView className="mt-[15px] px-3" testID="agent-avatar-color-selector">
|
|
295
|
+
<ColorSwatchPicker
|
|
296
|
+
label={messages.color}
|
|
297
|
+
value={chosenHex ?? ''}
|
|
298
|
+
onValueChange={(hex) => {
|
|
299
|
+
const color = swatches.keyOf[hex];
|
|
300
|
+
if (color !== undefined && color !== agent.color) onChange({ ...agent, color });
|
|
287
301
|
}}
|
|
288
|
-
|
|
289
|
-
{
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
return (
|
|
294
|
-
<StyledPressable
|
|
295
|
-
key={id}
|
|
296
|
-
accessibilityRole="button"
|
|
297
|
-
accessibilityLabel={messages.avatarColorLabel(
|
|
298
|
-
messages.characterOption('color', id, title),
|
|
299
|
-
)}
|
|
300
|
-
aria-pressed={active}
|
|
301
|
-
aria-disabled={disabled}
|
|
302
|
-
accessibilityState={{ selected: active, disabled }}
|
|
303
|
-
disabled={disabled}
|
|
304
|
-
onPress={() => edit({ color: id as typeof paintColor })}
|
|
305
|
-
className="relative shrink-0 cursor-pointer overflow-hidden rounded-full transition-transform duration-150 ease-out hover:scale-110 outline-none focus-visible:ring-2 focus-visible:ring-border-focus-ring focus-visible:ring-offset-2 size-[26px]"
|
|
306
|
-
>
|
|
307
|
-
<GlossArt center={hex} edge={hex} active={active} />
|
|
308
|
-
</StyledPressable>
|
|
309
|
-
);
|
|
310
|
-
})}
|
|
311
|
-
<Popover>
|
|
312
|
-
<PopoverTrigger asChild label={messages.customColor}>
|
|
313
|
-
<StyledPressable
|
|
314
|
-
aria-pressed={Boolean(customHex)}
|
|
315
|
-
accessibilityState={{ selected: Boolean(customHex) }}
|
|
316
|
-
className="relative size-[26px] shrink-0 overflow-hidden rounded-full"
|
|
317
|
-
>
|
|
318
|
-
<GlossArt
|
|
319
|
-
rainbow={!customHex}
|
|
320
|
-
center={customHex}
|
|
321
|
-
edge={customHex}
|
|
322
|
-
active={Boolean(customHex)}
|
|
323
|
-
/>
|
|
324
|
-
</StyledPressable>
|
|
325
|
-
</PopoverTrigger>
|
|
326
|
-
<PopoverContent
|
|
327
|
-
label={messages.customColor}
|
|
328
|
-
align="end"
|
|
329
|
-
minWidth={248}
|
|
330
|
-
maxWidth={248}
|
|
331
|
-
className="w-[248px] rounded-3xl p-2.5"
|
|
332
|
-
>
|
|
333
|
-
<CustomColorPicker
|
|
334
|
-
key={agent.id}
|
|
335
|
-
value={bodyHex}
|
|
336
|
-
onInteractionStart={history.begin}
|
|
337
|
-
onInteractionEnd={history.end}
|
|
338
|
-
onChange={(hex) => {
|
|
339
|
-
if (/^#[0-9a-f]{6}$/i.test(hex)) edit({ bodyColor: hex.toLowerCase() });
|
|
340
|
-
}}
|
|
341
|
-
/>
|
|
342
|
-
</PopoverContent>
|
|
343
|
-
</Popover>
|
|
344
|
-
</StyledView>
|
|
302
|
+
colors={swatches.hexes}
|
|
303
|
+
names={swatches.names}
|
|
304
|
+
size={22}
|
|
305
|
+
style={{ justifyContent: 'center' }}
|
|
306
|
+
/>
|
|
345
307
|
</StyledView>
|
|
346
|
-
<CharacterControls character={
|
|
308
|
+
<CharacterControls character={painted} onChange={history.change} />
|
|
347
309
|
<StyledView
|
|
348
310
|
className="mt-[15px] overflow-hidden rounded-2xl bg-background-secondary-default ps-3"
|
|
349
311
|
style={{ backgroundColor: colors.backgroundSecondary }}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createContext, useContext, useMemo } from 'react';
|
|
2
2
|
import { useMessages } from '../locale/messages';
|
|
3
|
-
import type * as PopoverParts from '../popover/Popover';
|
|
4
3
|
import type * as SelectParts from '../select';
|
|
5
4
|
import { AGENT_CREATOR_MESSAGES, type AgentCreatorMessages } from './messages';
|
|
6
5
|
|
|
@@ -14,7 +13,6 @@ export type AgentCreatorBindings = Pick<
|
|
|
14
13
|
| 'SelectItem'
|
|
15
14
|
| 'SelectItemText'
|
|
16
15
|
> &
|
|
17
|
-
Pick<typeof PopoverParts, 'Popover' | 'PopoverTrigger' | 'PopoverContent'> &
|
|
18
16
|
Pick<typeof import('../settings-modal/SettingsSelect'), 'SettingsSelect'> &
|
|
19
17
|
import('../screen/types').ScreenComponents;
|
|
20
18
|
export const AgentCreatorContext = createContext<AgentCreatorBindings | null>(null);
|