|
2 | 2 |
|
3 | 3 | [Back to documentation index.](index.md) |
4 | 4 |
|
5 | | -### Camera(batch, fov, nearZ, farZ, [canvas]) <a id='Camera'></a> |
| 5 | +### Camera() <a id='Camera'></a> |
6 | 6 |
|
7 | | -A class for controlling the projection and |
8 | | -view of a 3D scene, in the nature of an abstract "camera". |
9 | | -This class uses the concept of a "camera's position", or where |
10 | | -the camera is located in world space, as well |
11 | | -as a "reference point", or the point in world space that the camera |
12 | | -is looking at. |
| 7 | +<b>Deprecated: Use <a href="H3DU.Camera.md">H3DU.Camera</a> instead.</b> |
13 | 8 |
|
14 | | -This class is considered a supplementary class to the |
15 | | -Public Domain HTML 3D Library and is not considered part of that |
16 | | -library. |
17 | | - |
18 | | -To use this class, you must include the script "extras/camera.js"; the |
19 | | -class is not included in the "h3du_min.js" file which makes up |
20 | | -the HTML 3D Library. Example: |
21 | | - |
22 | | - <script type="text/javascript" src="extras/camera.js"></script> |
23 | | - |
24 | | -#### Parameters |
25 | | - |
26 | | -* `batch` (Type: <a href="H3DU.Batch3D.md">H3DU.Batch3D</a>)<br> |
27 | | - A 3D scene to associate with this camera object. |
28 | | -* `fov` (Type: Number)<br> |
29 | | - Vertical field of view, in degrees. Should be less than 180 degrees. (The smaller this number, the bigger close objects appear to be.) See <a href="H3DU.Math.md#H3DU.Math.mat4perspective">H3DU.Math.mat4perspective</a>. |
30 | | -* `nearZ` (Type: Number)<br> |
31 | | - The distance from the camera to the near clipping plane. See <a href="H3DU.Math.md#H3DU.Math.mat4perspective">H3DU.Math.mat4perspective</a>. seen. This should be slightly greater than 0. |
32 | | -* `farZ` (Type: Number)<br> |
33 | | - The distance from the camera to the far clipping plane. Objects beyond this distance will be too far to be seen. See <a href="H3DU.Math.md#H3DU.Math.mat4perspective">H3DU.Math.mat4perspective</a>. |
34 | | -* `canvas` (Type: HTMLCanvasElement) (optional)<br> |
35 | | - A canvas to associate with this camera object. <i>This argument is deprecated.</i> |
36 | | - |
37 | | -### Methods |
38 | | - |
39 | | -* [getDistance](#Camera_Camera_getDistance) |
40 | | -* [getPosition](#Camera_Camera_getPosition) |
41 | | -* [getVectorFromCenter](#Camera_Camera_getVectorFromCenter) |
42 | | -* [moveAngleHorizontal](#Camera_Camera_moveAngleHorizontal) |
43 | | -* [moveAngleVertical](#Camera_Camera_moveAngleVertical) |
44 | | -* [moveCenterHorizontal](#Camera_Camera_moveCenterHorizontal) |
45 | | -* [moveCenterVertical](#Camera_Camera_moveCenterVertical) |
46 | | -* [moveClose](#Camera_Camera_moveClose) |
47 | | -* [moveForward](#Camera_Camera_moveForward) |
48 | | -* [moveHorizontal](#Camera_Camera_moveHorizontal) |
49 | | -* [movePosition](#Camera_Camera_movePosition) |
50 | | -* [moveVertical](#Camera_Camera_moveVertical) |
51 | | -* [setDistance](#Camera_Camera_setDistance) |
52 | | -* [setPosition](#Camera_Camera_setPosition) |
53 | | -* [turnHorizontal](#Camera_Camera_turnHorizontal) |
54 | | -* [turnVertical](#Camera_Camera_turnVertical) |
55 | | -* [update](#Camera_Camera_update) |
56 | | - |
57 | | -### Camera#getDistance() <a id='Camera_Camera_getDistance'></a> |
58 | | - |
59 | | -Finds the distance from the camera's position to the reference point. |
60 | | - |
61 | | -#### Return Value |
62 | | - |
63 | | -Return value. (Type: Number) |
64 | | - |
65 | | -### Camera#getPosition() <a id='Camera_Camera_getPosition'></a> |
66 | | - |
67 | | -Gets the position of the camera. |
68 | | - |
69 | | -#### Return Value |
70 | | - |
71 | | -An array of three numbers giving |
72 | | -the X, Y, and Z coordinates of the camera's position, respectively. (Type: Array.<Number>) |
73 | | - |
74 | | -### Camera#getVectorFromCenter() <a id='Camera_Camera_getVectorFromCenter'></a> |
75 | | - |
76 | | -Gets the 3-element vector that points from the reference |
77 | | -point to the camera's position. |
78 | | - |
79 | | -#### Return Value |
80 | | - |
81 | | -The return value as a unit |
82 | | -vector (a <a href="H3DU.Math.md#H3DU.Math.vec3norm">"normalized" vector</a> with a length of 1). |
83 | | -Returns (0,0,0) if the reference point is the same as the camera's position. (Type: Array.<Number>) |
84 | | - |
85 | | -### Camera#moveAngleHorizontal(angleDegrees) <a id='Camera_Camera_moveAngleHorizontal'></a> |
86 | | - |
87 | | -Moves the camera to the left or right so that it faces |
88 | | -the same reference point at the same distance. |
89 | | - |
90 | | -#### Parameters |
91 | | - |
92 | | -* `angleDegrees` (Type: Number)<br> |
93 | | - The angle to rotate the camera, in degrees. If the coordinate-system is right-handed, positive values rotate the camera leftward, and negative values rightward. If the coordinate-system is left-handed, vice versa. |
94 | | - |
95 | | -#### Return Value |
96 | | - |
97 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
98 | | - |
99 | | -### Camera#moveAngleVertical(angleDegrees) <a id='Camera_Camera_moveAngleVertical'></a> |
100 | | - |
101 | | -Moves the camera upward or downward so that it faces |
102 | | -the same reference point at the same distance. |
103 | | - |
104 | | -#### Parameters |
105 | | - |
106 | | -* `angleDegrees` (Type: Number)<br> |
107 | | - The angle to rotate the camera, in degrees. If the coordinate-system is right-handed, positive values rotate the camera upward, and negative values downward. If the coordinate-system is left-handed, vice versa. |
108 | | - |
109 | | -#### Return Value |
110 | | - |
111 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
112 | | - |
113 | | -### Camera#moveCenterHorizontal(dist) <a id='Camera_Camera_moveCenterHorizontal'></a> |
114 | | - |
115 | | -<b>Deprecated: Use "moveHorizontal" instead.</b> |
116 | | - |
117 | | -Moves the camera horizontally relative to the camera's up vector. |
118 | | - |
119 | | -#### Parameters |
120 | | - |
121 | | -* `dist` (Type: Number)<br> |
122 | | - Distance to move the camera. |
123 | | - |
124 | | -#### Return Value |
125 | | - |
126 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
127 | | - |
128 | | -### Camera#moveCenterVertical(dist) <a id='Camera_Camera_moveCenterVertical'></a> |
129 | | - |
130 | | -<b>Deprecated: Use "moveVertical" instead.</b> |
131 | | - |
132 | | -Moves the camera toward or away from the camera's up vector. |
133 | | - |
134 | | -#### Parameters |
135 | | - |
136 | | -* `dist` (Type: Number)<br> |
137 | | - Distance to move the camera. |
138 | | - |
139 | | -#### Return Value |
140 | | - |
141 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
142 | | - |
143 | | -### Camera#moveClose(dist) <a id='Camera_Camera_moveClose'></a> |
144 | | - |
145 | | -Moves the camera the given distance, but not too close |
146 | | -to the reference point. |
147 | | - |
148 | | -#### Parameters |
149 | | - |
150 | | -* `dist` (Type: Number)<br> |
151 | | - The distance to move. Positive values mean forward, and negative distances mean back. |
152 | | - |
153 | | -#### Return Value |
154 | | - |
155 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
156 | | - |
157 | | -### Camera#moveForward(dist) <a id='Camera_Camera_moveForward'></a> |
158 | | - |
159 | | -Moves the camera forward the given distance. |
160 | | - |
161 | | -#### Parameters |
162 | | - |
163 | | -* `dist` (Type: Number)<br> |
164 | | - The distance to move. Positive values mean forward, and negative distances mean back. |
165 | | - |
166 | | -#### Return Value |
167 | | - |
168 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
169 | | - |
170 | | -### Camera#moveHorizontal(dist) <a id='Camera_Camera_moveHorizontal'></a> |
171 | | - |
172 | | -Moves the camera horizontally relative to the camera's up vector. |
173 | | - |
174 | | -#### Parameters |
175 | | - |
176 | | -* `dist` (Type: Number)<br> |
177 | | - Distance to move the camera. |
178 | | - |
179 | | -#### Return Value |
180 | | - |
181 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
182 | | - |
183 | | -### Camera#movePosition(cx, cy, cz) <a id='Camera_Camera_movePosition'></a> |
184 | | - |
185 | | -<b>Deprecated: Renamed to "setPosition".</b> |
186 | | - |
187 | | -Sets the position of the camera. |
188 | | - |
189 | | -#### Parameters |
190 | | - |
191 | | -* `cx` (Type: Number)<br> |
192 | | - The camera's new X-coordinate. |
193 | | -* `cy` (Type: Number)<br> |
194 | | - The camera's new Y-coordinate. |
195 | | -* `cz` (Type: Number)<br> |
196 | | - The camera's new Z-coordinate. |
197 | | - |
198 | | -#### Return Value |
199 | | - |
200 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
201 | | - |
202 | | -### Camera#moveVertical(dist) <a id='Camera_Camera_moveVertical'></a> |
203 | | - |
204 | | -Moves the camera toward or away from the camera's up vector. |
205 | | - |
206 | | -#### Parameters |
207 | | - |
208 | | -* `dist` (Type: Number)<br> |
209 | | - Distance to move the camera. |
210 | | - |
211 | | -#### Return Value |
212 | | - |
213 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
214 | | - |
215 | | -### Camera#setDistance(dist) <a id='Camera_Camera_setDistance'></a> |
216 | | - |
217 | | -Moves the camera a given distance from the reference |
218 | | -point without changing its orientation. |
219 | | - |
220 | | -#### Parameters |
221 | | - |
222 | | -* `dist` (Type: Number)<br> |
223 | | - Positive number giving the distance. If this is less than the near plane distance, the distance will be equal to the near plane distance. Does nothing if the distance is 0 or less. |
224 | | - |
225 | | -#### Return Value |
226 | | - |
227 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
228 | | - |
229 | | -### Camera#setPosition(cx, [cy], [cz]) <a id='Camera_Camera_setPosition'></a> |
230 | | - |
231 | | -Sets the position of the camera. |
232 | | - |
233 | | -#### Parameters |
234 | | - |
235 | | -* `cx` (Type: Number)<br> |
236 | | - The camera's new X-coordinate, or a 3-element vector containing the X, Y, and Z coordinates. In the latter case, "cy" and "cz" can be omitted. |
237 | | -* `cy` (Type: Number) (optional)<br> |
238 | | - The camera's new Y-coordinate. |
239 | | -* `cz` (Type: Number) (optional)<br> |
240 | | - The camera's new Z-coordinate. |
241 | | - |
242 | | -#### Return Value |
243 | | - |
244 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
245 | | - |
246 | | -### Camera#turnHorizontal(angleDegrees) <a id='Camera_Camera_turnHorizontal'></a> |
247 | | - |
248 | | -Turns the camera to the left or right so that it faces |
249 | | - the same distance from a reference point. |
250 | | - |
251 | | -#### Parameters |
252 | | - |
253 | | -* `angleDegrees` (Type: Number)<br> |
254 | | - The angle to rotate the camera, in degrees. If the coordinate-system is right-handed, positive values rotate the camera rightward, and negative values leftward. If the coordinate-system is left-handed, vice versa. |
255 | | - |
256 | | -#### Return Value |
257 | | - |
258 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
259 | | - |
260 | | -### Camera#turnVertical(angleDegrees) <a id='Camera_Camera_turnVertical'></a> |
261 | | - |
262 | | -Turns the camera upward or downward so that it faces |
263 | | - the same distance from a reference point. |
264 | | - |
265 | | -#### Parameters |
266 | | - |
267 | | -* `angleDegrees` (Type: Number)<br> |
268 | | - The angle to rotate the camera, in degrees. If the coordinate-system is right-handed, positive values rotate the camera upward, and negative values downward. If the coordinate-system is left-handed, vice versa. |
269 | | - |
270 | | -#### Return Value |
271 | | - |
272 | | -This object. (Type: <a href="Camera.md">Camera</a>) |
273 | | - |
274 | | -### Camera#update([input]) <a id='Camera_Camera_update'></a> |
275 | | - |
276 | | -Updates information about this camera based |
277 | | -on the state of an input tracker. |
278 | | - |
279 | | -#### Parameters |
280 | | - |
281 | | -* `input` (Type: <a href="H3DU.InputTracker.md">H3DU.InputTracker</a>) (optional)<br> |
282 | | - An input tracker. This method should be called right after the tracker's 'update' method was called. <i>Note that future versions may require this parameter.</i> |
283 | | - |
284 | | -#### Return Value |
285 | | - |
286 | | -Return value. (Type: Object) |
| 9 | +Alias for the <a href="H3DU.Camera.md">H3DU.Camera</a> class. |
0 commit comments