-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathH3DU.Camera.html
executable file
·369 lines (264 loc) · 17.1 KB
/
H3DU.Camera.html
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<!DOCTYPE html><html xmlns:dc="http://purl.org/dc/terms/"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width"><link rel=stylesheet type="text/css" href="/style.css">
<script type="text/x-mathjax-config"> MathJax.Hub.Config({"HTML-CSS": { availableFonts: ["STIX","TeX"], linebreaks: { automatic:true }, preferredFont: "TeX" },
tex2jax: { displayMath: [ ["$$","$$"], ["\\[", "\\]"] ], inlineMath: [ ["$", "$"], ["\\\\(","\\\\)"] ], processEscapes: true } });
</script><script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_HTML-full"></script></head><body> <div class="header">
<nav><p><a href="#navigation">Menu</a> - <a href="#top">Top</a> - <a href="/">Home</a></nav></div>
<div class="mainarea" id="top">
<h1 id="h3ducamera">H3DU.Camera</h1>
<p><a href="index.html">Back to documentation index.</a></p>
<p><a name="H3DU.Camera"></a>
### H3DU.Camera(batch, fov, nearZ, farZ, [canvas])</p>
<p>A class for controlling the projection and
view of a 3D scene, in the nature of an abstract “camera”.
This class uses the concept of a “camera’s position”, or where
the camera is located in world space, as well
as a “reference point”, or the point in world space that the camera
is looking at.</p>
<p>This class is considered a supplementary class to the
Public Domain HTML 3D Library and is not considered part of that
library.</p>
<p>To use this class, you must include the script “extras/camera.js”; the
class is not included in the “h3du_min.js” file which makes up
the HTML 3D Library. Example:</p>
<pre><script type="text/javascript" src="extras/camera.js"></script>
</pre>
<h4 id="parameters">Parameters</h4>
<ul>
<li><code>batch</code> (Type: H3DU.Batch3D)<br />A 3D batch to associate with this camera object. <i>Using a H3DU.Scene3D here is obsolete.</i></li>
<li><code>fov</code> (Type: number)<br />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.MathUtil.html#H3DU.MathUtil.mat4perspective">H3DU.MathUtil.mat4perspective</a>.</li>
<li><code>nearZ</code> (Type: number)<br />The distance from the camera to the near clipping plane. Objects closer than this distance won’t be seen. See <a href="H3DU.MathUtil.html#H3DU.MathUtil.mat4perspective">H3DU.MathUtil.mat4perspective</a>. This should be slightly greater than 0.</li>
<li><code>farZ</code> (Type: number)<br />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.MathUtil.html#H3DU.MathUtil.mat4perspective">H3DU.MathUtil.mat4perspective</a>.</li>
<li><code>canvas</code> (Type: HTMLCanvasElement) (optional)<br />A canvas to associate with this camera object. <i>This argument is obsolete.</i></li>
</ul>
<h3 id="methods">Methods</h3>
<ul>
<li><a href="#H3DU.Camera_getDistance">getDistance</a><br />Finds the distance from the camera’s position to the reference point.</li>
<li><a href="#H3DU.Camera_getPosition">getPosition</a><br />Gets the position of the camera.</li>
<li><a href="#H3DU.Camera_getVectorFromCenter">getVectorFromCenter</a><br />Gets the 3-element vector that points from the reference
point to the camera’s position.</li>
<li><a href="#H3DU.Camera_moveAngleHorizontal">moveAngleHorizontal</a><br />Moves the camera to the left or right so that it faces
the same reference point at the same distance.</li>
<li><a href="#H3DU.Camera_moveAngleVertical">moveAngleVertical</a><br />Moves the camera upward or downward so that it faces
the same reference point at the same distance.</li>
<li><a href="#H3DU.Camera_moveClose">moveClose</a><br />Moves the camera the specified distance, but not too close
to the reference point.</li>
<li><a href="#H3DU.Camera_moveForward">moveForward</a><br />Moves the camera forward the specified distance.</li>
<li><a href="#H3DU.Camera_moveHorizontal">moveHorizontal</a><br />Moves the camera horizontally relative to the camera’s up vector.</li>
<li><a href="#H3DU.Camera_moveVertical">moveVertical</a><br />Moves the camera toward or away from the camera’s up vector.</li>
<li><a href="#H3DU.Camera_setDistance">setDistance</a><br />Moves the camera a given distance from the reference
point without changing its orientation.</li>
<li><a href="#H3DU.Camera_setPosition">setPosition</a><br />Sets the position of the camera.</li>
<li><a href="#H3DU.Camera_turnAngleHorizontal">turnAngleHorizontal</a><br />Turns the camera to the left or right so that it faces
the same distance from a reference point.</li>
<li><a href="#H3DU.Camera_turnAngleVertical">turnAngleVertical</a><br />Turns the camera upward or downward so that it faces
the same distance from a reference point.</li>
<li><a href="#H3DU.Camera_turnHorizontal">turnHorizontal</a><br /><strong>Deprecated: Renamed to “moveAngleHorizontal”.</strong></li>
<li><a href="#H3DU.Camera_turnVertical">turnVertical</a><br /><strong>Deprecated: Renamed to “moveAngleVertical”.</strong></li>
<li><a href="#H3DU.Camera_update">update</a><br />Updates information about this camera based
on the state of an input tracker.</li>
</ul>
<p><a name="H3DU.Camera_getDistance"></a>
### H3DU.Camera#getDistance()</p>
<p>Finds the distance from the camera’s position to the reference point.</p>
<h4 id="return-value">Return Value</h4>
<p>Return value. (Type: number)</p>
<p><a name="H3DU.Camera_getPosition"></a>
### H3DU.Camera#getPosition()</p>
<p>Gets the position of the camera.</p>
<h4 id="return-value-1">Return Value</h4>
<p>An array of three numbers giving
the x-, y-, and z-coordinates of the camera’s position, respectively. (Type: Array.<number>)</p>
<p><a name="H3DU.Camera_getVectorFromCenter"></a>
### H3DU.Camera#getVectorFromCenter()</p>
<p>Gets the 3-element vector that points from the reference
point to the camera’s position.</p>
<h4 id="return-value-2">Return Value</h4>
<p>The return value as a unit
vector (a <a href="H3DU.MathUtil.html#H3DU.MathUtil.vec3normalize">“normalized” vector</a> with a length of 1).
Returns (0,0,0) if the reference point is the same as the camera’s position. (Type: Array.<number>)</p>
<p><a name="H3DU.Camera_moveAngleHorizontal"></a>
### H3DU.Camera#moveAngleHorizontal(angleDegrees)</p>
<p>Moves the camera to the left or right so that it faces
the same reference point at the same distance.</p>
<h4 id="parameters-1">Parameters</h4>
<ul>
<li><code>angleDegrees</code> (Type: number)<br />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.</li>
</ul>
<h4 id="return-value-3">Return Value</h4>
<p>This object. (Type: <a href="H3DU.Camera.html">H3DU.Camera</a>)</p>
<p><a name="H3DU.Camera_moveAngleVertical"></a>
### H3DU.Camera#moveAngleVertical(angleDegrees)</p>
<p>Moves the camera upward or downward so that it faces
the same reference point at the same distance.</p>
<h4 id="parameters-2">Parameters</h4>
<ul>
<li><code>angleDegrees</code> (Type: number)<br />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.</li>
</ul>
<h4 id="return-value-4">Return Value</h4>
<p>This object. (Type: <a href="H3DU.Camera.html">H3DU.Camera</a>)</p>
<p><a name="H3DU.Camera_moveClose"></a>
### H3DU.Camera#moveClose(dist)</p>
<p>Moves the camera the specified distance, but not too close
to the reference point.</p>
<h4 id="parameters-3">Parameters</h4>
<ul>
<li><code>dist</code> (Type: number)<br />The distance to move. Positive values mean forward, and negative distances mean back.</li>
</ul>
<h4 id="return-value-5">Return Value</h4>
<p>This object. (Type: <a href="H3DU.Camera.html">H3DU.Camera</a>)</p>
<p><a name="H3DU.Camera_moveForward"></a>
### H3DU.Camera#moveForward(dist)</p>
<p>Moves the camera forward the specified distance.</p>
<h4 id="parameters-4">Parameters</h4>
<ul>
<li><code>dist</code> (Type: number)<br />The distance to move. Positive values mean forward, and negative distances mean back.</li>
</ul>
<h4 id="return-value-6">Return Value</h4>
<p>This object. (Type: <a href="H3DU.Camera.html">H3DU.Camera</a>)</p>
<p><a name="H3DU.Camera_moveHorizontal"></a>
### H3DU.Camera#moveHorizontal(dist)</p>
<p>Moves the camera horizontally relative to the camera’s up vector.</p>
<h4 id="parameters-5">Parameters</h4>
<ul>
<li><code>dist</code> (Type: number)<br />Distance to move the camera.</li>
</ul>
<h4 id="return-value-7">Return Value</h4>
<p>This object. (Type: <a href="H3DU.Camera.html">H3DU.Camera</a>)</p>
<p><a name="H3DU.Camera_moveVertical"></a>
### H3DU.Camera#moveVertical(dist)</p>
<p>Moves the camera toward or away from the camera’s up vector.</p>
<h4 id="parameters-6">Parameters</h4>
<ul>
<li><code>dist</code> (Type: number)<br />Distance to move the camera.</li>
</ul>
<h4 id="return-value-8">Return Value</h4>
<p>This object. (Type: <a href="H3DU.Camera.html">H3DU.Camera</a>)</p>
<p><a name="H3DU.Camera_setDistance"></a>
### H3DU.Camera#setDistance(dist)</p>
<p>Moves the camera a given distance from the reference
point without changing its orientation.</p>
<h4 id="parameters-7">Parameters</h4>
<ul>
<li><code>dist</code> (Type: number)<br />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.</li>
</ul>
<h4 id="return-value-9">Return Value</h4>
<p>This object. (Type: <a href="H3DU.Camera.html">H3DU.Camera</a>)</p>
<p><a name="H3DU.Camera_setPosition"></a>
### H3DU.Camera#setPosition(cx, [cy], [cz])</p>
<p>Sets the position of the camera.</p>
<h4 id="parameters-8">Parameters</h4>
<ul>
<li><code>cx</code> (Type: number)<br />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.</li>
<li><code>cy</code> (Type: number) (optional)<br />The camera’s new y-coordinate.</li>
<li><code>cz</code> (Type: number) (optional)<br />The camera’s new z-coordinate.</li>
</ul>
<h4 id="return-value-10">Return Value</h4>
<p>This object. (Type: <a href="H3DU.Camera.html">H3DU.Camera</a>)</p>
<p><a name="H3DU.Camera_turnAngleHorizontal"></a>
### H3DU.Camera#turnAngleHorizontal(angleDegrees)</p>
<p>Turns the camera to the left or right so that it faces
the same distance from a reference point.</p>
<h4 id="parameters-9">Parameters</h4>
<ul>
<li><code>angleDegrees</code> (Type: number)<br />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.</li>
</ul>
<h4 id="return-value-11">Return Value</h4>
<p>This object. (Type: <a href="H3DU.Camera.html">H3DU.Camera</a>)</p>
<p><a name="H3DU.Camera_turnAngleVertical"></a>
### H3DU.Camera#turnAngleVertical(angleDegrees)</p>
<p>Turns the camera upward or downward so that it faces
the same distance from a reference point.</p>
<h4 id="parameters-10">Parameters</h4>
<ul>
<li><code>angleDegrees</code> (Type: number)<br />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.</li>
</ul>
<h4 id="return-value-12">Return Value</h4>
<p>This object. (Type: <a href="H3DU.Camera.html">H3DU.Camera</a>)</p>
<p><a name="H3DU.Camera_turnHorizontal"></a>
### H3DU.Camera#turnHorizontal(angleDegrees)</p>
<p><strong>Deprecated: Renamed to “moveAngleHorizontal”.</strong></p>
<p>Moves the camera to the left or right so that it faces
the same reference point at the same distance.</p>
<h4 id="parameters-11">Parameters</h4>
<ul>
<li><code>angleDegrees</code> (Type: number)<br />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.</li>
</ul>
<h4 id="return-value-13">Return Value</h4>
<p>This object. (Type: <a href="H3DU.Camera.html">H3DU.Camera</a>)</p>
<p><a name="H3DU.Camera_turnVertical"></a>
### H3DU.Camera#turnVertical(angleDegrees)</p>
<p><strong>Deprecated: Renamed to “moveAngleVertical”.</strong></p>
<p>Moves the camera upward or downward so that it faces
the same reference point at the same distance.</p>
<h4 id="parameters-12">Parameters</h4>
<ul>
<li><code>angleDegrees</code> (Type: number)<br />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.</li>
</ul>
<h4 id="return-value-14">Return Value</h4>
<p>This object. (Type: <a href="H3DU.Camera.html">H3DU.Camera</a>)</p>
<p><a name="H3DU.Camera_update"></a>
### H3DU.Camera#update([input])</p>
<p>Updates information about this camera based
on the state of an input tracker.</p>
<h4 id="parameters-13">Parameters</h4>
<ul>
<li><code>input</code> (Type: <a href="H3DU.InputTracker.html">H3DU.InputTracker</a>) (optional)<br />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></li>
</ul>
<h4 id="return-value-15">Return Value</h4>
<p>Return value. (Type: Object)</p>
<p><a href="index.html">Back to documentation index.</a></p>
</div><nav id="navigation"><ul>
<li><a href="/">Back to start site.</a>
<li><a href="https://github.com/peteroupc/peteroupc.github.io">This site's repository (source code)</a>
<li><a href="https://github.com/peteroupc/peteroupc.github.io/issues">Post an issue or comment</a></ul>
<div class="noprint">
<p>
<a href="//twitter.com/intent/tweet">Share via Twitter</a>, <a href="//www.facebook.com/sharer/sharer.php" id="sharer">Share via Facebook</a>
</p>
</div>
<h3 id="navigation">Navigation</h3>
<ul>
<li><a href="BSplineCurve.html">BSplineCurve</a></li>
<li><a href="BSplineSurface.html">BSplineSurface</a></li>
<li><a href="BufferAccessor.html">BufferAccessor</a></li>
<li><a href="Curve.html">Curve</a></li>
<li><a href="CurveBuilder.html">CurveBuilder</a></li>
<li><a href="GraphicsPath.html">GraphicsPath</a></li>
<li><a href="H3DU.html">H3DU</a></li>
<li><a href="MathUtil.html">MathUtil</a></li>
<li><a href="MeshBuffer.html">MeshBuffer</a></li>
<li><a href="Meshes.html">Meshes</a></li>
<li><a href="PiecewiseCurve.html">PiecewiseCurve</a></li>
<li><a href="Semantic.html">Semantic</a></li>
<li><a href="ShapeGroup.html">ShapeGroup</a></li>
<li><a href="Surface.html">Surface</a></li>
<li><a href="SurfaceBuilder.html">SurfaceBuilder</a></li>
<li><a href="Transform.html">Transform</a></li>
<li><a href="extras_camera.html">module:extras/camera</a></li>
<li><a href="extras_camera.Camera.html">module:extras/camera.Camera</a></li>
<li><a href="extras_camera.InputTracker.html">module:extras/camera.InputTracker</a></li>
<li><a href="extras_createwasher.html">module:extras/createwasher</a></li>
<li><a href="extras_curvetube.html">module:extras/curvetube</a></li>
<li><a href="extras_curvetube.CurveTube.html">module:extras/curvetube.CurveTube</a></li>
<li><a href="extras_derivedcurves.html">module:extras/derivedcurves</a></li>
<li><a href="extras_evaluators.html">module:extras/evaluators</a></li>
<li><a href="extras_evaluators.Roulette.html">module:extras/evaluators.Roulette</a></li>
<li><a href="extras_evaluators.SurfaceOfRevolution.html">module:extras/evaluators.SurfaceOfRevolution</a></li>
<li><a href="extras_fourierknot.html">module:extras/fourierknot</a></li>
<li><a href="extras_gradients.html">module:extras/gradients</a></li>
<li><a href="extras_marbleshader2.html">module:extras/marbleshader2</a></li>
<li><a href="extras_matrixstack.html">module:extras/matrixstack</a></li>
<li><a href="extras_matrixstack.MatrixStack.html">module:extras/matrixstack.MatrixStack</a></li>
<li><a href="extras_moresurfaces.html">module:extras/moresurfaces</a></li>
<li><a href="extras_moresurfaces.KleinBottle.html">module:extras/moresurfaces.KleinBottle</a></li>
<li><a href="extras_moresurfaces.MoebiusStrip.html">module:extras/moresurfaces.MoebiusStrip</a></li>
<li><a href="extras_pathutil.html">module:extras/pathutil</a></li>
<li><a href="extras_randompolygon.html">module:extras/randompolygon</a></li>
<li><a href="extras_starpolygon.html">module:extras/starpolygon</a></li>
<li><a href="extras_superellipsoid.html">module:extras/superellipsoid</a></li>
<li><a href="extras_superellipsoid.Supershape.html">module:extras/superellipsoid.Supershape</a></li>
<li><a href="extras_superellipsoid.Supertoroid.html">module:extras/superellipsoid.Supertoroid</a></li>
<li><a href="extras_torusknot.html">module:extras/torusknot</a></li>
<li><a href="extras_torusknot.TorusKnot.html">module:extras/torusknot.TorusKnot</a></li>
</ul>
</nav></body></html>