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

Function CreateXRInputSource

Plugins/NativeXr/Source/NativeXr.cpp:123–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121 }
122
123 Napi::ObjectReference CreateXRInputSource(xr::System::Session::Frame::InputSource& inputSource, Napi::Env& env)
124 {
125 constexpr std::array<const char*, 2> HANDEDNESS_STRINGS{
126 "left",
127 "right"};
128 constexpr const char* TARGET_RAY_MODE{"tracked-pointer"};
129
130 auto jsInputSource = Napi::Object::New(env);
131 jsInputSource.Set("handedness", Napi::String::New(env, HANDEDNESS_STRINGS[static_cast<size_t>(inputSource.Handedness)]));
132 jsInputSource.Set("targetRayMode", TARGET_RAY_MODE);
133 SetXRInputSourceSpaces(jsInputSource, inputSource);
134
135 auto profiles = Napi::Array::New(env, 1);
136 Napi::Value string = Napi::String::New(env, "generic-trigger-squeeze-touchpad-thumbstick");
137 profiles.Set(uint32_t{0}, string);
138 jsInputSource.Set("profiles", profiles);
139
140 return Napi::Persistent(jsInputSource);
141 }
142}
143
144// NativeXr implementation proper.

Callers 1

ProcessInputSourcesMethod · 0.85

Calls 3

SetXRInputSourceSpacesFunction · 0.85
PersistentFunction · 0.85
SetMethod · 0.80

Tested by

no test coverage detected