| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Vector4 - 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">Vector4</h1>
- <section>
- <header>
- <div class="class-description"><p>Class representing a 4D vector. A 4D vector is an ordered quadruplet of numbers
- (labeled x, y, z and w), which can be used to represent a number of things, such as:</p>
- <ul>
- <li>A point in 4D space.</li>
- <li>A direction and length in 4D space. In three.js the length will
- always be the Euclidean distance(straight-line distance) from <code>(0, 0, 0, 0)</code> to <code>(x, y, z, w)</code>
- and the direction is also measured from <code>(0, 0, 0, 0)</code> towards <code>(x, y, z, w)</code>.</li>
- <li>Any arbitrary ordered quadruplet of numbers.</li>
- </ul>
- <p>There are other things a 4D vector can be used to represent, however these
- are the most common uses in <em>three.js</em>.</p>
- <p>Iterating through a vector instance will yield its components <code>(x, y, z, w)</code> in
- the corresponding order.</p></div>
- <h2>Code Example</h2>
- <div translate="no"><pre><code class="language-js">const a = new THREE.Vector4( 0, 1, 0, 0 );
- //no arguments; will be initialised to (0, 0, 0, 1)
- const b = new THREE.Vector4( );
- const d = a.dot( b );
- </code></pre></div>
- </header>
- <article>
- <div class="container-overview">
- <h2>Constructor</h2>
- <h3 class="name name-method" id="Vector4" translate="no">new <a href="#Vector4">Vector4</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>, w : <span class="param-type">number</span> )</span> </h3>
- <div class="method">
- <div class="description">
- <p>Constructs a new 4D 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>
- <tr>
- <td class="name"><code>w</code></td>
- <td class="description last"><p>The w value of this vector.<br/>Default is <code>1</code>.</p></td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <h2 class="subsection-title">Properties</h2>
- <div class="member">
- <h3 class="name" id="height" translate="no">.<a href="#height">height</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>Alias for <a href="Vector4.html#w">Vector4#w</a>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="isVector4" translate="no">.<a href="#isVector4">isVector4</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="w" translate="no">.<a href="#w">w</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The w value of this vector.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="width" translate="no">.<a href="#width">width</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>Alias for <a href="Vector4.html#z">Vector4#z</a>.</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">Vector4</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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="Vector4.html">Vector4</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">Vector4</span>, s : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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">Vector4</span>, b : <span class="param-type">Vector4</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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="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="Vector4.html">Vector4</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Multiplies this vector with the given 4x4 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="ceil" translate="no">.<a href="#ceil">ceil</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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">Vector4</span>, max : <span class="param-type">Vector4</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>If this vector's x, y, z or w value is greater than the max vector's x, y, z or w
- value, it is replaced by the corresponding value.
- If this vector's x, y, z or w value is less than the min vector's x, y, z or w 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="Vector4.html">Vector4</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="Vector4.html">Vector4</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>If this vector's x, y, z or w values are greater than the max value, they are
- replaced by the max value.
- If this vector's x, y, z or w 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="Vector4.html">Vector4</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 | Vector4</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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="divide" translate="no">.<a href="#divide">divide</a><span class="signature">( v : <span class="param-type">Vector4</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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="Vector4.html">Vector4</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">Vector4</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">Vector4</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="Vector4.html">Vector4</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="Vector4.html">Vector4</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>,
- z value to be <code>array[ offset + 2 ]</code>, w value to be <code>array[ offset + 3 ]</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="Vector4.html">Vector4</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, <code>3</code> equals to w.</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, 0) to (x, y, z, w).</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, 0) to (x, y, z, w). 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">Vector4</span>, alpha : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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">Vector4</span>, v2 : <span class="param-type">Vector4</span>, alpha : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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="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">Vector4</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>If this vector's x, y, z or w value is less than the given vector's x, y, z or w
- 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">Vector4</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>If this vector's x, y, z or w value is greater than the given vector's x, y, z or w
- 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">Vector4</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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="Vector4.html">Vector4</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="negate" translate="no">.<a href="#negate">negate</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector4.html">Vector4</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Inverts this vector - i.e. sets x = -x, y = -y, z = -z, w = -w.</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="Vector4.html">Vector4</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="random" translate="no">.<a href="#random">random</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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="round" translate="no">.<a href="#round">round</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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="Vector4.html">Vector4</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>, w : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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>
- <tr>
- <td class="name"><code>w</code></td>
- <td class="description last"><p>The value of the w 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="setAxisAngleFromQuaternion" translate="no">.<a href="#setAxisAngleFromQuaternion">setAxisAngleFromQuaternion</a><span class="signature">( q : <span class="param-type">Quaternion</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the x, y and z components of this
- vector to the quaternion's axis and w to the angle.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>q</code></td>
- <td class="description last"><p>The Quaternion 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="setAxisAngleFromRotationMatrix" translate="no">.<a href="#setAxisAngleFromRotationMatrix">setAxisAngleFromRotationMatrix</a><span class="signature">( m : <span class="param-type">Matrix4</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the x, y and z components of this
- vector to the axis of rotation and w to the angle.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>m</code></td>
- <td class="description last"><p>A 4x4 matrix of which the upper left 3x3 matrix is a pure rotation 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="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="Vector4.html">Vector4</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, <code>3</code> equals to w.</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="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="Vector4.html">Vector4</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="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="Vector4.html">Vector4</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="Vector4.html">Vector4</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="setW" translate="no">.<a href="#setW">setW</a><span class="signature">( w : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the vector's w component to the given value</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>w</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="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="Vector4.html">Vector4</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="Vector4.html">Vector4</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="Vector4.html">Vector4</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">Vector4</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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="Vector4.html">Vector4</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">Vector4</span>, b : <span class="param-type">Vector4</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</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>
- <h2 class="subsection-title">Source</h2>
- <p>
- <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Vector4.js" target="_blank" rel="noopener" translate="no">src/math/Vector4.js</a>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|