Skip to content

feat: configurable reference frame for a north-referenced azimuth#96

Open
camilleRiquet wants to merge 69 commits into
tlserver:mainfrom
OwnWeb:feat/configurable-north-reference
Open

feat: configurable reference frame for a north-referenced azimuth#96
camilleRiquet wants to merge 69 commits into
tlserver:mainfrom
OwnWeb:feat/configurable-north-reference

Conversation

@camilleRiquet

Copy link
Copy Markdown

Closes #95

Motivation

The azimuth is inconsistent across platforms:

  • Android uses TYPE_ROTATION_VECTOR (magnetic-north, east-north-up), so eulerAngles.azimuth == 0 means the device points north.
  • iOS starts device motion with the default CMAttitudeReferenceFrame.xArbitraryZVertical: the yaw origin is arbitrary and changes on every sensor (re)start, so the azimuth is not a compass heading.

Details and a reproduction are in #95.

What this PR does

Adds an opt-in RotationSensor.referenceFrame:

enum ReferenceFrame { device, magneticNorth, trueNorth }

RotationSensor.referenceFrame = ReferenceFrame.magneticNorth;

  • device (default): behavior unchanged on both platforms - not a breaking change.
  • magneticNorth / trueNorth: the azimuth becomes a real compass heading (0 == north).

iOS

Maps the value to the matching CMAttitudeReferenceFrame. CoreMotion expresses a north frame as (north, west, up), whereas this package's documented world is (east, north, up). For north frames the attitude quaternion is rotated
90° about the vertical axis so the emitted orientation matches the package convention and the azimuth stays 0 == north, consistent with Android. The frame is re-applied (sensor restarted) when the value changes mid-stream.

Android

TYPE_ROTATION_VECTOR is already magnetic-north / east-north-up, so all values keep using it. True north would need the local geomagnetic declination (requires a location fix); until then trueNorth behaves like magneticNorth on
Android (documented in the enum).

Notes

  • trueNorth on iOS requires location services to be available.
  • The default value preserves the previous per-platform behavior.

Testing

Verified on a physical iOS device with magneticNorth: pointing north reads ~0°, east ~90°; the heading is stable under pitch/roll and only changes when rotating about the vertical axis; consistent across cold launches. Android
behavior unchanged.

Disclaimer

Sorry about the previous pull request; I meant to submit a pull request on my fork but made a mistake.

As mentioned in issue #95, I made this change to fix the issue that was discovered, but it might just be that I made a mistake in the initial configuration.

tlserver and others added 30 commits October 9, 2025 15:35
Bumps [simple_3d_renderer](https://github.com/MasahideMori-SimpleAppli/simple_3d_renderer) from 19.1.0 to 20.0.2.
- [Changelog](https://github.com/MasahideMori-SimpleAppli/simple_3d_renderer/blob/main/CHANGELOG.md)
- [Commits](https://github.com/MasahideMori-SimpleAppli/simple_3d_renderer/commits)

---
updated-dependencies:
- dependency-name: simple_3d_renderer
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.jetbrains.kotlin.android](https://github.com/JetBrains/kotlin) from 2.0.0 to 2.0.20.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.0.0...v2.0.20)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin.android
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps com.android.application from 8.5.1 to 8.6.0.

---
updated-dependencies:
- dependency-name: com.android.application
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.jetbrains.kotlin:kotlin-gradle-plugin](https://github.com/JetBrains/kotlin) from 2.0.0 to 2.0.20.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.0.0...v2.0.20)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps com.android.tools.build:gradle from 8.5.1 to 8.6.0.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.12.0 to 5.13.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v5.12.0...v5.13.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [flutter_lints](https://github.com/flutter/packages/tree/main/packages) from 4.0.0 to 5.0.0.
- [Release notes](https://github.com/flutter/packages/releases)
- [Commits](https://github.com/flutter/packages/commits/flutter_lints-v5.0.0/packages)

---
updated-dependencies:
- dependency-name: flutter_lints
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [flutter_lints](https://github.com/flutter/packages/tree/main/packages) from 4.0.0 to 5.0.0.
- [Release notes](https://github.com/flutter/packages/releases)
- [Commits](https://github.com/flutter/packages/commits/flutter_lints-v5.0.0/packages)

---
updated-dependencies:
- dependency-name: flutter_lints
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps com.android.application from 8.6.0 to 8.6.1.

---
updated-dependencies:
- dependency-name: com.android.application
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps com.android.tools.build:gradle from 8.6.0 to 8.6.1.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.13.0 to 5.14.1.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v5.13.0...v5.14.1)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps com.android.application from 8.6.1 to 8.7.2.

---
updated-dependencies:
- dependency-name: com.android.application
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.14.1 to 5.14.2.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v5.14.1...v5.14.2)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps com.android.tools.build:gradle from 8.6.1 to 8.7.2.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [simple_3d_renderer](https://github.com/MasahideMori-SimpleAppli/simple_3d_renderer) from 20.0.2 to 21.0.0.
- [Changelog](https://github.com/MasahideMori-SimpleAppli/simple_3d_renderer/blob/main/CHANGELOG.md)
- [Commits](https://github.com/MasahideMori-SimpleAppli/simple_3d_renderer/commits)

---
updated-dependencies:
- dependency-name: simple_3d_renderer
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.jetbrains.kotlin:kotlin-gradle-plugin](https://github.com/JetBrains/kotlin) from 2.0.20 to 2.1.0.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v2.1.0/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.0.20...v2.1.0)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.jetbrains.kotlin.android](https://github.com/JetBrains/kotlin) from 2.0.20 to 2.1.0.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v2.1.0/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.0.20...v2.1.0)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin.android
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.jetbrains.kotlin.android](https://github.com/JetBrains/kotlin) from 2.1.0 to 2.1.10.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.1.0...v2.1.10)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin.android
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.jetbrains.kotlin:kotlin-gradle-plugin](https://github.com/JetBrains/kotlin) from 2.1.0 to 2.1.10.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.1.0...v2.1.10)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.14.2 to 5.15.2.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v5.14.2...v5.15.2)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [simple_3d_renderer](https://github.com/MasahideMori-SimpleAppli/simple_3d_renderer) from 21.0.0 to 22.0.0.
- [Changelog](https://github.com/MasahideMori-SimpleAppli/simple_3d_renderer/blob/main/CHANGELOG.md)
- [Commits](https://github.com/MasahideMori-SimpleAppli/simple_3d_renderer/commits)

---
updated-dependencies:
- dependency-name: simple_3d_renderer
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps com.android.application from 8.7.2 to 8.8.2.

---
updated-dependencies:
- dependency-name: com.android.application
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
dependabot Bot and others added 26 commits October 21, 2025 23:12
Bumps [flutter_lints](https://github.com/flutter/packages/tree/main/packages) from 5.0.0 to 6.0.0.
- [Release notes](https://github.com/flutter/packages/releases)
- [Commits](https://github.com/flutter/packages/commits/flutter_lints-v6.0.0/packages)

---
updated-dependencies:
- dependency-name: flutter_lints
  dependency-version: 6.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [flutter_lints](https://github.com/flutter/packages/tree/main/packages) from 5.0.0 to 6.0.0.
- [Release notes](https://github.com/flutter/packages/releases)
- [Commits](https://github.com/flutter/packages/commits/flutter_lints-v6.0.0/packages)

---
updated-dependencies:
- dependency-name: flutter_lints
  dependency-version: 6.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.jetbrains.kotlin:kotlin-gradle-plugin](https://github.com/JetBrains/kotlin) from 2.1.20 to 2.2.0.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.1.20...v2.2.0)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
  dependency-version: 2.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.jetbrains.kotlin.android](https://github.com/JetBrains/kotlin) from 2.1.20 to 2.2.0.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.1.20...v2.2.0)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin.android
  dependency-version: 2.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
# Conflicts:
#	example/android/settings.gradle
Bumps com.android.tools.build:gradle from 8.9.2 to 8.11.0.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-version: 8.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps com.android.application from 8.9.2 to 8.11.0.

---
updated-dependencies:
- dependency-name: com.android.application
  dependency-version: 8.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
# Conflicts:
#	example/android/settings.gradle
Dependabot couldn't find the original pull request head commit, 3e14905.
….2.20 in /android

Dependabot couldn't find the original pull request head commit, da439a9.
…mple/android

Dependabot couldn't find the original pull request head commit, 92c135d.
…android

Dependabot couldn't find the original pull request head commit, 2b82b36.
…/android

Dependabot couldn't find the original pull request head commit, d3cac45.
Dependabot couldn't find the original pull request head commit, 85c5b23.
Displays whether the current platform (e.g., Android/iOS) supports rotation sensing.
@tlserver tlserver force-pushed the main branch 3 times, most recently from fcf46cb to 96f7d42 Compare June 23, 2026 16:45
@tlserver

Copy link
Copy Markdown
Owner

Thanks for the PR @camilleRiquet ! 🙏
This is a solid contribution and very well implemented. I will accept the PR with some modifications.
Since this work is closely related to issue #12 (adding proper support for a Game Rotation Vector-like sensor on iOS using xArbitraryZVertical), I’d like to handle both together in one go for better consistency and API design.
I’ll merge the core changes and then extend it slightly to also cover the case from #12.
Really appreciate the effort — this is a great improvement for the package!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: iOS azimuth is not north-referenced (arbitrary yaw origin), unlike Android

3 participants