forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector3.html
More file actions
391 lines (322 loc) · 9.45 KB
/
Copy pathVector3.html
File metadata and controls
391 lines (322 loc) · 9.45 KB
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script src="../../list.js"></script>
<script src="../../page.js"></script>
<link type="text/css" rel="stylesheet" href="../../page.css" />
</head>
<body>
<h1>[name]</h1>
<div class="desc">3D vector.</div>
<h2>Example</h2>
<code>var a = new THREE.Vector3( 1, 0, 0 );
var b = new THREE.Vector3( 0, 1, 0 );
var c = new THREE.Vector3();
c.crossVectors( a, b );
</code>
<h2>Constructor</h2>
<h3>[name]( [page:Float x], [page:Float y], [page:Float z] )</h3>
<div>
x -- [page:Float] the vector's x value <br />
y -- [page:Float] the vector's y value <br />
z -- [page:Float] the vector's z value
</div>
<div>
A 3 dimensional vector
</div>
<h2>Properties</h2>
<h3>.[page:Float x]</h3>
<h3>.[page:Float y]</h3>
<h3>.[page:Float z]</h3>
<h2>Methods</h2>
<h3>.set( [page:Float x], [page:Float y], [page:Float z] ) [page:this]</h3>
<div>
Sets value of this vector.
</div>
<h3>.setX( [page:Float x] ) [page:this]</h3>
<div>
Sets x value of this vector.
</div>
<h3>.setY( [page:Float y] ) [page:this]</h3>
<div>
Sets y value of this vector.
</div>
<h3>.setZ( [page:Float z] ) [page:this]</h3>
<div>
Sets z value of this vector.
</div>
<h3>.copy( [page:Vector3 v] ) [page:this]</h3>
<div>
Copies value of *v* to this vector.
</div>
<h3>.add( [page:Vector3 v] ) [page:this]</h3>
<div>
Adds *v* to this vector.
</div>
<h3>.addVectors( [page:Vector3 a], [page:Vector3 b] ) [page:this]</h3>
<div>
Sets this vector to *a + b*.
</div>
<h3>.sub( [page:Vector3 v] ) [page:this]</h3>
<div>
Subtracts *v* from this vector.
</div>
<h3>.subVectors( [page:Vector3 a], [page:Vector3 b] ) [page:this]</h3>
<div>
Sets this vector to *a - b*.
</div>
<h3>.multiplyScalar( [page:Float s] ) [page:this]</h3>
<div>
Multiplies this vector by scalar *s*.
</div>
<h3>.divideScalar( [page:Float s] ) [page:this]</h3>
<div>
Divides this vector by scalar *s*.<br />
Set vector to *( 0, 0, 0 )* if *s == 0*.
</div>
<h3>.negate() [page:this]</h3>
<div>
Inverts this vector.
</div>
<h3>.dot( [page:Vector3 v] ) [page:Float]</h3>
<div>
Computes dot product of this vector and *v*.
</div>
<h3>.lengthSq() [page:Float]</h3>
<div>
Computes squared length of this vector.
</div>
<h3>.length() [page:Float]</h3>
<div>
Computes length of this vector.
</div>
<h3>.lengthManhattan() [page:Float]</h3>
<div>
Computes Manhattan length of this vector.<br />
[link:http://en.wikipedia.org/wiki/Taxicab_geometry]
</div>
<h3>.normalize() [page:this]</h3>
<div>
Normalizes this vector. Transforms this Vector into a Unit vector by dividing the vector by it's length.
</div>
<h3>.distanceTo( [page:Vector3 v] ) [page:Float]</h3>
<div>
Computes distance of this vector to *v*.
</div>
<h3>.distanceToSquared( [page:Vector3 v] ) [page:Float]</h3>
<div>
Computes squared distance of this vector to *v*.
</div>
<h3>.setLength( [page:Float l] ) [page:this]</h3>
<div>
Normalizes this vector and multiplies it by *l*.
</div>
<h3>.cross( [page:Vector3 v] ) [page:this]</h3>
<div>
Sets this vector to cross product of itself and *v*.
</div>
<h3>.crossVectors( [page:Vector3 a], [page:Vector3 b] ) [page:this]</h3>
<div>
Sets this vector to cross product of *a* and *b*.
</div>
<h3>.getPositionFromMatrix( [page:Matrix4 m] ) [page:this]</h3>
<div>
Sets this vector extracting position from matrix transform.
</div>
<h3>.getScaleFromMatrix( [page:Matrix4 m] ) [page:this]</h3>
<div>
Sets this vector extracting scale from matrix transform.
</div>
<h3>.equals( [page:Vector3 v] ) [page:Boolean]</h3>
<div>
Checks for strict equality of this vector and *v*.
</div>
<h3>.clone() [page:Vector3]</h3>
<div>
Clones this vector.
</div>
<h3>.clamp([page:todo min], [page:todo max]) [page:this]</h3>
<div>
min -- [page:Vector3] <br />
max -- [page:Vector3]
</div>
<div>
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 /> 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.
</div>
<h3>.applyMatrix3([page:todo m]) [page:this]</h3>
<div>
m -- [page:Matrix3]
</div>
<div>
Multiplies this vector times a 3 x 3 matrix.
</div>
<h3>.applyMatrix4([page:todo m]) [page:todo this]</h3>
<div>
m -- [page:todo Matrix4]
</div>
<div>
Multiplies this vector by 4 x 3 subset of a Matrix4.
</div>
<h3>.projectOnPlane([page:todo planeNormal]) [page:todo this]</h3>
<div>
planeNormal -- [page:todo Plane.normal]
</div>
<div>
Projects this vector onto a plane by subtracting this vector projected onto the plane's normal from this vector.
</div>
<h3>.projectOnVector([page:todo vector]) [page:todo this]</h3>
<div>
vector -- [page:todo Vector3]
</div>
<div>
Projects this vector onto another vector.
</div>
<h3>.addScalar([page:todo s]) [page:todo this]</h3>
<div>
s -- [page:todo Float]
</div>
<div>
Adds a s to this vector.
</div>
<h3>.divide([page:todo v]) [page:todo this]</h3>
<div>
v -- [page:todo Vector3]
</div>
<div>
Divides this vector by vector v.
</div>
<h3>.min([page:todo v]) [page:todo]</h3>
<div>
v -- [page:todo Vector3]
</div>
<div>
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.
</div>
<h3>.setComponent([page:todo index], [page:todo value]) [page:todo this]</h3>
<div>
index -- 0, 1, or 2 <br />
value -- [page:todo Float]
</div>
<div>
If index equals 0 the method sets this vector's x value to value <br />
If index equals 1 the method sets this vector's y value to value <br />
If index equals 2 the method sets this vector's z value to value
</div>
<h3>.transformDirection([page:todo m]) [page:todo this]</h3>
<div>
m -- [page:todo Matrix4]
</div>
<div>
Multiplies this vector by a 3 x 3 subset of a Matrix4 and then normalizes the results.
</div>
<h3>.multiplyVectors([page:todo a], [page:todo b]) [page:todo this]</h3>
<div>
a -- [page:todo Vector3] <br />
b -- [page:todo Vector3]
</div>
<div>
Sets this vector equal the result of multiplying vector a by vector b.
</div>
<h3>.getComponent([page:todo index]) [page:todo Float]</h3>
<div>
index -- 0, 1, or 2
</div>
<div>
If index equals 0 the method returns this vector's x value <br />
If index equals 1 the method returns this vector's y value <br />
If index equals 2 the method returns this vector's z value
</div>
<h3>.applyAxisAngle([page:todo axis], [page:todo angle]) [page:todo this]</h3>
<div>
axis -- a normalized [page:todo Vector3] <br />
angle -- an angle in radians
</div>
<div>
Applies a rotation specified by an axis and an angle to this vector.
</div>
<h3>.lerp([page:todo v], [page:todo alpha]) [page:todo this]</h3>
<div>
v -- [page:todo Vector3] <br />
alpha -- [page:todo Float] between 0 and 1.
</div>
<div>
Linear Interpolation between this vector and vector v, where alpha is the percent along the line.
</div>
<h3>.max([page:todo v]) [page:todo this]</h3>
<div>
v -- [page:todo Vector3]
</div>
<div>
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.
</div>
<h3>.angleTo([page:todo v]) [page:todo Float]</h3>
<div>
v -- [page:todo Vector3]
</div>
<div>
Returns the angle between this vector and vector v in radians.
</div>
<h3>.getColumnFromMatrix([page:todo index], [page:todo matrix]) [page:todo this]</h3>
<div>
index -- 0, 1, 2, or 3 <br />
matrix -- [page:todo Matrix4]
</div>
<div>
Sets this vector's x, y, and z equal to the column of the matrix specified by the index.
</div>
<h3>.reflect([page:todo vector]) [page:todo this]</h3>
<div>
vector -- [page:todo Vector3] the vector to reflect about
</div>
<div>
Reflects this vector about a vector.
</div>
<h3>.fromArray([page:todo array]) [page:todo this]</h3>
<div>
array -- [page:todo Array]
</div>
<div>
Assigns this vectors x value to array[0]. <br />
Assigns this vectors y value to array[1]. <br />
Assigns this vectors z value to array[2]. <br />
</div>
<h3>.multiply([page:todo v]) [page:todo this]</h3>
<div>
v -- [page:todo Vector3] <br />
</div>
<div>
Multipies this vector by vector v.
</div>
<h3>.applyProjection([page:todo m]) [page:todo ths]</h3>
<div>
m -- [page:todo Matrix4] projection matrix.
</div>
<div>
Multiplies this vector and m, and divides by perspective.
</div>
<h3>.toArray() [page:todo Array]</h3>
<div>
Assigns this vector's x value to array[0]. <br />
Assigns this vector's y value to array[1]. <br />
Assigns this vector's z value to array[2]. <br />
Returns the created array.
</div>
<h3>.applyEuler( [page:todo euler] ) [page:todo this]</h3>
<div>
euler -- [page:todo Euler]
</div>
<div>
Applies euler transform to this vector by converting the [page:Euler] obect to a [page:Quaternion] and applying.
</div>
<h3>.applyQuaternion([page:todo q]) [page:todo this]</h3>
<div>
q -- [page:Quaternion]
</div>
<div>
Applies a [page:Quaternion] transform to this vector.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>