Browse Source

Fix typings for Ray intersects*

According to the [docs](https://threejs.org/docs/#api/en/math/Ray) and after being bitten by this in practice, it looks like these 4 methods can return `null`... so the TS signature is wrong.
Tommaso Checchi 5 years ago
parent
commit
5507b510de
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/math/Ray.d.ts

+ 4 - 4
src/math/Ray.d.ts

@@ -26,12 +26,12 @@ export class Ray {
 		optionalPointOnRay?: Vector3,
 		optionalPointOnRay?: Vector3,
 		optionalPointOnSegment?: Vector3
 		optionalPointOnSegment?: Vector3
 	): number;
 	): number;
-	intersectSphere( sphere: Sphere, target: Vector3 ): Vector3;
+	intersectSphere( sphere: Sphere, target: Vector3 ): Vector3 | null;
 	intersectsSphere( sphere: Sphere ): boolean;
 	intersectsSphere( sphere: Sphere ): boolean;
 	distanceToPlane( plane: Plane ): number;
 	distanceToPlane( plane: Plane ): number;
-	intersectPlane( plane: Plane, target: Vector3 ): Vector3;
+	intersectPlane( plane: Plane, target: Vector3 ): Vector3 | null;
 	intersectsPlane( plane: Plane ): boolean;
 	intersectsPlane( plane: Plane ): boolean;
-	intersectBox( box: Box3, target: Vector3 ): Vector3;
+	intersectBox( box: Box3, target: Vector3 ): Vector3 | null;
 	intersectsBox( box: Box3 ): boolean;
 	intersectsBox( box: Box3 ): boolean;
 	intersectTriangle(
 	intersectTriangle(
 		a: Vector3,
 		a: Vector3,
@@ -39,7 +39,7 @@ export class Ray {
 		c: Vector3,
 		c: Vector3,
 		backfaceCulling: boolean,
 		backfaceCulling: boolean,
 		target: Vector3
 		target: Vector3
-	): Vector3;
+	): Vector3 | null;
 	applyMatrix4( matrix4: Matrix4 ): Ray;
 	applyMatrix4( matrix4: Matrix4 ): Ray;
 	equals( ray: Ray ): boolean;
 	equals( ray: Ray ): boolean;