From ddb00d1ad17dd29ef68304f22ed9b9120a9320ff Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Mon, 9 Mar 2015 22:52:18 +0100 Subject: [PATCH] BufferGeometry: Implemented .center() --- src/core/BufferGeometry.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/BufferGeometry.js b/src/core/BufferGeometry.js index fbf6968b1f..14bfe1a97c 100644 --- a/src/core/BufferGeometry.js +++ b/src/core/BufferGeometry.js @@ -84,13 +84,13 @@ THREE.BufferGeometry.prototype = { } - if ( this.boundingBox instanceof THREE.Box3 ) { + if ( this.boundingBox !== null ) { this.computeBoundingBox(); } - if ( this.boundingSphere instanceof THREE.Sphere ) { + if ( this.boundingSphere !== null ) { this.computeBoundingSphere(); @@ -100,7 +100,13 @@ THREE.BufferGeometry.prototype = { center: function () { - // TODO + this.computeBoundingBox(); + + var offset = this.boundingBox.center().negate(); + + this.applyMatrix( new THREE.Matrix4().setPosition( offset ) ); + + return offset; }, -- GitLab