提交 911146db 编写于 作者: B Ben Houston

add Plane.flip() plus unit test.

上级 367fb776
......@@ -74,6 +74,15 @@ THREE.Plane.prototype = {
},
flip: function () {
this.constant *= -1;
this.normal.negate();
return this;
},
distanceToPoint: function ( point ) {
return this.normal.dot( point ) + this.constant;
......
......@@ -94,6 +94,18 @@ test( "normalize", function() {
ok( a.constant == 1, "Passed!" );
});
test( "flip/distanceToPoint", function() {
var a = new THREE.Plane( new THREE.Vector3( 2, 0, 0 ), -2 );
a.normalize();
ok( a.distanceToPoint( new THREE.Vector3( 4, 0, 0 ) ) === 3, "Passed!" );
ok( a.distanceToPoint( new THREE.Vector3( 1, 0, 0 ) ) === 0, "Passed!" );
a.flip();
ok( a.distanceToPoint( new THREE.Vector3( 4, 0, 0 ) ) === -3, "Passed!" );
ok( a.distanceToPoint( new THREE.Vector3( 1, 0, 0 ) ) === 0, "Passed!" );
});
test( "distanceToPoint", function() {
var a = new THREE.Plane( new THREE.Vector3( 2, 0, 0 ), -2 );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册