@@ -41,14 +41,6 @@ class CameraData:
41
41
"""Stores position, orientation, and zoom for a camera.
42
42
43
43
This is like where a camera is placed in 3D space.
44
-
45
- Attributes:
46
- position: A 3D vector which describes where the camera is located.
47
- up: A 3D vector which describes which direction is up (+y).
48
- forward: a 3D vector which describes which direction is forwards (+z).
49
- zoom: A scaler that records the zoom of the camera. While this most often affects the projection matrix
50
- it allows camera controllers access to the zoom functionality
51
- without interacting with the projection data.
52
44
"""
53
45
54
46
__slots__ = ("position" , "up" , "forward" , "zoom" )
@@ -59,9 +51,15 @@ def __init__(self,
59
51
forward : Point3 = (0.0 , 0.0 , - 1.0 ),
60
52
zoom : float = 1.0 ):
61
53
62
- # View matrix data
54
+ #: A 3D vector which describes where the camera is located.
63
55
self .position : Tuple [float , float , float ] = position
56
+ #: A 3D vector which describes which direction is up (+y).
64
57
self .up : Tuple [float , float , float ] = up
58
+ #: A scalar which describes which direction the camera is pointing.
59
+ #:
60
+ #: While this affects the projection matrix, it also allows camera
61
+ #: controllers to access zoom functionality without interacting with
62
+ #: projection data.
65
63
self .forward : Tuple [float , float , float ] = forward
66
64
67
65
# Zoom
@@ -104,15 +102,6 @@ class OrthographicProjectionData:
104
102
This is by default a Left-handed system. with the X axis going from left to right, The Y axis going from
105
103
bottom to top, and the Z axis going from towards the screen to away from the screen. This can be made
106
104
right-handed by making the near value greater than the far value.
107
-
108
- Attributes:
109
- left: The left most value, which gets mapped to x = -1.0 (anything below this value is not visible).
110
- right: The right most value, which gets mapped to x = 1.0 (anything above this value is not visible).
111
- bottom: The bottom most value, which gets mapped to y = -1.0 (anything below this value is not visible).
112
- top: The top most value, which gets mapped to y = 1.0 (anything above this value is not visible).
113
- near: The 'closest' value, which gets mapped to z = -1.0 (anything below this value is not visible).
114
- far: The 'furthest' value, Which gets mapped to z = 1.0 (anything above this value is not visible).
115
- viewport: The pixel bounds which will be drawn onto. (left, bottom, width, height)
116
105
"""
117
106
118
107
__slots__ = ("rect" , "near" , "far" )
@@ -129,11 +118,23 @@ def __init__(
129
118
130
119
# Data for generating Orthographic Projection matrix
131
120
self .rect : Rect = LRBT (left , right , bottom , top )
121
+ #: The 'closest' visible position along the forward direction.
122
+ #:
123
+ #: It will get mapped to z = -1.0. Anything closer than this value
124
+ #: is not visible.
132
125
self .near : float = near
126
+ #: The 'farthest' visible position along the forward direction.
127
+ #:
128
+ #: It will get mapped to z = 1.0. Anything father than this value
129
+ #: is not visible.
133
130
self .far : float = far
134
131
135
132
@property
136
133
def left (self ) -> float :
134
+ """"The left-side cutoff value, which gets mapped to x = -1.0.
135
+
136
+ Anything to the left of this value is not visible.
137
+ """
137
138
return self .rect .left
138
139
139
140
@left .setter
@@ -153,6 +154,10 @@ def left(self, new_left: AsFloat):
153
154
154
155
@property
155
156
def right (self ) -> float :
157
+ """"The right-side cutoff value, which gets mapped to x = 1.0.
158
+
159
+ Anything to the left of this value is not visible.
160
+ """
156
161
return self .rect .right
157
162
158
163
@right .setter
@@ -172,6 +177,10 @@ def right(self, new_right: AsFloat):
172
177
173
178
@property
174
179
def bottom (self ) -> float :
180
+ """"The bottom-side cutoff value, which gets mapped to -y = 1.0.
181
+
182
+ Anything to the left of this value is not visible.
183
+ """
175
184
return self .rect .bottom
176
185
177
186
@bottom .setter
@@ -191,6 +200,10 @@ def bottom(self, new_bottom: AsFloat):
191
200
192
201
@property
193
202
def top (self ) -> float :
203
+ """"The top-side cutoff value, which gets mapped to y = 1.0.
204
+
205
+ Anything to the left of this value is not visible.
206
+ """
194
207
return self .rect .top
195
208
196
209
@top .setter
@@ -239,14 +252,7 @@ def orthographic_from_rect(rect: Rect, near: float, far: float) -> OrthographicP
239
252
240
253
class PerspectiveProjectionData :
241
254
"""Describes a perspective projection.
242
-
243
- Attributes:
244
- aspect: The aspect ratio of the screen (width over height).
245
- fov: The field of view in degrees. With the aspect ratio defines
246
- the size of the projection at any given depth.
247
- near: The 'closest' value, which gets mapped to z = -1.0 (anything below this value is not visible).
248
- far: The 'furthest' value, Which gets mapped to z = 1.0 (anything above this value is not visible).
249
- viewport: The pixel bounds which will be drawn onto. (left, bottom, width, height)
255
+ )
250
256
"""
251
257
__slots__ = ("aspect" , "fov" , "near" , "far" )
252
258
@@ -255,10 +261,22 @@ def __init__(self,
255
261
fov : float ,
256
262
near : float ,
257
263
far : float ):
258
- # Data for generating Perspective Projection matrix
264
+ #: The aspect ratio of the screen (width over height).
259
265
self .aspect : float = aspect
266
+ #: The field of view in degrees.
267
+ #:
268
+ #: Together with the aspect ratio, it defines the size of the
269
+ #: perspective projection for any given depth.
260
270
self .fov : float = fov
271
+ #: The 'closest' visible position along the forward direction.
272
+ #:
273
+ #: It will get mapped to z = -1.0. Anything closer than this value
274
+ #: is not visible.
261
275
self .near : float = near
276
+ #: The 'farthest' visible position along the forward direction.
277
+ #:
278
+ #: It will get mapped to z = 1.0. Anything father than this value
279
+ #: is not visible.
262
280
self .far : float = far
263
281
264
282
def __str__ (self ):
0 commit comments