Skip to content

Latest commit

 

History

History
63 lines (46 loc) · 2 KB

three-story-controls.pointeradaptor.md

File metadata and controls

63 lines (46 loc) · 2 KB

Home > three-story-controls > PointerAdaptor

PointerAdaptor class

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

Remarks

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.

Example

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)
}

Constructors

Constructor Modifiers Description
(constructor)(props) Constructs a new instance of the PointerAdaptor class

Methods

Method Modifiers Description
connect()
disconnect()
isEnabled()
update(time)