-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathcommands.py
77 lines (63 loc) · 2.1 KB
/
commands.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from __future__ import absolute_import, division, print_function
import sys
if sys.version_info >= (3, 0):
unicode = str
from .geometry import (Geometry, Plane, Object, Mesh,
MeshPhongMaterial, PointsMaterial, Points, TextTexture)
class SetObject:
__slots__ = ["object", "path"]
def __init__(self, geometry_or_object, material=None, path=[]):
if isinstance(geometry_or_object, Object):
if material is not None:
raise(ArgumentError("Please supply either an Object OR a Geometry and a Material"))
self.object = geometry_or_object
else:
if material is None:
material = MeshPhongMaterial()
if isinstance(material, PointsMaterial):
self.object = Points(geometry_or_object, material)
else:
self.object = Mesh(geometry_or_object, material)
self.path = path
def lower(self):
return {
u"type": u"set_object",
u"object": self.object.lower(),
u"path": self.path.lower()
}
class SetTransform:
__slots__ = ["matrix", "path"]
def __init__(self, matrix, path=[]):
self.matrix = matrix
self.path = path
def lower(self):
return {
u"type": u"set_transform",
u"path": self.path.lower(),
u"matrix": list(self.matrix.T.flatten())
}
class Delete:
__slots__ = ["path"]
def __init__(self, path):
self.path = path
def lower(self):
return {
u"type": u"delete",
u"path": self.path.lower()
}
class SetAnimation:
__slots__ = ["animation", "play", "repetitions"]
def __init__(self, animation, play=True, repetitions=1):
self.animation = animation
self.play = play
self.repetitions = repetitions
def lower(self):
return {
u"type": u"set_animation",
u"animations": self.animation.lower(),
u"options": {
u"play": self.play,
u"repetitions": self.repetitions
},
u"path": ""
}