BoundingBoxHelper.js 652 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * @author WestLangley / http://github.com/WestLangley
  3. */
  4. // a helper to show the world-axis-aligned bounding box for an object
  5. THREE.BoundingBoxHelper = function ( object, hex ) {
  6. var color = hex || 0x888888;
  7. this.object = object;
  8. this.box = new THREE.Box3();
  9. THREE.Mesh.call( this, new THREE.CubeGeometry( 1, 1, 1 ), new THREE.MeshBasicMaterial( { color: color, wireframe: true } ) );
  10. };
  11. THREE.BoundingBoxHelper.prototype = Object.create( THREE.Mesh.prototype );
  12. THREE.BoundingBoxHelper.prototype.update = function () {
  13. this.box.setFromObject( this.object );
  14. this.box.size( this.scale );
  15. this.box.center( this.position );
  16. };