BoxHelper - Verge3D User Manual - Soft8Soft
Description: Learn how to use BoxHelper in your interactive 3D apps made with Verge3D

Object3D → Line → LineSegments →

# BoxHelper

Helper object to graphically show the world-axis-aligned bounding box around an object. The actual bounding box is handled with Box3, this is just a visual helper for debugging. It can be automatically resized with the BoxHelper.update method when the object it's created from is transformed. Note that the object must have a BufferGeometry for this to work, so it won't work with Sprites.

## Code Example

`const sphere = new v3d.SphereGeometry(); const object = new v3d.Mesh(sphere, new v3d.MeshBasicMaterial(0xff0000)); const box = new v3d.BoxHelper(object, 0xffff00); app.scene.add(box);`

## Constructor

### BoxHelper(object : Object3D, color : Color | Integer | String)

- object — (optional) the object3D to show the world-axis-aligned boundingbox.
- color — (optional) hexadecimal value that defines the box's color. Default is `0xffff00`.

Creates a new wireframe box that bounds the passed object. Internally this uses Box3.setFromObject to calculate the dimensions. Note that this includes any children.

## Properties

See the base LineSegments class for common properties.

## Methods

See the base LineSegments class for common methods.

### # .update()

Updates the helper's geometry to match the dimensions of the object, including any children. See Box3.setFromObject.

### # .setFromObject(object : Object3D) → this

object — Object3D to create the helper of.

Updates the wireframe box for the passed object.

### # .dispose()

Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.

## Source

For more info on how to obtain the source code of this module see this page.