|
@@ -35,7 +35,7 @@ Object.assign( Plane.prototype, {
|
|
setFromNormalAndCoplanarPoint: function ( normal, point ) {
|
|
setFromNormalAndCoplanarPoint: function ( normal, point ) {
|
|
|
|
|
|
this.normal.copy( normal );
|
|
this.normal.copy( normal );
|
|
- this.constant = - point.dot( this.normal ); // must be this.normal, not normal, as this.normal is normalized
|
|
|
|
|
|
+ this.constant = - point.dot( this.normal );
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
@@ -110,16 +110,9 @@ Object.assign( Plane.prototype, {
|
|
|
|
|
|
projectPoint: function ( point, optionalTarget ) {
|
|
projectPoint: function ( point, optionalTarget ) {
|
|
|
|
|
|
- return this.orthoPoint( point, optionalTarget ).sub( point ).negate();
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- orthoPoint: function ( point, optionalTarget ) {
|
|
|
|
-
|
|
|
|
- var perpendicularMagnitude = this.distanceToPoint( point );
|
|
|
|
-
|
|
|
|
var result = optionalTarget || new Vector3();
|
|
var result = optionalTarget || new Vector3();
|
|
- return result.copy( this.normal ).multiplyScalar( perpendicularMagnitude );
|
|
|
|
|
|
+
|
|
|
|
+ return result.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
@@ -189,6 +182,7 @@ Object.assign( Plane.prototype, {
|
|
coplanarPoint: function ( optionalTarget ) {
|
|
coplanarPoint: function ( optionalTarget ) {
|
|
|
|
|
|
var result = optionalTarget || new Vector3();
|
|
var result = optionalTarget || new Vector3();
|
|
|
|
+
|
|
return result.copy( this.normal ).multiplyScalar( - this.constant );
|
|
return result.copy( this.normal ).multiplyScalar( - this.constant );
|
|
|
|
|
|
},
|
|
},
|
|
@@ -200,14 +194,12 @@ Object.assign( Plane.prototype, {
|
|
|
|
|
|
return function applyMatrix4( matrix, optionalNormalMatrix ) {
|
|
return function applyMatrix4( matrix, optionalNormalMatrix ) {
|
|
|
|
|
|
|
|
+ var normalMatrix = optionalNormalMatrix || m1.getNormalMatrix( matrix );
|
|
|
|
+
|
|
var referencePoint = this.coplanarPoint( v1 ).applyMatrix4( matrix );
|
|
var referencePoint = this.coplanarPoint( v1 ).applyMatrix4( matrix );
|
|
|
|
|
|
- // transform normal based on theory here:
|
|
|
|
- // http://www.songho.ca/opengl/gl_normaltransform.html
|
|
|
|
- var normalMatrix = optionalNormalMatrix || m1.getNormalMatrix( matrix );
|
|
|
|
var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
|
|
var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
|
|
|
|
|
|
- // recalculate constant (like in setFromNormalAndCoplanarPoint)
|
|
|
|
this.constant = - referencePoint.dot( normal );
|
|
this.constant = - referencePoint.dot( normal );
|
|
|
|
|
|
return this;
|
|
return this;
|
|
@@ -218,7 +210,7 @@ Object.assign( Plane.prototype, {
|
|
|
|
|
|
translate: function ( offset ) {
|
|
translate: function ( offset ) {
|
|
|
|
|
|
- this.constant = this.constant - offset.dot( this.normal );
|
|
|
|
|
|
+ this.constant -= offset.dot( this.normal );
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|