Touch events and intersections with crosswalk / three.js on Android 4.0.4 device

烂漫一生 提交于 2019-12-12 01:58:07

问题


I have a crosswalk WebGL_Sample based app that behave correctly on all XDK emulators (I am not using XDK, just testing the EMU's) when I try to touch / intersect a Cube with Three.js's "raycaster.intersectObjects".

The problem is that if I shoot it on a real LGP920 running ICS, touch-sliding events are working (like for the sample's sliding cube) but touch-clicking are not whereas, again, everything works fine on EMU's...

Any clue about what is happening ?

here is what I use (the array "objects" contains only one cube element):

    var vector = new THREE.Vector3( ( e.clientX / window.innerWidth ) * 2 - 1, - ( e.clientY / window.innerHeight ) * 2 + 1, 0.999 );
    projector.unprojectVector( vector, camera );

    var raycaster = new THREE.Raycaster( camera.position, vector.sub( camera.position ).normalize() );

    var intersects = raycaster.intersectObjects( objects );

    if ( intersects.length > 0 ) {

        intersects[ 0 ].object.material.color.setHex( Math.random() * 0xffffff );

    }

Thanks !


回答1:


Ok got it, in XDK emulators the app was reacting when hovering the mouse pointer on the target cube surface but not with the finger on the device.

I should have used with e.touches[0].pageX and e.touches[0].pageY (instead of e.clientX and e.clientY) for the device.



来源:https://stackoverflow.com/questions/24615320/touch-events-and-intersections-with-crosswalk-three-js-on-android-4-0-4-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!