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:
- 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
attachControl
anddetachControl
have a parameterelement: HTMLElement
, but they don’t, according to the API docs (ICameraInput | Babylon.js Documentation) and source code (Babylon.js/cameraInputsManager.ts at preview · BabylonJS/Babylon.js · GitHub)
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.