mirror of
https://github.com/godotengine/godot.git
synced 2024-11-26 14:13:10 +00:00
Merge pull request #85521 from dsnopek/webxr-fix-ar-position-godot3
[3.x] Fix touch events in WebXR with an "immersive-ar" session
This commit is contained in:
commit
ee883cea40
@ -561,8 +561,15 @@ Vector2 WebXRInterfaceJS::_get_joy_vector_from_axes(int *p_axes) {
|
||||
}
|
||||
|
||||
Vector2 WebXRInterfaceJS::_get_screen_position_from_joy_vector(const Vector2 &p_joy_vector) {
|
||||
SceneTree *scene_tree = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
|
||||
if (!scene_tree) {
|
||||
return Vector2();
|
||||
}
|
||||
|
||||
Viewport *viewport = scene_tree->get_root();
|
||||
|
||||
Vector2 position_percentage((p_joy_vector.x + 1.0f) / 2.0f, ((p_joy_vector.y) + 1.0f) / 2.0f);
|
||||
Vector2 position = get_render_targetsize() * position_percentage;
|
||||
Vector2 position = viewport->get_size() * position_percentage;
|
||||
|
||||
return position;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user