Bringing AI Online: 3D AI Reallusion Avatars on Web Browsers using Three.js and React

By
Convai Team
May 30, 2024

Introduction

In the rapidly evolving world of game development, integrating AI into 3D characters has become a game-changer. This article will delve into how to bring AI online in web browsers using 3D Reallusion Avatars, Three.js, and React. This tutorial is based on our Convai video tutorial shared below, and aims to provide game developers, designers, and virtual world builders with an in-depth guide on creating AI-powered NPCs for immersive web-based experiences.

Benefits Of Bringing AI Online with 3D Reallusion Avatars:

Integrating AI Reallusion avatars in web browsers opens up a plethora of opportunities:

Game Development

Immersive NPCs: Create AI-driven NPCs, with Convai’s Character Creator, that can interact dynamically with players, providing a more engaging and lifelike gaming experience.

Adaptive Gameplay: Utilize AI to adapt game scenarios based on player interactions, making games more responsive and personalized.

Enhanced Storytelling: AI characters can contribute to richer and dynamic narratives by providing context-sensitive dialogues and actions. Read more about this, on our blog about Convai’s Narrative Design.

Online Educational Tools

Virtual Tutors: Develop interactive and responsive online educational tools where AI avatars can teach, answer questions, and provide feedback.

Personalized Learning: AI can adapt to individual learning styles and paces, offering customized educational experiences.

Engagement: Use AI characters to make learning more engaging and interactive, helping to maintain student interest and motivation.

Customer Service and Brand Representation

Dynamic Brand Agents: Implement AI-driven brand representatives on websites to enhance user experience through real-time interaction and personalized assistance. Check out Convai’s dynamic AI Characters representing Amdocs.

Customer Support: AI avatars can provide 24/7 customer support, answering FAQs, troubleshooting issues, and guiding users through processes.

Marketing: Use AI characters to engage users with promotional content, offers, and personalized recommendations.

Virtual Events, Interactive Hosts and Social Platforms

Interactive Hosts: AI avatars can act as hosts for virtual events, guiding attendees, answering questions, and providing information.

Social Interactions: Develop AI characters that can interact with users in virtual social platforms, creating a more vibrant and interactive community.

Event Management: Use AI to manage and organize virtual events, ensuring smooth operations and enhanced user experience.

Training and Simulations

Realistic Training Scenarios: Use AI avatars for training simulations, providing realistic and interactive scenarios for better learning and practice. In video games like Second Life, Convai powered bots are significantly helping reduce the learning curve for new players onboarding the platform.

Feedback and Assessment: AI can offer real-time feedback and assessment, helping trainees to improve their skills effectively.

Cost-Effective: Reduce the cost of training by using AI simulations instead of requiring physical presence or materials.

Setting Up Your AI Reallusion Character

Step 1: Exporting from Character Creator 4

1. Open Character Creator 4: Start by importing your character into Character Creator 4.

2. Export as FBX: Navigate to `Edit > Export FBX` and choose the `Blender` preset. Ensure that you deselect `Embed Textures` under FBX options.

3. Save Your File: Choose your project folder and save your character model.

Step 2: Adding Animations

1. Select Animations: Use the search bar to find `idle` and `talk` animations.

2. Export Animations: Export each animation as an FBX file, following the same steps as above.

Preparing Blender

Step 1: Installing Add-Ons

1. Download Blender Add-Ons: Get the `CC Blender Tool` and `Baking Add-On` from GitHub.

2. Install Add-Ons: Install these add-ons through the Blender preferences and enable them.

Step 2: Importing and Preparing Character

1. Import Character: Use the pipeline tab in Blender to import your character.

2. Rebuild Materials: Convert materials for web compatibility by selecting `Basic` and then `Rebuild Basic Materials`.

3. Bake Textures: Use the baking tab to bake textures into a designated bake folder.

Step 3: Exporting for Web

1. Export as GLTF: Ensure that you deselect `Animation` in the export options and save your file as a GLB.

2. Validate: Check your file in a GLTF viewer to ensure everything is correct.

Creating AI Minds with Convai

1. Create a New Character: Sign in to Convai and create a new character. Choose a voice and backstory.

2. Set Up Personality: Adjust personality traits to suit your character’s role. Learn more here.

3. Copy Character ID and API Key: You will need these for integrating Convai with your web setup.

Setting Up the React Environment

Step 1: Setting Up the Project

1. Create a React App: Use `npm create vite@latest .` to set up your React environment.

2. Install Dependencies: Install required packages like `react-three-fiber`, `drei`, `three.js`, and `lodash`. Read React Documentation here.

Step 2: Configuring the Environment

1. Setup 3D Space: Use `react-three-fiber` to create a 3D space. Configure lighting, sky, and grid components.

2. Implement Controls: Use `Convai FPS control` for first-person shooter-style movement.

Bringing it All Together

Step 1: Importing and Mapping Characters

1. Convert GLB Files: Use GLTF React Three Fiber tools to map nodes and materials.

2. Setup Animations: Extract and set up animations using `useAnimations` and `useConvaiClient` hooks. Additional information here.

Step 2: Implementing AI and Interactions

1. Lip Sync and Head Tracking: Use `useLipSync` and `useHeadTracking` hooks to enhance interactivity. Learn more here.

2. Crowd Characters: Import additional characters from Reallusion and set up animations similarly.

Conclusion

Bringing AI online with 3D Reallusion avatars using Three.js and React is a powerful way to enhance web-based experiences. Whether you're a game developer, designer, or virtual world builder, this integration can provide dynamic and interactive elements to your projects. By following this guide, you can create AI-powered NPCs that bring your virtual worlds to life.

Feel free to reach out to the Convai community on Discord or the support team at support@convai.com for any queries. Happy developing!