Add hidden camera property into documentation


Recently I’ve remembered about how I should make this post, so I am.

There is a “hidden” camera property that allows the free camera with collision to fall without moving at all. Normally when you walk off the platform in the babylon.js collisions playground demo, after falling for a little you can look up and see the cube you were just by, not getting any smaller since you are not falling. press and arrow key again and it will get smaller, until you let go and inertia runs out, returning you to the floating state.

Add the line camera._needMoveForGravity = true;, run the code, and walk off the platform again, and when looking at the box it will get smaller and smaller because you will never stop falling.

The property contradicts itself by stating that you have to move to have gravity, when in fact it has a reversed effect. by default it is set to false.

It is not in the API documentation, and I feel it is not very known about.

It was shown to me by @Wingnut here: Gravity only affects camera when moving

I feel it should be documented and set to false by default.

Let me know any thoughts!


Golden rule #1: Never touch something starting with _.
This is considered a private, not user accessible property.

It exists for performance reasons (and it is false by default)


There are many hidden properties in Babylon.js, these are private properties and are there to support the internal code. All private properties start with an underscore and are not documented in the API since they are not public properties. As such there is no guarantee that they will remain the same overtime though the public properties they support will. Since BJS is open source they can be found and set directly. In particular use cases they may produce an effect you need but might not be available in a later version and can produce unwanted effects in other circumstances.

If you think it necessary you can always make a request for a change to make a private property public though potential adverse consequences need to be considered.


thanks for the explination.

Wait, if anything starting with _ isn’t documented, why is this one? It’s in the camera’s API documentation.

EDIT: Why can’t I choose to posts as solutions? Both of you have really good explanations and I can’t choose both!
@JohnK your post is also a solution.

1 Like

Sorry Givo… I didn’t mean to show you an illegal command. It’s the only way I know… to make a gravity-active cam… start falling automatically. Perhaps @deltakosh will tell us the more-correct way to do that (kindly).

1 Like

I wouldn’t call it illegal. If it breaks the game then I’ll call it a funny bug to mess with. :upside_down_face:

Like some people say, If it ain’t broke, don’t fix it! :smile:

1 Like

Because of a typo. API is generated directly from the code. Currently code is

/** hidden */
public _computedViewMatrix = Matrix.Identity();

should be

/** @hidden */
public _computedViewMatrix = Matrix.Identity();

PR submitted

This particular property is made public so that it is available in other classes internally but should not be accessed externally. However it is neither illegal nor a bug to use it provided you are aware of the consequences of doing so and are happy that for your use it is safe to do so. If it works for you its fine to use it.

1 Like

It look likes there are other typos

('will not make a PR mysef, fearing of broking something here)
[edit] issue created: some typo exists for hidden properties · Issue #6390 · BabylonJS/Babylon.js · GitHub

1 Like

From not know that it is a hidden property to finding typos! cool!


you say there are consequences, so how bad can the code break?

Suppose both class A and class B require _hiddenProperty = false and class C requires _hiddenProperty = true. You write code that sets _hiddenProperty to true, later in your project you add something that needs class C, so far so good. Then you add in something that needs class A or class B, since _hiddenProperty is now true your code will have a bug that could be very hard to trace.

1 Like

Oh. Thanks for the explanation.