提交 90ab0b70 编写于 作者: M Mr.doob

Polyfill for Math.sign().

Chrome 38 will come with it and Firefox already implemented it.
上级 4a58b579
......@@ -171,8 +171,6 @@ THREE.Mirror.prototype.renderWithMirror = function ( otherMirror ) {
THREE.Mirror.prototype.updateTextureMatrix = function () {
var sign = THREE.Math.sign;
this.updateMatrixWorld();
this.camera.updateMatrixWorld();
......@@ -228,8 +226,8 @@ THREE.Mirror.prototype.updateTextureMatrix = function () {
var q = new THREE.Vector4();
var projectionMatrix = this.mirrorCamera.projectionMatrix;
q.x = ( sign(this.clipPlane.x) + projectionMatrix.elements[8] ) / projectionMatrix.elements[0];
q.y = ( sign(this.clipPlane.y) + projectionMatrix.elements[9] ) / projectionMatrix.elements[5];
q.x = ( Math.sign(this.clipPlane.x) + projectionMatrix.elements[8] ) / projectionMatrix.elements[0];
q.y = ( Math.sign(this.clipPlane.y) + projectionMatrix.elements[9] ) / projectionMatrix.elements[5];
q.z = - 1.0;
q.w = ( 1.0 + projectionMatrix.elements[10] ) / projectionMatrix.elements[14];
......
......@@ -5,12 +5,25 @@
var THREE = { REVISION: '69dev' };
// browserify support
if ( typeof module === 'object' ) {
module.exports = THREE;
}
// polyfills
if ( Math.sign === undefined ) {
Math.sign = function ( x ) {
return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : 0;
};
}
// GL STATE CONSTANTS
THREE.CullFaceNone = 0;
......
......@@ -193,7 +193,6 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
function getBevelVec( inPt, inPrev, inNext ) {
var EPSILON = 0.0000000001;
var sign = THREE.Math.sign;
// computes for inPt the corresponding point inPt' on a new contour
// shiftet by 1 unit (length of normalized vector) to the left
......@@ -259,7 +258,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
if ( v_prev_x < - EPSILON ) {
if ( v_next_x < - EPSILON ) { direction_eq = true; }
} else {
if ( sign(v_prev_y) == sign(v_next_y) ) { direction_eq = true; }
if ( Math.sign(v_prev_y) == Math.sign(v_next_y) ) { direction_eq = true; }
}
}
......
......@@ -122,12 +122,6 @@ THREE.Math = {
},
sign: function ( x ) {
return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : 0;
},
degToRad: function () {
var degreeToRadiansFactor = Math.PI / 180;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册