pmndrs / drei

🥉 useful helpers for react-three-fiber
https://docs.pmnd.rs/drei
MIT License
8.36k stars 699 forks source link

CameraControls `ACTION` not exported? #1816

Open SlawomirMazgaj opened 9 months ago

SlawomirMazgaj commented 9 months ago

Problem description:

Some exports seem to be missing for CameraControls. When trying to set mouseButtons one might think there is CameraControls.ACTION.* being there:

Screenshot 2024-02-06 at 11 52 00

but looks like it's not the case. I can't see ACTION being exported either.

Relevant code:

<Canvas>
  <CameraControls
    makeDefault
    mouseButtons={{ wheel: CameraControls.ACTION.ZOOM }}
  />
  <mesh>
    <boxGeometry args={[1, 1, 1]} />
    <meshNormalMaterial />
  </mesh>
</Canvas>

Sandbox

Suggested solution:

After cloning the drei repo it looks like ACTION can be imported from

import { ACTION } from 'camera-controls/dist/types'

I'm not sure if the best course of action is to export it from here or if it's actually a bug in camera-controls and that's why drei isn't forwarding it.

WebmasterTA commented 4 months ago

Hi,

It seems to work with int values declared in types :

export declare const ACTION: Readonly<{
    readonly NONE: 0;
    readonly ROTATE: 1;
    readonly TRUCK: 2;
    readonly OFFSET: 4;
    readonly DOLLY: 8;
    readonly ZOOM: 16;
    readonly TOUCH_ROTATE: 32;
    readonly TOUCH_TRUCK: 64;
    readonly TOUCH_OFFSET: 128;
    readonly TOUCH_DOLLY: 256;
    readonly TOUCH_ZOOM: 512;
    readonly TOUCH_DOLLY_TRUCK: 1024;
    readonly TOUCH_DOLLY_OFFSET: 2048;
    readonly TOUCH_DOLLY_ROTATE: 4096;
    readonly TOUCH_ZOOM_TRUCK: 8192;
    readonly TOUCH_ZOOM_OFFSET: 16384;
    readonly TOUCH_ZOOM_ROTATE: 32768;
}>;

It works in my case :

controls.current.mouseButtons.right = 0;
github-actions[bot] commented 5 days ago

Thank you for contributing! We’re marking this issue as stale as a gentle reminder to revisit it and give it the attention it needs to move forward.

Any activity, like adding an update or comment, will automatically remove the stale label so it stays on our radar.

Feel free to reach out on Discord if you need support or feedback from the community. This issue will close automatically soon if there’s no further activity. Thank you for understanding and for being part of the project!