1 | <!DOCTYPE html>
|
---|
2 | <html lang="en">
|
---|
3 | <head>
|
---|
4 | <meta charset="utf-8" />
|
---|
5 | <script src="../../list.js"></script>
|
---|
6 | <script src="../../page.js"></script>
|
---|
7 | <link type="text/css" rel="stylesheet" href="../../page.css" />
|
---|
8 | </head>
|
---|
9 | <body>
|
---|
10 | <h1>[name]</h1>
|
---|
11 |
|
---|
12 | <div class="desc">3D vector.</div>
|
---|
13 |
|
---|
14 |
|
---|
15 | <h2>Example</h2>
|
---|
16 |
|
---|
17 | <code>var a = new THREE.Vector3( 1, 0, 0 );
|
---|
18 | var b = new THREE.Vector3( 0, 1, 0 );
|
---|
19 |
|
---|
20 | var c = new THREE.Vector3();
|
---|
21 | c.crossVectors( a, b );
|
---|
22 | </code>
|
---|
23 |
|
---|
24 |
|
---|
25 | <h2>Constructor</h2>
|
---|
26 |
|
---|
27 |
|
---|
28 | <h3>[name]( [page:Float x], [page:Float y], [page:Float z] )</h3>
|
---|
29 | <div>
|
---|
30 | x -- [page:Float] the vector's x value <br />
|
---|
31 | y -- [page:Float] the vector's y value <br />
|
---|
32 | z -- [page:Float] the vector's z value
|
---|
33 | </div>
|
---|
34 | <div>
|
---|
35 | A 3 dimensional vector
|
---|
36 | </div>
|
---|
37 |
|
---|
38 |
|
---|
39 | <h2>Properties</h2>
|
---|
40 |
|
---|
41 | <h3>.[page:Float x]</h3>
|
---|
42 |
|
---|
43 | <h3>.[page:Float y]</h3>
|
---|
44 |
|
---|
45 | <h3>.[page:Float z]</h3>
|
---|
46 |
|
---|
47 |
|
---|
48 | <h2>Methods</h2>
|
---|
49 |
|
---|
50 | <h3>.set( [page:Float x], [page:Float y], [page:Float z] ) [page:Vector3 this]</h3>
|
---|
51 | <div>
|
---|
52 | Sets value of this vector.
|
---|
53 | </div>
|
---|
54 |
|
---|
55 | <h3>.setX( [page:Float x] ) [page:Vector3 this]</h3>
|
---|
56 | <div>
|
---|
57 | Sets x value of this vector.
|
---|
58 | </div>
|
---|
59 |
|
---|
60 | <h3>.setY( [page:Float y] ) [page:Vector3 this]</h3>
|
---|
61 | <div>
|
---|
62 | Sets y value of this vector.
|
---|
63 | </div>
|
---|
64 |
|
---|
65 | <h3>.setZ( [page:Float z] ) [page:Vector3 this]</h3>
|
---|
66 | <div>
|
---|
67 | Sets z value of this vector.
|
---|
68 | </div>
|
---|
69 |
|
---|
70 | <h3>.copy( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
---|
71 | <div>
|
---|
72 | Copies value of *v* to this vector.
|
---|
73 | </div>
|
---|
74 |
|
---|
75 | <h3>.add( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
---|
76 | <div>
|
---|
77 | Adds *v* to this vector.
|
---|
78 | </div>
|
---|
79 |
|
---|
80 | <h3>.addVectors( [page:Vector3 a], [page:Vector3 b] ) [page:Vector3 this]</h3>
|
---|
81 | <div>
|
---|
82 | Sets this vector to *a + b*.
|
---|
83 | </div>
|
---|
84 |
|
---|
85 | <h3>.sub( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
---|
86 | <div>
|
---|
87 | Subtracts *v* from this vector.
|
---|
88 | </div>
|
---|
89 |
|
---|
90 | <h3>.subVectors( [page:Vector3 a], [page:Vector3 b] ) [page:Vector3 this]</h3>
|
---|
91 | <div>
|
---|
92 | Sets this vector to *a - b*.
|
---|
93 | </div>
|
---|
94 |
|
---|
95 | <h3>.multiplyScalar( [page:Float s] ) [page:Vector3 this]</h3>
|
---|
96 | <div>
|
---|
97 | Multiplies this vector by scalar *s*.
|
---|
98 | </div>
|
---|
99 |
|
---|
100 | <h3>.divideScalar( [page:Float s] ) [page:Vector3 this]</h3>
|
---|
101 | <div>
|
---|
102 | Divides this vector by scalar *s*.<br />
|
---|
103 | Set vector to *( 0, 0, 0 )* if *s == 0*.
|
---|
104 | </div>
|
---|
105 |
|
---|
106 | <h3>.negate() [page:Vector3 this]</h3>
|
---|
107 | <div>
|
---|
108 | Inverts this vector.
|
---|
109 | </div>
|
---|
110 |
|
---|
111 | <h3>.dot( [page:Vector3 v] ) [page:Float]</h3>
|
---|
112 | <div>
|
---|
113 | Computes dot product of this vector and *v*.
|
---|
114 | </div>
|
---|
115 |
|
---|
116 | <h3>.lengthSq() [page:Float]</h3>
|
---|
117 | <div>
|
---|
118 | Computes squared length of this vector.
|
---|
119 | </div>
|
---|
120 |
|
---|
121 | <h3>.length() [page:Float]</h3>
|
---|
122 | <div>
|
---|
123 | Computes length of this vector.
|
---|
124 | </div>
|
---|
125 |
|
---|
126 | <h3>.lengthManhattan() [page:Float]</h3>
|
---|
127 | <div>
|
---|
128 | Computes Manhattan length of this vector.<br />
|
---|
129 | [link:http://en.wikipedia.org/wiki/Taxicab_geometry]
|
---|
130 | </div>
|
---|
131 |
|
---|
132 | <h3>.normalize() [page:Vector3 this]</h3>
|
---|
133 | <div>
|
---|
134 | Normalizes this vector. Transforms this Vector into a Unit vector by dividing the vector by it's length.
|
---|
135 | </div>
|
---|
136 |
|
---|
137 | <h3>.distanceTo( [page:Vector3 v] ) [page:Float]</h3>
|
---|
138 | <div>
|
---|
139 | Computes distance of this vector to *v*.
|
---|
140 | </div>
|
---|
141 |
|
---|
142 | <h3>.distanceToSquared( [page:Vector3 v] ) [page:Float]</h3>
|
---|
143 | <div>
|
---|
144 | Computes squared distance of this vector to *v*.
|
---|
145 | </div>
|
---|
146 |
|
---|
147 | <h3>.setLength( [page:Float l] ) [page:Vector3 this]</h3>
|
---|
148 | <div>
|
---|
149 | Normalizes this vector and multiplies it by *l*.
|
---|
150 | </div>
|
---|
151 |
|
---|
152 | <h3>.cross( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
---|
153 | <div>
|
---|
154 | Sets this vector to cross product of itself and *v*.
|
---|
155 | </div>
|
---|
156 |
|
---|
157 | <h3>.crossVectors( [page:Vector3 a], [page:Vector3 b] ) [page:Vector3 this]</h3>
|
---|
158 | <div>
|
---|
159 | Sets this vector to cross product of *a* and *b*.
|
---|
160 | </div>
|
---|
161 |
|
---|
162 | <h3>.setFromMatrixPosition( [page:Matrix4 m] ) [page:Vector3 this]</h3>
|
---|
163 | <div>
|
---|
164 | Sets this vector extracting position from matrix transform.
|
---|
165 | </div>
|
---|
166 |
|
---|
167 | <h3>.setFromMatrixScale( [page:Matrix4 m] ) [page:Vector3 this]</h3>
|
---|
168 | <div>
|
---|
169 | Sets this vector extracting scale from matrix transform.
|
---|
170 | </div>
|
---|
171 |
|
---|
172 | <h3>.equals( [page:Vector3 v] ) [page:Boolean]</h3>
|
---|
173 | <div>
|
---|
174 | Checks for strict equality of this vector and *v*.
|
---|
175 | </div>
|
---|
176 |
|
---|
177 | <h3>.clone() [page:Vector3]</h3>
|
---|
178 | <div>
|
---|
179 | Clones this vector.
|
---|
180 | </div>
|
---|
181 |
|
---|
182 |
|
---|
183 | <h3>.clamp([page:Vector3 min], [page:Vector3 max]) [page:Vector3 this]</h3>
|
---|
184 | <div>
|
---|
185 | min -- [page:Vector3] <br />
|
---|
186 | max -- [page:Vector3]
|
---|
187 | </div>
|
---|
188 | <div>
|
---|
189 | If this vector's x, y or z value is greater than the max vector's x, y or z value, it is replaced by the corresponding value. <br /><br />
|
---|
190 | If this vector's x, y or z value is less than the min vector's x, y or z value, it is replace by the corresponding value.
|
---|
191 | </div>
|
---|
192 |
|
---|
193 | <h3>.applyMatrix3([page:Matrix3 m]) [page:Vector3 this]</h3>
|
---|
194 | <div>
|
---|
195 | m -- [page:Matrix3]
|
---|
196 | </div>
|
---|
197 | <div>
|
---|
198 | Multiplies this vector times a 3 x 3 matrix.
|
---|
199 | </div>
|
---|
200 |
|
---|
201 | <h3>.applyMatrix4([page:Matrix3 m]) [page:Vector3 this]</h3>
|
---|
202 | <div>
|
---|
203 | m -- [page:Matrix4]
|
---|
204 | </div>
|
---|
205 | <div>
|
---|
206 | Multiplies this vector by 4 x 3 subset of a Matrix4.
|
---|
207 | </div>
|
---|
208 |
|
---|
209 | <h3>.projectOnPlane([page:Vector3 planeNormal]) [page:Vector3 this]</h3>
|
---|
210 | <div>
|
---|
211 | planeNormal -- [page:Vector3 planeNormal] A vector representing a plane normal.
|
---|
212 | </div>
|
---|
213 | <div>
|
---|
214 | Projects this vector onto a plane by subtracting this vector projected onto the plane's normal from this vector.
|
---|
215 | </div>
|
---|
216 |
|
---|
217 | <h3>.projectOnVector([page:Vector3]) [page:Vector3 this]</h3>
|
---|
218 | <div>
|
---|
219 | vector -- [page:Vector3]
|
---|
220 | </div>
|
---|
221 | <div>
|
---|
222 | Projects this vector onto another vector.
|
---|
223 | </div>
|
---|
224 |
|
---|
225 | <h3>.addScalar([page:Float]) [page:Vector3 this]</h3>
|
---|
226 | <div>
|
---|
227 | s -- [page:Float]
|
---|
228 | </div>
|
---|
229 | <div>
|
---|
230 | Adds a s to this vector.
|
---|
231 | </div>
|
---|
232 |
|
---|
233 | <h3>.divide([page:Vector3 v]) [page:Vector3 this]</h3>
|
---|
234 | <div>
|
---|
235 | v -- [page:Vector3]
|
---|
236 | </div>
|
---|
237 | <div>
|
---|
238 | Divides this vector by vector v.
|
---|
239 | </div>
|
---|
240 |
|
---|
241 | <h3>.min([page:Vector3 v]) [page:Vector3 this]</h3>
|
---|
242 | <div>
|
---|
243 | v -- [page:Vector3]
|
---|
244 | </div>
|
---|
245 | <div>
|
---|
246 | If this vector's x, y, or z value is less than vector v's x, y, or z value, that value is replaced by the corresponding vector v value.
|
---|
247 | </div>
|
---|
248 |
|
---|
249 | <h3>.max([page:Vector3 v]) [page:Vector3 this]</h3>
|
---|
250 | <div>
|
---|
251 | v -- [page:Vector3]
|
---|
252 | </div>
|
---|
253 | <div>
|
---|
254 | If this vector's x, y, or z value is greater than vector v's x, y, or z value, that value is replaced by the corresponding vector v value.
|
---|
255 | </div>
|
---|
256 |
|
---|
257 | <h3>.setComponent([page:Integer index], [page:Float value]) [page:Vector3 this]</h3>
|
---|
258 | <div>
|
---|
259 | index -- 0, 1, or 2 <br />
|
---|
260 | value -- [page:Float]
|
---|
261 | </div>
|
---|
262 | <div>
|
---|
263 | If index equals 0 the method sets this vector's x value to value <br />
|
---|
264 | If index equals 1 the method sets this vector's y value to value <br />
|
---|
265 | If index equals 2 the method sets this vector's z value to value
|
---|
266 | </div>
|
---|
267 |
|
---|
268 | <h3>.transformDirection([page:Matrix4 m]) [page:Vector3 this]</h3>
|
---|
269 | <div>
|
---|
270 | m -- [page:Matrix4]
|
---|
271 | </div>
|
---|
272 | <div>
|
---|
273 | Transforms the direction of this vector by a matrix (a 3 x 3 subset of a Matrix4) and then normalizes the result.
|
---|
274 | </div>
|
---|
275 |
|
---|
276 | <h3>.multiplyVectors([page:Vector3 a], [page:Vector3 b]) [page:Vector3 this]</h3>
|
---|
277 | <div>
|
---|
278 | a -- [page:Vector3] <br />
|
---|
279 | b -- [page:Vector3]
|
---|
280 | </div>
|
---|
281 | <div>
|
---|
282 | Sets this vector equal to the result of multiplying vector a by vector b.
|
---|
283 | </div>
|
---|
284 |
|
---|
285 | <h3>.getComponent([page:Integer index]) [page:Float]</h3>
|
---|
286 | <div>
|
---|
287 | index -- [page:Integer] 0, 1, or 2
|
---|
288 | </div>
|
---|
289 | <div>
|
---|
290 |
|
---|
291 | Returns the value of the vector component x, y, or z by an index. <br /><br />
|
---|
292 |
|
---|
293 | Index 0: x <br />
|
---|
294 | Index 1: y <br />
|
---|
295 | Index 2: z <br />
|
---|
296 | </div>
|
---|
297 |
|
---|
298 | <h3>.applyAxisAngle([page:Vector3 axis], [page:Float angle]) [page:Vector3 this]</h3>
|
---|
299 | <div>
|
---|
300 | axis -- A normalized [page:Vector3] <br />
|
---|
301 | angle -- An angle in radians
|
---|
302 | </div>
|
---|
303 | <div>
|
---|
304 | Applies a rotation specified by an axis and an angle to this vector.
|
---|
305 | </div>
|
---|
306 |
|
---|
307 | <h3>.lerp([page:Vector3 v], [page:Float alpha]) [page:Vector3 this]</h3>
|
---|
308 | <div>
|
---|
309 | v -- [page:Vector3] <br />
|
---|
310 | alpha -- [page:Float] between 0 and 1.
|
---|
311 | </div>
|
---|
312 | <div>
|
---|
313 | Linear Interpolation between this vector and vector v, where alpha is the percent along the line.
|
---|
314 | </div>
|
---|
315 |
|
---|
316 | <h3>.angleTo([page:Vector3 v]) [page:Float]</h3>
|
---|
317 | <div>
|
---|
318 | v -- [page:Vector3]
|
---|
319 | </div>
|
---|
320 | <div>
|
---|
321 | Returns the angle between this vector and vector v in radians.
|
---|
322 | </div>
|
---|
323 |
|
---|
324 | <h3>.setFromMatrixColumn([page:Integer index], [page:Matrix4 matrix]) [page:Vector3 this]</h3>
|
---|
325 | <div>
|
---|
326 | index -- 0, 1, 2, or 3 <br />
|
---|
327 | matrix -- [page:Matrix4]
|
---|
328 | </div>
|
---|
329 | <div>
|
---|
330 | Sets this vector's x, y, and z equal to the column of the matrix specified by the index.
|
---|
331 | </div>
|
---|
332 |
|
---|
333 | <h3>.reflect([page:Vector3 vector]) [page:Vector3 this]</h3>
|
---|
334 | <div>
|
---|
335 | vector -- [page:Vector3] the vector to reflect about
|
---|
336 | </div>
|
---|
337 | <div>
|
---|
338 | Reflects this vector about a vector.
|
---|
339 | </div>
|
---|
340 |
|
---|
341 | <h3>.fromArray([page:Array array]) [page:Vector3 this]</h3>
|
---|
342 | <div>
|
---|
343 | array -- [page:Array] [x, y, z]
|
---|
344 | </div>
|
---|
345 | <div>
|
---|
346 | Sets the vector's components based on an array formatted like [x, y, z]
|
---|
347 | </div>
|
---|
348 |
|
---|
349 | <h3>.multiply([page:Vector3 v]) [page:Vector3 this]</h3>
|
---|
350 | <div>
|
---|
351 | v -- [page:Vector3] <br />
|
---|
352 | </div>
|
---|
353 | <div>
|
---|
354 | Multipies this vector by vector v.
|
---|
355 | </div>
|
---|
356 |
|
---|
357 | <h3>.applyProjection([page:Matrix4 m]) [page:Vector3 this]</h3>
|
---|
358 | <div>
|
---|
359 | m -- [page:Matrix4] projection matrix.
|
---|
360 | </div>
|
---|
361 | <div>
|
---|
362 | Multiplies this vector and m, and divides by perspective.
|
---|
363 | </div>
|
---|
364 |
|
---|
365 | <h3>.toArray() [page:Array]</h3>
|
---|
366 | <div>
|
---|
367 | Assigns this vector's x value to array[0]. <br />
|
---|
368 | Assigns this vector's y value to array[1]. <br />
|
---|
369 | Assigns this vector's z value to array[2]. <br />
|
---|
370 | Returns the created array.
|
---|
371 | </div>
|
---|
372 |
|
---|
373 | <h3>.applyEuler([page:Euler euler]) [page:Vector3 this]</h3>
|
---|
374 | <div>
|
---|
375 | euler -- [page:Euler]
|
---|
376 | </div>
|
---|
377 | <div>
|
---|
378 | Applies euler transform to this vector by converting the [page:Euler] obect to a [page:Quaternion] and applying.
|
---|
379 | </div>
|
---|
380 |
|
---|
381 | <h3>.applyQuaternion([page:Quaternion quaternion]) [page:Vector3 this]</h3>
|
---|
382 | <div>
|
---|
383 | quaternion -- [page:Quaternion]
|
---|
384 | </div>
|
---|
385 | <div>
|
---|
386 | Applies a [page:Quaternion] transform to this vector.
|
---|
387 | </div>
|
---|
388 |
|
---|
389 | <h2>Source</h2>
|
---|
390 |
|
---|
391 | [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|
---|
392 | </body>
|
---|
393 | </html>
|
---|