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

TargetConstraint →

# TransformationConstraint

A constraint which allows to connect one type of transform property (location, rotation, or scale) of the target object to the same or a different type of transform property in the owner object, within a given range of values (which might be different for each target and owner property). You can also switch between axes, and use the range values not as limits, but rather as “markers” to define a mapping between input (target) and output (owner) values.

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

## Constructor

### TransformationConstraint(target : Object3D)

target — constraint's target object.

## Properties

See the base TargetConstraint class for inherited properties.

### # .coordSystem : String

Which coordinate system to use. For example if you exported your scene through Verge3d for Blender/3ds Max, then this value should be `'Z_UP_RIGHT'`. More info in Verge3D Wiki. Default is `'Y_UP_RIGHT'`.

### # .fixCameraLightRotation : Boolean

In Verge3D we use right-handed coordinate system with the Y axis pointing in the up direction, but Blender and 3ds Max uses right-handed coordinate system with Z axis pointing in the up direction (Verge3D Wiki). So, to correct the rotation for cameras and lights, set `fixCameraLightRotation = true`. Default is `false`.

### # .fromMax : Vector3

A fromMax controls the upper bound independently for each axis (X, Y, and Z) of the input value range. Default is `(0, 0, 0)`.

### # .fromMin : Vector3

A fromMin controls the lower bound independently for each axis (X, Y, and Z) of the input value range. Default is `(0, 0, 0)`.

### # .influence : Float

The percentage of influence the constraint has on the object. Default is `1.0` (100%).

### # .isTransformationConstraint : Boolean

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

### # .mapFrom : String

The type of property to use as an input. Can be one of the `'POSITION'`, `'ROTATION'`, `'SCALE'`. Default is `POSITION`.

### # .mapTo : String

The type of property to use as an output. Can be one of the `'POSITION'`, `'ROTATION'`, `'SCALE'`. Default is `POSITION`.

### # .mapToAxisFromAxis : Array

An array of three elements - axis switches, they allow you to select which input axis will be mapped to the output X, Y and Z axes, respectively (by index). Each element in array can be one of the `'X'`, `'-X'`, `'Y'`, `'-Y'`, `'Z'`, `'-Z'`. Default is `['X', 'Y', 'Z']`.

### # .mixMode : String

Specifies how the new transformation is combined with the existing transformation. Depends on mapTo:

- `'POSITION'`
  - `'ADD'` — the new values are added to the existing axis values.
  - `'REPLACE'` — the result of the constraint replaces the existing transformation.
- `'ROTATION'`
  - `'ADD'` — the new values are added to the existing axis values.
  - `'AFTER'` — the new rotation is added after the existing rotation, as if it was applied to a child of the constraint owner.
  - `'BEFORE'` — the new rotation is added before the existing rotation, as if it was applied to a parent of the constraint owner.
  - `'REPLACE'` — the result of the constraint replaces the existing transformation.
- `'SCALE'`
  - `'MULTIPLY'` — the new values are multiplied with the existing axis values.
  - `'REPLACE'` — the result of the constraint replaces the existing transformation.

Default is `'REPLACE'`.

### # .ownerSpace : Integer

The space used to evaluate the owner of the constraint. Can be one of the `v3d.ConstraintSpaceWorld`, `v3d.ConstraintSpaceCustom`, `v3d.ConstraintSpaceLocal`. Default is `v3d.ConstraintSpaceWorld`.

### # .ownerSpaceObj : Object3D

The custom object whose space is used to evaluate the owner of the constraint. Works only when ownerSpace = `v3d.ConstraintSpaceCustom`. Default is `null`.

### # .targetSpace : Integer

The space used to evaluate the target of the constraint. Can be one of the `v3d.ConstraintSpaceWorld`, `v3d.ConstraintSpaceCustom`, `v3d.ConstraintSpaceLocal`. Default is `v3d.ConstraintSpaceWorld`.

### # .targetSpaceObj : Object3D

The custom object whose space is used to evaluate the target of the constraint. Works only when targetSpace = `v3d.ConstraintSpaceCustom`. Default is `null`.

### # .toMax : Vector3

Controls the upper bound independently for each axis (X, Y, and Z) of the output value range. Default is `(0, 0, 0)`.

### # .toMin : Vector3

Controls the lower bound independently for each axis (X, Y, and Z) of the output value range. Default is `(0, 0, 0)`.

### # .type : String

The constraint's type. Equals to `'TransformationConstraint'`.

### # .useMotionExtrapolate : Boolean

By default, fromMin and fromMax act as strict boundaries for an input value, any value outside these limits will be "clipped" to the nearest boundary. When useMotionExtrapolate is enabled, the behavior changes - they become "markers" instead of strict limits. This allows for a proportional (linear) mapping between the input value and its corresponding output value. Default is `false`.

## Methods

See the base TargetConstraint class for inherited methods.

## Source

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