|
@@ -4,40 +4,40 @@ import { MathUtils } from './MathUtils.js';
|
|
|
const _startP = new Vector3();
|
|
|
const _startEnd = new Vector3();
|
|
|
|
|
|
-function Line3( start, end ) {
|
|
|
+class Line3 {
|
|
|
|
|
|
- this.start = ( start !== undefined ) ? start : new Vector3();
|
|
|
- this.end = ( end !== undefined ) ? end : new Vector3();
|
|
|
+ constructor( start, end ) {
|
|
|
|
|
|
-}
|
|
|
+ this.start = ( start !== undefined ) ? start : new Vector3();
|
|
|
+ this.end = ( end !== undefined ) ? end : new Vector3();
|
|
|
|
|
|
-Object.assign( Line3.prototype, {
|
|
|
+ }
|
|
|
|
|
|
- set: function ( start, end ) {
|
|
|
+ set( start, end ) {
|
|
|
|
|
|
this.start.copy( start );
|
|
|
this.end.copy( end );
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- clone: function () {
|
|
|
+ clone() {
|
|
|
|
|
|
return new this.constructor().copy( this );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- copy: function ( line ) {
|
|
|
+ copy( line ) {
|
|
|
|
|
|
this.start.copy( line.start );
|
|
|
this.end.copy( line.end );
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- getCenter: function ( target ) {
|
|
|
+ getCenter( target ) {
|
|
|
|
|
|
if ( target === undefined ) {
|
|
|
|
|
@@ -48,9 +48,9 @@ Object.assign( Line3.prototype, {
|
|
|
|
|
|
return target.addVectors( this.start, this.end ).multiplyScalar( 0.5 );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- delta: function ( target ) {
|
|
|
+ delta( target ) {
|
|
|
|
|
|
if ( target === undefined ) {
|
|
|
|
|
@@ -61,21 +61,21 @@ Object.assign( Line3.prototype, {
|
|
|
|
|
|
return target.subVectors( this.end, this.start );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- distanceSq: function () {
|
|
|
+ distanceSq() {
|
|
|
|
|
|
return this.start.distanceToSquared( this.end );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- distance: function () {
|
|
|
+ distance() {
|
|
|
|
|
|
return this.start.distanceTo( this.end );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- at: function ( t, target ) {
|
|
|
+ at( t, target ) {
|
|
|
|
|
|
if ( target === undefined ) {
|
|
|
|
|
@@ -86,9 +86,9 @@ Object.assign( Line3.prototype, {
|
|
|
|
|
|
return this.delta( target ).multiplyScalar( t ).add( this.start );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- closestPointToPointParameter: function ( point, clampToLine ) {
|
|
|
+ closestPointToPointParameter( point, clampToLine ) {
|
|
|
|
|
|
_startP.subVectors( point, this.start );
|
|
|
_startEnd.subVectors( this.end, this.start );
|
|
@@ -106,9 +106,9 @@ Object.assign( Line3.prototype, {
|
|
|
|
|
|
return t;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- closestPointToPoint: function ( point, clampToLine, target ) {
|
|
|
+ closestPointToPoint( point, clampToLine, target ) {
|
|
|
|
|
|
const t = this.closestPointToPointParameter( point, clampToLine );
|
|
|
|
|
@@ -121,24 +121,24 @@ Object.assign( Line3.prototype, {
|
|
|
|
|
|
return this.delta( target ).multiplyScalar( t ).add( this.start );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- applyMatrix4: function ( matrix ) {
|
|
|
+ applyMatrix4( matrix ) {
|
|
|
|
|
|
this.start.applyMatrix4( matrix );
|
|
|
this.end.applyMatrix4( matrix );
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- equals: function ( line ) {
|
|
|
+ equals( line ) {
|
|
|
|
|
|
return line.start.equals( this.start ) && line.end.equals( this.end );
|
|
|
|
|
|
}
|
|
|
|
|
|
-} );
|
|
|
+}
|
|
|
|
|
|
|
|
|
export { Line3 };
|