diff --git a/example/multi-user-3d-web-experience/client/src/index.ts b/example/multi-user-3d-web-experience/client/src/index.ts index e305254e..c35e0af6 100644 --- a/example/multi-user-3d-web-experience/client/src/index.ts +++ b/example/multi-user-3d-web-experience/client/src/index.ts @@ -27,6 +27,9 @@ const app = new Networked3dWebExperienceClient(holder, { skyboxHdrJpgUrl: hdrJpgUrl, mmlDocuments: [{ url: `${protocol}//${host}/mml-documents/example-mml.html` }], environmentConfiguration: {}, + avatarConfig: { + availableAvatars: [], + }, }); app.update(); diff --git a/packages/3d-web-experience-client/src/Networked3dWebExperienceClient.ts b/packages/3d-web-experience-client/src/Networked3dWebExperienceClient.ts index 38ba41f2..874c481a 100644 --- a/packages/3d-web-experience-client/src/Networked3dWebExperienceClient.ts +++ b/packages/3d-web-experience-client/src/Networked3dWebExperienceClient.ts @@ -53,6 +53,18 @@ type MMLDocumentConfiguration = { }; }; +type AvatarConfig = { + availableAvatars: Array<{ + avatarFileType: "glb" | "html"; + thumbnailUrl?: string; + isDefaultAvatar?: boolean; + avatarFileUrl: string; + avatarName?: string; + }>; + allowCustomAvatars?: boolean; + customAvatarWebhookUrl?: string; +}; + export type Networked3dWebExperienceClientConfig = { sessionToken: string; chatNetworkAddress?: string; @@ -64,6 +76,7 @@ export type Networked3dWebExperienceClientConfig = { skyboxHdrJpgUrl: string; enableTweakPane?: boolean; updateURLLocation?: boolean; + avatarConfig?: AvatarConfig; }; export class Networked3dWebExperienceClient { @@ -395,10 +408,24 @@ export class Networked3dWebExperienceClient { throw new Error("Own identity not found"); } + const defaultAvatar = + this.config.avatarConfig?.availableAvatars.find((avatar) => avatar.isDefaultAvatar) ?? + this.config.avatarConfig?.availableAvatars[0]; + + const characterDescription = defaultAvatar + ? ({ + meshFileUrl: + defaultAvatar.avatarFileType === "glb" ? defaultAvatar.avatarFileUrl : undefined, + mmlCharacterUrl: + defaultAvatar.avatarFileType === "html" ? defaultAvatar.avatarFileUrl : undefined, + mmlCharacterString: undefined, + } as CharacterDescription) + : ownIdentity.characterDescription; + this.characterManager.spawnLocalCharacter( this.clientId!, ownIdentity.username, - ownIdentity.characterDescription, + characterDescription, spawnPosition, spawnRotation, );