When providing a optional offsetRay to the hitTest.start method, playcanvas throws the following error:
xr-hit-test.js:239 Uncaught TypeError: Failed to construct 'XRRay': Direction's `w` component must be set to 0.0f!
at XrHitTest.start (xr-hit-test.js:239:32)
HitTest is started as described in api documentation:
var self = this;
this.ray = new pc.Ray(new pc.Vec3(0, 0, 0), new pc.Vec3(0, -1, 0));
this.app.xr.hitTest.start({
spaceType: pc.XRSPACE_LOCAL,
entityTypes: [pc.XRTRACKABLE_POINT, pc.XRTRACKABLE_PLANE],
offsetRay: self.ray,
callback: function (err, hitTestSource){...}
});
Can you provide an example project please with the issue?
Hey,
somehow the error does not show anymore, however, the overall behavior is still the same:
https://playcanvas.com/project/949687/overview/ar-hit-test-custom-ray
WebXR AR ‘immersive’ mode closes immediately after starting when custom ray is provided to hittest. Custom ray can be deactivated by the checkbox on the hitTest script on the root node.
I had a look at this and it looks like an exception is being thrown when start is called if you try to pass an offset to it:
https://github.com/playcanvas/engine/blob/main/src/xr/xr-hit-test.js#L239
It tries to create an instance of XRRay which doesn’t exist.
I will log a ticket for this in the engine
1 Like
Fixed in https://github.com/playcanvas/engine/pull/4372
I expect this to go out with engine version 1.54.2 if we do release a patch or 1.55.0
1 Like