AI 3D Model Spawner
AI 3D Model Spawner
A dynamic SightLab VR demo that allows you to generate and interact with 3D models in real time using generative AI tools like Meshy or MasterpieceX
Located in
ExampleScripts/AI_3D_Model_Spawner
๐งฉ What It Does
AI 3D Model Spawner allows participants or researchers to spawn objects into a virtual scene on demand, simply by typing text prompts or using speech recognition to speak model requests (e.g. โa glowing mushroomโ). The models are created via online APIs, refined, and automatically placed in the VR environment.
- ๐ค Text โ 3D model
- ๐ง Generative AI (Meshy and MasterpieceX currently supported, others will be added)
- ๐๏ธ Integrated gaze tracking and grabbing via SightLab
- ๐ Toggle lighting with
B
key - ๐ Generate new models any time using
N
key
โ๏ธ Setup Instructions
1. ๐ฆ Install Required Python Libraries
pip install mpx-genai-sdk pillow requests
SightLab and Vizard dependencies must already be installed and configured.
2. ๐ Get an API Key
๐น Meshy
- Visit: https://www.meshy.ai/
- Log in and go to: https://www.meshy.ai/api
- Copy your API key
- Requires Paid Subscription (minimum $20/month)
๐น MasterpieceX
- Sign up & docs: https://developers.masterpiecex.com
- Create your app and generate a Bearer Token here: ๐ https://developers.masterpiecex.com/apps
- ๐ฐ No subscription required โ just purchase API credits
- Example: 2,500 credits = $15
- You can purchase more as needed
3. ๐ Add API keys to key files
In windows search type "cmd" and enter the following
๐น For Meshy:
setx MESHY_API_KEY "your-meshy-api-key"
๐น For MasterpieceX:
setx MPX_SDK_BEARER_TOKEN "your-mpx-bearer-token"
โ ๏ธ Important: Restart Vizard (or your terminal) after setting these.
4. How to Run
- Run
AI_3D_Model_Spawner.py
- Choose your model generation library (MasterpieceX or Meshy currently) and hardware
- Press
N
to enter a text prompt (e.g.,a red futuristic drone
) - Press and hold
c
or the RH grip button to speak commands, let go to send command - A model is generated via the preview API call (geometry only). Before model loads a placeholder sphere will appear.
- Once loaded, it is automatically refined with texture and PBR
- The refined model replaces the preview in-scene for Meshy (for MasterpieceX there is no preview model)
- Press
B
to toggle lighting on/off to see what looks better - Press
N
or grip button orc
again to generate another model - Grab the new model using the trigger buttons or left mouse button
- Press trigger or spacebar to end the trial
Estimated time to model completion: MasterpieceX - 1-2 minutes
Meshy - 2-4 minutes
Config Global Options
# ===== Passthrough / AR Settings =====
USE_PASSTHROUGH = False
# ===== Environment Settings =====
ENVIRONMENT_MODEL = 'sightlab_resources/environments/RockyCavern.osgb'
# ===== GUI Options =====
USE_GUI = False
# ===== Speech Recognition =====
USE_SPEECH_RECOGNITION = True
# ===== Model Options =====
MODEL_STARTING_POINT = [0, 1.5, 2]
MODEL_STARTING_POINT_PASSTHROUGH = [0, 1.5, 0.8]
# ===== Data Saving =====
SAVE_DATA = False
๐ง Example Use Cases
Field | Idea Example |
---|---|
๐ง Psychology | Generate phobic stimuli like a spider , a syringe |
๐ฆด Education | Spawn anatomy models: human skull , brain cross-section |
โ Math/Cognition | Test symbolic vs object views: 3 apples , a number line |
๐งช UX/VR Dev | Prototype object-based interactions in VR |
๐ฎ Game Studies | On-demand in-scene assets for testing |
๐ก Tips
- All models are saved into the
/Resources/
folder automatically - Can delete Meshy preview models once refined
- Object names are auto-generated from prompt text for traceability
- You can grab models with controllers or interact via gaze
- SightLab automatically logs gaze and grab data per object
๐ Related Links
- ๐ Meshy API Docs
- ๐ MasterpieceX API Docs