Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

100
Vistas
Raycast threejs touch event not working using mouse event

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

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There is 2 reasons.

1:

You return null in the `getPositionOnScene` function.

2:

Touch is not the same as a mouse event.

You will have to do `document.addEventListener("mousedown", callback)`
so it supports mouse events too.
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda