-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgltf_load.py
More file actions
46 lines (35 loc) · 900 Bytes
/
gltf_load.py
File metadata and controls
46 lines (35 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import math
from mewnala import *
gltf = None
duck_geo = None
duck_mat = None
light = None
frame = 0
def setup():
global gltf, duck_geo, duck_mat, light
size(800, 600)
gltf = load_gltf("gltf/Duck.glb")
duck_geo = gltf.geometry("LOD3spShape")
duck_mat = gltf.material("blinn3-fx")
mode_3d()
gltf.camera(0)
light = gltf.light(0)
def draw():
global frame
t = frame * 0.02
radius = 1.5
lx = math.cos(t) * radius
ly = 1.5
lz = math.sin(t) * radius
light.position(lx, ly, lz)
light.look_at(0.0, 0.8, 0.0)
r = math.sin(t * 8.0) * 0.5 + 0.5
g = math.sin(t * 8.0 + 2.0) * 0.5 + 0.5
b = math.sin(t * 8.0 + 4.0) * 0.5 + 0.5
duck_mat.set(base_color=[r, g, b, 1.0])
background(25)
use_material(duck_mat)
draw_geometry(duck_geo)
frame += 1
# TODO: this should happen implicitly on module load somehow
run()