Bläddra i källkod

Merge pull request #20614 from Antony74/bugfix/19303-typescript-support-valid-usage

TS: Added additional type information toArray( ) to support valid usage.
Mr.doob 4 år sedan
förälder
incheckning
44ea080d15
5 ändrade filer med 26 tillägg och 0 borttagningar
  1. 7 0
      src/math/Matrix3.d.ts
  2. 9 0
      src/math/Matrix4.d.ts
  3. 3 0
      src/math/Vector2.d.ts
  4. 4 0
      src/math/Vector3.d.ts
  5. 3 0
      src/math/Vector4.d.ts

+ 7 - 0
src/math/Matrix3.d.ts

@@ -1,6 +1,12 @@
 import { Matrix4 } from './Matrix4';
 import { Vector3 } from './Vector3';
 
+type Matrix3Tuple = [
+	number, number, number,
+	number, number, number,
+	number, number, number,
+];
+
 /**
  * ( interface Matrix<T> )
  */
@@ -125,6 +131,7 @@ export class Matrix3 implements Matrix {
 	 * @return The created or provided array.
 	 */
 	toArray( array?: number[], offset?: number ): number[];
+	toArray( array?: Matrix3Tuple, offset?: 0 ): Matrix3Tuple;
 
 	/**
 	 * Copies he values of this matrix into the provided array-like.

+ 9 - 0
src/math/Matrix4.d.ts

@@ -2,6 +2,14 @@ import { Vector3 } from './Vector3';
 import { Euler } from './Euler';
 import { Quaternion } from './Quaternion';
 import { Matrix } from './Matrix3';
+
+type Matrix4Tuple = [
+	number, number, number, number,
+	number, number, number, number,
+	number, number, number, number,
+	number, number, number, number,
+];
+
 /**
  * A 4x4 Matrix.
  *
@@ -235,6 +243,7 @@ export class Matrix4 implements Matrix {
 	 * @return The created or provided array.
 	 */
 	toArray( array?: number[], offset?: number ): number[];
+	toArray( array?: Matrix4Tuple, offset?: 0 ): Matrix4Tuple;
 
 	/**
 	 * Copies he values of this matrix into the provided array-like.

+ 3 - 0
src/math/Vector2.d.ts

@@ -1,6 +1,8 @@
 import { Matrix3 } from './Matrix3';
 import { BufferAttribute } from './../core/BufferAttribute';
 
+type Vector2tuple = [number, number];
+
 /**
  * ( interface Vector<T> )
  *
@@ -427,6 +429,7 @@ export class Vector2 implements Vector {
 	 * @return The created or provided array.
 	 */
 	toArray( array?: number[], offset?: number ): number[];
+	toArray( array?: Vector2tuple, offset?: 0 ): Vector2tuple;
 
 	/**
 	 * Copies x and y into the provided array-like.

+ 4 - 0
src/math/Vector3.d.ts

@@ -8,6 +8,9 @@ import { Cylindrical } from './Cylindrical';
 import { BufferAttribute } from './../core/BufferAttribute';
 import { InterleavedBufferAttribute } from './../core/InterleavedBufferAttribute';
 import { Vector } from './Vector2';
+
+type Vector3Tuple = [number, number, number];
+
 /**
  * 3D vector.
  *
@@ -284,6 +287,7 @@ export class Vector3 implements Vector {
 	 * @return The created or provided array.
 	 */
 	toArray( array?: number[], offset?: number ): number[];
+	toArray( array?: Vector3Tuple, offset?: 0 ): Vector3Tuple;
 
 	/**
 	 * Copies x, y and z into the provided array-like.

+ 3 - 0
src/math/Vector4.d.ts

@@ -4,6 +4,8 @@ import { Matrix3 } from './Matrix3';
 import { BufferAttribute } from './../core/BufferAttribute';
 import { Vector } from './Vector2';
 
+type Vector4Tuple = [number, number, number, number];
+
 /**
  * 4D vector.
  *
@@ -211,6 +213,7 @@ export class Vector4 implements Vector {
 	 * @return The created or provided array.
 	 */
 	toArray( array?: number[], offset?: number ): number[];
+	toArray( array?: Vector4Tuple, offset?: 0 ): Vector4Tuple;
 
 	/**
 	 * Copies x, y, z and w into the provided array-like.