I am trying to ‘teleport’ a webxr camera to a new position facing a target. If I call webxr.setTarget() to do this, then entire scene gets tilted according to headsets current x and z rotation, which is kinda fun but not what I want.
I’ve studied teleportation code and still no joy. Any straightforward ideas or approaches? Probably a question for @RaananW.
The teleportation module allows you to set the direction you are facing when landing at a position. it does that using input from your controllers. there is currently no way to do that in code. Set target is probably not what you are trying to achieve - you want rotation on the Y axis only.
can you explain your exact use case? do you want to set a different direction right after teleporting? can you share the code you are using? or a playground?
Yes I am teleporting to a position then need to rotate on Y to face target. I’ve concluded as you say that setTarget() isn’t the way. Instead I’ll just work out rotation angle from destination and target pos. I’ll try that next. Will report results – Thanks @RaananW
Success. I had previously tried adjusting camera.y and got nowhere. But then I remembered I need to apply to quaternion to make it work. This gets it done:
I am happy you found the right solution. You could have generated a quaternion for the rotation only and multply the camera’s rotation with the new one, but the result would be the same
I am thinking maybe it makes sense to add this functionality to the webxr camera directly. i’ll see what I come up with.