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