nl_tokens: Event handler for touch movements . Pans center of view if one touch or adjusts zoom if two touches .
pl_tokens: function onDocumentTouchMove ( event ) { if ( ! config . draggable ) { return ; } // Override default action event . preventDefault ( ) ; if ( loaded ) { latestInteraction = Date . now ( ) ; } if ( isUserInteracting && loaded ) { var pos0 = mousePosition ( event . targetTouches [ 0 ] ) ; var clientX = pos0 . x ; var clientY = pos0 . y ; if ( event . targetTouches . <mask> == 2 && onPointerDownPointerDist != - 1 ) { var pos1 = mousePosition ( event . targetTouches [ 1 ] ) ; clientX += ( pos1 . x - pos0 . x ) * 0.5 ; clientY += ( pos1 . y - pos0 . y ) * 0.5 ; var clientDist = Math . sqrt ( ( pos0 . x - pos1 . x ) * ( pos0 . x - pos1 . x ) + ( pos0 . y - pos1 . y ) * ( pos0 . y - pos1 . y ) ) ; setHfov ( config . hfov + ( onPointerDownPointerDist - clientDist ) * 0.1 ) ; onPointerDownPointerDist = clientDist ; } // The smaller the config.hfov value (the more zoomed-in the user is), the faster // yaw/pitch are perceived to change on one-finger touchmove (panning) events and vice versa. // To improve usability at both small and large zoom levels (config.hfov values) // we introduce a dynamic pan speed coefficient. // // Currently this seems to *roughly* keep initial drag/pan start position close to // the user's finger while panning regardless of zoom level / config.hfov value. var touchmovePanSpeedCoeff = ( config . hfov / 360 ) * config . touchPanSpeedCoeffFactor ; var yaw = ( onPointerDownPointerX - clientX ) * touchmovePanSpeedCoeff + onPointerDownYaw ; speed . yaw = ( yaw - config . yaw ) % 360 * 0.2 ; config . yaw = yaw ; var pitch = ( clientY - onPointerDownPointerY ) * touchmovePanSpeedCoeff + onPointerDownPitch ; speed . pitch = ( pitch - config . pitch ) * 0.2 ; config . pitch = pitch ; } }