I’ve been working on threejs mouse raycast with fabricjs, and it is working now here but the problem is the object didn’t move if i was using smartphone which is using touch. Should i create another event listener for touch event? or should it be working just fine using mouse event?
here's how i can move the object
if (e.target !== this.upperCanvasEl) {
var positionOnScene = getPositionOnScene(container, e);
pointer.x = positionOnScene.x;
pointer.y = positionOnScene.y;
}
and here's 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 help me? any thought would be really helpful