5. Create a 3D display
This step adds a 3D view to the Luneray model. Roads are drawn as lines, buildings are extruded with textures, and people use an OBJ model while moving toward a target.

Draw roads and buildings in 3D​
The road aspect draws a line through the geometry's points. The building aspect extrudes its shape and uses separate roof and wall textures. The view above shows both layers in the same 3D scene.
species road {
aspect geom3D {
draw line(shape.points, 2.0) color: #black;
}
}
species building {
aspect geom3D {
draw shape depth: 20 #m border: #black texture: ["../includes/roof_top.jpg", "../includes/texture.jpg"];
}
}
Draw people with a 3D model​
The aspect loads people.obj from the model's includes folder only while a person has a destination. It rotates the model to match the agent heading and raises its location above the ground.
species people skills: [moving] {
float speed <- (2 + rnd(3)) #km/#h;
bool is_infected <- false;
point target;
reflex stay when: target = nil {
if flip(0.05) {
target <- any_location_in(one_of(building));
}
}
reflex move when: target != nil {
do goto(target: target, on: road_network);
if (location = target) {
target <- nil;
}
}
reflex infect when: is_infected {
ask people at_distance 10 #m {
if flip(0.05) {
is_infected <- true;
}
}
}
aspect geom3D {
if target != nil {
draw obj_file("../includes/people.obj", 90::{-1,0,0}) size: 5
at: location + {0, 0, 7} rotate: heading - 90 color: is_infected ? #red : #green;
}
}
}
Configure the 3D view​
The view3D declaration adds the georeferenced town image as a static picture layer. Buildings and roads use their 3D aspects; the people layer refreshes with the simulation.
experiment main mode: gui {
output {
display view3D renderer: 3d antialias: false {
light #ambient intensity: 80;
picture "../includes/luneray.jpg" refresh: false;
species building aspect: geom3D refresh: false;
species road aspect: geom3D refresh: false;
species people aspect: geom3D;
}
}
}
The complete Luneray Flu model 5 also includes the 2D map and chart displays.