Environment API
Configure lighting, materials, and rendering settings. Environment functions control how your models are displayed in the preview and rendered output.
Lighting Presets
Quickly apply predefined lighting configurations. Call any preset function to instantly set up sun direction, colors, and rendering options for common scenarios.
env_studio()
Neutral studio lighting with soft shadows. This is the default environment if no preset is specified. Ideal for showcasing models with even, professional lighting.
| Setting | Value |
|---|---|
| Sun Direction | (0.5, 1.0, 0.3) |
| Sun Color | Warm white |
| Ambient | Neutral gray fill |
| AO/Shadows | Enabled |
env_studio()
sphere(0.5)env_daylight()
Bright outdoor lighting simulating midday sun. High contrast with strong shadows, good for architectural or outdoor scene visualization.
| Setting | Value |
|---|---|
| Sun Direction | (0.3, 1.0, 0.2) |
| Sun Color | Bright white/yellow |
| Ambient | Sky blue fill |
| Background | Light blue sky |
env_daylight()
box3(1.0, 0.5, 1.0) // Architectural elementenv_sunset()
Warm orange/golden hour lighting. Creates dramatic, atmospheric renders with long shadows and rich warm tones.
| Setting | Value |
|---|---|
| Sun Direction | (0.8, 0.3, 0.2) |
| Sun Color | Orange/gold |
| Ambient | Purple/blue fill |
| Background | Gradient warm to cool |
env_sunset()
// Dramatic scene lighting
cylinder(0.3, 2.0).union(sphere(0.5).translate_y(1.2))env_night()
Dark, cool-toned night scene. Low-key lighting with blue tones, suitable for moody or mysterious renders.
| Setting | Value |
|---|---|
| Sun Direction | (0.2, 0.5, 0.8) |
| Sun Color | Pale blue (moonlight) |
| Ambient | Dark blue |
| Background | Near black |
env_night()
sphere(0.5).shell(0.05) // Ethereal hollow sphereenv_clay()
Soft ambient occlusion look without directional lighting. Shows form and detail clearly, similar to clay renders in traditional 3D software. Ideal for evaluating shape without lighting distractions.
| Setting | Value |
|---|---|
| Sun | Disabled/very soft |
| Ambient | Bright, even |
| Material | Neutral gray |
| AO | Enhanced |
env_clay()
// Focus on form without lighting distraction
torus(0.4, 0.15).smooth_union(sphere(0.3), 0.1)Lighting Settings
Fine-tune directional and ambient lighting. All color values use normalized RGB (0.0 to 1.0 range).
set_sun_direction(x, y, z)
Set the direction of the main directional light (sun). The vector is automatically normalized, so only the direction matters, not the magnitude.
| Parameter | Type | Description |
|---|---|---|
| x | float | X component of light direction |
| y | float | Y component (positive = from above) |
| z | float | Z component of light direction |
// Top-down lighting
set_sun_direction(0.0, 1.0, 0.0)
// Dramatic side lighting
set_sun_direction(1.0, 0.3, 0.0)
// Low angle (sunrise/sunset feel)
set_sun_direction(0.8, 0.2, 0.3)
sphere(0.5)set_sun_color(r, g, b)
Set the color of the directional light. Values are normalized RGB (0.0 to 1.0). Higher values increase light intensity.
| Parameter | Type | Description |
|---|---|---|
| r | float | Red component (0.0 to 1.0+) |
| g | float | Green component (0.0 to 1.0+) |
| b | float | Blue component (0.0 to 1.0+) |
// Warm sunlight
set_sun_color(1.0, 0.9, 0.7)
// Cool moonlight
set_sun_color(0.6, 0.7, 1.0)
// Intense white (overexposed)
set_sun_color(1.5, 1.5, 1.5)
sphere(0.5)set_ambient_color(r, g, b)
Set the ambient/fill light color. This affects areas not directly lit by the sun, simulating light bouncing from the environment.
| Parameter | Type | Description |
|---|---|---|
| r | float | Red component (0.0 to 1.0) |
| g | float | Green component (0.0 to 1.0) |
| b | float | Blue component (0.0 to 1.0) |
// Sky blue ambient (outdoor)
set_ambient_color(0.4, 0.5, 0.7)
// Warm interior bounce light
set_ambient_color(0.5, 0.4, 0.3)
// High contrast (dark shadows)
set_ambient_color(0.1, 0.1, 0.1)
sphere(0.5)set_background_color(r, g, b)
Set the background/sky color of the viewport. Does not affect lighting, only the visible background behind the model.
| Parameter | Type | Description |
|---|---|---|
| r | float | Red component (0.0 to 1.0) |
| g | float | Green component (0.0 to 1.0) |
| b | float | Blue component (0.0 to 1.0) |
// White background (product shot)
set_background_color(1.0, 1.0, 1.0)
// Dark background
set_background_color(0.1, 0.1, 0.12)
// Gradient-like teal
set_background_color(0.2, 0.3, 0.35)
sphere(0.5)Material Settings
Control the appearance of the model's surface material.
set_material_color(r, g, b)
Set the base color of the model using normalized RGB values.
| Parameter | Type | Description |
|---|---|---|
| r | float | Red component (0.0 to 1.0) |
| g | float | Green component (0.0 to 1.0) |
| b | float | Blue component (0.0 to 1.0) |
// Red material
set_material_color(0.9, 0.2, 0.2)
// Gold/brass
set_material_color(0.8, 0.6, 0.2)
// Teal
set_material_color(0.2, 0.6, 0.7)
sphere(0.5)set_material_color_hex(hex)
Set the base color using a hex color string. More convenient when working with colors from design tools or CSS.
| Parameter | Type | Description |
|---|---|---|
| hex | string | Hex color string (with or without #) |
// Coral red
set_material_color_hex("#ff5544")
// Forest green
set_material_color_hex("#2d5a27")
// Also works without #
set_material_color_hex("5b7a69")
sphere(0.5)Rendering Settings
Toggle rendering features that affect visual quality and performance.
set_ao_enabled(enabled)
Enable or disable ambient occlusion. AO adds soft shadows in crevices and corners, enhancing the perception of depth and form.
| Parameter | Type | Description |
|---|---|---|
| enabled | bool | true to enable, false to disable |
// Disable AO for cleaner look
set_ao_enabled(false)
// Enable AO (default)
set_ao_enabled(true)
// AO is particularly visible on complex shapes
torus(0.4, 0.1).smooth_union(sphere(0.25), 0.1)set_shadows_enabled(enabled)
Enable or disable cast shadows from the directional light. Shadows add realism but can be disabled for a flatter, illustrative look.
| Parameter | Type | Description |
|---|---|---|
| enabled | bool | true to enable, false to disable |
// Flat look without shadows
set_shadows_enabled(false)
// Enable shadows (default)
set_shadows_enabled(true)
// Ground plane to catch shadows
sphere(0.4).translate_y(0.4)
.union(ground_plane())Complete Example
Combine multiple environment settings to create a custom scene:
// Custom sunset scene
set_sun_direction(0.9, 0.3, 0.1)
set_sun_color(1.2, 0.7, 0.4)
set_ambient_color(0.3, 0.3, 0.5)
set_background_color(0.15, 0.1, 0.2)
set_material_color_hex("#c9a87c")
set_ao_enabled(true)
set_shadows_enabled(true)
// Scene with ground
let monument = cylinder(0.2, 1.5)
.smooth_union(sphere(0.35).translate_y(0.8), 0.1);
monument.union(ground_plane())Tip: Start with a preset that's close to your desired look, then fine-tune individual settings. This is faster than configuring everything from scratch.