Skip to content

allow disabling controls per axis#2706

Open
romankoho wants to merge 2 commits intopmndrs:v11-workingfrom
romankoho:feature/allow-disable-controls-per-axis
Open

allow disabling controls per axis#2706
romankoho wants to merge 2 commits intopmndrs:v11-workingfrom
romankoho:feature/allow-disable-controls-per-axis

Conversation

@romankoho
Copy link
Copy Markdown
Contributor

Why

When using the PivotControl with an orthographic camera certain elements of the control can collapse / project on the same plane.

In my screenshot below you see how the pink arch of the AxisRotator collapses with the arrow of the AxisArrow. The user tries to move the object along the axis but instead he/she interacts with the AxisRotator and rotates the element unintentionally.

In this case I would want to be able to control the visible elements per axis

image

With the solution implemented I would be able to hide the arch for the x and z axes if the camera forward vector is (almost) perfectly aligned with the world-up vector.

image

What

1. The disable props of the PivotControls now either accept a boolean to disable the element for all axes or an array of three booleans to turn on/off the element per axis.

  disableAxes?: boolean | [boolean, boolean, boolean]
  disableSliders?: boolean | [boolean, boolean, boolean]
  disableRotations?: boolean | [boolean, boolean, boolean]
  disableScaling?: boolean | [boolean, boolean, boolean]

the flag is then considered when rendering

    const disableAxesFinal = Array.isArray(disableAxes) ? disableAxes : [disableAxes, disableAxes, disableAxes]

    return (
          {!disableAxesFinal[0] && activeAxes[0] && <AxisArrow axis={0} direction={xDir} />}
          {!disableAxesFinal[1] && activeAxes[1] && <AxisArrow axis={1} direction={yDir} />}
          {!disableAxesFinal[2] && activeAxes[2] && <AxisArrow axis={2} direction={zDir} />}
    )

2. fix typo in PivotControls index.tsx (noticable to noticeable)

Checklist

  • Documentation updated (example)
  • Storybook entry added (example)
  • Ready to be merged

I had PR #2701 open but messed up the git history (a noob was doing noob stuff)

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 16, 2026

@romankoho is attempting to deploy a commit to the Poimandres Team on Vercel.

A member of the Team first needs to authorize it.

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci bot commented Mar 16, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@DennisSmolek
Copy link
Copy Markdown
Member

Why did you close the last PR for this? It removes the review/discussion threads and with bots/security being issues for libs it raises hairs.

@DennisSmolek
Copy link
Copy Markdown
Member

oh I see the git history note...

Copy link
Copy Markdown
Member

@DennisSmolek DennisSmolek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All in all this seems good.

It doesnt solve your ultimate problem though and requires users to straight disable them instead if the rotation to be off when the camera at the extreme angle.

These props are useful so I support merging it, however I made some semantic recommendations.

I would also be interested in an expanded version that takes the camera normal and potentially disables the rotation arcs which solves your actual problem.

The next thing is we are avoiding v10 merges unless fixing breaking/major things, so I'm not sure this would go in soon on v10, however, if you PR this against v11 with those minor changes I will merge it in immediately.

Copy link
Copy Markdown

@travisbreaks travisbreaks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both issues from my review on #2701 are resolved:

  1. Inverted ternary: disableScalingFinal now follows the same Array.isArray(x) ? x : [x, x, x] pattern as the other three props. Good.

  2. Axis index mapping: Sliders and rotators now index by the axis prop value (the normal axis) instead of render order. disableSlidersFinal[2] guards axis={2}, [1] guards axis={1}, [0] guards axis={0}. Consistent with disableAxes and disableScaling. This is exactly what I suggested.

Clean diff overall. The typo fix and storybook entry are nice touches. LGTM.

@romankoho romankoho changed the base branch from master to v11-working March 17, 2026 09:26
@romankoho
Copy link
Copy Markdown
Contributor Author

thanks @travisbreaks and @DennisSmolek for your review!
I've changed the target branch to v11-working

@travisbreaks I'm also curios about your thorough review. Did you you write it yourself or use a tool?
@DennisSmolek yes I'm aware that the PR doesn't solve my initial issue but at least it enables me to solve it on my end. I'd be open to actually fix it within the PivotControls component in a future PR.

@romankoho romankoho force-pushed the feature/allow-disable-controls-per-axis branch from c542252 to 7361cb4 Compare March 17, 2026 10:01
@romankoho
Copy link
Copy Markdown
Contributor Author

hey @DennisSmolek any more changes needed or is it good to merge?

@romankoho
Copy link
Copy Markdown
Contributor Author

you guys can also check out #2708
As previously discussed this branch would directly hide the control elements depending on the perspective

@DennisSmolek
Copy link
Copy Markdown
Member

hey @DennisSmolek any more changes needed or is it good to merge?

Ill spend time this weekend on drei and likely merge this to v11. Sorry for the delay. Starting a new job ate up some time. Will be catching up though

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.

3 participants