Vector3.d.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. import { Euler } from './Euler';
  2. import { Matrix3 } from './Matrix3';
  3. import { Matrix4 } from './Matrix4';
  4. import { Quaternion } from './Quaternion';
  5. import { Camera } from './../cameras/Camera';
  6. import { Spherical } from './Spherical';
  7. import { Cylindrical } from './Cylindrical';
  8. import { BufferAttribute } from './../core/BufferAttribute';
  9. import { Vector } from './Vector2';
  10. /**
  11. * 3D vector.
  12. *
  13. * @example
  14. * var a = new THREE.Vector3( 1, 0, 0 );
  15. * var b = new THREE.Vector3( 0, 1, 0 );
  16. * var c = new THREE.Vector3();
  17. * c.crossVectors( a, b );
  18. *
  19. * @see <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Vector3.js">src/math/Vector3.js</a>
  20. *
  21. * ( class Vector3 implements Vector<Vector3> )
  22. */
  23. export class Vector3 implements Vector {
  24. constructor( x?: number, y?: number, z?: number );
  25. x: number;
  26. y: number;
  27. z: number;
  28. isVector3: true;
  29. /**
  30. * Sets value of this vector.
  31. */
  32. set( x: number, y: number, z: number ): this;
  33. /**
  34. * Sets all values of this vector.
  35. */
  36. setScalar( scalar: number ): this;
  37. /**
  38. * Sets x value of this vector.
  39. */
  40. setX( x: number ): Vector3;
  41. /**
  42. * Sets y value of this vector.
  43. */
  44. setY( y: number ): Vector3;
  45. /**
  46. * Sets z value of this vector.
  47. */
  48. setZ( z: number ): Vector3;
  49. setComponent( index: number, value: number ): this;
  50. getComponent( index: number ): number;
  51. /**
  52. * Clones this vector.
  53. */
  54. clone(): this;
  55. /**
  56. * Copies value of v to this vector.
  57. */
  58. copy( v: Vector3 ): this;
  59. /**
  60. * Adds v to this vector.
  61. */
  62. add( a: Vector3, b?: Vector3 ): this;
  63. addScalar( s: number ): this;
  64. addScaledVector( v: Vector3, s: number ): this;
  65. /**
  66. * Sets this vector to a + b.
  67. */
  68. addVectors( a: Vector3, b: Vector3 ): this;
  69. /**
  70. * Subtracts v from this vector.
  71. */
  72. sub( a: Vector3 ): this;
  73. subScalar( s: number ): this;
  74. /**
  75. * Sets this vector to a - b.
  76. */
  77. subVectors( a: Vector3, b: Vector3 ): this;
  78. multiply( v: Vector3 ): this;
  79. /**
  80. * Multiplies this vector by scalar s.
  81. */
  82. multiplyScalar( s: number ): this;
  83. multiplyVectors( a: Vector3, b: Vector3 ): this;
  84. applyEuler( euler: Euler ): this;
  85. applyAxisAngle( axis: Vector3, angle: number ): this;
  86. applyMatrix3( m: Matrix3 ): this;
  87. applyMatrix4( m: Matrix4 ): this;
  88. applyQuaternion( q: Quaternion ): this;
  89. project( camera: Camera ): this;
  90. unproject( camera: Camera ): this;
  91. transformDirection( m: Matrix4 ): this;
  92. divide( v: Vector3 ): this;
  93. /**
  94. * Divides this vector by scalar s.
  95. * Set vector to ( 0, 0, 0 ) if s == 0.
  96. */
  97. divideScalar( s: number ): this;
  98. min( v: Vector3 ): this;
  99. max( v: Vector3 ): this;
  100. clamp( min: Vector3, max: Vector3 ): this;
  101. clampScalar( min: number, max: number ): this;
  102. clampLength( min: number, max: number ): this;
  103. floor(): this;
  104. ceil(): this;
  105. round(): this;
  106. roundToZero(): this;
  107. /**
  108. * Inverts this vector.
  109. */
  110. negate(): this;
  111. /**
  112. * Computes dot product of this vector and v.
  113. */
  114. dot( v: Vector3 ): number;
  115. /**
  116. * Computes squared length of this vector.
  117. */
  118. lengthSq(): number;
  119. /**
  120. * Computes length of this vector.
  121. */
  122. length(): number;
  123. /**
  124. * Computes Manhattan length of this vector.
  125. * http://en.wikipedia.org/wiki/Taxicab_geometry
  126. *
  127. * @deprecated Use {@link Vector3#manhattanLength .manhattanLength()} instead.
  128. */
  129. lengthManhattan(): number;
  130. /**
  131. * Computes the Manhattan length of this vector.
  132. *
  133. * @return {number}
  134. *
  135. * @see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry}
  136. */
  137. manhattanLength(): number;
  138. /**
  139. * Computes the Manhattan length (distance) from this vector to the given vector v
  140. *
  141. * @param {Vector3} v
  142. *
  143. * @return {number}
  144. *
  145. * @see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry}
  146. */
  147. manhattanDistanceTo( v: Vector3 ): number;
  148. /**
  149. * Normalizes this vector.
  150. */
  151. normalize(): this;
  152. /**
  153. * Normalizes this vector and multiplies it by l.
  154. */
  155. setLength( l: number ): this;
  156. lerp( v: Vector3, alpha: number ): this;
  157. lerpVectors( v1: Vector3, v2: Vector3, alpha: number ): this;
  158. /**
  159. * Sets this vector to cross product of itself and v.
  160. */
  161. cross( a: Vector3, w?: Vector3 ): this;
  162. /**
  163. * Sets this vector to cross product of a and b.
  164. */
  165. crossVectors( a: Vector3, b: Vector3 ): this;
  166. projectOnVector( v: Vector3 ): this;
  167. projectOnPlane( planeNormal: Vector3 ): this;
  168. reflect( vector: Vector3 ): this;
  169. angleTo( v: Vector3 ): number;
  170. /**
  171. * Computes distance of this vector to v.
  172. */
  173. distanceTo( v: Vector3 ): number;
  174. /**
  175. * Computes squared distance of this vector to v.
  176. */
  177. distanceToSquared( v: Vector3 ): number;
  178. /**
  179. * @deprecated Use {@link Vector3#manhattanDistanceTo .manhattanDistanceTo()} instead.
  180. */
  181. distanceToManhattan( v: Vector3 ): number;
  182. setFromSpherical( s: Spherical ): this;
  183. setFromCylindrical( s: Cylindrical ): this;
  184. setFromMatrixPosition( m: Matrix4 ): this;
  185. setFromMatrixScale( m: Matrix4 ): this;
  186. setFromMatrixColumn( matrix: Matrix4, index: number ): this;
  187. /**
  188. * Checks for strict equality of this vector and v.
  189. */
  190. equals( v: Vector3 ): boolean;
  191. fromArray( xyz: number[], offset?: number ): Vector3;
  192. /**
  193. * Returns an array [x, y, z], or copies x, y and z into the provided array.
  194. * @param array (optional) array to store the vector to. If this is not provided, a new array will be created.
  195. * @param offset (optional) optional offset into the array.
  196. * @return The created or provided array.
  197. */
  198. toArray( xyz?: number[], offset?: number ): number[];
  199. /**
  200. * Copies x, y and z into the provided array-like.
  201. * @param array array-like to store the vector to.
  202. * @param offset (optional) optional offset into the array.
  203. * @return The provided array-like.
  204. */
  205. toArray( xyz: ArrayLike<number>, offset?: number ): ArrayLike<number>;
  206. fromBufferAttribute(
  207. attribute: BufferAttribute,
  208. index: number,
  209. offset?: number
  210. ): this;
  211. }
粤ICP备19079148号