| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Vector3 - Three.js Docs</title>
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <script src="../scripts/highlight.min.js"></script>
- <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
- <link type="text/css" rel="stylesheet" href="../styles/page.css">
- </head>
- <body>
- <h1 translate="no">Vector3</h1>
- <section>
- <header>
- <div class="class-description"><p>Class representing a 3D vector. A 3D vector is an ordered triplet of numbers
- (labeled x, y and z), which can be used to represent a number of things, such as:</p>
- <ul>
- <li>A point in 3D space.</li>
- <li>A direction and length in 3D space. In three.js the length will
- always be the Euclidean distance(straight-line distance) from <code>(0, 0, 0)</code> to <code>(x, y, z)</code>
- and the direction is also measured from <code>(0, 0, 0)</code> towards <code>(x, y, z)</code>.</li>
- <li>Any arbitrary ordered triplet of numbers.</li>
- </ul>
- <p>There are other things a 3D vector can be used to represent, such as
- momentum vectors and so on, however these are the most
- common uses in three.js.</p>
- <p>Iterating through a vector instance will yield its components <code>(x, y, z)</code> in
- the corresponding order.</p></div>
- <h2>Code Example</h2>
- <div translate="no"><pre><code class="language-js">const a = new THREE.Vector3( 0, 1, 0 );
- //no arguments; will be initialised to (0, 0, 0)
- const b = new THREE.Vector3( );
- const d = a.distanceTo( b );
- </code></pre></div>
- </header>
- <article>
- <div class="container-overview">
- <h2>Constructor</h2>
- <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>
- <div class="method">
- <div class="description">
- <p>Constructs a new 3D vector.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>x</code></td>
- <td class="description last"><p>The x value of this vector.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>y</code></td>
- <td class="description last"><p>The y value of this vector.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>z</code></td>
- <td class="description last"><p>The z value of this vector.<br/>Default is <code>0</code>.</p></td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <h2 class="subsection-title">Properties</h2>
- <div class="member">
- <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>
- <div class="description">
- <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="x" translate="no">.<a href="#x">x</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The x value of this vector.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="y" translate="no">.<a href="#y">y</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The y value of this vector.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="z" translate="no">.<a href="#z">z</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The z value of this vector.</p>
- </div>
- </div>
- <h2 class="subsection-title">Methods</h2>
- <h3 class="name name-method" id="add" translate="no">.<a href="#add">add</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Adds the given vector to this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to add.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Adds the given scalar value to all components of this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>s</code></td>
- <td class="description last"><p>The scalar to add.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="addScaledVector" translate="no">.<a href="#addScaledVector">addScaledVector</a><span class="signature">( v : <span class="param-type">Vector3 | Vector4</span>, s : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Adds the given vector scaled by the given factor to this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector.</p></td>
- </tr>
- <tr>
- <td class="name"><code>s</code></td>
- <td class="description last"><p>The factor that scales <code>v</code>.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="addVectors" translate="no">.<a href="#addVectors">addVectors</a><span class="signature">( a : <span class="param-type">Vector3</span>, b : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Adds the given vectors and stores the result in this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>a</code></td>
- <td class="description last"><p>The first vector.</p></td>
- </tr>
- <tr>
- <td class="name"><code>b</code></td>
- <td class="description last"><p>The second vector.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="angleTo" translate="no">.<a href="#angleTo">angleTo</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : number</span> </h3>
- <div class="method">
- <div class="description">
- <p>Returns the angle between the given vector and this instance in radians.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to compute the angle with.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The angle in radians.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="applyAxisAngle" translate="no">.<a href="#applyAxisAngle">applyAxisAngle</a><span class="signature">( axis : <span class="param-type">Vector3</span>, angle : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Applies a rotation specified by an axis and an angle to this vector.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>axis</code></td>
- <td class="description last"><p>A normalized vector representing the rotation axis.</p></td>
- </tr>
- <tr>
- <td class="name"><code>angle</code></td>
- <td class="description last"><p>The angle in radians.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="applyEuler" translate="no">.<a href="#applyEuler">applyEuler</a><span class="signature">( euler : <span class="param-type">Euler</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Applies the given Euler rotation to this vector.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>euler</code></td>
- <td class="description last"><p>The Euler angles.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="applyMatrix3" translate="no">.<a href="#applyMatrix3">applyMatrix3</a><span class="signature">( m : <span class="param-type">Matrix3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Multiplies this vector with the given 3x3 matrix.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>m</code></td>
- <td class="description last"><p>The 3x3 matrix.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="applyMatrix4" translate="no">.<a href="#applyMatrix4">applyMatrix4</a><span class="signature">( m : <span class="param-type">Matrix4</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Multiplies this vector (with an implicit 1 in the 4th dimension) by m, and
- divides by perspective.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>m</code></td>
- <td class="description last"><p>The matrix to apply.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="applyNormalMatrix" translate="no">.<a href="#applyNormalMatrix">applyNormalMatrix</a><span class="signature">( m : <span class="param-type">Matrix3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Multiplies this vector by the given normal matrix and normalizes
- the result.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>m</code></td>
- <td class="description last"><p>The normal matrix.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="applyQuaternion" translate="no">.<a href="#applyQuaternion">applyQuaternion</a><span class="signature">( q : <span class="param-type">Quaternion</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Applies the given Quaternion to this vector.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>q</code></td>
- <td class="description last"><p>The Quaternion.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>The components of this vector are rounded up to the nearest integer value.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="clamp" translate="no">.<a href="#clamp">clamp</a><span class="signature">( min : <span class="param-type">Vector3</span>, max : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>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.
- If this vector's x, y or z value is less than the min vector's x, y or z value,
- it is replaced by the corresponding value.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>min</code></td>
- <td class="description last"><p>The minimum x, y and z values.</p></td>
- </tr>
- <tr>
- <td class="name"><code>max</code></td>
- <td class="description last"><p>The maximum x, y and z values in the desired range.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>If this vector's length is greater than the max value, it is replaced by
- the max value.
- If this vector's length is less than the min value, it is replaced by the
- min value.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>min</code></td>
- <td class="description last"><p>The minimum value the vector length will be clamped to.</p></td>
- </tr>
- <tr>
- <td class="name"><code>max</code></td>
- <td class="description last"><p>The maximum value the vector length will be clamped to.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>If this vector's x, y or z values are greater than the max value, they are
- replaced by the max value.
- If this vector's x, y or z values are less than the min value, they are
- replaced by the min value.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>minVal</code></td>
- <td class="description last"><p>The minimum value the components will be clamped to.</p></td>
- </tr>
- <tr>
- <td class="name"><code>maxVal</code></td>
- <td class="description last"><p>The maximum value the components will be clamped to.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Returns a new vector with copied values from this instance.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Copies the values of the given vector to this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to copy.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="cross" translate="no">.<a href="#cross">cross</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Calculates the cross product of the given vector with this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to compute the cross product with.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The result of the cross product.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="crossVectors" translate="no">.<a href="#crossVectors">crossVectors</a><span class="signature">( a : <span class="param-type">Vector3</span>, b : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Calculates the cross product of the given vectors and stores the result
- in this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>a</code></td>
- <td class="description last"><p>The first vector.</p></td>
- </tr>
- <tr>
- <td class="name"><code>b</code></td>
- <td class="description last"><p>The second vector.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="distanceTo" translate="no">.<a href="#distanceTo">distanceTo</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : number</span> </h3>
- <div class="method">
- <div class="description">
- <p>Computes the distance from the given vector to this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to compute the distance to.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The distance.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="distanceToSquared" translate="no">.<a href="#distanceToSquared">distanceToSquared</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : number</span> </h3>
- <div class="method">
- <div class="description">
- <p>Computes the squared distance from the given vector to this instance.
- If you are just comparing the distance with another distance, you should compare
- the distance squared instead as it is slightly more efficient to calculate.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to compute the squared distance to.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The squared distance.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="divide" translate="no">.<a href="#divide">divide</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Divides this instance by the given vector.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to divide.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Divides this vector by the given scalar.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>scalar</code></td>
- <td class="description last"><p>The scalar to divide.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="dot" translate="no">.<a href="#dot">dot</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : number</span> </h3>
- <div class="method">
- <div class="description">
- <p>Calculates the dot product of the given vector with this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to compute the dot product with.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The result of the dot product.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : boolean</span> </h3>
- <div class="method">
- <div class="description">
- <p>Returns <code>true</code> if this vector is equal with the given one.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to test for equality.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> Whether this vector is equal with the given one.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>The components of this vector are rounded down to the nearest integer value.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="fromArray" translate="no">.<a href="#fromArray">fromArray</a><span class="signature">( array : <span class="param-type">Array.<number></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets this vector's x value to be <code>array[ offset ]</code>, y value to be <code>array[ offset + 1 ]</code>
- and z value to be <code>array[ offset + 2 ]</code>.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>array</code></td>
- <td class="description last"><p>An array holding the vector component values.</p></td>
- </tr>
- <tr>
- <td class="name"><code>offset</code></td>
- <td class="description last"><p>The offset into the array.<br/>Default is <code>0</code>.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="fromBufferAttribute" translate="no">.<a href="#fromBufferAttribute">fromBufferAttribute</a><span class="signature">( attribute : <span class="param-type">BufferAttribute</span>, index : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the components of this vector from the given buffer attribute.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>attribute</code></td>
- <td class="description last"><p>The buffer attribute holding vector data.</p></td>
- </tr>
- <tr>
- <td class="name"><code>index</code></td>
- <td class="description last"><p>The index into the attribute.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Returns the value of the vector component which matches the given index.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>index</code></td>
- <td class="description last"><p>The component index. <code>0</code> equals to x, <code>1</code> equals to y, <code>2</code> equals to z.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A vector component value.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z).</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The length of this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Computes the square of the Euclidean length (straight-line length) from
- (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should
- compare the length squared instead as it is slightly more efficient to calculate.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The square length of this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="lerp" translate="no">.<a href="#lerp">lerp</a><span class="signature">( v : <span class="param-type">Vector3</span>, alpha : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Linearly interpolates between the given vector and this instance, where
- alpha is the percent distance along the line - alpha = 0 will be this
- vector, and alpha = 1 will be the given one.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to interpolate towards.</p></td>
- </tr>
- <tr>
- <td class="name"><code>alpha</code></td>
- <td class="description last"><p>The interpolation factor, typically in the closed interval <code>[0, 1]</code>.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="lerpVectors" translate="no">.<a href="#lerpVectors">lerpVectors</a><span class="signature">( v1 : <span class="param-type">Vector3</span>, v2 : <span class="param-type">Vector3</span>, alpha : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Linearly interpolates between the given vectors, where alpha is the percent
- distance along the line - alpha = 0 will be first vector, and alpha = 1 will
- be the second one. The result is stored in this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v1</code></td>
- <td class="description last"><p>The first vector.</p></td>
- </tr>
- <tr>
- <td class="name"><code>v2</code></td>
- <td class="description last"><p>The second vector.</p></td>
- </tr>
- <tr>
- <td class="name"><code>alpha</code></td>
- <td class="description last"><p>The interpolation factor, typically in the closed interval <code>[0, 1]</code>.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="manhattanDistanceTo" translate="no">.<a href="#manhattanDistanceTo">manhattanDistanceTo</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : number</span> </h3>
- <div class="method">
- <div class="description">
- <p>Computes the Manhattan distance from the given vector to this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to compute the Manhattan distance to.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The Manhattan distance.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Computes the Manhattan length of this vector.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The length of this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="max" translate="no">.<a href="#max">max</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>If this vector's x, y or z value is less than the given vector's x, y or z
- value, replace that value with the corresponding max value.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="min" translate="no">.<a href="#min">min</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>If this vector's x, y or z value is greater than the given vector's x, y or z
- value, replace that value with the corresponding min value.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="multiply" translate="no">.<a href="#multiply">multiply</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Multiplies the given vector with this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to multiply.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Multiplies the given scalar value with all components of this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>scalar</code></td>
- <td class="description last"><p>The scalar to multiply.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="multiplyVectors" translate="no">.<a href="#multiplyVectors">multiplyVectors</a><span class="signature">( a : <span class="param-type">Vector3</span>, b : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Multiplies the given vectors and stores the result in this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>a</code></td>
- <td class="description last"><p>The first vector.</p></td>
- </tr>
- <tr>
- <td class="name"><code>b</code></td>
- <td class="description last"><p>The second vector.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Inverts this vector - i.e. sets x = -x, y = -y and z = -z.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Converts this vector to a unit vector - that is, sets it equal to a vector
- with the same direction as this one, but with a vector length of <code>1</code>.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="project" translate="no">.<a href="#project">project</a><span class="signature">( camera : <span class="param-type">Camera</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Projects this vector from world space into the camera's normalized
- device coordinate (NDC) space.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>camera</code></td>
- <td class="description last"><p>The camera.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="projectOnPlane" translate="no">.<a href="#projectOnPlane">projectOnPlane</a><span class="signature">( planeNormal : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Projects this vector onto a plane by subtracting this
- vector projected onto the plane's normal from this vector.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>planeNormal</code></td>
- <td class="description last"><p>The plane normal.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="projectOnVector" translate="no">.<a href="#projectOnVector">projectOnVector</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Projects this vector onto the given one.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to project to.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets each component of this vector to a pseudo-random value between <code>0</code> and
- <code>1</code>, excluding <code>1</code>.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets this vector to a uniformly random point on a unit sphere.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="reflect" translate="no">.<a href="#reflect">reflect</a><span class="signature">( normal : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Reflects this vector off a plane orthogonal to the given normal vector.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>normal</code></td>
- <td class="description last"><p>The (normalized) normal vector.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>The components of this vector are rounded to the nearest integer value</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>The components of this vector are rounded towards zero (up if negative,
- down if positive) to an integer value.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets the vector components.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>x</code></td>
- <td class="description last"><p>The value of the x component.</p></td>
- </tr>
- <tr>
- <td class="name"><code>y</code></td>
- <td class="description last"><p>The value of the y component.</p></td>
- </tr>
- <tr>
- <td class="name"><code>z</code></td>
- <td class="description last"><p>The value of the z component.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Allows to set a vector component with an index.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>index</code></td>
- <td class="description last"><p>The component index. <code>0</code> equals to x, <code>1</code> equals to y, <code>2</code> equals to z.</p></td>
- </tr>
- <tr>
- <td class="name"><code>value</code></td>
- <td class="description last"><p>The value to set.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromColor" translate="no">.<a href="#setFromColor">setFromColor</a><span class="signature">( c : <span class="param-type">Color</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the vector components from the RGB components of the
- given color.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>c</code></td>
- <td class="description last"><p>The color to set.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromCylindrical" translate="no">.<a href="#setFromCylindrical">setFromCylindrical</a><span class="signature">( c : <span class="param-type">Cylindrical</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the vector components from the given cylindrical coordinates.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>c</code></td>
- <td class="description last"><p>The cylindrical coordinates.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets the vector components from the given cylindrical coordinates.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>radius</code></td>
- <td class="description last"><p>The radius.</p></td>
- </tr>
- <tr>
- <td class="name"><code>theta</code></td>
- <td class="description last"><p>The theta angle in radians.</p></td>
- </tr>
- <tr>
- <td class="name"><code>y</code></td>
- <td class="description last"><p>The y value.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromEuler" translate="no">.<a href="#setFromEuler">setFromEuler</a><span class="signature">( e : <span class="param-type">Euler</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the vector components from the given Euler angles.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>e</code></td>
- <td class="description last"><p>The Euler angles to set.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromMatrix3Column" translate="no">.<a href="#setFromMatrix3Column">setFromMatrix3Column</a><span class="signature">( m : <span class="param-type">Matrix3</span>, index : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the vector components from the specified matrix column.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>m</code></td>
- <td class="description last"><p>The 3x3 matrix.</p></td>
- </tr>
- <tr>
- <td class="name"><code>index</code></td>
- <td class="description last"><p>The column index.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromMatrixColumn" translate="no">.<a href="#setFromMatrixColumn">setFromMatrixColumn</a><span class="signature">( m : <span class="param-type">Matrix4</span>, index : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the vector components from the specified matrix column.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>m</code></td>
- <td class="description last"><p>The 4x4 matrix.</p></td>
- </tr>
- <tr>
- <td class="name"><code>index</code></td>
- <td class="description last"><p>The column index.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromMatrixPosition" translate="no">.<a href="#setFromMatrixPosition">setFromMatrixPosition</a><span class="signature">( m : <span class="param-type">Matrix4</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the vector components to the position elements of the
- given transformation matrix.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>m</code></td>
- <td class="description last"><p>The 4x4 matrix.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromMatrixScale" translate="no">.<a href="#setFromMatrixScale">setFromMatrixScale</a><span class="signature">( m : <span class="param-type">Matrix4</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the vector components to the scale elements of the
- given transformation matrix.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>m</code></td>
- <td class="description last"><p>The 4x4 matrix.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromSpherical" translate="no">.<a href="#setFromSpherical">setFromSpherical</a><span class="signature">( s : <span class="param-type">Spherical</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the vector components from the given spherical coordinates.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>s</code></td>
- <td class="description last"><p>The spherical coordinates.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets the vector components from the given spherical coordinates.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>radius</code></td>
- <td class="description last"><p>The radius.</p></td>
- </tr>
- <tr>
- <td class="name"><code>phi</code></td>
- <td class="description last"><p>The phi angle in radians.</p></td>
- </tr>
- <tr>
- <td class="name"><code>theta</code></td>
- <td class="description last"><p>The theta angle in radians.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets this vector to a vector with the same direction as this one, but
- with the specified length.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>length</code></td>
- <td class="description last"><p>The new length of this vector.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets the vector components to the same value.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>scalar</code></td>
- <td class="description last"><p>The value to set for all vector components.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets the vector's x component to the given value</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>x</code></td>
- <td class="description last"><p>The value to set.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets the vector's y component to the given value</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>y</code></td>
- <td class="description last"><p>The value to set.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets the vector's z component to the given value</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>z</code></td>
- <td class="description last"><p>The value to set.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="sub" translate="no">.<a href="#sub">sub</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Subtracts the given vector from this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>v</code></td>
- <td class="description last"><p>The vector to subtract.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Subtracts the given scalar value from all components of this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>s</code></td>
- <td class="description last"><p>The scalar to subtract.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="subVectors" translate="no">.<a href="#subVectors">subVectors</a><span class="signature">( a : <span class="param-type">Vector3</span>, b : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Subtracts the given vectors and stores the result in this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>a</code></td>
- <td class="description last"><p>The first vector.</p></td>
- </tr>
- <tr>
- <td class="name"><code>b</code></td>
- <td class="description last"><p>The second vector.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="toArray" translate="no">.<a href="#toArray">toArray</a><span class="signature">( array : <span class="param-type">Array.<number></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : Array.<number></span> </h3>
- <div class="method">
- <div class="description">
- <p>Writes the components of this vector to the given array. If no array is provided,
- the method returns a new instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>array</code></td>
- <td class="description last"><p>The target array holding the vector components.<br/>Default is <code>[]</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>offset</code></td>
- <td class="description last"><p>Index of the first element in the array.<br/>Default is <code>0</code>.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The vector components.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="transformDirection" translate="no">.<a href="#transformDirection">transformDirection</a><span class="signature">( m : <span class="param-type">Matrix4</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Transforms the direction of this vector by a matrix (the upper left 3 x 3
- subset of the given 4x4 matrix and then normalizes the result.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>m</code></td>
- <td class="description last"><p>The matrix.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="unproject" translate="no">.<a href="#unproject">unproject</a><span class="signature">( camera : <span class="param-type">Camera</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Unprojects this vector from the camera's normalized device coordinate (NDC)
- space into world space.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>camera</code></td>
- <td class="description last"><p>The camera.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this vector.</dt>
- </dl>
- </div>
- <h2 class="subsection-title">Source</h2>
- <p>
- <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Vector3.js" target="_blank" rel="noopener" translate="no">src/math/Vector3.js</a>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|