06 - Interactive visualization¶
scene.show() opens a 3-D viewer in your browser for inspecting the scene, running simulations and looking at the results.
Opening the viewer¶
import less
scene = less.Scene()
scene.size = 10
scene.terrain = less.Terrain(property=less.Lambertian(reflectance=0.2))
scene.terrain.set_property(less.ThermalProperty(temperature=300))
scene.illumination = less.Illumination(
source=less.Sun(zenith=30), atmosphere=less.NoAtmosphere())
maize = less.Object("maize", mesh=less.asset_path("maize.obj"))
maize.set_property(less.Prospect(cab=40))
maize.set_property(less.ThermalProperty(temperature=303))
scene.add(maize, positions=[[3, 3, 0], [5, 5, 0], [7, 7, 0]])
scene.show()
The viewer starts a local web server and opens it in your default browser. Object positions, rotations and scales are shown exactly as in the scene, so it is a good way to check placement.
Mouse controls:
- left drag: rotate;
- right drag or Shift + left drag: pan;
- wheel: zoom.
Running simulations in the viewer¶
Pass sensors and processes to show() to choose and run them in the viewer:
sensors = [
less.OpticalImager(less.Orthographic(image_size=128),
bands=[650, 550, 450], quality=32, name="RGB"),
less.ThermalImager(less.Orthographic(image_size=128),
bands=[10600], quality=32, name="Thermal"),
]
processes = [
less.RadiationFieldProcess(n_samples=32, name="Radiation field"),
]
scene.show(sensors=sensors, processes=processes)
The viewer has three pages:
| Page | Purpose |
|---|---|
| Visualize | Look at objects, terrain, components and instances |
| Simulate | Choose a sensor or process, adjust parameters and run it |
| Products | View, compare and download results |
Per-triangle results, such as the absorption of each face, are painted back onto the scene. After changing the geometry, simulate again before painting the new result onto the scene.
Built-in examples¶
The examples come with RGB, multispectral, thermal and LiDAR sensors already set up, which you can run one by one on the Simulate page.
Without the viewer¶
For batch runs on a server, simply call simulate() in a loop and save the results:
from pathlib import Path
output = Path("output")
output.mkdir(exist_ok=True)
for sensor in sensors:
scene.simulate(sensor).save(output / f"{sensor.name}.tif")