diff --git a/packages/3d-web-avatar-editor-ui/src/CharacterPartsSelector.tsx b/packages/3d-web-avatar-editor-ui/src/CharacterPartsSelector.tsx index 8d948703..07418a9e 100644 --- a/packages/3d-web-avatar-editor-ui/src/CharacterPartsSelector.tsx +++ b/packages/3d-web-avatar-editor-ui/src/CharacterPartsSelector.tsx @@ -1,3 +1,4 @@ +import { createMMLCharacterString } from "@mml-io/3d-web-avatar"; import { useCallback, useEffect, useState } from "react"; import { AssetDescription, CharacterComposition, CollectionDataType } from "./types"; @@ -32,10 +33,13 @@ export function CharacterPartsSelector({ const createMMLDescription = useCallback(() => { const fullBody = currentSelection[fullBodyKey]; const remainingParts = Object.entries(currentSelection).filter(([key]) => key !== fullBodyKey); - const description = ` -${remainingParts.map(([key, asset]) => ``).join("\n")} - - `; + + const description = createMMLCharacterString({ + base: { url: fullBody.asset }, + parts: remainingParts.map(([, assetDescription]) => { + return { url: assetDescription.asset }; + }), + }); console.log(description); }, [currentSelection, fullBodyKey]); diff --git a/packages/3d-web-avatar/src/helpers/createMMLCharacterString.ts b/packages/3d-web-avatar/src/helpers/createMMLCharacterString.ts new file mode 100644 index 00000000..58a1db4b --- /dev/null +++ b/packages/3d-web-avatar/src/helpers/createMMLCharacterString.ts @@ -0,0 +1,13 @@ +import { MMLCharacterDescription } from "./parseMMLDescription"; + +export const createMMLCharacterString = (characterDescription: MMLCharacterDescription): string => { + const base = characterDescription.base.url; + + const partsTags = characterDescription.parts.map( + (part) => ``, + ); + + return ` + ${partsTags.join("\n ")} +`; +}; diff --git a/packages/3d-web-avatar/src/index.ts b/packages/3d-web-avatar/src/index.ts index f5ada3b1..f18c8231 100644 --- a/packages/3d-web-avatar/src/index.ts +++ b/packages/3d-web-avatar/src/index.ts @@ -7,3 +7,4 @@ export { type MMLCharacterDescription, parseMMLDescription, } from "./helpers/parseMMLDescription"; +export { createMMLCharacterString } from "./helpers/createMMLCharacterString";