Overview
Threebox provides built-in methods to create simple 3D geometric primitives. These objects are lightweight alternatives to loading external models and are useful for markers, paths, and basic visualizations.Sphere
Create spherical objects for markers, points of interest, or particles.Basic Usage
API Signature
Options
| Parameter | Type | Default | Description |
|---|---|---|---|
radius | number | 1 | Sphere radius in specified units |
sides | number | 20 | Number of segments (higher = smoother) |
units | 'scene' | 'meters' | 'scene' | Coordinate system |
material | string | THREE.Material | 'MeshBasicMaterial' | Material type |
color | string | number | 'black' | Sphere color |
opacity | number | 1 | Opacity (0-1) |
anchor | string | 'bottom-left' | Anchor point |
adjustment | {x, y, z} | {x:0, y:0, z:0} | Center adjustment |
bbox | boolean | true | Show bounding box when selected |
tooltip | boolean | true | Enable tooltip |
raycasted | boolean | true | Include in raycasting |
Examples
Spheres use
THREE.SphereBufferGeometry internally. Higher sides values create smoother spheres but impact performance.Line
Create lines in full 3D space. Lines render with consistent color regardless of scene lighting.Basic Usage
API Signature
Options
| Parameter | Type | Default | Description |
|---|---|---|---|
geometry | Array<[lng, lat, alt]> | required | Array of coordinates |
color | string | number | 'black' | Line color (renders exactly as specified) |
width | number | 1 | Line width in pixels |
opacity | number | 1 | Line opacity (0-1) |
Examples
Tube
Create tubular/cylindrical shapes along a path using CatmullRom curves.Basic Usage
API Signature
Options
| Parameter | Type | Default | Description |
|---|---|---|---|
geometry | Array<[x, y, z]> | required | Array of 3D points defining the curve |
radius | number | 1 | Tube radius |
sides | number | 6 | Number of radial segments |
units | 'scene' | 'meters' | 'scene' | Coordinate system |
material | string | THREE.Material | 'MeshBasicMaterial' | Material type |
color | string | number | 'black' | Tube color |
opacity | number | 1 | Opacity (0-1) |
anchor | string | 'center' | Anchor point |
adjustment | {x, y, z} | {x:0, y:0, z:0} | Center adjustment |
bbox | boolean | true | Show bounding box when selected |
tooltip | boolean | true | Enable tooltip |
raycasted | boolean | true | Include in raycasting |
Examples
Tubes use
THREE.TubeGeometry with THREE.CatmullRomCurve3 to create smooth curves through the provided points. The curve is non-closed by default.Material Options
All primitives support Three.js material types:MeshBasicMaterial- Unaffected by lights, flat colorMeshStandardMaterial- PBR material with realistic lighting (recommended)MeshPhongMaterial- Shiny/glossy appearanceMeshLambertMaterial- Matte, diffuse appearance- Custom
THREE.Materialinstance
Common Patterns
Animated Marker
Flight Path Visualization
Pipe Network
Performance Tips
Optimize Geometry Complexity
Optimize Geometry Complexity
- Keep
sidesparameter reasonable (8-32 for most uses) - Use fewer points in line/tube geometry when possible
- Consider LOD (Level of Detail) for distant objects
Material Selection
Material Selection
- Use
MeshBasicMaterialfor non-lit objects (better performance) - Use
MeshStandardMaterialwhen lighting is important - Avoid expensive materials like
MeshPhysicalMaterialfor many objects
Batch Similar Objects
Batch Similar Objects
- Group objects with the same material
- Consider InstancedMesh for many identical objects
- Reuse geometries when possible
Next Steps
Loading Models
Load complex 3D models from external files
Extrusions
Create 3D shapes from GeoJSON polygons