فهرست منبع

Frustum bug fix: clone and constructor should be real copies. Fix bug in unit test to catch this in the future.

Ben Houston 12 سال پیش
والد
کامیت
9fb65f6769
2فایلهای تغییر یافته به همراه11 افزوده شده و 10 حذف شده
  1. 7 9
      src/math/Frustum.js
  2. 4 1
      test/unit/math/Frustum.js

+ 7 - 9
src/math/Frustum.js

@@ -8,12 +8,12 @@ THREE.Frustum = function ( p0, p1, p2, p3, p4, p5 ) {
 
 	this.planes = [
 
-		( p0 !== undefined ) ? p0 : new THREE.Plane(),
-		( p1 !== undefined ) ? p1 : new THREE.Plane(),
-		( p2 !== undefined ) ? p2 : new THREE.Plane(),
-		( p3 !== undefined ) ? p3 : new THREE.Plane(),
-		( p4 !== undefined ) ? p4 : new THREE.Plane(),
-		( p5 !== undefined ) ? p5 : new THREE.Plane()
+		( p0 !== undefined ) ? p0.clone() : new THREE.Plane(),
+		( p1 !== undefined ) ? p1.clone() : new THREE.Plane(),
+		( p2 !== undefined ) ? p2.clone() : new THREE.Plane(),
+		( p3 !== undefined ) ? p3.clone() : new THREE.Plane(),
+		( p4 !== undefined ) ? p4.clone() : new THREE.Plane(),
+		( p5 !== undefined ) ? p5.clone() : new THREE.Plane()
 
 	];
 
@@ -136,9 +136,7 @@ THREE.Frustum.prototype = {
 
 	clone: function () {
 
-		var planes = this.planes;
-
-		return new THREE.Frustum( planes[0], planes[1], planes[2], planes[3], planes[4], planes[5] );
+		return new THREE.Frustum().copy( this );
 
 	}
 

+ 4 - 1
test/unit/math/Frustum.js

@@ -42,6 +42,9 @@ test( "constructor", function() {
 	ok( a.planes[3].equals( p3 ), "Passed!" );
 	ok( a.planes[4].equals( p4 ), "Passed!" );
 	ok( a.planes[5].equals( p5 ), "Passed!" );
+
+	p0.copy( p1 );
+	ok( ! a.planes[0].equals( p0 ), "Passed!" );
 });
 
 test( "copy", function() {
@@ -151,6 +154,6 @@ test( "clone", function() {
 	ok( a.planes[5].equals( p5 ), "Passed!" );
 
 	// ensure it is a true copy by modifying source
-	b.planes[0] = p1;
+	b.planes[0].copy( p1 );
 	ok( a.planes[0].equals( p0 ), "Passed!" );
 });