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

Camera Options & Context Menu #1079

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from
Open

Camera Options & Context Menu #1079

wants to merge 19 commits into from

Conversation

HunterBarclay
Copy link
Member

@HunterBarclay HunterBarclay commented Aug 3, 2024

Description

In order to add the context menu and camera options I wanted, I had to rewrite the entire Camera Controller from the ground up. Good news, we now have an avenue towards mobile touch controls.

Camera

Made a custom orbit camera controller. This controller can be provided a MirabufSceneObject which will act as a provider for dictating what the camera follows around in the scene. You now also have the option to lock the camera orientation to that of the assembly you are following. Left-click to orbit, Right-click to pan.

On mobile, the first touch is for orbiting. If a second touch is detected, it will measure the change in distance between the two touches to determine zoom. Currently Firefox on mobile has something wrong with the movement data it gives, but other than that, it has been working pretty consistently.

Context Menu

If you Right-click, but don't move the mouse by a given threshold, it will instead open a context menu, depending on what you clicked on. Right now, MirabufSceneObject have support for the context menu, supplying options for camera options, scheme changing, and removing the assembly from the scene. If nothing is detected as being clicked on, it will populate with default scene options. Currently this only includes adding assemblies to the scene.

SSL

To test on other devices with the dev server. I have a boolean in vite.config.ts to enable/disable ssl. This will allow you to easily connect to the server AND have OPFS support for the caching system.

TODO

  • Low DeltaT causes horridly fast controls of the camera

@HunterBarclay HunterBarclay added enhancement ui/ux Relating to user interface, or in general, user experience labels Aug 3, 2024
@HunterBarclay HunterBarclay self-assigned this Aug 3, 2024
@HunterBarclay HunterBarclay requested a review from a team as a code owner August 3, 2024 00:30
@HunterBarclay HunterBarclay requested review from a-crowell and LucaHaverty and removed request for a team August 3, 2024 00:30
@HunterBarclay HunterBarclay changed the title Barclah/context menu Camera Options & Context Menu Aug 3, 2024
Copy link
Collaborator

@a-crowell a-crowell left a comment

Choose a reason for hiding this comment

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

This is super cool! Love the context menu.

  • Zooming in seems to zoom in the whole screen => MainHUD/Scoreboard out of view and field blurry rather than controlling scene cam. Note: browser is still on normal zoom seeing this.

image

  • Moving a MirabufSceneObject while camera is focused on it causes fun jumps that are more difficult to control. Temporarily unfocus?

image

  • Second time you move a MirabufSceneObject, the Move gizmo starts based on the last move rather than the current position. For the most part this can be worked around, but it would be nice to not have to go to the other side of the field
  • Could you make an option to lock heading/yaw follow without pitch and roll following? Or just make lock heading only to begin with

@HunterBarclay
Copy link
Member Author

@a-crowell

Zooming in seems to zoom in the whole screen => MainHUD/Scoreboard out of view and field blurry rather than controlling scene cam. Note: browser is still on normal zoom seeing this.

I have no idea what's happening there and I haven't ever seen it before. Could you give steps to reproduce it?

Moving a MirabufSceneObject while camera is focused on it causes fun jumps that are more difficult to control. Temporarily unfocus?

An unfocus would probably be a good idea, tho a better fix will probably be needed later down the line.

Second time you move a MirabufSceneObject, the Move gizmo starts based on the last move rather than the current position. For the most part this can be worked around, but it would be nice to not have to go to the other side of the field

This is a fundamental issue with how the transform gizmos are done. This may have to become it's own PR.

Could you make an option to lock heading/yaw follow without pitch and roll following? Or just make lock heading only to begin with

This runs into a lot of issues. The more the robot isn't upright, the more unreliable doing something like this becomes.

Copy link
Collaborator

@LucaHaverty LucaHaverty left a comment

Choose a reason for hiding this comment

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

Could you add rotation to the move gizmo in case robots tip over?

@a-crowell
Copy link
Collaborator

@HunterBarclay

Zooming in

On my work laptop, normal zoom: put two fingers down and moved the second outward. Happened every time I zoomed in, but never on zoom out. Happy to hop on call to show you.

Everything else sounds good.

@HunterBarclay
Copy link
Member Author

Could you add rotation to the move gizmo in case robots tip over?

Going to wait on @Dhruv-0-Arora 's transform gizmos fix for that.

@HunterBarclay
Copy link
Member Author

@a-crowell Where are you placing your fingers? Are they over any of the UI elements?

@LucaHaverty
Copy link
Collaborator

Could you make it so when you add/edit either a scoring zone, intake, or ejector, the camera follows the transform gizmo like in v6? I believe the camera stayed still while dragging the gizmo, then snapped to it when the mouse was released.

@a-crowell
Copy link
Collaborator

@a-crowell Where are you placing your fingers? Are they over any of the UI elements?

They're not over any UI, just the floor mesh or blank space surrounding. Want to hop on call so I can show you?

@LucaHaverty
Copy link
Collaborator

@HunterBarclay

Zooming in

On my work laptop, normal zoom: put two fingers down and moved the second outward. Happened every time I zoomed in, but never on zoom out. Happy to hop on call to show you.

Everything else sounds good.

@HunterBarclay for the solution, see InputSystem.ts line 167.

// Disable gesture inputs on track pad to zoom into UI
window.addEventListener(
    "wheel",
    function (e) {
        if (e.ctrlKey) {
            e.preventDefault() // Prevent the zoom
        }
    },
    { passive: false }
)

Copy link
Member

@BrandonPacewic BrandonPacewic left a comment

Choose a reason for hiding this comment

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

// Disable gesture inputs on track pad to zoom into UI
window.addEventListener(
"wheel",
function (e) {
if (e.ctrlKey) {
e.preventDefault() // Prevent the zoom
}
},
{ passive: false }
)
}

👀

@HunterBarclay
Copy link
Member Author

@LucaHaverty @a-crowell Added the fix, haven't tested it yet tho. Make sure you pull --rebase when getting changes, I'm trying out rebasing with this project.

@LucaHaverty
Copy link
Collaborator

@LucaHaverty @a-crowell Added the fix, haven't tested it yet tho. Make sure you pull --rebase when getting changes, I'm trying out rebasing with this project.

@HunterBarclay I'm unable to zoom at all now. It looks like with your custom camera, blocking the scroll wheel default blocks the camera inputs, but the threejs camera does something different that's not affected. Does it work with a mouse?

@LucaHaverty
Copy link
Collaborator

When opening the context menu:

Warning: Each child in a list should have a unique "key" prop.

Check the render method of `ContextMenu`. See https://reactjs.org/link/warning-keys for more information.
    at Button (http://127.0.0.1:3000/fission/src/ui/components/Button.tsx:19:19)
    at ContextMenu (http://127.0.0.1:3000/fission/src/ui/components/ContextMenu.tsx:20:31)
    at ToastProvider (http://127.0.0.1:3000/fission/src/ui/ToastContext.tsx:22:33)
    at PanelControlProvider (http://127.0.0.1:3000/fission/src/ui/PanelContext.tsx:20:40)
    at ModalControlProvider (http://127.0.0.1:3000/fission/src/ui/ModalContext.tsx:20:40)
    at PresenceChild (http://127.0.0.1:3000/fission/node_modules/.vite/deps/framer-motion.js?v=131b123d:7102:24)
    at AnimatePresence (http://127.0.0.1:3000/fission/node_modules/.vite/deps/framer-motion.js?v=131b123d:7168:26)
    at TooltipControlProvider (http://127.0.0.1:3000/fission/src/ui/TooltipContext.tsx:24:42)
    at PresenceChild (http://127.0.0.1:3000/fission/node_modules/.vite/deps/framer-motion.js?v=131b123d:7102:24)
    at AnimatePresence (http://127.0.0.1:3000/fission/node_modules/.vite/deps/framer-motion.js?v=131b123d:7168:26)
    at Synthesis (http://127.0.0.1:3000/fission/src/Synthesis.tsx:73:62)
    at ThemeProvider (http://127.0.0.1:3000/fission/src/ui/ThemeContext.tsx:22:33)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ui/ux Relating to user interface, or in general, user experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants