Browse Source

Add makeEmpty function to Sphere

samfoster 5 years ago
parent
commit
c0a69a1f79
4 changed files with 16 additions and 0 deletions
  1. 3 0
      docs/api/en/math/Sphere.html
  2. 3 0
      docs/api/zh/math/Sphere.html
  3. 1 0
      src/math/Sphere.d.ts
  4. 9 0
      src/math/Sphere.js

+ 3 - 0
docs/api/en/math/Sphere.html

@@ -76,6 +76,9 @@
 		<h3>[method:Boolean empty]()</h3>
 		<h3>[method:Boolean empty]()</h3>
 		<p>Checks to see if the sphere is empty (the radius set to 0).</p>
 		<p>Checks to see if the sphere is empty (the radius set to 0).</p>
 
 
+		<h3>[method:Sphere makeEmpty]()</h3>
+		<p>Makes the sphere empty by setting [page:.center center] to (0, 0, 0) and [page:.radius radius] to 0.</p>
+
 		<h3>[method:Boolean equals]( [param:Sphere sphere] )</h3>
 		<h3>[method:Boolean equals]( [param:Sphere sphere] )</h3>
 		<p>
 		<p>
 		Checks to see if the two spheres' centers and radii are equal.
 		Checks to see if the two spheres' centers and radii are equal.

+ 3 - 0
docs/api/zh/math/Sphere.html

@@ -73,6 +73,9 @@
 		<h3>[method:Boolean empty]()</h3>
 		<h3>[method:Boolean empty]()</h3>
 		<p>检查球是否为空(其半径设为了0).</p>
 		<p>检查球是否为空(其半径设为了0).</p>
 
 
+		<h3>[method:Sphere makeEmpty]()</h3>
+		<p>Makes the sphere empty by setting [page:.center center] to (0, 0, 0) and [page:.radius radius] to 0.</p>
+
 		<h3>[method:Boolean equals]( [param:Sphere sphere] )</h3>
 		<h3>[method:Boolean equals]( [param:Sphere sphere] )</h3>
 		<p>
 		<p>
 		检查这两个球的球心与半径是否相等。
 		检查这两个球的球心与半径是否相等。

+ 1 - 0
src/math/Sphere.d.ts

@@ -15,6 +15,7 @@ export class Sphere {
 	clone(): this;
 	clone(): this;
 	copy( sphere: Sphere ): this;
 	copy( sphere: Sphere ): this;
 	empty(): boolean;
 	empty(): boolean;
+	makeEmpty(): this;
 	containsPoint( point: Vector3 ): boolean;
 	containsPoint( point: Vector3 ): boolean;
 	distanceToPoint( point: Vector3 ): number;
 	distanceToPoint( point: Vector3 ): number;
 	intersectsSphere( sphere: Sphere ): boolean;
 	intersectsSphere( sphere: Sphere ): boolean;

+ 9 - 0
src/math/Sphere.js

@@ -75,6 +75,15 @@ Object.assign( Sphere.prototype, {
 
 
 	},
 	},
 
 
+	makeEmpty: function () {
+
+		this.center.set( 0, 0, 0 );
+		this.radius = 0;
+
+		return this;
+
+	},
+
 	containsPoint: function ( point ) {
 	containsPoint: function ( point ) {
 
 
 		return ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );
 		return ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );