Home > three-story-controls > PointerAdaptor
Parse pointer events to emit dampened, normalized coordinates along with the pointer count (for detecting multi-touch or drag events)
Signature:
export declare class PointerAdaptor extends BaseAdaptor
Extends: BaseAdaptor
See PointerAdaptorProps for all properties that can be passed to the constructor. See PointerAdaptorEvent for emitted event signatures. Note: CSS property touch-action: none
will probably be needed on listener element.
Pointer adaptor
const pointerAdaptor = new PointerAdaptor()
pointerAdaptor.connect()
pointerAdaptor.addEventListener('update', (event) => {
switch(event.pointerCount) {
case 0:
cube.scale.x = event.values.x
cube.scale.y = event.values.y
break
case 1:
cube.position.x += event.deltas.x
cube.position.y -= event.deltas.y
break
default:
break
}
})
// in RAF loop:
function animate(t) {
pointerAdaptor.update(t)
}
Constructor | Modifiers | Description |
---|---|---|
(constructor)(props) | Constructs a new instance of the PointerAdaptor class |
Method | Modifiers | Description |
---|---|---|
connect() | ||
disconnect() | ||
isEnabled() | ||
update(time) |