File: src/shapes/Plane.js
module.exports = Plane;
var Shape = require('./Shape');
var Vec3 = require('../math/Vec3');
/**
* A plane, facing in the Z direction. The plane has its surface at z=0 and everything below z=0 is assumed to be solid plane. To make the plane face in some other direction than z, you must put it inside a RigidBody and rotate that body. See the demos.
* @class Plane
* @constructor
* @extends Shape
* @author schteppe
*/
function Plane(){
Shape.call(this);
this.type = Shape.types.PLANE;
// World oriented normal
this.worldNormal = new Vec3();
this.worldNormalNeedsUpdate = true;
this.boundingSphereRadius = Number.MAX_VALUE;
}
Plane.prototype = new Shape();
Plane.prototype.constructor = Plane;
Plane.prototype.computeWorldNormal = function(quat){
var n = this.worldNormal;
n.set(0,0,1);
quat.vmult(n,n);
this.worldNormalNeedsUpdate = false;
};
Plane.prototype.calculateLocalInertia = function(mass,target){
target = target || new Vec3();
return target;
};
Plane.prototype.volume = function(){
return Number.MAX_VALUE; // The plane is infinite...
};
var tempNormal = new Vec3();
Plane.prototype.calculateWorldAABB = function(pos, quat, min, max){
// The plane AABB is infinite, except if the normal is pointing along any axis
tempNormal.set(0,0,1); // Default plane normal is z
quat.vmult(tempNormal,tempNormal);
var maxVal = Number.MAX_VALUE;
min.set(-maxVal, -maxVal, -maxVal);
max.set(maxVal, maxVal, maxVal);
if(tempNormal.x === 1){ max.x = pos.x; }
if(tempNormal.y === 1){ max.y = pos.y; }
if(tempNormal.z === 1){ max.z = pos.z; }
if(tempNormal.x === -1){ min.x = pos.x; }
if(tempNormal.y === -1){ min.y = pos.y; }
if(tempNormal.z === -1){ min.z = pos.z; }
};
Plane.prototype.updateBoundingSphereRadius = function(){
this.boundingSphereRadius = Number.MAX_VALUE;
};