Procházet zdrojové kódy

Merge remote-tracking branch 'WestLangley/dev-objectBB' into dev

Mr.doob před 12 roky
rodič
revize
70a279af25

+ 29 - 0
src/extras/helpers/BoundingBoxHelper.js

@@ -0,0 +1,29 @@
+/**
+ * @author WestLangley / http://github.com/WestLangley
+ */
+
+// a helper to show the world-axis-aligned bounding box for an object
+
+THREE.BoundingBoxHelper = function ( object, hex ) {
+
+	var color = hex || 0x888888;
+
+	this.object = object;
+
+	this.box = new THREE.Box3();
+
+	THREE.Mesh.call( this, new THREE.CubeGeometry( 1, 1, 1 ), new THREE.MeshBasicMaterial( { color: color, wireframe: true } ) );
+
+};
+
+THREE.BoundingBoxHelper.prototype = Object.create( THREE.Mesh.prototype );
+
+THREE.BoundingBoxHelper.prototype.update = function () {
+
+	this.object.computeBoundingBox();
+
+	this.object.boundingBox.size( this.scale );
+
+	this.object.boundingBox.center( this.position );
+
+};

+ 1 - 0
utils/build/includes/extras.json

@@ -46,6 +46,7 @@
 	"src/extras/helpers/AxisHelper.js",
 	"src/extras/helpers/ArrowHelper.js",
 	"src/extras/helpers/BoxHelper.js",
+	"src/extras/helpers/BoundingBoxHelper.js",
 	"src/extras/helpers/CameraHelper.js",
 	"src/extras/helpers/DirectionalLightHelper.js",
 	"src/extras/helpers/FaceNormalsHelper.js",