XR input with BABYLON.WebXRInput?

I BADLY need a working example with the QUEST controller fully working. I am having trouble with

var xrInput = new BABYLON.WebXRInput(xrHelper);

This line does not seem to work. It crashes my program whenever I add it.

It is used in several examples in

Use WebXR (WebVR, WebAR, Magic Window, Etc.) - Babylon.js Documentation.

and crashes there. (The examples seem to work when anything with this line – and anything with xrinput – are commented out.)


I have no idea what “Use WebXR (WebVR, WebAR, Magic Window, Etc.) - Babylon.js Documentation” is. Looks like an old copy of the real site.

The current docs have examples on the right side. I think your code might be blowing up because it is backwards. My code tgets the input from the helper, not passing a BABYLON.WebXRDefaultExperience to a constructor.

let xrInput = defaultExperience.input;

1 Like

Thanks. I will try that.

You write: " Looks like an old copy of the real site." I am having trouble finding the best documentation. Where did you get the documentation that you used to use

let xrInput = defaultExperience.input; ?

I would urge BABYLON to
(a) Purge obsolete documentation.
(b) Complete all the documentation of XR with working examples.
(b1) Include the HTML (explicitly) necessary to make a Playground example work. (Some examples need particular scripts to be included. The documentation of the underlying API does not usually make it clear what needs to be included in the HTML file calling for a createScene() function. )
© Hire an editor to improve the writing in the documentation. Parts of the documentation are poorly written, grammatically incorrect, and almost inscrutable.

Adding @RaananW and @PirateJC for the comments on the doc

@qporit the real documentation site is here: doc.babylonjs.com

Hey buddy, please watch your tone. We are all working on a Open source project. please enlighten us by doing some PR to improve the documentation



Thanks for your comments and answers to my questions.

You wrote: “Hey buddy, please watch your tone. We are all working on a Open source project. please enlighten us by doing some PR to improve the documentation.”

I did not mean to be mean. I think my statement is a factual description of the quality of some of the language in the documentation. I have a great deal of interest in BABYLON and I am putting a great deal of effort into developing a BABYLON-centric webXR site. I believe that the people working on BABYLON are working very hard. But the part of the documentation related to XR is not yet complete, it is not well-written, and it is not sufficient as-is to get up to speed quickly.

I could have listed many other suggestions for improving the documentation, including

a focus on the design and writing of documentation that understands what people who do not know how to program in BABYLON do not understand. (Once I understand BABYLON, much of what is now incomprehensible will make sense, but documentation must be written to make simple, immediate sense to people who do not understand it.)

I’d love to contribute to creating documentation; even write a new book about the updated BAYBYLON. Unfortunately, I can not contribute to the documentation yet because I do not understand it.

I have learned many computer languages from documentation, written documentation for IBM, helped a French company translate documentation into English, and consulted for many companies in many computer languages. My remarks were intended as constructive suggestions to help BABYLON improve its documentation to enable newcomers to webXR (ie everybody… including me) to program webXR sites with BABYLON.


They clearly not come through as is. Please note also that we are an international set of people and some barely speak english. You are lucky to be english or to speak english natively. Please just consider that as a chance and not as an obvious state

For instance I’m french.

Anyway…I hope you will find what you need.


I think it is great that people from all over the world can contribute to the creation of technology and science and to BABYLON in particular.

I also think that one part of that is that the documentation in every language must be optimized as fluent, clear, grammatical and helpful for that language. I stand by my statement that the English language documentation can, should, and hopefully will be improved.

(When the content is good, but the presentation of it is not, a very good approach is to have a person with documentation editing expertise be dedicated to the creation of the documentation, translating the knowledge of expert developers into the most effective communication for new developers. That’s why I suggested “hiring” a dedicated editor.)

This is not intended as criticism, it is intended to help BABYLON succeed.


My use for input is to enable the hands tracking feature. This feature needs a WebXRInput in the options. I get it from the helper. Just as it is shown here:

I do not know what you are doing, but your line of code has a xrHelper in it, so you already have an XRInput. I have never even bothered to find out what one is, so can be of no more assistance, other than I read the source code. It is never out of date, nor more definitive.

1 Like

Thanks. My program runs now with the line you suggested. I will go on to the next step now.

Are you reading the source code from the BABYLON github? Or from an example with hand tracking?

As you have eventually found out what you needed, here are my 2 cents on this:

This was done.

I am not sure what is not complete, and where you couldn’t find examples. Every page has a few examples of the subject at hand. If there aren’t, we will be happy to add.
It is always easy to forget that this is an open source project. COntributions are welcomed, and I can’t remember the last time I rejected a PR to the docs page.

Download a playground and you will have everything you need to get started. There are also many examples on the playground about code structure and how to get started.

We are very strict about that, and this shouldn’t happen. There are some cases where an external engine/framework is needed (like physics engines), but anything that is not included in our playground is not supported by us anyhow. So - not sure what you refer to, maybe provide an example instead.

createScene() is just one way of starting your scene. this is what the playground does. This is not the only way.

It seems to me like you jumped into “diving deeper” before you read the getting started guide. WebXR is just a part of this framework. there are a few other aspects to it that you will need to understand in order to get everything to work. If you understand babylon, the camera system, user input, observables, you will have no problem dealing with webxr using babylon.js. If, on the other hand you will only read the webxr documentation, you will have a lot of open questions that need to be answered.

Oh, and:

If you are referring to the WebXR documentation, that would be on me. I will forward that to my high school English teacher. I am sure she won’t be happy about it.

Once again, we are fully open-sourced. We hide nothing. Everything - source code, examples, PRs. We have one source of truth, and that is our source code. It is fully documented though it does contain a few spelling mistakes! But some great person (thanks Jason!) started correcting them, and we were really happy about it.

We are certainly not perfect, and are always eager to learn from our users. If you have any specific question, we will be more than happy to answer it.


The answer in this case was from some PG I searched for, then expanded to github source, but that was because I started working in this area right at year end.

The hand tracking feature was put in very late for the 4.2 release. There was no documentation released on it till last Wednesday.

In general, this level of scrounging is only required when looking at features being added for a release, or one that just barely made it into a release.

I am also prone to reading source files from my system, directly in the Ide I use, Netbeans. I usually execute this first on my clone of my github fork:

git pull upstream master