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

TargetConstraint →

# CanvasFitConstraint

This constraint fits camera-parented UI elements such as buttons, panels, or texts, regardless of the screen resolution or a device.

To influence some object, push a CanvasFitConstraint instance into the Object3D.constraints array.

## Constructor

### CanvasFitConstraint(target : Object3D)

target — constraint's target object.

## Properties

See the base TargetConstraint class for common properties.

### # .edgeH : String

The horizontal canvas edge to fit to. Default is `'NONE'`.

- `'LEFT'` — left edge.
- `'RIGHT'` — right edge.
- `'STRETCH'` — stretch from left to right edge.
- `'NONE'` — no horizontal fit.

### # .edgeV : String

The vertical canvas edge to fit to. Default is `'NONE'`.

- `'TOP'` — top edge.
- `'BOTTOM'` — bottom edge.
- `'STRETCH'` — stretch from top to bottom.
- `'NONE'` — no vertical fit.

### # .offset : Float

Additional fit offset (can be negative). Default is `0.0`.

### # .isCanvasFitConstraint : Boolean

Read-only flag to check if a given object is of type CanvasFitConstraint.

### # .type : String

The constraint's type. Equals to `"CanvasFitConstraint"`.

### # .fitShape : String

Bounding shape for canvas fit. Default is `'BOX'`.

- `'SPHERE'` — bounding sphere.
- `'BOX'` — bounding box.
- `'POINT'` — zero-sized fit shape (point).

## Methods

See the base TargetConstraint class for common methods.

## Source

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