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

Orbital Controls modes of input to accomodate null values #228

Closed
wants to merge 1 commit into from

Conversation

Heaust-ops
Copy link
Contributor

So say I want left click to control nothing.
Right now I have to do this,

    controls.mouseButtons = {
      LEFT: null as unknown as THREE.MOUSE,
      MIDDLE: THREE.MOUSE.ROTATE,
      RIGHT: THREE.MOUSE.LEFT,
    };

This PR tells typescript to expect null values when the dev wants a specific mode of input not to control anything.
'null' is probably better than making it optional / undefined because it's explicit and fields can unknowingly be left undefined.

So say I want left click to control nothing.
Right now I have to do this,
```
    controls.mouseButtons = {
      LEFT: null as unknown as THREE.MOUSE,
      MIDDLE: THREE.MOUSE.ROTATE,
      RIGHT: THREE.MOUSE.LEFT,
    };
```
This PR tells typescript to expect null values when the dev wants a specific mode of input to not control anything.
'null' is probably better than making it optional / undefined because it's explicit and fields can unknowingly be left undefined.
@joshuaellis
Copy link
Member

Can you point to the THREE documentation // src code where this type change should be allowed?

@Heaust-ops
Copy link
Contributor Author

Yeah, orbital controls handles these options with switch case,
like in line 868 in OrbitControls.js,
a default case is handled, that means anything other than the expected value, like null, is handled,
and in such a case (unexpected value, like null), the orbital controls won't do anything, or sit idle, line 947.
which is exactly what we want, for them to sit idle on null.

@joshuaellis
Copy link
Member

closed in favor of #236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants