Skip to content

Commit

Permalink
Changed ArNode anchor update interval
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasGorisse committed May 6, 2022
1 parent f18e7de commit a6e4bd3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ data class ArFrame(
it.trackingState == TrackingState.TRACKING
}

fun intervalSeconds(arFrame: ArFrame?): Double = time.intervalSeconds(arFrame?.time)

val fps: Double = time.fps

fun fps(arFrame: ArFrame?): Double = time.fps(arFrame?.time)
Expand Down
10 changes: 8 additions & 2 deletions arsceneview/src/main/java/io/github/sceneview/ar/node/ArNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ open class ArNode() : ModelNode(), ArSceneLifecycleObserver {
*/
var smoothPose = true

var anchorUpdatePrecision = 0.05f
/**
* ### Interval of the anchor pose update in seconds
*
* Try to retrieve more accurate anchor position and rotation during time.
* Only used when the [ArNode] is anchored
*/
var anchorUpdateInterval = 2.0f
var lastAnchorUpdateFrame: ArFrame? = null

/**
Expand Down Expand Up @@ -132,7 +138,7 @@ open class ArNode() : ModelNode(), ArSceneLifecycleObserver {

// Update the anchor position if any
if (anchor.trackingState == TrackingState.TRACKING) {
if (arFrame.precision(lastAnchorUpdateFrame) <= anchorUpdatePrecision) {
if (arFrame.intervalSeconds(lastAnchorUpdateFrame) >= anchorUpdateInterval) {
lastAnchorUpdateFrame = arFrame
pose = anchor.pose
}
Expand Down

0 comments on commit a6e4bd3

Please sign in to comment.