[WebXr] onHitTestResultObservable always gives non zero results.length

hitTest.onHitTestResultObservable.add((results) => {
if (results.length) {
dot.isVisible = true;
results[0].transformationMatrix.decompose(
dot.scaling,
dot.rotationQuaternion,
dot.position
);
} else {
dot.isVisible = false;
}
});

In above code (taken from hit-test example) its never going in else part .

In WebXRHitTest.ts.
Its notifying when results.length is non zero.
if (results.length) {
this.onHitTestResultObservable.notifyObservers(results);
}

How to know when I am not getting the hit ?

Definitely a question for our friend @RaananW but it would be amazing if you could create a PR highlighting the issue ??? it will definitely help him :slight_smile:

Yep, you are right.

This observable is only triggered when new hit test results are available, so there is no real way of knowing when the system sent no results.

Let me think of a proper way to do that. The simplest would be so send an empty array, but that negates the entire idea of this observable.

Want to submit a github issue for that?

1 Like

Yeah , I will submit the issue. May be make a new method with name getHitTestResults.

1 Like