Skip to content

Conversation

@quillaja
Copy link
Contributor

@quillaja quillaja commented Feb 25, 2022

Finally following up to #124 on my ancient promises of an alternative camera control to Orbit. I see there is also PR #196 and #262 for something similar.

I used a series of maps to allow the user to configure the keys, mouse, speeds, and constraints. Translation, Yaw, Pitch, Roll, FoV Zoom are available, and pitching is not restricted to [-90, 90] from world up.

I tried to describe the use of FlyControl as succinctly as possible in its documentation:

    FlyControl provides a camera controller that allows looking at the scene
    from a first person style view. It allows for translation in the
    Forward/Backward, Right/Left, and Up/Down directions, and rotation in the
    Yaw/Pitch/Roll directions from the camera's point of view. The camera's
    field of view can also be modified to allow ZoomOut/ZoomIn.

    For maximum flexibility, the FlyControl is very configurable, but two main
    modes of operation exist: "manual" and "automatic".

    "Manual" mode requires the user to directly make adjustments to the
    FlyControl's position and orientation by using the Forward(), Right(),
    Yaw(), Pitch() and other similar methods. Manual mode does not subscribe to
    key or mouse events, nor does it use the FlyControl's member maps "Speeds",
    "Keys", or "Mouse" ("Constraints" is used). A FlyControl created (eg with
    NewFlyControl()) with no options defaults to "manual" mode.

    "Automatic" mode subscribes to key and mouse events, and handles position
    and orientation adjustments according to parameters specified in the "Keys",
    "Mouse", "Speed", and "Constraint" maps. Generally, methods such as
    Forward() will not be used. Some preconfigured options are available with
    FPSStyle() and FlightSimStyle(), and can be further configured by the
    With*() options, and by modifying the FlyControl's Keys (etc) maps directly.

@quillaja
Copy link
Contributor Author

One thing to add would be a way to use the constraints to restrict translational movement to a plane (eg XY).

@dolanor
Copy link

dolanor commented Nov 10, 2025

I would really love to have that integrated. I know it's been a long time, but if you're still motivated, could you add a use case so we could see it in actions like in the demos? To see how to use the API.

@quillaja
Copy link
Contributor Author

Yea, I can do that, or at the very least put up a gist. I think I was testing it using the g3n OBJ viewer example... if I can find it in my src dir.

@dolanor
Copy link

dolanor commented Nov 13, 2025

Yea, I can do that, or at the very least put up a gist. I think I was testing it using the g3n OBJ viewer example... if I can find it in my src dir.

Amazing that you're still available and still motivated to keep that going… Thanks!

@quillaja
Copy link
Contributor Author

quillaja commented Nov 14, 2025

here's a fork of the demos repo with the changes i had made to the "view" demo to use FlyCamera. I suppose to build it, you'll have to add a replacement of g3n to your local repo. Something like
replace github.com/g3n/engine v0.2.0 => ../../engine in go.mod

quillaja/demos@9b36dba

It's mostly a drop-in replacement for the orbit control, due to the camera control interface. I couldn't build it now on my current (windows) machine because my mingw64 appears to lack a couple dlls. And I'm also missing a lib in WSL so I also couldn't launch the linux binary I had built years ago.

@dolanor
Copy link

dolanor commented Nov 15, 2025

That's amazing! Thank you so much.
One thing I noticed is that it doesn't work anymore once we load a model in the viewer. No more keyboard moves.

Do you know what's acting up?

@quillaja
Copy link
Contributor Author

That seems familiar, but I don't recall anything specific and I don't see any thing I changed in my copy of the demo to prevent that. Have you tried loading a model from the cmd line when launching the exe? I wonder if the gui is stealing focus or something like that. I'll try to investigate a little more in the next few days.

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