1

I'm trying to add my canvas to a div-container, so I had to make some changes to my raycasters vectors:

var vector = new THREE.Vector3((event.clientX / window.innerWidth ) * 2 - 1, -(event.clientY / window.innerHeight ) * 2 + 1, 0.5);

to

var vector = new THREE.Vector3(((event.clientX - renderer.domElement.offsetLeft)//renderer.domElement.width ) * 2 - 1, -((event.clientY - renderer.domElement.offsetTop) / renderer.domElement.height) * 2 + 1, 0.5);

as seen in: THREE.js Ray Intersect fails by adding div

It works perfectly on desktop, but fails on mobile (iPhone 4s and Nexus 5). In my eyes there's nothing wrong with the calculation, so what am I missing?

Community
  • 1
  • 1
Torben
  • 21
  • 3
  • I haven't checked your vector calculation but on some mobile devices `event.clientX/Y` are [wrong](https://stackoverflow.com/questions/5885808/includes-touch-events-clientx-y-scrolling-or-not). – IceCreamYou Sep 07 '14 at 23:55

0 Answers0