Camera control like in 3D application

Hello everyone,

I’m new to BabylonJS, and i have to say that so far, the development experience has been great. Also the documentation is top notch! …I’d like to ask one question though:


Is there a specific camera preset or snippet that makes the UniversalCamera feel like a camera out of a 3D application like Blender or Maya?


I understand that the default behavior is geared towards gaming, but it seems to me that i wouldn’t be the first one who wants to use the canvas more like a OpenGL viewport from an application like Blender or Maya, am i? Specifically i want to:

  • rotate with alt+lmb
  • stafe with alt+mmb
  • zoom with alt+rmb

Just like the Blender cam when set to Industry compatible mode. I don’t need any gaming related features like walking feel-alike behavior, collision detection etc.

Thankful for any hints or snippets.

Related question:


How can I frame with a UniversalCamera or FreeCamera?


This was very comfortable using the FramingBehavior of an ArcRotateCamera.

So the documentation leads me to believe that UniversalCameras implement the BehaviorInterface and they also have an addBehavior() method, however when I try universalCamera.addBehavior(new FramingBehavior()) I get an error:

ERROR TypeError: Cannot read property 'add' of undefined
    at FramingBehavior.push../node_modules/@babylonjs/core/Behaviors/Cameras/framingBehavior.js.FramingBehavior.attach (framingBehavior.js:198)
    at UniversalCamera.push../node_modules/@babylonjs/core/node.js.Node.addBehavior (node.js:248)
    at SceneManager.setupUniversalCamera (scene-manager.ts:365)
...

The same happens with a FreeCamera.

Hi @timmwagener and welcome to the forum.

More than a snippet but you can rewrite how a camera reacts to an input Customize Camera Inputs - Babylon.js Documentation

Thanks @JohnK this looks like it would provide the building blocks to implement the desired behavior, in case there is not yet a canonical implementation/snippet floating around. Had seen inputs previously and briefly but was under the impression that it was mostly useed to enable input methods like Gamepad etc. …hadn’t realized it’s whole potential.

As it seems there is no ready-made preset for this case, if there is a feature wishlist or so (github issues?) i’d throw in the idea of a specific new EditorCamera camera type next to FlyCamera, FollowCamera etc. that behaves exactly like a Maya or Blender Industry Compatible camera to navigate 3D scenes for editing. (Or is there a reason why this shouldn’t exist?)

https://forum.babylonjs.com/c/features/11

Great, i’ll add a wish there.


Concerning the addition of FramingBehavior to a UniversalCamera or FreeCamera, is this broken or did I misuse it?

Am I supposed to build the framing behavior for UniversalCameras using:

  • vector to target mesh
  • orient along that vector
  • move along that vector until target mesh bbox is in frame
  • ease in/out movement using animation API primitives

?

Cannot help with this. Suggest you re-ask this question in a new top along with a simple playground showing the issue

1 Like