Skip to content

Anchors appear only when show Geomatry #118

Description

@ysamak

Geospatial anchors not visible unless "Show Geometry" is enabled (iOS only)
Issue Body
Description
In the GeospatialExample from the ARCore iOS SDK, geospatial anchors are not visible unless the "Show Geometry" option is enabled. When "Show Geometry" is disabled, all anchor marks disappear. This behavior differs from the Android implementation where anchors remain visible regardless of the geometry display setting.
Steps to Reproduce

Run the GeospatialExample app from /Examples/GeospatialExample
Place geospatial anchors in the scene
Toggle "Show Geometry" off
Observe that all anchor marks disappear
Toggle "Show Geometry" back on
Observe that anchor marks reappear

and you can not add visible anchor while show geometry is closed
Expected Behavior
Geospatial anchor marks should remain visible regardless of whether "Show Geometry" is enabled or disabled, matching the behavior on Android.
Actual Behavior
Geospatial anchor marks are only visible when "Show Geometry" is enabled. Disabling this option causes all marks to disappear.
Environment

ARCore iOS SDK version: 1.5
iOS version: 18.4
Device: iPhone 14 Pro
Xcode version: 16

Additional Context
This issue is specific to iOS. The Android version of the GeospatialExample maintains anchor visibility independent of the geometry display setting.

func tapPoint(_ point: CGPoint) {
   guard let garSession, !localizationFailed,
     anchors.count + pendingFutures.count < Constants.maxAnchorCount
   else { return }

   guard
     let raycastQuery = arView.makeRaycastQuery(
       from: point, allowing: .existingPlaneGeometry, alignment: .horizontal)
   else { return }
   if streetscapeGeometryEnabled {
     do {
       let results = try garSession.raycastStreetscapeGeometry(
         origin: raycastQuery.origin, direction: raycastQuery.direction)
       guard let result = results.first else { return }
       let geospatialTransform = try garSession.geospatialTransform(
         transform: result.worldTransform)
       switch anchorType {
       case .geospatial:
         let anchor = try garSession.createAnchor(
           geometry: result.streetscapeGeometry, transform: result.worldTransform)
         // Don't save anchors on Streetscape Geometry between sessions.
         anchors.append(anchor)
         anchorTypes[anchor.identifier] = .geospatial
       case .terrain:
         addTerrainAnchor(
           coordinate: geospatialTransform.coordinate,
           eastUpSouthQTarget: simd_quaternion(0, 0, 0, 1), save: true)
       case .rooftop:
         addRooftopAnchor(
           coordinate: geospatialTransform.coordinate,
           eastUpSouthQTarget: simd_quaternion(0, 0, 0, 1), save: true)
       }

     } catch {
       print("Error adding anchor on StreetscapeGeometry: \(error)")
     }
   } else {
     let results = arView.session.raycast(raycastQuery)
      // these always return empty array that's why  it does not work
     guard let result = results.first else { return }
     let geospatialTransform: GARGeospatialTransform
     do {
       geospatialTransform = try garSession.geospatialTransform(transform: result.worldTransform)
     } catch {
       print("Error converting transform to Geospatial transform: \(error)")
       return
     }
     switch anchorType {
     case .geospatial:
       addAnchor(
         coordinate: geospatialTransform.coordinate, altitude: geospatialTransform.altitude,
         eastUpSouthQTarget: geospatialTransform.eastUpSouthQTarget, save: true)
     case .terrain:
       addTerrainAnchor(
         coordinate: geospatialTransform.coordinate,
         eastUpSouthQTarget: geospatialTransform.eastUpSouthQTarget, save: true)
     case .rooftop:
       addRooftopAnchor(
         coordinate: geospatialTransform.coordinate,
         eastUpSouthQTarget: geospatialTransform.eastUpSouthQTarget, save: true)
     }
   }
 }


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions