| 662 | } |
| 663 | |
| 664 | void Update(const Napi::CallbackInfo& info, const xr::System::Session::Frame::Space& space, gsl::span<const xr::System::Session::Frame::View> views) |
| 665 | { |
| 666 | // Update the transform. |
| 667 | m_transform.Update(space, true); |
| 668 | |
| 669 | // Update the views array if necessary. |
| 670 | const auto oldSize = static_cast<uint32_t>(m_views.size()); |
| 671 | const auto newSize = static_cast<uint32_t>(views.size()); |
| 672 | if (oldSize != newSize) |
| 673 | { |
| 674 | auto newViews = Napi::Array::New(m_jsViews.Env(), newSize); |
| 675 | m_views.resize(newSize); |
| 676 | |
| 677 | for (uint32_t idx = 0; idx < newSize; ++idx) |
| 678 | { |
| 679 | if (idx < oldSize) |
| 680 | { |
| 681 | newViews.Set(idx, m_jsViews.Value().Get(idx)); |
| 682 | } |
| 683 | else |
| 684 | { |
| 685 | newViews.Set(idx, XRView::New(info)); |
| 686 | } |
| 687 | |
| 688 | m_views[idx] = XRView::Unwrap(newViews.Get(idx).As<Napi::Object>()); |
| 689 | } |
| 690 | |
| 691 | m_jsViews = Napi::Persistent(newViews); |
| 692 | } |
| 693 | |
| 694 | // Update the individual views. |
| 695 | for (uint32_t idx = 0; idx < static_cast<uint32_t>(views.size()); ++idx) |
| 696 | { |
| 697 | const auto& view = views[idx]; |
| 698 | m_views[idx]->Update(idx, CreateProjectionMatrix(view), view.Space); |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | private: |
| 703 | Napi::ObjectReference m_jsTransform{}; |
nothing calls this directly
no test coverage detected