From 5578c057a95b84972f80fecf134485e9666f0ea3 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Wed, 14 Sep 2016 14:18:57 -0700 Subject: [PATCH] Box2/Box3: Renamed center/size to getCenter/getSize. See #9675. --- src/Three.Legacy.js | 16 ++++++++++++++++ src/core/BufferGeometry.js | 4 ++-- src/core/Geometry.js | 2 +- src/extras/helpers/BoundingBoxHelper.js | 2 +- src/math/Box2.js | 4 ++-- src/math/Box3.js | 6 +++--- src/math/Sphere.js | 2 +- 7 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/Three.Legacy.js b/src/Three.Legacy.js index 537570ab68..5d7334444c 100644 --- a/src/Three.Legacy.js +++ b/src/Three.Legacy.js @@ -85,6 +85,10 @@ export function Vertex ( x, y, z ) { // Object.assign( Box2.prototype, { + center: function ( optionalTarget ) { + console.warn( 'THREE.Box2: .center() has been renamed to .getCenter().' ); + return this.getCenter( optionalTarget ); + }, empty: function () { console.warn( 'THREE.Box2: .empty() has been renamed to .isEmpty().' ); return this.isEmpty(); @@ -92,10 +96,18 @@ Object.assign( Box2.prototype, { isIntersectionBox: function ( box ) { console.warn( 'THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().' ); return this.intersectsBox( box ); + }, + size: function ( optionalTarget ) { + console.warn( 'THREE.Box2: .size() has been renamed to .getSize().' ); + return this.getSize( optionalTarget ); } } ); Object.assign( Box3.prototype, { + center: function ( optionalTarget ) { + console.warn( 'THREE.Box3: .center() has been renamed to .getCenter().' ); + return this.getCenter( optionalTarget ); + }, empty: function () { console.warn( 'THREE.Box3: .empty() has been renamed to .isEmpty().' ); return this.isEmpty(); @@ -107,6 +119,10 @@ Object.assign( Box3.prototype, { isIntersectionSphere: function ( sphere ) { console.warn( 'THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().' ); return this.intersectsSphere( sphere ); + }, + size: function ( optionalTarget ) { + console.warn( 'THREE.Box3: .size() has been renamed to .getSize().' ); + return this.getSize( optionalTarget ); } } ); diff --git a/src/core/BufferGeometry.js b/src/core/BufferGeometry.js index 903cdd78c4..0128726a33 100644 --- a/src/core/BufferGeometry.js +++ b/src/core/BufferGeometry.js @@ -280,7 +280,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { this.computeBoundingBox(); - var offset = this.boundingBox.center().negate(); + var offset = this.boundingBox.getCenter().negate(); this.translate( offset.x, offset.y, offset.z ); @@ -620,7 +620,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { var center = this.boundingSphere.center; box.setFromArray( array ); - box.center( center ); + box.getCenter( center ); // hoping to find a boundingSphere with a radius smaller than the // boundingSphere of the boundingBox: sqrt(3) smaller in the best case diff --git a/src/core/Geometry.js b/src/core/Geometry.js index 92ef064b14..a65e8082db 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -356,7 +356,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { this.computeBoundingBox(); - var offset = this.boundingBox.center().negate(); + var offset = this.boundingBox.getCenter().negate(); this.translate( offset.x, offset.y, offset.z ); diff --git a/src/extras/helpers/BoundingBoxHelper.js b/src/extras/helpers/BoundingBoxHelper.js index e30745c714..bd2c843b7b 100644 --- a/src/extras/helpers/BoundingBoxHelper.js +++ b/src/extras/helpers/BoundingBoxHelper.js @@ -30,7 +30,7 @@ BoundingBoxHelper.prototype.update = function () { this.box.size( this.scale ); - this.box.center( this.position ); + this.box.getCenter( this.position ); }; diff --git a/src/math/Box2.js b/src/math/Box2.js index 8494b59d8c..9daef14a55 100644 --- a/src/math/Box2.js +++ b/src/math/Box2.js @@ -86,14 +86,14 @@ Box2.prototype = { }, - center: function ( optionalTarget ) { + getCenter: function ( optionalTarget ) { var result = optionalTarget || new Vector2(); return this.isEmpty() ? result.set( 0, 0 ) : result.addVectors( this.min, this.max ).multiplyScalar( 0.5 ); }, - size: function ( optionalTarget ) { + getSize: function ( optionalTarget ) { var result = optionalTarget || new Vector2(); return this.isEmpty() ? result.set( 0, 0 ) : result.subVectors( this.max, this.min ); diff --git a/src/math/Box3.js b/src/math/Box3.js index abc7f21ae0..a6ee50ae2c 100644 --- a/src/math/Box3.js +++ b/src/math/Box3.js @@ -201,14 +201,14 @@ Box3.prototype = { }, - center: function ( optionalTarget ) { + getCenter: function ( optionalTarget ) { var result = optionalTarget || new Vector3(); return this.isEmpty() ? result.set( 0, 0, 0 ) : result.addVectors( this.min, this.max ).multiplyScalar( 0.5 ); }, - size: function ( optionalTarget ) { + getSize: function ( optionalTarget ) { var result = optionalTarget || new Vector3(); return this.isEmpty() ? result.set( 0, 0, 0 ) : result.subVectors( this.max, this.min ); @@ -394,7 +394,7 @@ Box3.prototype = { var result = optionalTarget || new Sphere(); - result.center = this.center(); + result.center = this.getCenter(); result.radius = this.size( v1 ).length() * 0.5; return result; diff --git a/src/math/Sphere.js b/src/math/Sphere.js index 776f8cfb93..3d8b944cd2 100644 --- a/src/math/Sphere.js +++ b/src/math/Sphere.js @@ -40,7 +40,7 @@ Sphere.prototype = { } else { - box.setFromPoints( points ).center( center ); + box.setFromPoints( points ).getCenter( center ); } -- GitLab