Skip to content

Commit a490b6e

Browse files
committed
Add an example and running_geometry field to state
1 parent 219d754 commit a490b6e

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from processing import *
2+
from math import sin, cos
3+
from random import gauss
4+
5+
geometry = None
6+
7+
def setup():
8+
global geometry
9+
size(800, 600)
10+
mode_3d()
11+
create_geometry()
12+
13+
def draw():
14+
global geometry
15+
16+
camera_position(150.0, 150.0, 150.0)
17+
camera_look_at( 0.0, 0.0, 0.0)
18+
background(220, 200, 140)
19+
20+
draw_geometry(geometry)
21+
22+
def create_geometry():
23+
global geometry
24+
25+
beginGeometry()
26+
27+
for i in range(60):
28+
x = gauss(400, 200)
29+
y = gauss(350, 175)
30+
z = gauss(0, 100)
31+
32+
push_matrix()
33+
translate(x, y, z)
34+
sphere(10)
35+
pop_matrix()
36+
37+
geometry = endGeometry()
38+
39+
# TODO: this should happen implicitly on module load somehow
40+
run()

crates/processing_render/src/geometry/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Topology {
6060
}
6161
}
6262

63-
#[derive(Component)]
63+
#[derive(Debug, Component)]
6464
pub struct Geometry {
6565
pub handle: Handle<Mesh>,
6666
pub layout: Entity,

crates/processing_render/src/render/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub struct RenderState {
6060
pub stroke_color: Option<Color>,
6161
pub stroke_weight: f32,
6262
pub transform: TransformStack,
63+
pub running_geometry: Option<Geometry>,
6364
}
6465

6566
impl Default for RenderState {
@@ -69,6 +70,7 @@ impl Default for RenderState {
6970
stroke_color: Some(Color::BLACK),
7071
stroke_weight: 1.0,
7172
transform: TransformStack::new(),
73+
running_geometry: None,
7274
}
7375
}
7476
}

0 commit comments

Comments
 (0)