1
0

Vector3.html 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Vector3 - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <h1 translate="no">Vector3</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Class representing a 3D vector. A 3D vector is an ordered triplet of numbers
  16. (labeled x, y and z), which can be used to represent a number of things, such as:</p>
  17. <ul>
  18. <li>A point in 3D space.</li>
  19. <li>A direction and length in 3D space. In three.js the length will
  20. always be the Euclidean distance(straight-line distance) from <code>(0, 0, 0)</code> to <code>(x, y, z)</code>
  21. and the direction is also measured from <code>(0, 0, 0)</code> towards <code>(x, y, z)</code>.</li>
  22. <li>Any arbitrary ordered triplet of numbers.</li>
  23. </ul>
  24. <p>There are other things a 3D vector can be used to represent, such as
  25. momentum vectors and so on, however these are the most
  26. common uses in three.js.</p>
  27. <p>Iterating through a vector instance will yield its components <code>(x, y, z)</code> in
  28. the corresponding order.</p></div>
  29. <h2>Code Example</h2>
  30. <div translate="no"><pre><code class="language-js">const a = new THREE.Vector3( 0, 1, 0 );
  31. //no arguments; will be initialised to (0, 0, 0)
  32. const b = new THREE.Vector3( );
  33. const d = a.distanceTo( b );
  34. </code></pre></div>
  35. </header>
  36. <article>
  37. <div class="container-overview">
  38. <h2>Constructor</h2>
  39. <h3 class="name name-method" id="Vector3" translate="no">new <a href="#Vector3">Vector3</a><span class="signature">( x : <span class="param-type">number</span>, y : <span class="param-type">number</span>, z : <span class="param-type">number</span> )</span> </h3>
  40. <div class="method">
  41. <div class="description">
  42. <p>Constructs a new 3D vector.</p>
  43. </div>
  44. <table class="params">
  45. <tbody>
  46. <tr>
  47. <td class="name">
  48. <strong>x</strong>
  49. </td>
  50. <td class="description last">
  51. <p>The x value of this vector.</p>
  52. <p>Default is <code>0</code>.</p>
  53. </td>
  54. </tr>
  55. <tr>
  56. <td class="name">
  57. <strong>y</strong>
  58. </td>
  59. <td class="description last">
  60. <p>The y value of this vector.</p>
  61. <p>Default is <code>0</code>.</p>
  62. </td>
  63. </tr>
  64. <tr>
  65. <td class="name">
  66. <strong>z</strong>
  67. </td>
  68. <td class="description last">
  69. <p>The z value of this vector.</p>
  70. <p>Default is <code>0</code>.</p>
  71. </td>
  72. </tr>
  73. </tbody>
  74. </table>
  75. </div>
  76. </div>
  77. <h2 class="subsection-title">Properties</h2>
  78. <div class="member">
  79. <h3 class="name" id="isVector3" translate="no">.<a href="#isVector3">isVector3</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  80. <div class="description">
  81. <p>This flag can be used for type testing.</p>
  82. <p>Default is <code>true</code>.</p>
  83. </div>
  84. </div>
  85. <div class="member">
  86. <h3 class="name" id="x" translate="no">.<a href="#x">x</a><span class="type-signature"> : number</span> </h3>
  87. <div class="description">
  88. <p>The x value of this vector.</p>
  89. </div>
  90. </div>
  91. <div class="member">
  92. <h3 class="name" id="y" translate="no">.<a href="#y">y</a><span class="type-signature"> : number</span> </h3>
  93. <div class="description">
  94. <p>The y value of this vector.</p>
  95. </div>
  96. </div>
  97. <div class="member">
  98. <h3 class="name" id="z" translate="no">.<a href="#z">z</a><span class="type-signature"> : number</span> </h3>
  99. <div class="description">
  100. <p>The z value of this vector.</p>
  101. </div>
  102. </div>
  103. <h2 class="subsection-title">Methods</h2>
  104. <h3 class="name name-method" id="add" translate="no">.<a href="#add">add</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  105. <div class="method">
  106. <div class="description">
  107. <p>Adds the given vector to this instance.</p>
  108. </div>
  109. <table class="params">
  110. <tbody>
  111. <tr>
  112. <td class="name">
  113. <strong>v</strong>
  114. </td>
  115. <td class="description last">
  116. <p>The vector to add.</p>
  117. </td>
  118. </tr>
  119. </tbody>
  120. </table>
  121. <dl class="details">
  122. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  123. </dl>
  124. </div>
  125. <h3 class="name name-method" id="addScalar" translate="no">.<a href="#addScalar">addScalar</a><span class="signature">( s : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  126. <div class="method">
  127. <div class="description">
  128. <p>Adds the given scalar value to all components of this instance.</p>
  129. </div>
  130. <table class="params">
  131. <tbody>
  132. <tr>
  133. <td class="name">
  134. <strong>s</strong>
  135. </td>
  136. <td class="description last">
  137. <p>The scalar to add.</p>
  138. </td>
  139. </tr>
  140. </tbody>
  141. </table>
  142. <dl class="details">
  143. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  144. </dl>
  145. </div>
  146. <h3 class="name name-method" id="addScaledVector" translate="no">.<a href="#addScaledVector">addScaledVector</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a> | <a href="Vector4.html">Vector4</a></span>, s : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  147. <div class="method">
  148. <div class="description">
  149. <p>Adds the given vector scaled by the given factor to this instance.</p>
  150. </div>
  151. <table class="params">
  152. <tbody>
  153. <tr>
  154. <td class="name">
  155. <strong>v</strong>
  156. </td>
  157. <td class="description last">
  158. <p>The vector.</p>
  159. </td>
  160. </tr>
  161. <tr>
  162. <td class="name">
  163. <strong>s</strong>
  164. </td>
  165. <td class="description last">
  166. <p>The factor that scales <code>v</code>.</p>
  167. </td>
  168. </tr>
  169. </tbody>
  170. </table>
  171. <dl class="details">
  172. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  173. </dl>
  174. </div>
  175. <h3 class="name name-method" id="addVectors" translate="no">.<a href="#addVectors">addVectors</a><span class="signature">( a : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, b : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  176. <div class="method">
  177. <div class="description">
  178. <p>Adds the given vectors and stores the result in this instance.</p>
  179. </div>
  180. <table class="params">
  181. <tbody>
  182. <tr>
  183. <td class="name">
  184. <strong>a</strong>
  185. </td>
  186. <td class="description last">
  187. <p>The first vector.</p>
  188. </td>
  189. </tr>
  190. <tr>
  191. <td class="name">
  192. <strong>b</strong>
  193. </td>
  194. <td class="description last">
  195. <p>The second vector.</p>
  196. </td>
  197. </tr>
  198. </tbody>
  199. </table>
  200. <dl class="details">
  201. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  202. </dl>
  203. </div>
  204. <h3 class="name name-method" id="angleTo" translate="no">.<a href="#angleTo">angleTo</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : number</span> </h3>
  205. <div class="method">
  206. <div class="description">
  207. <p>Returns the angle between the given vector and this instance in radians.</p>
  208. </div>
  209. <table class="params">
  210. <tbody>
  211. <tr>
  212. <td class="name">
  213. <strong>v</strong>
  214. </td>
  215. <td class="description last">
  216. <p>The vector to compute the angle with.</p>
  217. </td>
  218. </tr>
  219. </tbody>
  220. </table>
  221. <dl class="details">
  222. <dt class="tag-returns"><strong>Returns:</strong> The angle in radians.</dt>
  223. </dl>
  224. </div>
  225. <h3 class="name name-method" id="applyAxisAngle" translate="no">.<a href="#applyAxisAngle">applyAxisAngle</a><span class="signature">( axis : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, angle : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  226. <div class="method">
  227. <div class="description">
  228. <p>Applies a rotation specified by an axis and an angle to this vector.</p>
  229. </div>
  230. <table class="params">
  231. <tbody>
  232. <tr>
  233. <td class="name">
  234. <strong>axis</strong>
  235. </td>
  236. <td class="description last">
  237. <p>A normalized vector representing the rotation axis.</p>
  238. </td>
  239. </tr>
  240. <tr>
  241. <td class="name">
  242. <strong>angle</strong>
  243. </td>
  244. <td class="description last">
  245. <p>The angle in radians.</p>
  246. </td>
  247. </tr>
  248. </tbody>
  249. </table>
  250. <dl class="details">
  251. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  252. </dl>
  253. </div>
  254. <h3 class="name name-method" id="applyEuler" translate="no">.<a href="#applyEuler">applyEuler</a><span class="signature">( euler : <span class="param-type"><a href="Euler.html">Euler</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  255. <div class="method">
  256. <div class="description">
  257. <p>Applies the given Euler rotation to this vector.</p>
  258. </div>
  259. <table class="params">
  260. <tbody>
  261. <tr>
  262. <td class="name">
  263. <strong>euler</strong>
  264. </td>
  265. <td class="description last">
  266. <p>The Euler angles.</p>
  267. </td>
  268. </tr>
  269. </tbody>
  270. </table>
  271. <dl class="details">
  272. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  273. </dl>
  274. </div>
  275. <h3 class="name name-method" id="applyMatrix3" translate="no">.<a href="#applyMatrix3">applyMatrix3</a><span class="signature">( m : <span class="param-type"><a href="Matrix3.html">Matrix3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  276. <div class="method">
  277. <div class="description">
  278. <p>Multiplies this vector with the given 3x3 matrix.</p>
  279. </div>
  280. <table class="params">
  281. <tbody>
  282. <tr>
  283. <td class="name">
  284. <strong>m</strong>
  285. </td>
  286. <td class="description last">
  287. <p>The 3x3 matrix.</p>
  288. </td>
  289. </tr>
  290. </tbody>
  291. </table>
  292. <dl class="details">
  293. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  294. </dl>
  295. </div>
  296. <h3 class="name name-method" id="applyMatrix4" translate="no">.<a href="#applyMatrix4">applyMatrix4</a><span class="signature">( m : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  297. <div class="method">
  298. <div class="description">
  299. <p>Multiplies this vector (with an implicit 1 in the 4th dimension) by m, and
  300. divides by perspective.</p>
  301. </div>
  302. <table class="params">
  303. <tbody>
  304. <tr>
  305. <td class="name">
  306. <strong>m</strong>
  307. </td>
  308. <td class="description last">
  309. <p>The matrix to apply.</p>
  310. </td>
  311. </tr>
  312. </tbody>
  313. </table>
  314. <dl class="details">
  315. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  316. </dl>
  317. </div>
  318. <h3 class="name name-method" id="applyNormalMatrix" translate="no">.<a href="#applyNormalMatrix">applyNormalMatrix</a><span class="signature">( m : <span class="param-type"><a href="Matrix3.html">Matrix3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  319. <div class="method">
  320. <div class="description">
  321. <p>Multiplies this vector by the given normal matrix and normalizes
  322. the result.</p>
  323. </div>
  324. <table class="params">
  325. <tbody>
  326. <tr>
  327. <td class="name">
  328. <strong>m</strong>
  329. </td>
  330. <td class="description last">
  331. <p>The normal matrix.</p>
  332. </td>
  333. </tr>
  334. </tbody>
  335. </table>
  336. <dl class="details">
  337. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  338. </dl>
  339. </div>
  340. <h3 class="name name-method" id="applyQuaternion" translate="no">.<a href="#applyQuaternion">applyQuaternion</a><span class="signature">( q : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  341. <div class="method">
  342. <div class="description">
  343. <p>Applies the given Quaternion to this vector.</p>
  344. </div>
  345. <table class="params">
  346. <tbody>
  347. <tr>
  348. <td class="name">
  349. <strong>q</strong>
  350. </td>
  351. <td class="description last">
  352. <p>The Quaternion.</p>
  353. </td>
  354. </tr>
  355. </tbody>
  356. </table>
  357. <dl class="details">
  358. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  359. </dl>
  360. </div>
  361. <h3 class="name name-method" id="ceil" translate="no">.<a href="#ceil">ceil</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  362. <div class="method">
  363. <div class="description">
  364. <p>The components of this vector are rounded up to the nearest integer value.</p>
  365. </div>
  366. <dl class="details">
  367. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  368. </dl>
  369. </div>
  370. <h3 class="name name-method" id="clamp" translate="no">.<a href="#clamp">clamp</a><span class="signature">( min : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, max : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  371. <div class="method">
  372. <div class="description">
  373. <p>If this vector's x, y or z value is greater than the max vector's x, y or z
  374. value, it is replaced by the corresponding value.
  375. If this vector's x, y or z value is less than the min vector's x, y or z value,
  376. it is replaced by the corresponding value.</p>
  377. </div>
  378. <table class="params">
  379. <tbody>
  380. <tr>
  381. <td class="name">
  382. <strong>min</strong>
  383. </td>
  384. <td class="description last">
  385. <p>The minimum x, y and z values.</p>
  386. </td>
  387. </tr>
  388. <tr>
  389. <td class="name">
  390. <strong>max</strong>
  391. </td>
  392. <td class="description last">
  393. <p>The maximum x, y and z values in the desired range.</p>
  394. </td>
  395. </tr>
  396. </tbody>
  397. </table>
  398. <dl class="details">
  399. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  400. </dl>
  401. </div>
  402. <h3 class="name name-method" id="clampLength" translate="no">.<a href="#clampLength">clampLength</a><span class="signature">( min : <span class="param-type">number</span>, max : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  403. <div class="method">
  404. <div class="description">
  405. <p>If this vector's length is greater than the max value, it is replaced by
  406. the max value.
  407. If this vector's length is less than the min value, it is replaced by the
  408. min value.</p>
  409. </div>
  410. <table class="params">
  411. <tbody>
  412. <tr>
  413. <td class="name">
  414. <strong>min</strong>
  415. </td>
  416. <td class="description last">
  417. <p>The minimum value the vector length will be clamped to.</p>
  418. </td>
  419. </tr>
  420. <tr>
  421. <td class="name">
  422. <strong>max</strong>
  423. </td>
  424. <td class="description last">
  425. <p>The maximum value the vector length will be clamped to.</p>
  426. </td>
  427. </tr>
  428. </tbody>
  429. </table>
  430. <dl class="details">
  431. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  432. </dl>
  433. </div>
  434. <h3 class="name name-method" id="clampScalar" translate="no">.<a href="#clampScalar">clampScalar</a><span class="signature">( minVal : <span class="param-type">number</span>, maxVal : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  435. <div class="method">
  436. <div class="description">
  437. <p>If this vector's x, y or z values are greater than the max value, they are
  438. replaced by the max value.
  439. If this vector's x, y or z values are less than the min value, they are
  440. replaced by the min value.</p>
  441. </div>
  442. <table class="params">
  443. <tbody>
  444. <tr>
  445. <td class="name">
  446. <strong>minVal</strong>
  447. </td>
  448. <td class="description last">
  449. <p>The minimum value the components will be clamped to.</p>
  450. </td>
  451. </tr>
  452. <tr>
  453. <td class="name">
  454. <strong>maxVal</strong>
  455. </td>
  456. <td class="description last">
  457. <p>The maximum value the components will be clamped to.</p>
  458. </td>
  459. </tr>
  460. </tbody>
  461. </table>
  462. <dl class="details">
  463. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  464. </dl>
  465. </div>
  466. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  467. <div class="method">
  468. <div class="description">
  469. <p>Returns a new vector with copied values from this instance.</p>
  470. </div>
  471. <dl class="details">
  472. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  473. </dl>
  474. </div>
  475. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  476. <div class="method">
  477. <div class="description">
  478. <p>Copies the values of the given vector to this instance.</p>
  479. </div>
  480. <table class="params">
  481. <tbody>
  482. <tr>
  483. <td class="name">
  484. <strong>v</strong>
  485. </td>
  486. <td class="description last">
  487. <p>The vector to copy.</p>
  488. </td>
  489. </tr>
  490. </tbody>
  491. </table>
  492. <dl class="details">
  493. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  494. </dl>
  495. </div>
  496. <h3 class="name name-method" id="cross" translate="no">.<a href="#cross">cross</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  497. <div class="method">
  498. <div class="description">
  499. <p>Calculates the cross product of the given vector with this instance.</p>
  500. </div>
  501. <table class="params">
  502. <tbody>
  503. <tr>
  504. <td class="name">
  505. <strong>v</strong>
  506. </td>
  507. <td class="description last">
  508. <p>The vector to compute the cross product with.</p>
  509. </td>
  510. </tr>
  511. </tbody>
  512. </table>
  513. <dl class="details">
  514. <dt class="tag-returns"><strong>Returns:</strong> The result of the cross product.</dt>
  515. </dl>
  516. </div>
  517. <h3 class="name name-method" id="crossVectors" translate="no">.<a href="#crossVectors">crossVectors</a><span class="signature">( a : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, b : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  518. <div class="method">
  519. <div class="description">
  520. <p>Calculates the cross product of the given vectors and stores the result
  521. in this instance.</p>
  522. </div>
  523. <table class="params">
  524. <tbody>
  525. <tr>
  526. <td class="name">
  527. <strong>a</strong>
  528. </td>
  529. <td class="description last">
  530. <p>The first vector.</p>
  531. </td>
  532. </tr>
  533. <tr>
  534. <td class="name">
  535. <strong>b</strong>
  536. </td>
  537. <td class="description last">
  538. <p>The second vector.</p>
  539. </td>
  540. </tr>
  541. </tbody>
  542. </table>
  543. <dl class="details">
  544. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  545. </dl>
  546. </div>
  547. <h3 class="name name-method" id="distanceTo" translate="no">.<a href="#distanceTo">distanceTo</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : number</span> </h3>
  548. <div class="method">
  549. <div class="description">
  550. <p>Computes the distance from the given vector to this instance.</p>
  551. </div>
  552. <table class="params">
  553. <tbody>
  554. <tr>
  555. <td class="name">
  556. <strong>v</strong>
  557. </td>
  558. <td class="description last">
  559. <p>The vector to compute the distance to.</p>
  560. </td>
  561. </tr>
  562. </tbody>
  563. </table>
  564. <dl class="details">
  565. <dt class="tag-returns"><strong>Returns:</strong> The distance.</dt>
  566. </dl>
  567. </div>
  568. <h3 class="name name-method" id="distanceToSquared" translate="no">.<a href="#distanceToSquared">distanceToSquared</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : number</span> </h3>
  569. <div class="method">
  570. <div class="description">
  571. <p>Computes the squared distance from the given vector to this instance.
  572. If you are just comparing the distance with another distance, you should compare
  573. the distance squared instead as it is slightly more efficient to calculate.</p>
  574. </div>
  575. <table class="params">
  576. <tbody>
  577. <tr>
  578. <td class="name">
  579. <strong>v</strong>
  580. </td>
  581. <td class="description last">
  582. <p>The vector to compute the squared distance to.</p>
  583. </td>
  584. </tr>
  585. </tbody>
  586. </table>
  587. <dl class="details">
  588. <dt class="tag-returns"><strong>Returns:</strong> The squared distance.</dt>
  589. </dl>
  590. </div>
  591. <h3 class="name name-method" id="divide" translate="no">.<a href="#divide">divide</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  592. <div class="method">
  593. <div class="description">
  594. <p>Divides this instance by the given vector.</p>
  595. </div>
  596. <table class="params">
  597. <tbody>
  598. <tr>
  599. <td class="name">
  600. <strong>v</strong>
  601. </td>
  602. <td class="description last">
  603. <p>The vector to divide.</p>
  604. </td>
  605. </tr>
  606. </tbody>
  607. </table>
  608. <dl class="details">
  609. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  610. </dl>
  611. </div>
  612. <h3 class="name name-method" id="divideScalar" translate="no">.<a href="#divideScalar">divideScalar</a><span class="signature">( scalar : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  613. <div class="method">
  614. <div class="description">
  615. <p>Divides this vector by the given scalar.</p>
  616. </div>
  617. <table class="params">
  618. <tbody>
  619. <tr>
  620. <td class="name">
  621. <strong>scalar</strong>
  622. </td>
  623. <td class="description last">
  624. <p>The scalar to divide.</p>
  625. </td>
  626. </tr>
  627. </tbody>
  628. </table>
  629. <dl class="details">
  630. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  631. </dl>
  632. </div>
  633. <h3 class="name name-method" id="dot" translate="no">.<a href="#dot">dot</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : number</span> </h3>
  634. <div class="method">
  635. <div class="description">
  636. <p>Calculates the dot product of the given vector with this instance.</p>
  637. </div>
  638. <table class="params">
  639. <tbody>
  640. <tr>
  641. <td class="name">
  642. <strong>v</strong>
  643. </td>
  644. <td class="description last">
  645. <p>The vector to compute the dot product with.</p>
  646. </td>
  647. </tr>
  648. </tbody>
  649. </table>
  650. <dl class="details">
  651. <dt class="tag-returns"><strong>Returns:</strong> The result of the dot product.</dt>
  652. </dl>
  653. </div>
  654. <h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  655. <div class="method">
  656. <div class="description">
  657. <p>Returns <code>true</code> if this vector is equal with the given one.</p>
  658. </div>
  659. <table class="params">
  660. <tbody>
  661. <tr>
  662. <td class="name">
  663. <strong>v</strong>
  664. </td>
  665. <td class="description last">
  666. <p>The vector to test for equality.</p>
  667. </td>
  668. </tr>
  669. </tbody>
  670. </table>
  671. <dl class="details">
  672. <dt class="tag-returns"><strong>Returns:</strong> Whether this vector is equal with the given one.</dt>
  673. </dl>
  674. </div>
  675. <h3 class="name name-method" id="floor" translate="no">.<a href="#floor">floor</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  676. <div class="method">
  677. <div class="description">
  678. <p>The components of this vector are rounded down to the nearest integer value.</p>
  679. </div>
  680. <dl class="details">
  681. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  682. </dl>
  683. </div>
  684. <h3 class="name name-method" id="fromArray" translate="no">.<a href="#fromArray">fromArray</a><span class="signature">( array : <span class="param-type">Array.&lt;number></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  685. <div class="method">
  686. <div class="description">
  687. <p>Sets this vector's x value to be <code>array[ offset ]</code>, y value to be <code>array[ offset + 1 ]</code>
  688. and z value to be <code>array[ offset + 2 ]</code>.</p>
  689. </div>
  690. <table class="params">
  691. <tbody>
  692. <tr>
  693. <td class="name">
  694. <strong>array</strong>
  695. </td>
  696. <td class="description last">
  697. <p>An array holding the vector component values.</p>
  698. </td>
  699. </tr>
  700. <tr>
  701. <td class="name">
  702. <strong>offset</strong>
  703. </td>
  704. <td class="description last">
  705. <p>The offset into the array.</p>
  706. <p>Default is <code>0</code>.</p>
  707. </td>
  708. </tr>
  709. </tbody>
  710. </table>
  711. <dl class="details">
  712. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  713. </dl>
  714. </div>
  715. <h3 class="name name-method" id="fromBufferAttribute" translate="no">.<a href="#fromBufferAttribute">fromBufferAttribute</a><span class="signature">( attribute : <span class="param-type"><a href="BufferAttribute.html">BufferAttribute</a></span>, index : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  716. <div class="method">
  717. <div class="description">
  718. <p>Sets the components of this vector from the given buffer attribute.</p>
  719. </div>
  720. <table class="params">
  721. <tbody>
  722. <tr>
  723. <td class="name">
  724. <strong>attribute</strong>
  725. </td>
  726. <td class="description last">
  727. <p>The buffer attribute holding vector data.</p>
  728. </td>
  729. </tr>
  730. <tr>
  731. <td class="name">
  732. <strong>index</strong>
  733. </td>
  734. <td class="description last">
  735. <p>The index into the attribute.</p>
  736. </td>
  737. </tr>
  738. </tbody>
  739. </table>
  740. <dl class="details">
  741. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  742. </dl>
  743. </div>
  744. <h3 class="name name-method" id="getComponent" translate="no">.<a href="#getComponent">getComponent</a><span class="signature">( index : <span class="param-type">number</span> )</span><span class="type-signature"> : number</span> </h3>
  745. <div class="method">
  746. <div class="description">
  747. <p>Returns the value of the vector component which matches the given index.</p>
  748. </div>
  749. <table class="params">
  750. <tbody>
  751. <tr>
  752. <td class="name">
  753. <strong>index</strong>
  754. </td>
  755. <td class="description last">
  756. <p>The component index. <code>0</code> equals to x, <code>1</code> equals to y, <code>2</code> equals to z.</p>
  757. </td>
  758. </tr>
  759. </tbody>
  760. </table>
  761. <dl class="details">
  762. <dt class="tag-returns"><strong>Returns:</strong> A vector component value.</dt>
  763. </dl>
  764. </div>
  765. <h3 class="name name-method" id="length" translate="no">.<a href="#length">length</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  766. <div class="method">
  767. <div class="description">
  768. <p>Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z).</p>
  769. </div>
  770. <dl class="details">
  771. <dt class="tag-returns"><strong>Returns:</strong> The length of this vector.</dt>
  772. </dl>
  773. </div>
  774. <h3 class="name name-method" id="lengthSq" translate="no">.<a href="#lengthSq">lengthSq</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  775. <div class="method">
  776. <div class="description">
  777. <p>Computes the square of the Euclidean length (straight-line length) from
  778. (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should
  779. compare the length squared instead as it is slightly more efficient to calculate.</p>
  780. </div>
  781. <dl class="details">
  782. <dt class="tag-returns"><strong>Returns:</strong> The square length of this vector.</dt>
  783. </dl>
  784. </div>
  785. <h3 class="name name-method" id="lerp" translate="no">.<a href="#lerp">lerp</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, alpha : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  786. <div class="method">
  787. <div class="description">
  788. <p>Linearly interpolates between the given vector and this instance, where
  789. alpha is the percent distance along the line - alpha = 0 will be this
  790. vector, and alpha = 1 will be the given one.</p>
  791. </div>
  792. <table class="params">
  793. <tbody>
  794. <tr>
  795. <td class="name">
  796. <strong>v</strong>
  797. </td>
  798. <td class="description last">
  799. <p>The vector to interpolate towards.</p>
  800. </td>
  801. </tr>
  802. <tr>
  803. <td class="name">
  804. <strong>alpha</strong>
  805. </td>
  806. <td class="description last">
  807. <p>The interpolation factor, typically in the closed interval <code>[0, 1]</code>.</p>
  808. </td>
  809. </tr>
  810. </tbody>
  811. </table>
  812. <dl class="details">
  813. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  814. </dl>
  815. </div>
  816. <h3 class="name name-method" id="lerpVectors" translate="no">.<a href="#lerpVectors">lerpVectors</a><span class="signature">( v1 : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, v2 : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, alpha : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  817. <div class="method">
  818. <div class="description">
  819. <p>Linearly interpolates between the given vectors, where alpha is the percent
  820. distance along the line - alpha = 0 will be first vector, and alpha = 1 will
  821. be the second one. The result is stored in this instance.</p>
  822. </div>
  823. <table class="params">
  824. <tbody>
  825. <tr>
  826. <td class="name">
  827. <strong>v1</strong>
  828. </td>
  829. <td class="description last">
  830. <p>The first vector.</p>
  831. </td>
  832. </tr>
  833. <tr>
  834. <td class="name">
  835. <strong>v2</strong>
  836. </td>
  837. <td class="description last">
  838. <p>The second vector.</p>
  839. </td>
  840. </tr>
  841. <tr>
  842. <td class="name">
  843. <strong>alpha</strong>
  844. </td>
  845. <td class="description last">
  846. <p>The interpolation factor, typically in the closed interval <code>[0, 1]</code>.</p>
  847. </td>
  848. </tr>
  849. </tbody>
  850. </table>
  851. <dl class="details">
  852. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  853. </dl>
  854. </div>
  855. <h3 class="name name-method" id="manhattanDistanceTo" translate="no">.<a href="#manhattanDistanceTo">manhattanDistanceTo</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : number</span> </h3>
  856. <div class="method">
  857. <div class="description">
  858. <p>Computes the Manhattan distance from the given vector to this instance.</p>
  859. </div>
  860. <table class="params">
  861. <tbody>
  862. <tr>
  863. <td class="name">
  864. <strong>v</strong>
  865. </td>
  866. <td class="description last">
  867. <p>The vector to compute the Manhattan distance to.</p>
  868. </td>
  869. </tr>
  870. </tbody>
  871. </table>
  872. <dl class="details">
  873. <dt class="tag-returns"><strong>Returns:</strong> The Manhattan distance.</dt>
  874. </dl>
  875. </div>
  876. <h3 class="name name-method" id="manhattanLength" translate="no">.<a href="#manhattanLength">manhattanLength</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  877. <div class="method">
  878. <div class="description">
  879. <p>Computes the Manhattan length of this vector.</p>
  880. </div>
  881. <dl class="details">
  882. <dt class="tag-returns"><strong>Returns:</strong> The length of this vector.</dt>
  883. </dl>
  884. </div>
  885. <h3 class="name name-method" id="max" translate="no">.<a href="#max">max</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  886. <div class="method">
  887. <div class="description">
  888. <p>If this vector's x, y or z value is less than the given vector's x, y or z
  889. value, replace that value with the corresponding max value.</p>
  890. </div>
  891. <table class="params">
  892. <tbody>
  893. <tr>
  894. <td class="name">
  895. <strong>v</strong>
  896. </td>
  897. <td class="description last">
  898. <p>The vector.</p>
  899. </td>
  900. </tr>
  901. </tbody>
  902. </table>
  903. <dl class="details">
  904. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  905. </dl>
  906. </div>
  907. <h3 class="name name-method" id="min" translate="no">.<a href="#min">min</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  908. <div class="method">
  909. <div class="description">
  910. <p>If this vector's x, y or z value is greater than the given vector's x, y or z
  911. value, replace that value with the corresponding min value.</p>
  912. </div>
  913. <table class="params">
  914. <tbody>
  915. <tr>
  916. <td class="name">
  917. <strong>v</strong>
  918. </td>
  919. <td class="description last">
  920. <p>The vector.</p>
  921. </td>
  922. </tr>
  923. </tbody>
  924. </table>
  925. <dl class="details">
  926. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  927. </dl>
  928. </div>
  929. <h3 class="name name-method" id="multiply" translate="no">.<a href="#multiply">multiply</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  930. <div class="method">
  931. <div class="description">
  932. <p>Multiplies the given vector with this instance.</p>
  933. </div>
  934. <table class="params">
  935. <tbody>
  936. <tr>
  937. <td class="name">
  938. <strong>v</strong>
  939. </td>
  940. <td class="description last">
  941. <p>The vector to multiply.</p>
  942. </td>
  943. </tr>
  944. </tbody>
  945. </table>
  946. <dl class="details">
  947. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  948. </dl>
  949. </div>
  950. <h3 class="name name-method" id="multiplyScalar" translate="no">.<a href="#multiplyScalar">multiplyScalar</a><span class="signature">( scalar : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  951. <div class="method">
  952. <div class="description">
  953. <p>Multiplies the given scalar value with all components of this instance.</p>
  954. </div>
  955. <table class="params">
  956. <tbody>
  957. <tr>
  958. <td class="name">
  959. <strong>scalar</strong>
  960. </td>
  961. <td class="description last">
  962. <p>The scalar to multiply.</p>
  963. </td>
  964. </tr>
  965. </tbody>
  966. </table>
  967. <dl class="details">
  968. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  969. </dl>
  970. </div>
  971. <h3 class="name name-method" id="multiplyVectors" translate="no">.<a href="#multiplyVectors">multiplyVectors</a><span class="signature">( a : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, b : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  972. <div class="method">
  973. <div class="description">
  974. <p>Multiplies the given vectors and stores the result in this instance.</p>
  975. </div>
  976. <table class="params">
  977. <tbody>
  978. <tr>
  979. <td class="name">
  980. <strong>a</strong>
  981. </td>
  982. <td class="description last">
  983. <p>The first vector.</p>
  984. </td>
  985. </tr>
  986. <tr>
  987. <td class="name">
  988. <strong>b</strong>
  989. </td>
  990. <td class="description last">
  991. <p>The second vector.</p>
  992. </td>
  993. </tr>
  994. </tbody>
  995. </table>
  996. <dl class="details">
  997. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  998. </dl>
  999. </div>
  1000. <h3 class="name name-method" id="negate" translate="no">.<a href="#negate">negate</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1001. <div class="method">
  1002. <div class="description">
  1003. <p>Inverts this vector - i.e. sets x = -x, y = -y and z = -z.</p>
  1004. </div>
  1005. <dl class="details">
  1006. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1007. </dl>
  1008. </div>
  1009. <h3 class="name name-method" id="normalize" translate="no">.<a href="#normalize">normalize</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1010. <div class="method">
  1011. <div class="description">
  1012. <p>Converts this vector to a unit vector - that is, sets it equal to a vector
  1013. with the same direction as this one, but with a vector length of <code>1</code>.</p>
  1014. </div>
  1015. <dl class="details">
  1016. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1017. </dl>
  1018. </div>
  1019. <h3 class="name name-method" id="project" translate="no">.<a href="#project">project</a><span class="signature">( camera : <span class="param-type"><a href="Camera.html">Camera</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1020. <div class="method">
  1021. <div class="description">
  1022. <p>Projects this vector from world space into the camera's normalized
  1023. device coordinate (NDC) space.</p>
  1024. </div>
  1025. <table class="params">
  1026. <tbody>
  1027. <tr>
  1028. <td class="name">
  1029. <strong>camera</strong>
  1030. </td>
  1031. <td class="description last">
  1032. <p>The camera.</p>
  1033. </td>
  1034. </tr>
  1035. </tbody>
  1036. </table>
  1037. <dl class="details">
  1038. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1039. </dl>
  1040. </div>
  1041. <h3 class="name name-method" id="projectOnPlane" translate="no">.<a href="#projectOnPlane">projectOnPlane</a><span class="signature">( planeNormal : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1042. <div class="method">
  1043. <div class="description">
  1044. <p>Projects this vector onto a plane by subtracting this
  1045. vector projected onto the plane's normal from this vector.</p>
  1046. </div>
  1047. <table class="params">
  1048. <tbody>
  1049. <tr>
  1050. <td class="name">
  1051. <strong>planeNormal</strong>
  1052. </td>
  1053. <td class="description last">
  1054. <p>The plane normal.</p>
  1055. </td>
  1056. </tr>
  1057. </tbody>
  1058. </table>
  1059. <dl class="details">
  1060. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1061. </dl>
  1062. </div>
  1063. <h3 class="name name-method" id="projectOnVector" translate="no">.<a href="#projectOnVector">projectOnVector</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1064. <div class="method">
  1065. <div class="description">
  1066. <p>Projects this vector onto the given one.</p>
  1067. </div>
  1068. <table class="params">
  1069. <tbody>
  1070. <tr>
  1071. <td class="name">
  1072. <strong>v</strong>
  1073. </td>
  1074. <td class="description last">
  1075. <p>The vector to project to.</p>
  1076. </td>
  1077. </tr>
  1078. </tbody>
  1079. </table>
  1080. <dl class="details">
  1081. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1082. </dl>
  1083. </div>
  1084. <h3 class="name name-method" id="random" translate="no">.<a href="#random">random</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1085. <div class="method">
  1086. <div class="description">
  1087. <p>Sets each component of this vector to a pseudo-random value between <code>0</code> and
  1088. <code>1</code>, excluding <code>1</code>.</p>
  1089. </div>
  1090. <dl class="details">
  1091. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1092. </dl>
  1093. </div>
  1094. <h3 class="name name-method" id="randomDirection" translate="no">.<a href="#randomDirection">randomDirection</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1095. <div class="method">
  1096. <div class="description">
  1097. <p>Sets this vector to a uniformly random point on a unit sphere.</p>
  1098. </div>
  1099. <dl class="details">
  1100. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1101. </dl>
  1102. </div>
  1103. <h3 class="name name-method" id="reflect" translate="no">.<a href="#reflect">reflect</a><span class="signature">( normal : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1104. <div class="method">
  1105. <div class="description">
  1106. <p>Reflects this vector off a plane orthogonal to the given normal vector.</p>
  1107. </div>
  1108. <table class="params">
  1109. <tbody>
  1110. <tr>
  1111. <td class="name">
  1112. <strong>normal</strong>
  1113. </td>
  1114. <td class="description last">
  1115. <p>The (normalized) normal vector.</p>
  1116. </td>
  1117. </tr>
  1118. </tbody>
  1119. </table>
  1120. <dl class="details">
  1121. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1122. </dl>
  1123. </div>
  1124. <h3 class="name name-method" id="round" translate="no">.<a href="#round">round</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1125. <div class="method">
  1126. <div class="description">
  1127. <p>The components of this vector are rounded to the nearest integer value</p>
  1128. </div>
  1129. <dl class="details">
  1130. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1131. </dl>
  1132. </div>
  1133. <h3 class="name name-method" id="roundToZero" translate="no">.<a href="#roundToZero">roundToZero</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1134. <div class="method">
  1135. <div class="description">
  1136. <p>The components of this vector are rounded towards zero (up if negative,
  1137. down if positive) to an integer value.</p>
  1138. </div>
  1139. <dl class="details">
  1140. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1141. </dl>
  1142. </div>
  1143. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( x : <span class="param-type">number</span>, y : <span class="param-type">number</span>, z : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1144. <div class="method">
  1145. <div class="description">
  1146. <p>Sets the vector components.</p>
  1147. </div>
  1148. <table class="params">
  1149. <tbody>
  1150. <tr>
  1151. <td class="name">
  1152. <strong>x</strong>
  1153. </td>
  1154. <td class="description last">
  1155. <p>The value of the x component.</p>
  1156. </td>
  1157. </tr>
  1158. <tr>
  1159. <td class="name">
  1160. <strong>y</strong>
  1161. </td>
  1162. <td class="description last">
  1163. <p>The value of the y component.</p>
  1164. </td>
  1165. </tr>
  1166. <tr>
  1167. <td class="name">
  1168. <strong>z</strong>
  1169. </td>
  1170. <td class="description last">
  1171. <p>The value of the z component.</p>
  1172. </td>
  1173. </tr>
  1174. </tbody>
  1175. </table>
  1176. <dl class="details">
  1177. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1178. </dl>
  1179. </div>
  1180. <h3 class="name name-method" id="setComponent" translate="no">.<a href="#setComponent">setComponent</a><span class="signature">( index : <span class="param-type">number</span>, value : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1181. <div class="method">
  1182. <div class="description">
  1183. <p>Allows to set a vector component with an index.</p>
  1184. </div>
  1185. <table class="params">
  1186. <tbody>
  1187. <tr>
  1188. <td class="name">
  1189. <strong>index</strong>
  1190. </td>
  1191. <td class="description last">
  1192. <p>The component index. <code>0</code> equals to x, <code>1</code> equals to y, <code>2</code> equals to z.</p>
  1193. </td>
  1194. </tr>
  1195. <tr>
  1196. <td class="name">
  1197. <strong>value</strong>
  1198. </td>
  1199. <td class="description last">
  1200. <p>The value to set.</p>
  1201. </td>
  1202. </tr>
  1203. </tbody>
  1204. </table>
  1205. <dl class="details">
  1206. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1207. </dl>
  1208. </div>
  1209. <h3 class="name name-method" id="setFromColor" translate="no">.<a href="#setFromColor">setFromColor</a><span class="signature">( c : <span class="param-type"><a href="Color.html">Color</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1210. <div class="method">
  1211. <div class="description">
  1212. <p>Sets the vector components from the RGB components of the
  1213. given color.</p>
  1214. </div>
  1215. <table class="params">
  1216. <tbody>
  1217. <tr>
  1218. <td class="name">
  1219. <strong>c</strong>
  1220. </td>
  1221. <td class="description last">
  1222. <p>The color to set.</p>
  1223. </td>
  1224. </tr>
  1225. </tbody>
  1226. </table>
  1227. <dl class="details">
  1228. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1229. </dl>
  1230. </div>
  1231. <h3 class="name name-method" id="setFromCylindrical" translate="no">.<a href="#setFromCylindrical">setFromCylindrical</a><span class="signature">( c : <span class="param-type"><a href="Cylindrical.html">Cylindrical</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1232. <div class="method">
  1233. <div class="description">
  1234. <p>Sets the vector components from the given cylindrical coordinates.</p>
  1235. </div>
  1236. <table class="params">
  1237. <tbody>
  1238. <tr>
  1239. <td class="name">
  1240. <strong>c</strong>
  1241. </td>
  1242. <td class="description last">
  1243. <p>The cylindrical coordinates.</p>
  1244. </td>
  1245. </tr>
  1246. </tbody>
  1247. </table>
  1248. <dl class="details">
  1249. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1250. </dl>
  1251. </div>
  1252. <h3 class="name name-method" id="setFromCylindricalCoords" translate="no">.<a href="#setFromCylindricalCoords">setFromCylindricalCoords</a><span class="signature">( radius : <span class="param-type">number</span>, theta : <span class="param-type">number</span>, y : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1253. <div class="method">
  1254. <div class="description">
  1255. <p>Sets the vector components from the given cylindrical coordinates.</p>
  1256. </div>
  1257. <table class="params">
  1258. <tbody>
  1259. <tr>
  1260. <td class="name">
  1261. <strong>radius</strong>
  1262. </td>
  1263. <td class="description last">
  1264. <p>The radius.</p>
  1265. </td>
  1266. </tr>
  1267. <tr>
  1268. <td class="name">
  1269. <strong>theta</strong>
  1270. </td>
  1271. <td class="description last">
  1272. <p>The theta angle in radians.</p>
  1273. </td>
  1274. </tr>
  1275. <tr>
  1276. <td class="name">
  1277. <strong>y</strong>
  1278. </td>
  1279. <td class="description last">
  1280. <p>The y value.</p>
  1281. </td>
  1282. </tr>
  1283. </tbody>
  1284. </table>
  1285. <dl class="details">
  1286. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1287. </dl>
  1288. </div>
  1289. <h3 class="name name-method" id="setFromEuler" translate="no">.<a href="#setFromEuler">setFromEuler</a><span class="signature">( e : <span class="param-type"><a href="Euler.html">Euler</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1290. <div class="method">
  1291. <div class="description">
  1292. <p>Sets the vector components from the given Euler angles.</p>
  1293. </div>
  1294. <table class="params">
  1295. <tbody>
  1296. <tr>
  1297. <td class="name">
  1298. <strong>e</strong>
  1299. </td>
  1300. <td class="description last">
  1301. <p>The Euler angles to set.</p>
  1302. </td>
  1303. </tr>
  1304. </tbody>
  1305. </table>
  1306. <dl class="details">
  1307. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1308. </dl>
  1309. </div>
  1310. <h3 class="name name-method" id="setFromMatrix3Column" translate="no">.<a href="#setFromMatrix3Column">setFromMatrix3Column</a><span class="signature">( m : <span class="param-type"><a href="Matrix3.html">Matrix3</a></span>, index : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1311. <div class="method">
  1312. <div class="description">
  1313. <p>Sets the vector components from the specified matrix column.</p>
  1314. </div>
  1315. <table class="params">
  1316. <tbody>
  1317. <tr>
  1318. <td class="name">
  1319. <strong>m</strong>
  1320. </td>
  1321. <td class="description last">
  1322. <p>The 3x3 matrix.</p>
  1323. </td>
  1324. </tr>
  1325. <tr>
  1326. <td class="name">
  1327. <strong>index</strong>
  1328. </td>
  1329. <td class="description last">
  1330. <p>The column index.</p>
  1331. </td>
  1332. </tr>
  1333. </tbody>
  1334. </table>
  1335. <dl class="details">
  1336. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1337. </dl>
  1338. </div>
  1339. <h3 class="name name-method" id="setFromMatrixColumn" translate="no">.<a href="#setFromMatrixColumn">setFromMatrixColumn</a><span class="signature">( m : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span>, index : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1340. <div class="method">
  1341. <div class="description">
  1342. <p>Sets the vector components from the specified matrix column.</p>
  1343. </div>
  1344. <table class="params">
  1345. <tbody>
  1346. <tr>
  1347. <td class="name">
  1348. <strong>m</strong>
  1349. </td>
  1350. <td class="description last">
  1351. <p>The 4x4 matrix.</p>
  1352. </td>
  1353. </tr>
  1354. <tr>
  1355. <td class="name">
  1356. <strong>index</strong>
  1357. </td>
  1358. <td class="description last">
  1359. <p>The column index.</p>
  1360. </td>
  1361. </tr>
  1362. </tbody>
  1363. </table>
  1364. <dl class="details">
  1365. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1366. </dl>
  1367. </div>
  1368. <h3 class="name name-method" id="setFromMatrixPosition" translate="no">.<a href="#setFromMatrixPosition">setFromMatrixPosition</a><span class="signature">( m : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1369. <div class="method">
  1370. <div class="description">
  1371. <p>Sets the vector components to the position elements of the
  1372. given transformation matrix.</p>
  1373. </div>
  1374. <table class="params">
  1375. <tbody>
  1376. <tr>
  1377. <td class="name">
  1378. <strong>m</strong>
  1379. </td>
  1380. <td class="description last">
  1381. <p>The 4x4 matrix.</p>
  1382. </td>
  1383. </tr>
  1384. </tbody>
  1385. </table>
  1386. <dl class="details">
  1387. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1388. </dl>
  1389. </div>
  1390. <h3 class="name name-method" id="setFromMatrixScale" translate="no">.<a href="#setFromMatrixScale">setFromMatrixScale</a><span class="signature">( m : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1391. <div class="method">
  1392. <div class="description">
  1393. <p>Sets the vector components to the scale elements of the
  1394. given transformation matrix.</p>
  1395. </div>
  1396. <table class="params">
  1397. <tbody>
  1398. <tr>
  1399. <td class="name">
  1400. <strong>m</strong>
  1401. </td>
  1402. <td class="description last">
  1403. <p>The 4x4 matrix.</p>
  1404. </td>
  1405. </tr>
  1406. </tbody>
  1407. </table>
  1408. <dl class="details">
  1409. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1410. </dl>
  1411. </div>
  1412. <h3 class="name name-method" id="setFromSpherical" translate="no">.<a href="#setFromSpherical">setFromSpherical</a><span class="signature">( s : <span class="param-type"><a href="Spherical.html">Spherical</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1413. <div class="method">
  1414. <div class="description">
  1415. <p>Sets the vector components from the given spherical coordinates.</p>
  1416. </div>
  1417. <table class="params">
  1418. <tbody>
  1419. <tr>
  1420. <td class="name">
  1421. <strong>s</strong>
  1422. </td>
  1423. <td class="description last">
  1424. <p>The spherical coordinates.</p>
  1425. </td>
  1426. </tr>
  1427. </tbody>
  1428. </table>
  1429. <dl class="details">
  1430. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1431. </dl>
  1432. </div>
  1433. <h3 class="name name-method" id="setFromSphericalCoords" translate="no">.<a href="#setFromSphericalCoords">setFromSphericalCoords</a><span class="signature">( radius : <span class="param-type">number</span>, phi : <span class="param-type">number</span>, theta : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1434. <div class="method">
  1435. <div class="description">
  1436. <p>Sets the vector components from the given spherical coordinates.</p>
  1437. </div>
  1438. <table class="params">
  1439. <tbody>
  1440. <tr>
  1441. <td class="name">
  1442. <strong>radius</strong>
  1443. </td>
  1444. <td class="description last">
  1445. <p>The radius.</p>
  1446. </td>
  1447. </tr>
  1448. <tr>
  1449. <td class="name">
  1450. <strong>phi</strong>
  1451. </td>
  1452. <td class="description last">
  1453. <p>The phi angle in radians.</p>
  1454. </td>
  1455. </tr>
  1456. <tr>
  1457. <td class="name">
  1458. <strong>theta</strong>
  1459. </td>
  1460. <td class="description last">
  1461. <p>The theta angle in radians.</p>
  1462. </td>
  1463. </tr>
  1464. </tbody>
  1465. </table>
  1466. <dl class="details">
  1467. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1468. </dl>
  1469. </div>
  1470. <h3 class="name name-method" id="setLength" translate="no">.<a href="#setLength">setLength</a><span class="signature">( length : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1471. <div class="method">
  1472. <div class="description">
  1473. <p>Sets this vector to a vector with the same direction as this one, but
  1474. with the specified length.</p>
  1475. </div>
  1476. <table class="params">
  1477. <tbody>
  1478. <tr>
  1479. <td class="name">
  1480. <strong>length</strong>
  1481. </td>
  1482. <td class="description last">
  1483. <p>The new length of this vector.</p>
  1484. </td>
  1485. </tr>
  1486. </tbody>
  1487. </table>
  1488. <dl class="details">
  1489. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1490. </dl>
  1491. </div>
  1492. <h3 class="name name-method" id="setScalar" translate="no">.<a href="#setScalar">setScalar</a><span class="signature">( scalar : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1493. <div class="method">
  1494. <div class="description">
  1495. <p>Sets the vector components to the same value.</p>
  1496. </div>
  1497. <table class="params">
  1498. <tbody>
  1499. <tr>
  1500. <td class="name">
  1501. <strong>scalar</strong>
  1502. </td>
  1503. <td class="description last">
  1504. <p>The value to set for all vector components.</p>
  1505. </td>
  1506. </tr>
  1507. </tbody>
  1508. </table>
  1509. <dl class="details">
  1510. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1511. </dl>
  1512. </div>
  1513. <h3 class="name name-method" id="setX" translate="no">.<a href="#setX">setX</a><span class="signature">( x : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1514. <div class="method">
  1515. <div class="description">
  1516. <p>Sets the vector's x component to the given value</p>
  1517. </div>
  1518. <table class="params">
  1519. <tbody>
  1520. <tr>
  1521. <td class="name">
  1522. <strong>x</strong>
  1523. </td>
  1524. <td class="description last">
  1525. <p>The value to set.</p>
  1526. </td>
  1527. </tr>
  1528. </tbody>
  1529. </table>
  1530. <dl class="details">
  1531. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1532. </dl>
  1533. </div>
  1534. <h3 class="name name-method" id="setY" translate="no">.<a href="#setY">setY</a><span class="signature">( y : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1535. <div class="method">
  1536. <div class="description">
  1537. <p>Sets the vector's y component to the given value</p>
  1538. </div>
  1539. <table class="params">
  1540. <tbody>
  1541. <tr>
  1542. <td class="name">
  1543. <strong>y</strong>
  1544. </td>
  1545. <td class="description last">
  1546. <p>The value to set.</p>
  1547. </td>
  1548. </tr>
  1549. </tbody>
  1550. </table>
  1551. <dl class="details">
  1552. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1553. </dl>
  1554. </div>
  1555. <h3 class="name name-method" id="setZ" translate="no">.<a href="#setZ">setZ</a><span class="signature">( z : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1556. <div class="method">
  1557. <div class="description">
  1558. <p>Sets the vector's z component to the given value</p>
  1559. </div>
  1560. <table class="params">
  1561. <tbody>
  1562. <tr>
  1563. <td class="name">
  1564. <strong>z</strong>
  1565. </td>
  1566. <td class="description last">
  1567. <p>The value to set.</p>
  1568. </td>
  1569. </tr>
  1570. </tbody>
  1571. </table>
  1572. <dl class="details">
  1573. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1574. </dl>
  1575. </div>
  1576. <h3 class="name name-method" id="sub" translate="no">.<a href="#sub">sub</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1577. <div class="method">
  1578. <div class="description">
  1579. <p>Subtracts the given vector from this instance.</p>
  1580. </div>
  1581. <table class="params">
  1582. <tbody>
  1583. <tr>
  1584. <td class="name">
  1585. <strong>v</strong>
  1586. </td>
  1587. <td class="description last">
  1588. <p>The vector to subtract.</p>
  1589. </td>
  1590. </tr>
  1591. </tbody>
  1592. </table>
  1593. <dl class="details">
  1594. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1595. </dl>
  1596. </div>
  1597. <h3 class="name name-method" id="subScalar" translate="no">.<a href="#subScalar">subScalar</a><span class="signature">( s : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1598. <div class="method">
  1599. <div class="description">
  1600. <p>Subtracts the given scalar value from all components of this instance.</p>
  1601. </div>
  1602. <table class="params">
  1603. <tbody>
  1604. <tr>
  1605. <td class="name">
  1606. <strong>s</strong>
  1607. </td>
  1608. <td class="description last">
  1609. <p>The scalar to subtract.</p>
  1610. </td>
  1611. </tr>
  1612. </tbody>
  1613. </table>
  1614. <dl class="details">
  1615. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1616. </dl>
  1617. </div>
  1618. <h3 class="name name-method" id="subVectors" translate="no">.<a href="#subVectors">subVectors</a><span class="signature">( a : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, b : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1619. <div class="method">
  1620. <div class="description">
  1621. <p>Subtracts the given vectors and stores the result in this instance.</p>
  1622. </div>
  1623. <table class="params">
  1624. <tbody>
  1625. <tr>
  1626. <td class="name">
  1627. <strong>a</strong>
  1628. </td>
  1629. <td class="description last">
  1630. <p>The first vector.</p>
  1631. </td>
  1632. </tr>
  1633. <tr>
  1634. <td class="name">
  1635. <strong>b</strong>
  1636. </td>
  1637. <td class="description last">
  1638. <p>The second vector.</p>
  1639. </td>
  1640. </tr>
  1641. </tbody>
  1642. </table>
  1643. <dl class="details">
  1644. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1645. </dl>
  1646. </div>
  1647. <h3 class="name name-method" id="toArray" translate="no">.<a href="#toArray">toArray</a><span class="signature">( array : <span class="param-type">Array.&lt;number></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : Array.&lt;number></span> </h3>
  1648. <div class="method">
  1649. <div class="description">
  1650. <p>Writes the components of this vector to the given array. If no array is provided,
  1651. the method returns a new instance.</p>
  1652. </div>
  1653. <table class="params">
  1654. <tbody>
  1655. <tr>
  1656. <td class="name">
  1657. <strong>array</strong>
  1658. </td>
  1659. <td class="description last">
  1660. <p>The target array holding the vector components.</p>
  1661. <p>Default is <code>[]</code>.</p>
  1662. </td>
  1663. </tr>
  1664. <tr>
  1665. <td class="name">
  1666. <strong>offset</strong>
  1667. </td>
  1668. <td class="description last">
  1669. <p>Index of the first element in the array.</p>
  1670. <p>Default is <code>0</code>.</p>
  1671. </td>
  1672. </tr>
  1673. </tbody>
  1674. </table>
  1675. <dl class="details">
  1676. <dt class="tag-returns"><strong>Returns:</strong> The vector components.</dt>
  1677. </dl>
  1678. </div>
  1679. <h3 class="name name-method" id="transformDirection" translate="no">.<a href="#transformDirection">transformDirection</a><span class="signature">( m : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1680. <div class="method">
  1681. <div class="description">
  1682. <p>Transforms the direction of this vector by a matrix (the upper left 3 x 3
  1683. subset of the given 4x4 matrix and then normalizes the result.</p>
  1684. </div>
  1685. <table class="params">
  1686. <tbody>
  1687. <tr>
  1688. <td class="name">
  1689. <strong>m</strong>
  1690. </td>
  1691. <td class="description last">
  1692. <p>The matrix.</p>
  1693. </td>
  1694. </tr>
  1695. </tbody>
  1696. </table>
  1697. <dl class="details">
  1698. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1699. </dl>
  1700. </div>
  1701. <h3 class="name name-method" id="unproject" translate="no">.<a href="#unproject">unproject</a><span class="signature">( camera : <span class="param-type"><a href="Camera.html">Camera</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  1702. <div class="method">
  1703. <div class="description">
  1704. <p>Unprojects this vector from the camera's normalized device coordinate (NDC)
  1705. space into world space.</p>
  1706. </div>
  1707. <table class="params">
  1708. <tbody>
  1709. <tr>
  1710. <td class="name">
  1711. <strong>camera</strong>
  1712. </td>
  1713. <td class="description last">
  1714. <p>The camera.</p>
  1715. </td>
  1716. </tr>
  1717. </tbody>
  1718. </table>
  1719. <dl class="details">
  1720. <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
  1721. </dl>
  1722. </div>
  1723. <h2 class="subsection-title">Source</h2>
  1724. <p>
  1725. <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Vector3.js" translate="no" target="_blank" rel="noopener">src/math/Vector3.js</a>
  1726. </p>
  1727. </article>
  1728. </section>
  1729. <script src="../scripts/linenumber.js"></script>
  1730. <script src="../scripts/page.js"></script>
  1731. </body>
  1732. </html>
粤ICP备19079148号