@@ -1255,8 +1255,18 @@ void VROARSessioniOS::removeGeospatialAnchor(std::shared_ptr<VROGeospatialAnchor
12551255#pragma mark - Scene Semantics API
12561256
12571257bool VROARSessioniOS::isSemanticModeSupported () const {
1258- // Scene Semantics on iOS requires ARCore Geospatial SDK with Semantics extension
1259- // Check if the cloud anchor provider with semantics support is available
1258+ // Scene Semantics on iOS requires ARCore SDK with Semantics extension
1259+ // Initialize the provider if needed to check support
1260+ if (_cloudAnchorProviderARCore == nil) {
1261+ // Try to create provider temporarily to check support
1262+ // Note: This is a const method, so we need a mutable cast
1263+ VROARSessioniOS *mutableSelf = const_cast <VROARSessioniOS *>(this );
1264+ mutableSelf->_cloudAnchorProviderARCore = [[VROCloudAnchorProviderARCore alloc] init];
1265+ if (mutableSelf->_cloudAnchorProviderARCore ) {
1266+ pinfo (" ARCore provider initialized for Scene Semantics support check" );
1267+ }
1268+ }
1269+
12601270 if (_cloudAnchorProviderARCore != nil) {
12611271 return [_cloudAnchorProviderARCore isSemanticModeSupported];
12621272 }
@@ -1266,6 +1276,19 @@ bool VROARSessioniOS::isSemanticModeSupported() const {
12661276void VROARSessioniOS::setSemanticModeEnabled (bool enabled) {
12671277 _semanticModeEnabled = enabled;
12681278
1279+ // Initialize ARCore provider if needed for semantics
1280+ if (_cloudAnchorProviderARCore == nil && enabled) {
1281+ _cloudAnchorProviderARCore = [[VROCloudAnchorProviderARCore alloc] init];
1282+ if (_cloudAnchorProviderARCore) {
1283+ pinfo (" ARCore provider initialized for Scene Semantics" );
1284+ } else {
1285+ pwarn (" ⚠️ Failed to initialize ARCore provider for Scene Semantics" );
1286+ pwarn (" ⚠️ Make sure GARAPIKey is set in Info.plist" );
1287+ _semanticModeEnabled = false ;
1288+ return ;
1289+ }
1290+ }
1291+
12691292 if (_cloudAnchorProviderARCore != nil) {
12701293 // Check if semantic mode is supported before enabling
12711294 if (enabled && !isSemanticModeSupported ()) {
@@ -1277,11 +1300,18 @@ void VROARSessioniOS::setSemanticModeEnabled(bool enabled) {
12771300 [_cloudAnchorProviderARCore setSemanticModeEnabled:enabled];
12781301 pinfo (" Scene Semantics mode set to %s" , enabled ? " ENABLED" : " DISABLED" );
12791302 } else if (enabled) {
1280- pwarn (" ⚠️ Scene Semantics requires ARCore Geospatial provider to be configured " );
1303+ pwarn (" ⚠️ Scene Semantics requires ARCore SDK. Add ARCore/Semantics pod to your Podfile. " );
12811304 _semanticModeEnabled = false ;
12821305 }
12831306}
12841307
1308+ float VROARSessioniOS::getSemanticLabelFraction (VROSemanticLabel label) const {
1309+ if (_cloudAnchorProviderARCore != nil) {
1310+ return [_cloudAnchorProviderARCore getSemanticLabelFraction:(NSInteger)label];
1311+ }
1312+ return 0 .0f ;
1313+ }
1314+
12851315#pragma mark - VROARKitSessionDelegate
12861316
12871317@interface VROARKitSessionDelegate ()
0 commit comments