-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcube.py
58 lines (50 loc) · 1.84 KB
/
cube.py
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
47
48
49
50
51
52
53
54
55
56
57
58
from pyunity import *
class Oscillator(Behaviour):
a = 0
speed = ShowInInspector(int, 5)
renderer = ShowInInspector(MeshRenderer)
def Start(self):
self.renderer.mat = Material(RGB(255, 0, 0))
def Update(self, dt):
self.a += dt * self.speed / 10
self.renderer.mat.color = HSV(self.a % 3 * 360, 100, 100)
class Oscillator2(Behaviour):
a = 0
speed = ShowInInspector(int, 10)
def Update(self, dt):
self.a += dt * self.speed / 10
size = Mathf.LerpUnclamped(Mathf.Cos(self.a), 0.75, 1)
self.transform.localScale = Vector3.one() * size
class Rotator(Behaviour):
def Update(self, dt):
self.transform.eulerAngles += Vector3(0, 90, 135) * dt
scene = SceneManager.AddScene("Scene")
scene.mainCamera.transform.position = Vector3(0, 5, -5)
scene.mainCamera.transform.eulerAngles = Quaternion.Euler(Vector3(45, 0, 0))
scene.gameObjects[1].transform.eulerAngles = Quaternion.Euler(Vector3(75, -25, 0))
root = GameObject("Root")
root.AddComponent(Rotator)
root.AddComponent(Oscillator2)
scene.Add(root)
i = 0
for direction in [Vector3.up(), Vector3.right(), Vector3.forward()]:
for parity in [-1, 1]:
i += 1
side = direction * parity
go = GameObject("Side", root)
renderer = go.AddComponent(MeshRenderer)
renderer.mesh = Loader.Primitives.double_quad
oscillator = go.AddComponent(Oscillator)
oscillator.renderer = renderer
oscillator.speed = i
go.transform.localPosition = side
if direction == Vector3.forward():
angle = 0
elif direction == Vector3.back():
angle = 180
else:
angle = 90
go.transform.localRotation = Quaternion.FromAxis(angle, Vector3.forward().cross(side))
scene.Add(go)
SceneManager.LoadScene(scene)
Loader.GenerateProject("Test")