Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math area and space: move to es6 classes #20076

Merged
merged 9 commits into from
Aug 15, 2020
Merged
Prev Previous commit
Next Next commit
Frustum: Convert to es6 class
yomotsu committed Aug 15, 2020
commit 676ad636dba544179447a0a4a43da1c838ce5aaa
58 changes: 29 additions & 29 deletions src/math/Frustum.js
Original file line number Diff line number Diff line change
@@ -5,24 +5,24 @@ import { Plane } from './Plane.js';
const _sphere = new Sphere();
const _vector = new Vector3();

function Frustum( p0, p1, p2, p3, p4, p5 ) {
class Frustum {

this.planes = [
constructor( p0, p1, p2, p3, p4, p5 ) {

( p0 !== undefined ) ? p0 : new Plane(),
( p1 !== undefined ) ? p1 : new Plane(),
( p2 !== undefined ) ? p2 : new Plane(),
( p3 !== undefined ) ? p3 : new Plane(),
( p4 !== undefined ) ? p4 : new Plane(),
( p5 !== undefined ) ? p5 : new Plane()
this.planes = [

];
( p0 !== undefined ) ? p0 : new Plane(),
( p1 !== undefined ) ? p1 : new Plane(),
( p2 !== undefined ) ? p2 : new Plane(),
( p3 !== undefined ) ? p3 : new Plane(),
( p4 !== undefined ) ? p4 : new Plane(),
( p5 !== undefined ) ? p5 : new Plane()

}
];

Object.assign( Frustum.prototype, {
}

set: function ( p0, p1, p2, p3, p4, p5 ) {
set( p0, p1, p2, p3, p4, p5 ) {

const planes = this.planes;

@@ -35,15 +35,15 @@ Object.assign( Frustum.prototype, {

return this;

},
}

clone: function () {
clone() {

return new this.constructor().copy( this );

},
}

copy: function ( frustum ) {
copy( frustum ) {

const planes = this.planes;

@@ -55,9 +55,9 @@ Object.assign( Frustum.prototype, {

return this;

},
}

setFromProjectionMatrix: function ( m ) {
setFromProjectionMatrix( m ) {

const planes = this.planes;
const me = m.elements;
@@ -75,9 +75,9 @@ Object.assign( Frustum.prototype, {

return this;

},
}

intersectsObject: function ( object ) {
intersectsObject( object ) {

const geometry = object.geometry;

@@ -87,19 +87,19 @@ Object.assign( Frustum.prototype, {

return this.intersectsSphere( _sphere );

},
}

intersectsSprite: function ( sprite ) {
intersectsSprite( sprite ) {

_sphere.center.set( 0, 0, 0 );
_sphere.radius = 0.7071067811865476;
_sphere.applyMatrix4( sprite.matrixWorld );

return this.intersectsSphere( _sphere );

},
}

intersectsSphere: function ( sphere ) {
intersectsSphere( sphere ) {

const planes = this.planes;
const center = sphere.center;
@@ -119,9 +119,9 @@ Object.assign( Frustum.prototype, {

return true;

},
}

intersectsBox: function ( box ) {
intersectsBox( box ) {

const planes = this.planes;

@@ -145,9 +145,9 @@ Object.assign( Frustum.prototype, {

return true;

},
}

containsPoint: function ( point ) {
containsPoint( point ) {

const planes = this.planes;

@@ -165,7 +165,7 @@ Object.assign( Frustum.prototype, {

}

} );
}


export { Frustum };