Skip to content

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

@chuckdries

Description

@chuckdries
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingv11For v11 related tasks

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions