Skip to content

Commit 37e490c

Browse files
feat: add rvGetProject
1 parent 4ff15e5 commit 37e490c

11 files changed

Lines changed: 77 additions & 0 deletions

File tree

ViroRenderer/VROARSession.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,11 @@ class VROARSession {
581581
std::function<void(bool success, std::string jsonData, std::string error)> callback) {
582582
if (callback) callback(false, "", "Not supported");
583583
}
584+
virtual void rvGetProject(
585+
const std::string& projectId,
586+
std::function<void(bool success, std::string jsonData, std::string error)> callback) {
587+
if (callback) callback(false, "", "Not supported");
588+
}
584589

585590
// ========================================================================
586591
// ReactVision Geospatial CRUD API

android/sharedCode/src/main/cpp/arcore/ARSceneController_JNI.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,29 @@ VRO_METHOD(void, nativeRvGetSceneAssets)(VRO_ARGS
922922
});
923923
}
924924

925+
VRO_METHOD(void, nativeRvGetProject)(VRO_ARGS
926+
VRO_REF(VROARSceneController) arSceneControllerPtr,
927+
jstring key_j,
928+
jstring projectId_j) {
929+
std::string keyStr = VRO_STRING_STL(key_j);
930+
std::string projectIdStr = VRO_STRING_STL(projectId_j);
931+
std::weak_ptr<VROARScene> arScene_w = std::dynamic_pointer_cast<VROARScene>(
932+
VRO_REF_GET(VROARSceneController, arSceneControllerPtr)->getScene());
933+
VRO_WEAK weakObj = VRO_NEW_WEAK_GLOBAL_REF(obj);
934+
VROPlatformDispatchAsyncRenderer([arScene_w, weakObj, keyStr, projectIdStr] {
935+
std::shared_ptr<VROARScene> arScene = arScene_w.lock();
936+
std::shared_ptr<VROARSession> arSession = arScene ? arScene->getARSession() : nullptr;
937+
if (!arSession) {
938+
rvFireCloudResult(weakObj, keyStr, false, "", "AR session not available");
939+
return;
940+
}
941+
arSession->rvGetProject(projectIdStr,
942+
[weakObj, keyStr](bool success, std::string jsonData, std::string error) {
943+
rvFireCloudResult(weakObj, keyStr, success, jsonData, error);
944+
});
945+
});
946+
}
947+
925948
VRO_METHOD(void, nativeRvGetScene)(VRO_ARGS
926949
VRO_REF(VROARSceneController) arSceneControllerPtr,
927950
jstring key_j,

android/sharedCode/src/main/cpp/arcore/VROARSessionARCore.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,6 +2502,26 @@ void VROARSessionARCore::rvTrackCloudAnchorResolution(
25022502
if (callback) callback(false, "ReactVision cloud anchor provider not available");
25032503
}
25042504

2505+
void VROARSessionARCore::rvGetProject(
2506+
const std::string& projectId,
2507+
std::function<void(bool, std::string, std::string)> callback) {
2508+
#if RVCCA_AVAILABLE
2509+
if (_cloudAnchorProviderRV) {
2510+
auto p = _cloudAnchorProviderRV->getProvider();
2511+
if (p) {
2512+
p->getProject(projectId,
2513+
[callback](ReactVisionCCA::ApiResult<std::string> r) {
2514+
if (callback) {
2515+
callback(r.success, r.data, r.success ? "" : r.error.message);
2516+
}
2517+
});
2518+
return;
2519+
}
2520+
}
2521+
#endif
2522+
if (callback) callback(false, "", "ReactVision cloud anchor provider not available");
2523+
}
2524+
25052525
void VROARSessionARCore::rvGetScene(
25062526
const std::string& sceneId,
25072527
std::function<void(bool, std::string, std::string)> callback) {

android/sharedCode/src/main/cpp/arcore/VROARSessionARCore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ class VROARSessionARCore : public VROARSession,
225225
double confidence, int matchCount, int inlierCount, int processingTimeMs,
226226
const std::string& platform, const std::string& externalUserId,
227227
std::function<void(bool, std::string)> callback) override;
228+
void rvGetProject(const std::string& projectId,
229+
std::function<void(bool, std::string, std::string)> callback) override;
228230
void rvGetScene(const std::string& sceneId,
229231
std::function<void(bool, std::string, std::string)> callback) override;
230232
void rvGetSceneAssets(const std::string& sceneId,

android/sharedCode/src/main/java/com/viro/core/ARScene.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,12 @@ public void rvRemoveAssetFromCloudAnchor(String anchorId, String assetId,
13931393
nativeRvRemoveAssetFromCloudAnchor(mNativeRef, key, anchorId, assetId);
13941394
}
13951395

1396+
public void rvGetProject(String projectId, RvCloudAnchorCallback callback) {
1397+
String key = "rvGetProject_" + System.nanoTime();
1398+
mRvCloudCallbacks.put(key, callback);
1399+
nativeRvGetProject(mNativeRef, key, projectId);
1400+
}
1401+
13961402
public void rvGetScene(String sceneId, RvCloudAnchorCallback callback) {
13971403
String key = "rvGetScene_" + System.nanoTime();
13981404
mRvCloudCallbacks.put(key, callback);
@@ -1706,6 +1712,7 @@ private native void nativeRvUpdateCloudAnchor(long sceneControllerRef, String ke
17061712
private native void nativeRvFindNearbyCloudAnchors(long sceneControllerRef, String key,
17071713
double lat, double lng,
17081714
double radius, int limit);
1715+
private native void nativeRvGetProject(long sceneControllerRef, String key, String projectId);
17091716
private native void nativeRvGetScene(long sceneControllerRef, String key, String sceneId);
17101717
private native void nativeRvGetSceneAssets(long sceneControllerRef, String key, String sceneId);
17111718
private native void nativeRvAttachAssetToCloudAnchor(long sceneControllerRef, String key,
Binary file not shown.
Binary file not shown.
9.63 KB
Binary file not shown.
19.6 KB
Binary file not shown.

ios/ViroKit/VROARSessioniOS.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,6 +2506,24 @@ void VROARSessioniOS::rvTrackCloudAnchorResolution(
25062506
if (callback) callback(false, "ReactVision cloud anchor provider not available");
25072507
}
25082508

2509+
void VROARSessioniOS::rvGetProject(
2510+
const std::string& projectId,
2511+
std::function<void(bool, std::string, std::string)> callback) {
2512+
#if RVCCA_AVAILABLE
2513+
auto p = [_cloudAnchorProviderRV cppProvider];
2514+
if (p) {
2515+
p->getProject(projectId,
2516+
[callback](ReactVisionCCA::ApiResult<std::string> r) {
2517+
if (callback) {
2518+
callback(r.success, r.data, r.success ? "" : r.error.message);
2519+
}
2520+
});
2521+
return;
2522+
}
2523+
#endif
2524+
if (callback) callback(false, "", "ReactVision cloud anchor provider not available");
2525+
}
2526+
25092527
void VROARSessioniOS::rvGetScene(
25102528
const std::string& sceneId,
25112529
std::function<void(bool, std::string, std::string)> callback) {

0 commit comments

Comments
 (0)