Vector4.d.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. import { Matrix4 } from './Matrix4';
  2. import { Quaternion } from './Quaternion';
  3. import { Matrix3 } from './Matrix3';
  4. import { BufferAttribute } from './../core/BufferAttribute';
  5. import { Vector } from './Vector2';
  6. /**
  7. * 4D vector.
  8. *
  9. * ( class Vector4 implements Vector<Vector4> )
  10. */
  11. export class Vector4 implements Vector {
  12. constructor( x?: number, y?: number, z?: number, w?: number );
  13. x: number;
  14. y: number;
  15. z: number;
  16. w: number;
  17. width: number;
  18. height: number;
  19. isVector4: true;
  20. /**
  21. * Sets value of this vector.
  22. */
  23. set( x: number, y: number, z: number, w: number ): this;
  24. /**
  25. * Sets all values of this vector.
  26. */
  27. setScalar( scalar: number ): this;
  28. /**
  29. * Sets X component of this vector.
  30. */
  31. setX( x: number ): this;
  32. /**
  33. * Sets Y component of this vector.
  34. */
  35. setY( y: number ): this;
  36. /**
  37. * Sets Z component of this vector.
  38. */
  39. setZ( z: number ): this;
  40. /**
  41. * Sets w component of this vector.
  42. */
  43. setW( w: number ): this;
  44. setComponent( index: number, value: number ): this;
  45. getComponent( index: number ): number;
  46. /**
  47. * Clones this vector.
  48. */
  49. clone(): this;
  50. /**
  51. * Copies value of v to this vector.
  52. */
  53. copy( v: Vector4 ): this;
  54. /**
  55. * Adds v to this vector.
  56. */
  57. add( v: Vector4, w?: Vector4 ): this;
  58. addScalar( scalar: number ): this;
  59. /**
  60. * Sets this vector to a + b.
  61. */
  62. addVectors( a: Vector4, b: Vector4 ): this;
  63. addScaledVector( v: Vector4, s: number ): this;
  64. /**
  65. * Subtracts v from this vector.
  66. */
  67. sub( v: Vector4 ): this;
  68. subScalar( s: number ): this;
  69. /**
  70. * Sets this vector to a - b.
  71. */
  72. subVectors( a: Vector4, b: Vector4 ): this;
  73. /**
  74. * Multiplies this vector by scalar s.
  75. */
  76. multiplyScalar( s: number ): this;
  77. applyMatrix4( m: Matrix4 ): this;
  78. /**
  79. * Divides this vector by scalar s.
  80. * Set vector to ( 0, 0, 0 ) if s == 0.
  81. */
  82. divideScalar( s: number ): this;
  83. /**
  84. * http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
  85. * @param q is assumed to be normalized
  86. */
  87. setAxisAngleFromQuaternion( q: Quaternion ): this;
  88. /**
  89. * http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
  90. * @param m assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
  91. */
  92. setAxisAngleFromRotationMatrix( m: Matrix3 ): this;
  93. min( v: Vector4 ): this;
  94. max( v: Vector4 ): this;
  95. clamp( min: Vector4, max: Vector4 ): this;
  96. clampScalar( min: number, max: number ): this;
  97. floor(): this;
  98. ceil(): this;
  99. round(): this;
  100. roundToZero(): this;
  101. /**
  102. * Inverts this vector.
  103. */
  104. negate(): this;
  105. /**
  106. * Computes dot product of this vector and v.
  107. */
  108. dot( v: Vector4 ): number;
  109. /**
  110. * Computes squared length of this vector.
  111. */
  112. lengthSq(): number;
  113. /**
  114. * Computes length of this vector.
  115. */
  116. length(): number;
  117. /**
  118. * Computes the Manhattan length of this vector.
  119. *
  120. * @return {number}
  121. *
  122. * @see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry}
  123. */
  124. manhattanLength(): number;
  125. /**
  126. * Normalizes this vector.
  127. */
  128. normalize(): this;
  129. /**
  130. * Normalizes this vector and multiplies it by l.
  131. */
  132. setLength( length: number ): this;
  133. /**
  134. * Linearly interpolate between this vector and v with alpha factor.
  135. */
  136. lerp( v: Vector4, alpha: number ): this;
  137. lerpVectors( v1: Vector4, v2: Vector4, alpha: number ): this;
  138. /**
  139. * Checks for strict equality of this vector and v.
  140. */
  141. equals( v: Vector4 ): boolean;
  142. fromArray( xyzw: number[], offset?: number ): this;
  143. toArray( xyzw?: number[], offset?: number ): number[];
  144. fromBufferAttribute(
  145. attribute: BufferAttribute,
  146. index: number,
  147. offset?: number
  148. ): this;
  149. }