Addition of Camera type that matches 3D applications

TL;DR


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.
3 Likes

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.

This is an excellent idea! I do like it

Would you be ok to create it or write the how to?

https://doc.babylonjs.com/how_to/how_to_start
https://doc.babylonjs.com/how_to/contribute_to_documentation

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.

1 Like

This is what I look for actually. I created Babylon.js as a community project and I think the more we are to contribute the better it becomes :wink:

3 Likes

Can this work for your needs?


Or are you looking for a simpler camera type?

I’m trying to implement a beaviour like this for a couple of days/weeks now in my spare time, so far I’ve come to this: https://www.babylonjs-playground.com/#E2Q8RH#9

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 :slight_smile: 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.

Do not know what I am doing wrong but I cannot get movement of the camera at all in your PG https://www.babylonjs-playground.com/#E2Q8RH#9

While not what you want the camera to do the this use of camera inputs might provide a template to produce the behavior you require

You need to keep a key pressed (j for eg) then move the camera (click left on the area first to give it focus).

Already did all that prior to posting, in FF74.0, Edge 44.18362.449.0 and Chrome 80.0.3987.149

Forgot to say you must also keep the left mouse button pressed, but I guess you also tried this?

It does work for me in Chrome and Firefox.

I did, also tried using Caps on and off. Wonder if its because I am using the lap top mouse pad?

@JohnK Hmm weird, are you seeing a red sphere where you clicked with your mouse?

No, onPointerDown is not firing if a key is pressed.

No idea, why it‘s not working for you :-/ Maybe you could try to comment out the lines in the pointerup event to try the operations one by one?

I decided to give this another try by utilizing custom camera inputs. So far rotation around a pivot point is working: https://www.babylonjs-playground.com/#LTI9BG#10

Zoom is now working too :tada:
https://www.babylonjs-playground.com/#LTI9BG#13

Edit: And panning aswell! https://www.babylonjs-playground.com/#LTI9BG#14

2 Likes

@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 :slight_smile: To answer your questions:

  1. 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.
  2. No not yet. I might need this functionality for my side project though, so when I integrate this, I’ll probably mention it here :slight_smile:
  3. 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?