未验证 提交 8f92ca23 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #16859 from gero3/addPlaneUnittests

add Plane unittests
......@@ -16,6 +16,8 @@ function Plane( normal, constant ) {
Object.assign( Plane.prototype, {
isPlane: true,
set: function ( normal, constant ) {
this.normal.copy( normal );
......
......@@ -8,6 +8,7 @@ import { Plane } from '../../../../src/math/Plane';
import { Vector3 } from '../../../../src/math/Vector3';
import { Line3 } from '../../../../src/math/Line3';
import { Sphere } from '../../../../src/math/Sphere';
import { Box3 } from '../../../../src/math/Box3';
import { Matrix4 } from '../../../../src/math/Matrix4';
import {
x,
......@@ -54,9 +55,14 @@ export default QUnit.module( 'Maths', () => {
} );
// PUBLIC STUFF
QUnit.todo( "isPlane", ( assert ) => {
QUnit.test( "isPlane", ( assert ) => {
var a = new Plane();
assert.ok( a.isPlane === true, "Passed!" );
var b = new Vector3();
assert.ok( ! b.isPlane, "Passed!" );
assert.ok( false, "everything's gonna be alright" );
} );
......@@ -118,9 +124,13 @@ export default QUnit.module( 'Maths', () => {
} );
QUnit.todo( "clone", ( assert ) => {
QUnit.test( "clone", ( assert ) => {
var a = new Plane( 2.0, 0.5, 0.25 );
var b = a.clone();
assert.ok( a.equals( b ), "clones are equal" );
assert.ok( false, "everything's gonna be alright" );
} );
......@@ -229,15 +239,41 @@ export default QUnit.module( 'Maths', () => {
} );
QUnit.todo( "intersectsBox", ( assert ) => {
assert.ok( false, "everything's gonna be alright" );
QUnit.test( "intersectsBox", ( assert ) => {
var a = new Box3( zero3.clone(), one3.clone() );
var b = new Plane( new Vector3( 0, 1, 0 ), 1 );
var c = new Plane( new Vector3( 0, 1, 0 ), 1.25 );
var d = new Plane( new Vector3( 0, - 1, 0 ), 1.25 );
var e = new Plane( new Vector3( 0, 1, 0 ), 0.25 );
var f = new Plane( new Vector3( 0, 1, 0 ), - 0.25 );
var g = new Plane( new Vector3( 0, 1, 0 ), - 0.75 );
var h = new Plane( new Vector3( 0, 1, 0 ), - 1 );
var i = new Plane( new Vector3( 1, 1, 1 ).normalize(), - 1.732 );
var j = new Plane( new Vector3( 1, 1, 1 ).normalize(), - 1.733 );
assert.ok( ! b.intersectsBox( a ), "Passed!" );
assert.ok( ! c.intersectsBox( a ), "Passed!" );
assert.ok( ! d.intersectsBox( a ), "Passed!" );
assert.ok( ! e.intersectsBox( a ), "Passed!" );
assert.ok( f.intersectsBox( a ), "Passed!" );
assert.ok( g.intersectsBox( a ), "Passed!" );
assert.ok( h.intersectsBox( a ), "Passed!" );
assert.ok( i.intersectsBox( a ), "Passed!" );
assert.ok( ! j.intersectsBox( a ), "Passed!" );
} );
QUnit.todo( "intersectsSphere", ( assert ) => {
QUnit.test( "intersectsSphere", ( assert ) => {
var a = new Sphere( zero3.clone(), 1 );
var b = new Plane( new Vector3( 0, 1, 0 ), 1 );
var c = new Plane( new Vector3( 0, 1, 0 ), 1.25 );
var d = new Plane( new Vector3( 0, - 1, 0 ), 1.25 );
assert.ok( false, "everything's gonna be alright" );
assert.ok( b.intersectsSphere( a ), "Passed!" );
assert.ok( ! c.intersectsSphere( a ), "Passed!" );
assert.ok( ! d.intersectsSphere( a ), "Passed!" );
} );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册