Skip to content

Commit dcf2b23

Browse files
authored
Merge pull request #3 from catilac/py_camera_controllers
2 parents 14735e2 + 6884397 commit dcf2b23

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

crates/processing_pyo3/assets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../assets

crates/processing_pyo3/examples/assets

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from mewnala import *
2+
3+
angle = 0.0
4+
mode = 0
5+
6+
def setup():
7+
size(800, 600)
8+
mode_3d()
9+
orbit_camera()
10+
11+
dir_light = create_directional_light((1.0, 0.98, 0.95), 1500.0)
12+
dir_light.position(300.0, 400.0, 300.0)
13+
dir_light.look_at(0.0, 0.0, 0.0)
14+
15+
def draw():
16+
global angle, mode
17+
18+
if key_just_pressed(KEY_1):
19+
mode_3d()
20+
orbit_camera()
21+
mode = 0
22+
if key_just_pressed(KEY_2):
23+
mode_3d()
24+
free_camera()
25+
mode = 1
26+
if key_just_pressed(KEY_3):
27+
mode_2d()
28+
pan_camera()
29+
mode = 2
30+
31+
background(13, 13, 18)
32+
if mode < 2:
33+
fill(255, 217, 145)
34+
roughness(0.3)
35+
metallic(0.8)
36+
push_matrix()
37+
rotate(angle)
38+
box(100.0, 100.0, 100.0)
39+
pop_matrix()
40+
else:
41+
fill(204, 77, 51)
42+
rect(300.0, 200.0, 200.0, 200.0)
43+
44+
angle += 0.02
45+
46+
run()

crates/processing_pyo3/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,12 @@ mod mewnala {
739739
graphics!(module).mode_3d()
740740
}
741741

742+
#[pyfunction]
743+
#[pyo3(pass_module)]
744+
fn mode_2d(module: &Bound<'_, PyModule>) -> PyResult<()> {
745+
graphics!(module).mode_2d()
746+
}
747+
742748
#[pyfunction]
743749
#[pyo3(pass_module, signature = (*args))]
744750
fn camera_position(module: &Bound<'_, PyModule>, args: &Bound<'_, PyTuple>) -> PyResult<()> {

0 commit comments

Comments
 (0)