Skip to content

NgtsTrackballControls

NgtsTrackballControls is a wrapper around Three.js TrackballControls which provides trackball-style camera controls. Unlike OrbitControls, TrackballControls have no restrictions on vertical rotation, allowing the camera to flip upside down.

Usage

import { NgtsTrackballControls } from 'angular-three-soba/controls';
<ngts-trackball-controls />

With Options

<ngts-trackball-controls [options]="{ makeDefault: true }" />

Handling Events

<ngts-trackball-controls
(changed)="onControlsChange($event)"
(started)="onStart()"
(ended)="onEnd()"
/>
onControlsChange(event: any) {
console.log('Camera changed');
}
onStart() {
console.log('User interaction started');
}
onEnd() {
console.log('User interaction ended');
}

Outputs

name type description
changed any Emits when the camera position/orientation changes.
started any Emits when user interaction starts.
ended any Emits when user interaction ends.

Options

options input accepts any properties from TrackballControls in addition to the following:

Properties

name type description
camera THREE.Camera The camera to control. If not provided, the default camera will be used.
domElement HTMLElement The DOM element to attach the controls to. If not provided, the current connected element will be used.
target [number, number, number] The target point to orbit around. Default: [0, 0, 0]
makeDefault boolean Whether to make this control the default one. Default: false
regress boolean Whether to regress performance. Default: false