this is a feature request to introduce a new Camera type/preset to BabylonJS: EditorCamera, to match typical 3D editor cameras.
Description
The new EditorCamera camera type should provide an out-of-the-box camera that matches a camera one would know from the typical 3D editor OpenGL viewport (Maya, 3D Studio Max, Blender, Houdini, Nuke 3d viewport, etc…). They more or less all control the same:
rotate with alt+lmb
strafe with alt+mmb
zoom with alt+rmb
ability to frame selected objects (FramingBehavior compatible)
Blender has a settings which it calls Industry compatible control, which makes the camera behave like that. So it should be a rather known/usefull control scheme, which may be familiar to many artists.
Use case
The use cases for this would be scenarios where Babylon is used to just present information in a 3D scene and that have no direct relation to gaming, physics, player movement etc. A user is not part of a “world/level/game”, he just aseptically and with least interference wants to browse information rendered in 3D. He wants to do it in the same way he knows from other applications, so nothing needs to be relearned.
Misc.
Can it already be done? I think one could possibly build it using CameraInputs. However it might be hard to do and easy to get kinda wrong for new Babylon devs. A preset from the core devs. that gets it right in all ways seems preferable over many attempts that may vary in quality. Also I feel like the use case is broad enough…!?
Why doesn’t it exist already? I’m knew to Babylon and coming from a 3D/VFX background, not a gaming background. So I’m used to using 3D as described above and was kind of surprised not to find the basic camera type i’m used to. But maybe there are good reasons for that!? Maybe I overestimate what it takes to build it myself with CameraInputs? The fact that it doesn’t exist may hint at the fact that typical Babylon users so far didn’t needed it or built it themselves easily.
Alternatively: If it’s really easy to turn a UniversalCamera into the requested EditorCamera by modifying CameraInputs, an offical How To would be appreciated and fullfil the feature request as well.
Well, after a few days of using Babylon, I do not necessarily see myself as the most qualified person for the job. But i may end up giving it a try. Should I succeed in creating the camera behavior according to my request using only CameraInput and FramingBehavior, i’d surely make a PR containing a HowTo writeup.
Note: The controls are mapped to: j, k, l (rotate, pan, zoom). Every operation uses the point under the cursor as the pivot. It’s really hacky and also there are still some bugs, but it looks like it can be done Maybe we can join our efforts to bring this forward.
The „hack” I’m using for the rotation is basically to parent a second camera to an arc rotate camera and calculating an offset so the camera view stays the same while the target changes. This breaks sometimes, especially when you rotate the camera to a top-down view and back a couple of times.
I’m sure there is a better way to do this, but I’m not that much of an expert with everything regarding the math needed for something like this.
I also think this would be a really cool addition to BabylonJS, I could try to implement this, but it would probably take me months to finish, if I could make it work at all.
@Deltakosh Maybe dev(s) of the Babylon core team are willing to implement this? I think I could at least describe the behaviour of the camera quite precisely and I’d also be willing to write the documentation for that.
@thomasaull Sorry for the late reply and thanks for the great work! The last playground (using a custom CameraInput) seems to work very well from what i can test. A few questions:
Are you planning on making a pull request for this to get it reviewed and possibly refine/progress/merge it?
Does it support setting FramingBehavior? I was struggling to get this to work because of errors, but having framing seems like a necessity for an editor viewport camera?
As a side question: Isn’t an ordinary editor camera something that would be needed anyways for the Babylon editor at some point? (Rather sooner than later…!?) Or is navigation in primarily game related DCC viewports like Unreal Editor, Unity Editor etc. different by default from general purpose 3D DCCs like Blender, Maya etc.
@timmwagener Sorry for the late reply aswell To answer your questions:
Probably I won’t have the time nor the skills for that I’m afraid. I have abstracted the playground code into a Javascript Module which could be used more easily in real projects — if there’s any interest I’m happy to share it. Also I think I made some additional bugfixes along the way.
No not yet. I might need this functionality for my side project though, so when I integrate this, I’ll probably mention it here
I was wondering the same, actually the Editor was one of the first places where I looked for a camera like this. As far as I know the primary input in 3D DCCs is a classic WASD First Person Shooter like navigation. But in Unreal there is a “Editor-like” input mechanism in place …I think. Maybe the creator of the editor is willing to pick this up? @julien-moreau this is you, isn’t it?