ソースを参照

BoxHelper: Added .setFromObject()

Mugen87 8 年 前
コミット
3a656f2884
3 ファイル変更25 行追加7 行削除
  1. 9 2
      docs/api/helpers/BoxHelper.html
  2. 4 4
      editor/js/Viewport.js
  3. 12 1
      src/helpers/BoxHelper.js

+ 9 - 2
docs/api/helpers/BoxHelper.html

@@ -56,8 +56,15 @@
 
 		<h3>[method:null update]()</h3>
 		<div>
-			Updates the helper's geometry to match the dimensions of the
-		 	of the object, including any children. See [page:Box3.setFromObject].
+			Updates the helper's geometry to match the dimensions
+			of the object, including any children. See [page:Box3.setFromObject].
+		</div>
+
+	<h3>[method:null setFromObject]( [page:Object3D object] )</h3>
+		<div>
+			[page:Object3D object] - [page:Object3D] to create the helper of.<br /><br />
+
+			Updates the wireframe box for the passed object.
 		</div>
 
 		<h2>Source</h2>

+ 4 - 4
editor/js/Viewport.js

@@ -60,7 +60,7 @@ var Viewport = function ( editor ) {
 
 		if ( object !== undefined ) {
 
-			selectionBox.update( object );
+			selectionBox.setFromObject( object );
 
 			if ( editor.helpers[ object.id ] !== undefined ) {
 
@@ -385,7 +385,7 @@ var Viewport = function ( editor ) {
 
 			if ( box.isEmpty() === false ) {
 
-				selectionBox.update( box );
+				selectionBox.setFromObject( object );
 				selectionBox.visible = true;
 
 			}
@@ -408,7 +408,7 @@ var Viewport = function ( editor ) {
 
 		if ( object !== undefined ) {
 
-			selectionBox.update( object );
+			selectionBox.setFromObject( object );
 
 		}
 
@@ -430,7 +430,7 @@ var Viewport = function ( editor ) {
 
 		if ( editor.selected === object ) {
 
-			selectionBox.update( object );
+			selectionBox.setFromObject( object );
 			transformControls.update();
 
 		}

+ 12 - 1
src/helpers/BoxHelper.js

@@ -45,7 +45,11 @@ BoxHelper.prototype.update = ( function () {
 
 		}
 
-		box.setFromObject( this.object );
+		if ( this.object !== undefined ) {
+
+			box.setFromObject( this.object );
+
+		}
 
 		if ( box.isEmpty() ) return;
 
@@ -88,5 +92,12 @@ BoxHelper.prototype.update = ( function () {
 
 } )();
 
+BoxHelper.prototype.setFromObject = function ( object ) {
+
+	this.object = object;
+	this.update();
+
+};
+
 
 export { BoxHelper };