MCPcopy Create free account
hub / github.com/BabylonJS/BabylonNative / Update

Method Update

Plugins/NativeXr/Source/NativeXr.cpp:664–700  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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{};

Callers

nothing calls this directly

Calls 8

PersistentFunction · 0.85
CreateProjectionMatrixFunction · 0.85
SetMethod · 0.80
ValueMethod · 0.80
UnwrapFunction · 0.50
UpdateMethod · 0.45
EnvMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected