Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DragControls movement doesn't map to mouse when used within RenderTexture #2350

Open
chuckdries opened this issue Feb 12, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@chuckdries
Copy link

chuckdries commented Feb 12, 2025

  • three version: 0.173.0
  • @react-three/fiber version: 8.17.14
  • @react-three/drei version: 9.121.4
  • node version: N/A (sandbox)
  • npm (or yarn) version: N/A (sandbox)

Problem description:

My naive expectation would be that using a DragControls within a RenderTexture, the dragged object would track the mouse's raycasted position across the surface the texture is rendered on (such as the threejs raycast texture example). Instead, it seems to map to the mouse's position across the Canvas.

dragcontrols.within.rendertexture.2.mp4

Relevant code:

https://codesandbox.io/p/sandbox/kws3cx

<Box>
  <meshStandardMaterial>
    <RenderTexture attach="map" anisotropy={16}>
      <PerspectiveCamera
        makeDefault
        manual
        aspect={1 / 1}
        position={[0, 0, 5]}
      />
      <color attach="background" args={["orange"]} />
      <DragControls axisLock="z">
        <Circle>
          <meshBasicMaterial color="red" />
        </Circle>
      </DragControls>
    </RenderTexture>
  </meshStandardMaterial>
</Box>

Suggested solution:

It's clear to me that we need to be doing a raycast, but I'm still pretty new to threejs and 3d programming in general, so I don't really know where to start with implementing it.

@chuckdries chuckdries added the bug Something isn't working label Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant