Interface AugmentedRealityService

  • All Known Implementing Classes:
    AndroidAugmentedRealityService, DefaultAugmentedRealityService, DummyAugmentedRealityService, IOSAugmentedRealityService

    public interface AugmentedRealityService
    The Augmented Reality Service allows accessing the native AR kit, if it is available. The developer can check if the device has Augmented Reality support.


     AugmentedRealityService.create().ifPresent(service -> {
           Availability availability = service.checkAR(() -> {
              // perform action after ARCore is installed
           System.out.println("AR availability: " +;
    A 3D model with .obj format can be added, and when the user taps on the Augmented Reality world, it will be displayed. The .obj file can make reference to other .mtl files, and/or to texture files. All of these files have to be placed in the /src/main/resources/ folder or subfolders.


    The following example includes two files: DukeKing.obj and DukeKing.mtl under the src/main/resources/models folder

     AugmentedRealityService.create().ifPresent(service -> {
           ARModel model = new ARModel();
           service.cancelled().addListener((obs, ov, nv) -> {
               if (nv) {
                   System.out.println("AR was cancelled");

    Android Configuration

    Add the following to the manifest

    Note: these modifications are handled automatically by GluonFX plugin if it is used.
     <manifest ...>
       <uses-permission android:name="android.permission.CAMERA" />
       <!--<uses-feature android:name="" android:required="true"/>-->
       <application ...>
           <meta-data android:name="" android:value="optional" />
           <!--<meta-data android:name="" android:value="required" />-->

    Note: Uncomment the above commented lines if ARCore is strictly required.

    Note: All these modifications are handled automatically by the GluonFX plugin during the package goal.

    iOS Configuration

    • Method Detail

      • availabilityProperty<AugmentedRealityService.Availability> availabilityProperty()
        Property that can be used to listen if the AR availability has changed
        a ReadOnlyObjectProperty
      • setModel

        void setModel​(ARModel model)
        Sets the 3D model that is going to be used by the AR session. The .obj 3D model can be displayed during the AR session when the user taps on the screen after the camera recognizes a feature plane or point The model files have to be placed directly or within a folder under /src/ios/assets/ for iOS, while for Android these can be placed under /src/android/assets/ or /src/main/resources/assets/.
        model - the entity model
      • showAR

        void showAR()
        Opens AR
      • debugAR

        void debugAR​(boolean enable)
        Shows debug information
        enable - set to true to get verbose output
      • cancelled cancelled()
        Boolean property that can be used to listen if the AR session was cancelled
        a ReadOnlyBooleanProperty