Two.ZUI

Two.ZUI is an extra class to turn your Two.js scene into a Google Maps or Adobe Illustrator style interface. See https://codepen.io/jonobr1/pen/PobMKwb for example usage.

Constructor

ArgumentDescription
groupThe scene or group to enable panning and zooming on.
domElementThe HTML Element to attach event listeners to.

addLimits

ArgumentDescription
minThe minimum scale the ZUI can zoom out to.
maxThe maximum scale the ZUI can zoom in to.

clientToSurface

Overloaded

Returns: Object

  • An object with x, y, and z components
ArgumentDescription
a

Convert an x, y coordinate in the user’s space to the object's projected space. Optionally pass a z property on the object to apply depth.

clientToSurface

Overloaded

Returns: Object

  • An object with x, y, and z components
ArgumentDescription
aThe x component of position to be transformed.
bThe y component of position to be transformed.
cThe optional z component of position to be transformed.

Convert an x, y coordinate in the user’s space to the object's projected space. Optionally pass a z property on the object to apply depth.

surfaceToClient

Overloaded

Returns: Object

  • An object with x, y, and z components
ArgumentDescription
a

Convert an x, y coordinate in projected space to the user’s space. Optionally pass a z property on the object to apply depth.

surfaceToClient

Overloaded

Returns: Object

  • An object with x, y, and z components
ArgumentDescription
aThe x component of position to be transformed.
bThe y component of position to be transformed.
cThe optional z component of position to be transformed.

Convert an x, y coordinate in projected space to the user’s space. Optionally pass a z property on the object to apply depth.

zoomBy

ArgumentDescription
byFThe factor to scale by.
clientXThe x position of the user's input.
clientYThe y position of the user's input.

A function to zoom by an incremental amount and a position. Typically used for pinch-and-zoom or mousewheel effects.

zoomSet

ArgumentDescription
zoomThe level of the zoom.
clientXThe x position of the user's input.
clientYThe y position of the user's input.

A function to set the zoom amount and the origin position. This is used internally by {@Two.ZUI#zoomBy}.

translateSurface

ArgumentDescription
xThe x amount to pan.
yThe y amount to pan.

Set the position of the ZUI by an incremental translation amount.

reset

Reset the zoom and scale factors to their original instantiated state.