Import 3D Models
Load 3D models into your scene from various file formats
Supported Formats#
WiTwin supports a wide range of 3D model formats for importing geometry into your scenes.
| Format | Extension | Description |
|---|---|---|
| OBJ | .obj | Wavefront OBJ format |
| STL | .stl | Stereolithography format |
| PLY | .ply | Polygon File Format |
| GLTF/GLB | .gltf, .glb | GL Transmission Format |
Advanced Formats
Support for advanced formats like NeRF and 3D Gaussian Splatting will enable importing learned 3D representations directly into your digital twin scenes.
Import Methods#
There are two ways to import 3D models into your scene, both supporting bidirectional synchronization:
Method 1: Python Code#
Load models programmatically using the Python API.
Load OBJ Model
from witwin import Scene, FileImport
scene = Scene()
# Load OBJ file
building = FileImport.load_obj(
path="models/building.obj",
name="MainBuilding"
)
# The object is automatically added to the scene
# Access and modify properties
building.transform.position = [10, 0, 0]
building.transform.scale = [1, 1, 1]
# Add material
material = building.get_component("Material")
if material:
material.color = [0.8, 0.8, 0.8, 1.0]Load STL Model
from witwin import FileImport
# Load STL file (commonly used for 3D printing models)
antenna = FileImport.load_stl(
path="models/antenna.stl",
name="Antenna"
)
antenna.transform.position = [5, 0, 0]
# STL models are automatically converted to mesh objects
mesh = antenna.get_component("Mesh")
print(f"Loaded model with {mesh.vertex_count} vertices")Bidirectional Sync
Models loaded via Python immediately appear in the WiTwin Studio. Any modifications made in the Studio are instantly reflected in the Python code.
Method 2: Drag & Drop in Studio#
Import models directly in the WiTwin Studio interface.
How to Import
- Open the WiTwin Studio (launch from Python or access via web)
- Locate your 3D model file in your file system
- Drag the file from your file explorer directly into the Viewport panel
- The model will be automatically imported and added to the scene
- Access the imported object in Python code immediately
Supported Drag & Drop
| Format | Status |
|---|---|
.obj | Supported |
.stl | Supported |
.ply | Supported |
.gltf / .glb | Supported |
Working with Imported Models#
Access Mesh Data#
from witwin import Scene
scene = Scene()
# Get an object by name
building = scene.get_object("MainBuilding")
# Access mesh component
mesh = building.get_component("Mesh")
print(f"Vertices: {mesh.vertex_count}")
print(f"Faces: {mesh.face_count}")Modify Transform#
# Position
building.transform.position = [0, 0, 0]
# Rotation (Euler angles in degrees)
building.transform.rotation = [0, 45, 0]
# Scale
building.transform.scale = [2, 2, 2]Apply Materials#
# Get or add material component
material = building.get_component("Material")
if not material:
building.add_component("Material")
material = building.get_component("Material")
# Set material properties
material.color = [0.5, 0.5, 0.5, 1.0] # Gray RGBA
material.metalness = 0.0
material.roughness = 0.8
# Electromagnetic properties
material.permittivity = 4.0 # Relative permittivity
material.conductivity = 0.01 # Conductivity (S/m)Using the Library Panel#
The Library panel provides a quick way to add primitive objects:
- Open the Library panel in the Studio
- Browse categories: Basic, Lights, Cameras, RF/Wireless
- Click an item to add it at the camera focus point
- Or drag an item into the Viewport to place it precisely
Available Primitives#
| Category | Items |
|---|---|
| Basic | Cube, Sphere, Cylinder, Plane, Cone, Torus |
| Lights | Point Light, Directional Light, Spot Light |
| Cameras | Perspective Camera |
| RF/Wireless | Transmitter, Receiver, Radar |
Next Steps#
- Component System - Learn about components
- Radar Simulation - Set up radar systems
- Properties Panel - Edit object properties