Skip to main content Link Menu Expand (external link) Copy Copied

Translation limit

Translation limit can be set on the controls. The anchor point is the position of the object when the setTranslationLimit function is called. This puts a limit on the object’s translation.

{ x: [-1, 2], y: false, z: false } - sets the translation limit to 1 unit in the -x-direction, +2 units in the +x-direction, and no limit on the y and z-direction. Setting the limit to false disables the limit in all directions.

const controls = new ControlsManager.anchor(box);
// move the object around
box.position.z = 1;
// set translation limit around the object's position (0, 0, 1)
controls.setTranslationLimit({
  x: [-1, 3],
  y: false,
  z: false
});
// disable all limits
controls.setTranslationLimit(false);

An example showing translation limits can be seen below.

View example

Next section: API Reference