Recently, I have been experimenting with a threejs mouse raycast combined with fabricjs and managed to get it working. However, I encountered an issue where the object did not move when using a smartphone with touch capability. Should I implement a separate event listener for touch events or is it supposed to work with just mouse events?
Here's how I am currently moving the object:
if (e.target !== this.upperCanvasEl) {
var positionOnScene = getPositionOnScene(container, e);
pointer.x = positionOnScene.x;
pointer.y = positionOnScene.y;
}
And here's the getPositionOnScene
function:
function getPositionOnScene(sceneContainer, evt) {
var array = getMousePosition(container, evt.clientX, evt.clientY);
onClickPosition.fromArray(array);
var intersects = getIntersects(onClickPosition, scene.children);
if (intersects.length > 0 && intersects[0].uv) {
var uv = intersects[0].uv;
intersects[0].object.material.map.transformUv(uv);
return {
x: getRealPosition('x', uv.x),
y: getRealPosition('y', uv.y)
}
}
return null
}
Can anyone provide some insight or assistance on this matter? Any thoughts would be greatly appreciated.