Vector3.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <h1>[name]</h1>
  2. <div class="desc">3D vector.</div>
  3. <h2>Example</h2>
  4. <code>var a = new THREE.Vector3( 1, 0, 0 );
  5. var b = new THREE.Vector3( 0, 1, 0 );
  6. var c = new THREE.Vector3();
  7. c.cross( a, b );
  8. </code>
  9. <h2>Constructor</h2>
  10. <h3>[name]( [page:Float x], [page:Float y], [page:Float z] )</h3>
  11. <h2>Properties</h2>
  12. <h3>.[page:Float x]</h3>
  13. <h3>.[page:Float y]</h3>
  14. <h3>.[page:Float z]</h3>
  15. <h2>Methods</h2>
  16. <h3>.set( [page:Float x], [page:Float y], [page:Float z] ) [page:Vector3]</h3>
  17. <div>
  18. Sets value of this vector.
  19. </div>
  20. <h3>.setX( [page:Float x] ) [page:Vector3]</h3>
  21. <div>
  22. Sets x value of this vector.
  23. </div>
  24. <h3>.setY( [page:Float y] ) [page:Vector3]</h3>
  25. <div>
  26. Sets y value of this vector.
  27. </div>
  28. <h3>.setZ( [page:Float z] ) [page:Vector3]</h3>
  29. <div>
  30. Sets z value of this vector.
  31. </div>
  32. <h3>.copy( [page:Vector3 v] ) [page:Vector3]</h3>
  33. <div>
  34. Copies value of *v* to this vector.
  35. </div>
  36. <h3>.add( [page:Vector3 a], [page:Vector3 b] ) [page:Vector3]</h3>
  37. <div>
  38. Sets this vector to *a + b*.
  39. </div>
  40. <h3>.addSelf( [page:Vector3 v] ) [page:Vector3]</h3>
  41. <div>
  42. Adds *v* to this vector.
  43. </div>
  44. <h3>.sub( [page:Vector3 a], [page:Vector3 b] ) [page:Vector3]</h3>
  45. <div>
  46. Sets this vector to *a - b*.
  47. </div>
  48. <h3>.subSelf( [page:Vector3 v] ) [page:Vector3]</h3>
  49. <div>
  50. Subtracts *v* from this vector.
  51. </div>
  52. <h3>.multiplyScalar( [page:Float s] ) [page:Vector3]</h3>
  53. <div>
  54. Multiplies this vector by scalar *s*.
  55. </div>
  56. <h3>.divideScalar( [page:Float s] ) [page:Vector3]</h3>
  57. <div>
  58. Divides this vector by scalar *s*.<br />
  59. Set vector to *( 0, 0, 0 )* if *s == 0*.
  60. </div>
  61. <h3>.negate() [page:Vector3]</h3>
  62. <div>
  63. Inverts this vector.
  64. </div>
  65. <h3>.dot( [page:Vector3 v] ) [page:Float]</h3>
  66. <div>
  67. Computes dot product of this vector and *v*.
  68. </div>
  69. <h3>.lengthSq() [page:Float]</h3>
  70. <div>
  71. Computes squared length of this vector.
  72. </div>
  73. <h3>.length() [page:Float]</h3>
  74. <div>
  75. Computes length of this vector.
  76. </div>
  77. <h3>.lengthManhattan() [page:Float]</h3>
  78. <div>
  79. Computes Manhattan length of this vector.<br />
  80. [link:http://en.wikipedia.org/wiki/Taxicab_geometry]
  81. </div>
  82. <h3>.normalize() [page:Vector3]</h3>
  83. <div>
  84. Normalizes this vector.
  85. </div>
  86. <h3>.distanceTo( [page:Vector3 v] ) [page:Vector3]</h3>
  87. <div>
  88. Computes distance of this vector to *v*.
  89. </div>
  90. <h3>.distanceToSquared( [page:Vector3 v] ) [page:Vector3]</h3>
  91. <div>
  92. Computes squared distance of this vector to *v*.
  93. </div>
  94. <h3>.normalize() [page:Vector3]</h3>
  95. <div>
  96. Normalizes this vector.
  97. </div>
  98. <h3>.setLength( [page:Float l] ) [page:Vector3]</h3>
  99. <div>
  100. Normalizes this vector and multiplies it by *l*.
  101. </div>
  102. <h3>.cross( [page:Vector3 a], [page:Vector3 b] ) [page:Vector3]</h3>
  103. <div>
  104. Sets this vector to cross product of *a* and *b*.
  105. </div>
  106. <h3>.crossSelf( [page:Vector3 v] ) [page:Vector3]</h3>
  107. <div>
  108. Sets this vector to cross product of itself and *v*.
  109. </div>
  110. <h3>.getPositionFromMatrix( [page:Matrix4 m] ) [page:Vector3]</h3>
  111. <div>
  112. Sets this vector extracting position from matrix transform.
  113. </div>
  114. <h3>.getRotationFromMatrix( [page:Matrix4 m] ) [page:Vector3]</h3>
  115. <div>
  116. Sets this vector extracting Euler angles rotation from matrix transform.
  117. </div>
  118. <h3>.getScaleFromMatrix( [page:Matrix4 m] ) [page:Vector3]</h3>
  119. <div>
  120. Sets this vector extracting scale from matrix transform.
  121. </div>
  122. <h3>.equals( [page:Vector3 v] ) [page:Vector3]</h3>
  123. <div>
  124. Checks for strict equality of this vector and *v*.
  125. </div>
  126. <h3>.isZero() [page:Boolean]</h3>
  127. <div>
  128. Checks if length of this vector is within small epsilon (*0.0001*).
  129. </div>
  130. <h3>.clone() [page:Vector3]</h3>
  131. <div>
  132. Clones this vector.
  133. </div>
  134. <h2>Source</h2>
  135. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]