Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

92
Views
UseGesture Arrastrar se mueve a la mitad de la pantalla en R3F

Estoy usando useGuesture y para hacer que algunos elementos se puedan arrastrar en R3F.

Cuando empiezo a arrastrar (o incluso hago clic en el elemento), se mueve al centro de la pantalla antes de que sea posible arrastrarlo.

¿Cómo puedo hacer que se arrastre desde su posición actual?

Este es un código que obtuve de https://maxrohde.com/2019/10/19/creating-a-draggable-shape-with-react-three-fiber/ e intenté que funcionara con objetos que sí no comience en el centro de la pantalla.

 export default function Draggable(props) { const [position, setPosition] = useState(props.position); const { size, viewport } = useThree(); const aspect = size.width / viewport.width; const bind: any = useGesture( { onDrag: ({ event, offset: [x, y] }) => { const [, , z] = position; setPosition([x / aspect, -y / aspect, z]); }, onDragEnd: event => { props.onMove(position); }, onClick: props.onClick, }, { drag: { filterTaps: true } }, ); if (!props.children) return null; return ( <mesh position={position} {...bind()}> {props.children} </mesh> ); }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!