xeokit / xeokit-sdk

Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
https://xeokit.io
Other
738 stars 291 forks source link

[with solution]: missing camera movement during touch processing #110

Closed tmarti closed 5 years ago

tmarti commented 5 years ago

On following lines of code related to mousemoveevents...

https://github.com/xeokit/xeokit-sdk/blob/6d449ebe58500f0b60b4e30a5c46e3db047d74ba/src/viewer/scene/camera/CameraControl.js#L1006-L1007

... the code takes into account that multiple mousemove events might be processed for each scene tick event (the actual camera movement is done during the processing of scene ticks, and the code simply accumulates deltas).

Instead, during the processing of the touchmove event, the following is done...

https://github.com/xeokit/xeokit-sdk/blob/6d449ebe58500f0b60b4e30a5c46e3db047d74ba/src/viewer/scene/camera/CameraControl.js#L1218-L1219

... and the following:

https://github.com/xeokit/xeokit-sdk/blob/6d449ebe58500f0b60b4e30a5c46e3db047d74ba/src/viewer/scene/camera/CameraControl.js#L1234-L1235

Previous two code snippets DO NOT take into account that multiple touchmove events could be processed between scene ticks, and this has the effect of the CameraControl class missing some touchmove events when using a mobile device.

Shouldn't previous two snippets be refactored to (1st snippet):

rotateVx += rotateY; 
rotateVy += -rotateX; 

and (2nd snippet):

panVx += touch0Vec[0] * touchPanRate;
panVy += touch0Vec[1] * touchPanRate;

(Notice the += instead of =)

Tested the navigation with the proposed fix and camera movement with fingers is waay finer 😃, (and independent of frame rate, i.e. scene tick rate) on touch screens.

xeolabs commented 5 years ago

Fixed in https://github.com/xeokit/xeokit-sdk/commit/768da512aac62b5f3dcb879d9d5f484e8587515b