FreeCameraKeyboardWalkInput example/docs not flanging with the actual BabylonJS API?

Hi! I’m referring to this doc and this playground (which don’t match, but are close):

https://playground.babylonjs.com/#CTCSWQ#1

I’m trying to adapt these to a TypeScript class so I can tweak the logic and use it in my code – basically, I want arrow keys to “look” without “moving” the camera. I’m using the latest 5.0 releases in my app.

I’ve run into a few problems I’m hoping someone can shed light on:

Registering/Unregistering top root events

The docs use this:

BABYLON.Tools.RegisterTopRootEvents(canvas, ...)
BABYLON.Tools.UnregisterTopRootEvents(canvas, ...)

However, there is no “canvas” in scope here. The playground example doesn’t even call RegisterTopRootEvents, but does call UnregisterTopRootEvents, and when it does so, does not provide a first argument. However, this doesn’t match the functions, which need a Window as the first argument:

Should I use camera.getScene().getEngine().getHostWindow() for that, as shown here?

The purpose of _onLostFocus()?

The documentation also doesn’t actually show an implementation of _onLostFocus(), but the playground example has one, it just sets this._keys = [];. Is that the appropriate logic? Seems reasonable based on what I think it is doing there.

TCamera doesn’t match its use in CheckInputs()

According to the docs, our custom input manager should implement ICameraInput, defined here:

However, in the documentation’s implementation:

If I’m interpreting all of this correctly, I’m happy to put a PR in to update the documentation – assuming the docs are even meant to align with the master or current Babylon 5 alpha? There is, unfortunately, no indication on the documentation pages or API docs about which version they are targeting.

1 Like

Actually all you found makes sense and we would greatly appreciate a PR to fix it !!!

The doc is always matching latest preview :slight_smile:

Thanks a ton @richardtallent

1 Like

Not sure that this is true. I thought the API section of the docs was generated from the comments in the source code of the current version (now 4.2) rather than the preview (now 5). The other sections of the docs were written at various times and could be several years old.

However, since Babylon.js has a very rigid - No Breaking Changes- policy the docs should accurately reflect the current version. In the extremely rare occasions of a breaking change occuring in the preview version this should be reflected in the current main body of the docs by the time the preview version becomes the current version. This is also true of of new features in the preview version.

Having said all that, historic errors in the docs can continue from version to version. It could be that a page of the main body of the docs was written during the development of a feature in a preview, published and not updated as the feature was tweaked before preview became current. Other ways of creating doc errors are available.

API is built from the current version (I hope so actually, so checking with @RaananW )

Yes, this is true. The docs are based on the latest nightly (the last one when the doc page was built, which is roughly 2 days ago)

2 Likes