Hi! I’m referring to this doc and this playground (which don’t match, but are close):
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:
https://github.com/BabylonJS/Babylon.js/blob/preview/src/Cameras/cameraInputsManager.ts
However, in the documentation’s implementation:
- It accesses
camera.cameraRotation, which doesn’t exist onCamera, but it is defined onTargetCamera. Not a big deal, just needs to be cast differently. - It says
attachControlanddetachControlhave a parameterelement: HTMLElement, but they don’t, according to the API docs (Babylon.js docs) and source code (https://github.com/BabylonJS/Babylon.js/blob/preview/src/Cameras/cameraInputsManager.ts#L35)
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.
