BoundingBoxHelper.js 747 B

123456789101112131415161718192021222324252627282930
  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 !== undefined ) ? hex : 0x888888;
  7. this.object = object;
  8. this.box = new THREE.Box3();
  9. THREE.Mesh.call( this, new THREE.BoxGeometry( 1, 1, 1 ), new THREE.MeshBasicMaterial( { color: color, wireframe: true } ) );
  10. };
  11. THREE.BoundingBoxHelper.prototype = Object.create( THREE.Mesh.prototype );
  12. THREE.BoundingBoxHelper.prototype.constructor = THREE.BoundingBoxHelper;
  13. THREE.BoundingBoxHelper.prototype.update = function () {
  14. this.box.setFromObject( this.object );
  15. this.box.size( this.scale );
  16. this.box.center( this.position );
  17. };
粤ICP备19079148号