├── react-native-arcore
├── android
│ ├── .gradle
│ │ ├── 4.1
│ │ │ ├── fileChanges
│ │ │ │ └── last-build.bin
│ │ │ └── fileHashes
│ │ │ │ ├── fileHashes.bin
│ │ │ │ └── fileHashes.lock
│ │ └── 3.3
│ │ │ └── taskArtifacts
│ │ │ ├── fileHashes.bin
│ │ │ ├── fileSnapshots.bin
│ │ │ ├── taskArtifacts.bin
│ │ │ └── taskArtifacts.lock
│ ├── bin
│ │ ├── .gradle
│ │ │ ├── 4.1
│ │ │ │ ├── fileChanges
│ │ │ │ │ └── last-build.bin
│ │ │ │ └── fileHashes
│ │ │ │ │ ├── fileHashes.bin
│ │ │ │ │ └── fileHashes.lock
│ │ │ └── 3.3
│ │ │ │ └── taskArtifacts
│ │ │ │ ├── fileHashes.bin
│ │ │ │ ├── fileSnapshots.bin
│ │ │ │ ├── taskArtifacts.bin
│ │ │ │ └── taskArtifacts.lock
│ │ ├── .idea
│ │ │ ├── modules.xml
│ │ │ ├── libraries
│ │ │ │ ├── com_google_ar_core_0_91_0.xml
│ │ │ │ ├── org_webkit_android_jsc_r174650.xml
│ │ │ │ ├── de_javagl_obj_0_2_1_jar.xml
│ │ │ │ ├── com_google_zxing_core_3_2_1_jar.xml
│ │ │ │ ├── com_squareup_okio_okio_1_6_0_jar.xml
│ │ │ │ ├── com_adobe_xmp_xmpcore_5_1_2_jar.xml
│ │ │ │ ├── commons_cli_commons_cli_1_2_jar.xml
│ │ │ │ ├── com_facebook_stetho_stetho_1_2_0_jar.xml
│ │ │ │ ├── com_squareup_okhttp_okhttp_2_5_0_jar.xml
│ │ │ │ ├── com_nineoldandroids_library_2_4_0_jar.xml
│ │ │ │ ├── com_google_code_findbugs_jsr305_3_0_0_jar.xml
│ │ │ │ ├── com_squareup_okhttp_okhttp_ws_2_5_0_jar.xml
│ │ │ │ ├── com_parse_bolts_bolts_android_1_1_4_jar.xml
│ │ │ │ ├── com_facebook_stetho_stetho_okhttp_1_2_0_jar.xml
│ │ │ │ ├── com_drewnoakes_metadata_extractor_2_9_1_jar.xml
│ │ │ │ ├── com_fasterxml_jackson_core_jackson_core_2_2_3_jar.xml
│ │ │ │ ├── com_facebook_fresco_drawee_0_8_1.xml
│ │ │ │ ├── com_facebook_fresco_fbcore_0_8_1.xml
│ │ │ │ ├── com_facebook_fresco_fresco_0_8_1.xml
│ │ │ │ ├── com_android_support_design_26_0_0_alpha1.xml
│ │ │ │ ├── com_android_support_support_v4_26_0_0_alpha1.xml
│ │ │ │ ├── com_android_support_transition_26_0_0_alpha1.xml
│ │ │ │ ├── com_android_support_appcompat_v7_26_0_0_alpha1.xml
│ │ │ │ ├── com_facebook_fresco_imagepipeline_0_8_1.xml
│ │ │ │ ├── com_android_support_recyclerview_v7_26_0_0_alpha1.xml
│ │ │ │ ├── com_android_support_support_compat_26_0_0_alpha1.xml
│ │ │ │ ├── com_android_support_support_core_ui_26_0_0_alpha1.xml
│ │ │ │ ├── com_android_support_support_fragment_26_0_0_alpha1.xml
│ │ │ │ ├── com_android_support_support_core_utils_26_0_0_alpha1.xml
│ │ │ │ ├── com_android_support_support_media_compat_26_0_0_alpha1.xml
│ │ │ │ ├── com_facebook_fresco_imagepipeline_okhttp_0_8_1.xml
│ │ │ │ ├── com_android_support_support_vector_drawable_26_0_0_alpha1.xml
│ │ │ │ ├── com_android_support_animated_vector_drawable_26_0_0_alpha1.xml
│ │ │ │ ├── com_facebook_react_react_native_0_20_1.xml
│ │ │ │ └── com_android_support_support_annotations_26_0_0_alpha1_jar.xml
│ │ │ ├── runConfigurations.xml
│ │ │ ├── gradle.xml
│ │ │ └── misc.xml
│ │ ├── local.properties
│ │ ├── android.iml
│ │ └── react-native-arcore.iml
│ ├── .settings
│ │ └── org.eclipse.buildship.core.prefs
│ ├── src
│ │ └── main
│ │ │ ├── assets
│ │ │ ├── andy.png
│ │ │ ├── trigrid.png
│ │ │ ├── andy_shadow.png
│ │ │ └── andy_shadow.obj
│ │ │ ├── res
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── raw
│ │ │ │ ├── passthrough_fragment.shader
│ │ │ │ ├── screenquad_vertex.shader
│ │ │ │ ├── screenquad_fragment_oes.shader
│ │ │ │ ├── point_cloud_vertex.shader
│ │ │ │ ├── plane_vertex.shader
│ │ │ │ ├── object_vertex.shader
│ │ │ │ ├── plane_fragment.shader
│ │ │ │ └── object_fragment.shader
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ └── com
│ │ │ └── reactlibrary
│ │ │ ├── arutil
│ │ │ ├── package-info.java
│ │ │ └── rendering
│ │ │ │ ├── package-info.java
│ │ │ │ ├── CameraPermissionHelper.java
│ │ │ │ ├── ShaderUtil.java
│ │ │ │ ├── DisplayRotationHelper.java
│ │ │ │ ├── PointCloudRenderer.java
│ │ │ │ ├── BackgroundRenderer.java
│ │ │ │ └── ObjectRenderer.java
│ │ │ ├── RNReactNativeArcorePackage.java
│ │ │ ├── RNReactNativeArcoreViewManager.java
│ │ │ ├── RNReactNativeArcoreModule.java
│ │ │ ├── RNReactNativeArcoreMainView.java
│ │ │ └── JsonUtils.java
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── .idea
│ │ ├── modules.xml
│ │ ├── libraries
│ │ │ ├── com_google_ar_core_0_91_0.xml
│ │ │ ├── org_webkit_android_jsc_r174650.xml
│ │ │ ├── de_javagl_obj_0_2_1_jar.xml
│ │ │ ├── com_google_zxing_core_3_2_1_jar.xml
│ │ │ ├── com_adobe_xmp_xmpcore_5_1_2_jar.xml
│ │ │ ├── com_squareup_okio_okio_1_6_0_jar.xml
│ │ │ ├── commons_cli_commons_cli_1_2_jar.xml
│ │ │ ├── com_facebook_stetho_stetho_1_2_0_jar.xml
│ │ │ ├── com_squareup_okhttp_okhttp_2_5_0_jar.xml
│ │ │ ├── com_nineoldandroids_library_2_4_0_jar.xml
│ │ │ ├── com_squareup_okhttp_okhttp_ws_2_5_0_jar.xml
│ │ │ ├── com_google_code_findbugs_jsr305_3_0_0_jar.xml
│ │ │ ├── com_parse_bolts_bolts_android_1_1_4_jar.xml
│ │ │ ├── com_facebook_stetho_stetho_okhttp_1_2_0_jar.xml
│ │ │ ├── com_drewnoakes_metadata_extractor_2_9_1_jar.xml
│ │ │ ├── com_fasterxml_jackson_core_jackson_core_2_2_3_jar.xml
│ │ │ ├── com_android_support_design_26_0_0_alpha1.xml
│ │ │ ├── com_facebook_fresco_drawee_0_8_1.xml
│ │ │ ├── com_facebook_fresco_fbcore_0_8_1.xml
│ │ │ ├── com_facebook_fresco_fresco_0_8_1.xml
│ │ │ ├── com_android_support_support_v4_26_0_0_alpha1.xml
│ │ │ ├── com_android_support_transition_26_0_0_alpha1.xml
│ │ │ ├── com_android_support_appcompat_v7_26_0_0_alpha1.xml
│ │ │ ├── com_facebook_fresco_imagepipeline_0_8_1.xml
│ │ │ ├── com_android_support_support_compat_26_0_0_alpha1.xml
│ │ │ ├── com_android_support_recyclerview_v7_26_0_0_alpha1.xml
│ │ │ ├── com_android_support_support_core_ui_26_0_0_alpha1.xml
│ │ │ ├── com_android_support_support_fragment_26_0_0_alpha1.xml
│ │ │ ├── com_android_support_support_core_utils_26_0_0_alpha1.xml
│ │ │ ├── com_facebook_fresco_imagepipeline_okhttp_0_8_1.xml
│ │ │ ├── com_android_support_support_media_compat_26_0_0_alpha1.xml
│ │ │ ├── com_android_support_support_vector_drawable_26_0_0_alpha1.xml
│ │ │ ├── com_android_support_animated_vector_drawable_26_0_0_alpha1.xml
│ │ │ ├── com_facebook_react_react_native_0_20_1.xml
│ │ │ └── com_android_support_support_annotations_26_0_0_alpha1_jar.xml
│ │ ├── runConfigurations.xml
│ │ ├── gradle.xml
│ │ └── misc.xml
│ ├── .classpath
│ ├── .project
│ ├── local.properties
│ ├── build.gradle
│ ├── gradlew.bat
│ ├── gradlew
│ ├── android.iml
│ └── react-native-arcore.iml
├── package.json
├── README.md
└── index.js
└── README.md
/react-native-arcore/android/.gradle/4.1/fileChanges/last-build.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.gradle/4.1/fileChanges/last-build.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | connection.project.dir=
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/assets/andy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/src/main/assets/andy.png
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/assets/trigrid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/src/main/assets/trigrid.png
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/assets/andy_shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/src/main/assets/andy_shadow.png
--------------------------------------------------------------------------------
/react-native-arcore/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/react-native-arcore/android/.gradle/4.1/fileHashes/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/.gradle/4.1/fileHashes/fileHashes.bin
--------------------------------------------------------------------------------
/react-native-arcore/android/.gradle/4.1/fileHashes/fileHashes.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/.gradle/4.1/fileHashes/fileHashes.lock
--------------------------------------------------------------------------------
/react-native-arcore/android/.gradle/3.3/taskArtifacts/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/.gradle/3.3/taskArtifacts/fileHashes.bin
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.gradle/4.1/fileHashes/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/bin/.gradle/4.1/fileHashes/fileHashes.bin
--------------------------------------------------------------------------------
/react-native-arcore/android/.gradle/3.3/taskArtifacts/fileSnapshots.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/.gradle/3.3/taskArtifacts/fileSnapshots.bin
--------------------------------------------------------------------------------
/react-native-arcore/android/.gradle/3.3/taskArtifacts/taskArtifacts.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/.gradle/3.3/taskArtifacts/taskArtifacts.bin
--------------------------------------------------------------------------------
/react-native-arcore/android/.gradle/3.3/taskArtifacts/taskArtifacts.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/.gradle/3.3/taskArtifacts/taskArtifacts.lock
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.gradle/3.3/taskArtifacts/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/bin/.gradle/3.3/taskArtifacts/fileHashes.bin
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.gradle/4.1/fileHashes/fileHashes.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/bin/.gradle/4.1/fileHashes/fileHashes.lock
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.gradle/3.3/taskArtifacts/fileSnapshots.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/bin/.gradle/3.3/taskArtifacts/fileSnapshots.bin
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.gradle/3.3/taskArtifacts/taskArtifacts.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/bin/.gradle/3.3/taskArtifacts/taskArtifacts.bin
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.gradle/3.3/taskArtifacts/taskArtifacts.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritasam/react-native-arcore/HEAD/react-native-arcore/android/bin/.gradle/3.3/taskArtifacts/taskArtifacts.lock
--------------------------------------------------------------------------------
/react-native-arcore/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jan 29 13:20:44 CET 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/package.json:
--------------------------------------------------------------------------------
1 |
2 | {
3 | "name": "react-native-arcore",
4 | "version": "1.0.0",
5 | "description": "",
6 | "main": "index.js",
7 | "scripts": {
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "keywords": [
11 | "react-native"
12 | ],
13 | "author": "",
14 | "license": "",
15 | "peerDependencies": {
16 | "react-native": "^0.41.2",
17 | "react-native-windows": "0.41.0-rc.1",
18 | "prop-types": "^15.5.10"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_google_ar_core_0_91_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_google_ar_core_0_91_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/org_webkit_android_jsc_r174650.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | android
4 | Project react-native-arcore created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/org_webkit_android_jsc_r174650.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/de_javagl_obj_0_2_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/de_javagl_obj_0_2_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/assets/andy_shadow.obj:
--------------------------------------------------------------------------------
1 | # This file uses centimeters as units for non-parametric coordinates.
2 |
3 | g default
4 | v -0.100000 -0.000000 0.100000
5 | v 0.100000 -0.000000 0.100000
6 | v -0.100000 0.000000 -0.100000
7 | v 0.100000 0.000000 -0.100000
8 | vt 0.000000 0.000000
9 | vt 1.000000 0.000000
10 | vt 0.000000 1.000000
11 | vt 1.000000 1.000000
12 | vn 0.000000 1.000000 0.000000
13 | vn 0.000000 1.000000 0.000000
14 | vn 0.000000 1.000000 0.000000
15 | vn 0.000000 1.000000 0.000000
16 | s off
17 | g AndyBlobShadow_GEO
18 | f 4/4/1 3/3/2 1/1/3 2/2/4
19 |
--------------------------------------------------------------------------------
/react-native-arcore/android/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Mon Jan 29 12:47:09 CET 2018
11 | ndk.dir=/Users/pritambolenwar/Library/Android/sdk/ndk-bundle
12 | sdk.dir=/Users/pritambolenwar/Library/Android/sdk
13 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_google_zxing_core_3_2_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Mon Jan 29 12:47:09 CET 2018
11 | ndk.dir=/Users/pritambolenwar/Library/Android/sdk/ndk-bundle
12 | sdk.dir=/Users/pritambolenwar/Library/Android/sdk
13 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_adobe_xmp_xmpcore_5_1_2_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_squareup_okio_okio_1_6_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_google_zxing_core_3_2_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_squareup_okio_okio_1_6_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/commons_cli_commons_cli_1_2_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_adobe_xmp_xmpcore_5_1_2_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/commons_cli_commons_cli_1_2_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_facebook_stetho_stetho_1_2_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_squareup_okhttp_okhttp_2_5_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_facebook_stetho_stetho_1_2_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_squareup_okhttp_okhttp_2_5_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_nineoldandroids_library_2_4_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_nineoldandroids_library_2_4_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_squareup_okhttp_okhttp_ws_2_5_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_google_code_findbugs_jsr305_3_0_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_google_code_findbugs_jsr305_3_0_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_squareup_okhttp_okhttp_ws_2_5_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_parse_bolts_bolts_android_1_1_4_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_parse_bolts_bolts_android_1_1_4_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_facebook_stetho_stetho_okhttp_1_2_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_facebook_stetho_stetho_okhttp_1_2_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_drewnoakes_metadata_extractor_2_9_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_drewnoakes_metadata_extractor_2_9_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_fasterxml_jackson_core_jackson_core_2_2_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_fasterxml_jackson_core_jackson_core_2_2_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_design_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_facebook_fresco_drawee_0_8_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_facebook_fresco_fbcore_0_8_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_facebook_fresco_fresco_0_8_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_facebook_fresco_drawee_0_8_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_facebook_fresco_fbcore_0_8_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_facebook_fresco_fresco_0_8_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_design_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_support_v4_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_transition_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_support_v4_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_transition_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_appcompat_v7_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_facebook_fresco_imagepipeline_0_8_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_appcompat_v7_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_facebook_fresco_imagepipeline_0_8_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_support_compat_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_recyclerview_v7_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_support_core_ui_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_support_fragment_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_recyclerview_v7_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_support_compat_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_support_core_ui_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_support_fragment_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_support_core_utils_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_facebook_fresco_imagepipeline_okhttp_0_8_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_support_core_utils_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_support_media_compat_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_support_media_compat_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_facebook_fresco_imagepipeline_okhttp_0_8_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_support_vector_drawable_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_animated_vector_drawable_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_support_vector_drawable_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_animated_vector_drawable_26_0_0_alpha1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | HelloAR Java
19 |
20 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/res/raw/passthrough_fragment.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | precision mediump float;
17 | varying vec4 v_Color;
18 |
19 | void main() {
20 | gl_FragColor = v_Color;
21 | }
22 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_facebook_react_react_native_0_20_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/arutil/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * A sample showing how to build an Augmented Reality app using ARCore.
18 | */
19 | package com.reactlibrary.arutil;
20 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_facebook_react_react_native_0_20_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/arutil/rendering/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * This package contains classes that do the rendering for this example.
18 | */
19 | package com.reactlibrary.arutil.rendering;
20 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/libraries/com_android_support_support_annotations_26_0_0_alpha1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/libraries/com_android_support_support_annotations_26_0_0_alpha1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/res/raw/screenquad_vertex.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | attribute vec4 a_Position;
17 | attribute vec2 a_TexCoord;
18 |
19 | varying vec2 v_TexCoord;
20 |
21 | void main() {
22 | gl_Position = a_Position;
23 | v_TexCoord = a_TexCoord;
24 | }
25 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/res/raw/screenquad_fragment_oes.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 | #extension GL_OES_EGL_image_external : require
16 |
17 | precision mediump float;
18 | varying vec2 v_TexCoord;
19 | uniform samplerExternalOES sTexture;
20 |
21 |
22 | void main() {
23 | gl_FragColor = texture2D(sTexture, v_TexCoord);
24 | }
25 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/res/raw/point_cloud_vertex.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | uniform mat4 u_ModelViewProjection;
17 | uniform vec4 u_Color;
18 | uniform float u_PointSize;
19 |
20 | attribute vec4 a_Position;
21 |
22 | varying vec4 v_Color;
23 |
24 | void main() {
25 | v_Color = u_Color;
26 | gl_Position = u_ModelViewProjection * vec4(a_Position.xyz, 1.0);
27 | gl_PointSize = u_PointSize;
28 | }
29 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/res/raw/plane_vertex.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | uniform mat4 u_Model;
17 | uniform mat4 u_ModelViewProjection;
18 | uniform mat2 u_PlaneUvMatrix;
19 |
20 | attribute vec3 a_XZPositionAlpha; // (x, z, alpha)
21 |
22 | varying vec3 v_TexCoordAlpha;
23 |
24 | void main() {
25 | vec4 position = vec4(a_XZPositionAlpha.x, 0.0, a_XZPositionAlpha.y, 1.0);
26 | v_TexCoordAlpha = vec3(u_PlaneUvMatrix * (u_Model * position).xz, a_XZPositionAlpha.z);
27 | gl_Position = u_ModelViewProjection * position;
28 | }
29 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/res/raw/object_vertex.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | uniform mat4 u_ModelView;
17 | uniform mat4 u_ModelViewProjection;
18 |
19 | attribute vec4 a_Position;
20 | attribute vec3 a_Normal;
21 | attribute vec2 a_TexCoord;
22 |
23 | varying vec3 v_ViewPosition;
24 | varying vec3 v_ViewNormal;
25 | varying vec2 v_TexCoord;
26 |
27 | void main() {
28 | v_ViewPosition = (u_ModelView * a_Position).xyz;
29 | v_ViewNormal = normalize((u_ModelView * vec4(a_Normal, 0.0)).xyz);
30 | v_TexCoord = a_TexCoord;
31 | gl_Position = u_ModelViewProjection * a_Position;
32 | }
33 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/RNReactNativeArcorePackage.java:
--------------------------------------------------------------------------------
1 |
2 | package com.reactlibrary;
3 |
4 | import com.facebook.react.ReactPackage;
5 | import com.facebook.react.bridge.JavaScriptModule;
6 | import com.facebook.react.bridge.NativeModule;
7 | import com.facebook.react.bridge.ReactApplicationContext;
8 | import com.facebook.react.uimanager.ViewManager;
9 |
10 | import java.util.ArrayList;
11 | import java.util.Arrays;
12 | import java.util.List;
13 | public class RNReactNativeArcorePackage implements ReactPackage {
14 |
15 | @Override
16 | public List createNativeModules(ReactApplicationContext reactContext) {
17 |
18 | List modules = new ArrayList<>();
19 | modules.add(new RNReactNativeArcoreModule(reactContext));
20 | return modules;
21 |
22 | // return Arrays.asList();
23 | }
24 |
25 | @Override
26 | public List createViewManagers(ReactApplicationContext reactContext) {
27 | return Arrays.asList(new RNReactNativeArcoreViewManager(reactContext));
28 |
29 | }
30 |
31 | public List> createJSModules() {
32 | return Arrays.asList();
33 | }
34 | }
--------------------------------------------------------------------------------
/react-native-arcore/android/build.gradle:
--------------------------------------------------------------------------------
1 |
2 | buildscript {
3 | repositories {
4 | jcenter()
5 | }
6 |
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.2'
9 |
10 | }
11 | }
12 |
13 | apply plugin: 'com.android.library'
14 |
15 | android {
16 | compileSdkVersion 27
17 | buildToolsVersion "25.0.3"
18 | defaultConfig {
19 | minSdkVersion 16
20 | targetSdkVersion 27
21 | versionCode 1
22 | versionName "1.0"
23 | }
24 | lintOptions {
25 | abortOnError false
26 | }
27 | compileOptions {
28 | sourceCompatibility JavaVersion.VERSION_1_8
29 | targetCompatibility JavaVersion.VERSION_1_8
30 | }
31 | }
32 |
33 |
34 | repositories {
35 | mavenCentral()
36 |
37 | }
38 |
39 | dependencies {
40 | compile 'de.javagl:obj:0.2.1'
41 | compile 'com.google.ar:core:1.5.0'
42 | compile 'com.facebook.react:react-native:+'
43 | compile group: 'com.drewnoakes', name: 'metadata-extractor', version: '2.9.1'
44 | compile "com.google.zxing:core:3.2.1"
45 | compile 'com.android.support:design:27.1.1'
46 | compile 'com.android.support:appcompat-v7:27.1.1'
47 | // sourceCompatibility = 1.8
48 | // targetCompatibility = 1.8
49 | }
50 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
21 |
22 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
22 |
29 |
30 |
31 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/res/raw/plane_fragment.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | precision highp float;
17 | uniform sampler2D u_Texture;
18 | uniform vec4 u_dotColor;
19 | uniform vec4 u_lineColor;
20 | uniform vec4 u_gridControl; // dotThreshold, lineThreshold, lineFadeShrink, occlusionShrink
21 | varying vec3 v_TexCoordAlpha;
22 |
23 | void main() {
24 | vec4 control = texture2D(u_Texture, v_TexCoordAlpha.xy);
25 | float dotScale = v_TexCoordAlpha.z;
26 | float lineFade = max(0.0, u_gridControl.z * v_TexCoordAlpha.z - (u_gridControl.z - 1.0));
27 | vec3 color = (control.r * dotScale > u_gridControl.x) ? u_dotColor.rgb
28 | : (control.g > u_gridControl.y) ? u_lineColor.rgb * lineFade
29 | : (u_lineColor.rgb * 0.25 * lineFade) ;
30 | gl_FragColor = vec4(color, v_TexCoordAlpha.z * u_gridControl.w);
31 | }
32 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/RNReactNativeArcoreViewManager.java:
--------------------------------------------------------------------------------
1 |
2 | package com.reactlibrary;
3 | import com.facebook.infer.annotation.Assertions;
4 | import com.facebook.react.bridge.ReactApplicationContext;
5 | import com.facebook.react.bridge.ReadableArray;
6 | import com.facebook.react.uimanager.ThemedReactContext;
7 | import com.facebook.react.uimanager.ViewGroupManager;
8 |
9 | import javax.annotation.Nullable;
10 |
11 | public class RNReactNativeArcoreViewManager extends ViewGroupManager {
12 |
13 | public static final String PROPS_VIEW_MODE = "viewMode";
14 |
15 |
16 | private RNReactNativeArcoreModule mContextModule;
17 |
18 |
19 | public RNReactNativeArcoreViewManager(ReactApplicationContext reactContext) {
20 | mContextModule = new RNReactNativeArcoreModule(reactContext);
21 | }
22 |
23 | @Override
24 | public String getName() {
25 | return "RNReactNativeArcoreModule";
26 | }
27 |
28 |
29 |
30 | // @ReactProp(name = PROPS_VIEW_MODE)
31 | public void setViewMode(RNReactNativeArcoreMainView view, @Nullable String viewMode) {
32 | if (view != null) {
33 | // view.setViewMode(viewMode);
34 | }
35 | }
36 |
37 | @Override
38 | protected RNReactNativeArcoreMainView createViewInstance(ThemedReactContext reactContext) {
39 | return new RNReactNativeArcoreMainView(reactContext, mContextModule.getActivity());
40 | }
41 |
42 | @Override
43 | public void receiveCommand(
44 | RNReactNativeArcoreMainView view,
45 | int commandType,
46 | @Nullable ReadableArray args) {
47 | Assertions.assertNotNull(view);
48 | Assertions.assertNotNull(args);
49 | }
50 | }
--------------------------------------------------------------------------------
/react-native-arcore/README.md:
--------------------------------------------------------------------------------
1 |
2 | # react-native-react-native-arcore
3 |
4 | ## Getting started
5 |
6 | `$ npm install react-native-react-native-arcore --save`
7 |
8 | ### Mostly automatic installation
9 |
10 | `$ react-native link react-native-react-native-arcore`
11 |
12 | ### Manual installation
13 |
14 |
15 | #### iOS
16 |
17 | 1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
18 | 2. Go to `node_modules` ➜ `react-native-react-native-arcore` and add `RNReactNativeArcore.xcodeproj`
19 | 3. In XCode, in the project navigator, select your project. Add `libRNReactNativeArcore.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
20 | 4. Run your project (`Cmd+R`)<
21 |
22 | #### Android
23 |
24 | 1. Open up `android/app/src/main/java/[...]/MainActivity.java`
25 | - Add `import com.reactlibrary.RNReactNativeArcorePackage;` to the imports at the top of the file
26 | - Add `new RNReactNativeArcorePackage()` to the list returned by the `getPackages()` method
27 | 2. Append the following lines to `android/settings.gradle`:
28 | ```
29 | include ':react-native-react-native-arcore'
30 | project(':react-native-react-native-arcore').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-react-native-arcore/android')
31 | ```
32 | 3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
33 | ```
34 | compile project(':react-native-react-native-arcore')
35 | ```
36 |
37 | #### Windows
38 | [Read it! :D](https://github.com/ReactWindows/react-native)
39 |
40 | 1. In Visual Studio add the `RNReactNativeArcore.sln` in `node_modules/react-native-react-native-arcore/windows/RNReactNativeArcore.sln` folder to their solution, reference from their app.
41 | 2. Open up your `MainPage.cs` app
42 | - Add `using React.Native.Arcore.RNReactNativeArcore;` to the usings at the top of the file
43 | - Add `new RNReactNativeArcorePackage()` to the `List` returned by the `Packages` method
44 |
45 |
46 | ## Usage
47 | ```javascript
48 | import RNReactNativeArcore from 'react-native-react-native-arcore';
49 |
50 | // TODO: What to do with the module?
51 | RNReactNativeArcore;
52 | ```
53 |
--------------------------------------------------------------------------------
/react-native-arcore/android/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | Android
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | Android
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/RNReactNativeArcoreModule.java:
--------------------------------------------------------------------------------
1 |
2 | package com.reactlibrary;
3 |
4 | import android.app.Activity;
5 | import android.content.Intent;
6 | import android.os.Handler;
7 |
8 | import com.facebook.react.bridge.ActivityEventListener;
9 | import com.facebook.react.bridge.BaseActivityEventListener;
10 | import com.facebook.react.bridge.Promise;
11 | import com.facebook.react.bridge.ReactApplicationContext;
12 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
13 | import com.facebook.react.bridge.ReactMethod;
14 | import com.google.ar.core.ArCoreApk;
15 |
16 | public class RNReactNativeArcoreModule extends ReactContextBaseJavaModule {
17 |
18 | private final ReactApplicationContext reactContext;
19 |
20 | public RNReactNativeArcoreModule(ReactApplicationContext reactContext) {
21 | super(reactContext);
22 | this.reactContext = reactContext;
23 |
24 | }
25 | private Promise mPickerPromise;
26 |
27 | private final ActivityEventListener mActivityEventListener = new BaseActivityEventListener() {
28 |
29 | @Override
30 | public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent intent) {
31 |
32 |
33 | }
34 | };
35 |
36 |
37 | @ReactMethod
38 | public void checkIfDeviceSupportAR(Promise promise) {
39 | ArCoreApk.Availability availability = ArCoreApk.getInstance().checkAvailability(reactContext);
40 | if (availability.isTransient()) {
41 | // Re-query at 5Hz while compatibility is checked in the background.
42 | new Handler().postDelayed(new Runnable() {
43 | @Override
44 | public void run() {
45 |
46 | // checkIfDeviceSupportAR(promise);
47 | }
48 | }, 200);
49 | }
50 | if (availability != ArCoreApk.Availability.UNSUPPORTED_DEVICE_NOT_CAPABLE) {
51 | promise.resolve(true);
52 | }
53 | else {
54 | promise.resolve(false);
55 | }
56 | /* if (availability.isSupported()) {
57 | promise.resolve("Pritam ");
58 | // indicator on the button.
59 | } else { // Unsupported or unknown.
60 | promise.resolve("NON supported Pritam ");
61 | }*/
62 | }
63 |
64 |
65 | @Override
66 | public String getName() {
67 | return "RNReactNativeArcoreModule";
68 | }
69 |
70 |
71 | public Activity getActivity() {
72 | return this.getCurrentActivity();
73 | }
74 | }
--------------------------------------------------------------------------------
/react-native-arcore/index.js:
--------------------------------------------------------------------------------
1 |
2 | 'use strict';
3 |
4 | var ReactNative = require('react-native');
5 | var React = require('react');
6 | var PropTypes = require('prop-types');
7 | var {
8 | requireNativeComponent,
9 | View,
10 | UIManager,
11 | DeviceEventEmitter,
12 | Text,
13 | } = ReactNative;
14 |
15 | class ARCORE extends React.Component {
16 |
17 | constructor() {
18 | super();
19 | this.onChange = this.onChange.bind(this);
20 | this.subscriptions = [];
21 | }
22 |
23 | onChange(event) {
24 |
25 |
26 | if(event.nativeEvent.planeDetected){
27 | if (!this.props.onPlaneDetected) {
28 | return;
29 | }
30 | this.props.onPlaneDetected({
31 | planeDetected: event.nativeEvent
32 | });
33 | }
34 |
35 |
36 | if(event.nativeEvent.planeHitDetected){
37 | if (!this.props.onPlaneHitDetected) {
38 | return;
39 | }
40 | this.props.onPlaneHitDetected({
41 | onPlaneHitDetected: event.nativeEvent
42 | });
43 | }
44 |
45 | }
46 |
47 | componentDidMount() {
48 |
49 | if (this.props.onPlaneDetected) {
50 | let sub = DeviceEventEmitter.addListener(
51 | 'onPlaneDetected',
52 | this.props.onPlaneDetected
53 | );
54 | this.subscriptions.push(sub);
55 | }
56 |
57 | if (this.props.onPlaneHitDetected) {
58 | let sub = DeviceEventEmitter.addListener(
59 | 'onPlaneHitDetected',
60 | this.props.onPlaneHitDetected
61 | );
62 | this.subscriptions.push(sub);
63 | }
64 |
65 | }
66 |
67 | componentWillUnmount() {
68 | this.subscriptions.forEach(sub => sub.remove());
69 | this.subscriptions = [];
70 | }
71 |
72 | render() {
73 | return (
74 | // /*
75 |
77 | RNReactNativeArcoreModule>
78 | // */
79 |
80 | // and red
81 | );
82 | }
83 | }
84 |
85 | ARCORE.propTypes = {
86 | ...View.propTypes,
87 | viewMode: PropTypes.string
88 | };
89 |
90 |
91 | var RNReactNativeArcoreModule = requireNativeComponent('RNReactNativeArcoreModule', ARCORE, {
92 | nativeOnly: { onChange: true }
93 | });
94 |
95 | module.exports = ARCORE;
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/RNReactNativeArcoreMainView.java:
--------------------------------------------------------------------------------
1 |
2 | package com.reactlibrary;
3 |
4 | import android.app.Activity;
5 | import android.graphics.Color;
6 | import android.util.Log;
7 | import android.view.ViewGroup;
8 | import android.widget.LinearLayout;
9 |
10 | import com.facebook.react.bridge.ReactContext;
11 | import com.facebook.react.bridge.WritableMap;
12 | import com.facebook.react.uimanager.ThemedReactContext;
13 | import com.facebook.react.uimanager.events.RCTEventEmitter;
14 |
15 |
16 | public class RNReactNativeArcoreMainView extends LinearLayout implements RNReactNativeArCoreView.CoreViewCallback {
17 |
18 | RNReactNativeArCoreView arCoreView;
19 | Activity mActivity;
20 | int mOriginalOrientation;
21 | String viewMode = "portrait";
22 |
23 | public RNReactNativeArcoreMainView(ThemedReactContext context, Activity activity)
24 | {
25 | super(context);
26 | Log.d("React:", "RNReactNativeArcoreMainView(Contructtor)");
27 | // mOriginalOrientation = activity.getRequestedOrientation();
28 | mActivity = activity;
29 | this.setOrientation(LinearLayout.VERTICAL);
30 | // add the buttons and signature views
31 | this.setBackgroundColor(Color.TRANSPARENT);
32 | this.arCoreView = new RNReactNativeArCoreView(context,this);
33 | this.addView(arCoreView);
34 | setLayoutParams(new android.view.ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
35 | ViewGroup.LayoutParams.MATCH_PARENT));
36 | }
37 |
38 | public void setViewMode(String viewMode) {
39 | this.viewMode = viewMode;
40 | // GestureDetectingView.valuesTesting = 20;
41 | if (viewMode.equalsIgnoreCase("portrait")) {
42 | // mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
43 | } else if (viewMode.equalsIgnoreCase("landscape")) {
44 | // mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
45 | }
46 | }
47 |
48 | @Override
49 | public void planeDetected(WritableMap event) {
50 | ReactContext reactContext = (ReactContext) getContext();
51 | reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(getId(), "topChange", event);
52 | }
53 |
54 | @Override
55 | public void planeHitDetected(WritableMap event) {
56 | ReactContext reactContext = (ReactContext) getContext();
57 | reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(getId(), "topChange", event);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/arutil/rendering/CameraPermissionHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 | package com.reactlibrary.arutil.rendering;
16 |
17 | import android.Manifest;
18 | import android.app.Activity;
19 | import android.content.Intent;
20 | import android.content.pm.PackageManager;
21 | import android.net.Uri;
22 | import android.provider.Settings;
23 | import android.support.v4.app.ActivityCompat;
24 | import android.support.v4.content.ContextCompat;
25 |
26 | /** Helper to ask camera permission. */
27 | public final class CameraPermissionHelper {
28 | private static final int CAMERA_PERMISSION_CODE = 0;
29 | private static final String CAMERA_PERMISSION = Manifest.permission.CAMERA;
30 |
31 | /**
32 | * Check to see we have the necessary permissions for this app.
33 | */
34 | public static boolean hasCameraPermission(Activity activity) {
35 | return ContextCompat.checkSelfPermission(activity, CAMERA_PERMISSION)
36 | == PackageManager.PERMISSION_GRANTED;
37 | }
38 |
39 | /**
40 | * Check to see we have the necessary permissions for this app, and ask for them if we don't.
41 | */
42 | public static void requestCameraPermission(Activity activity) {
43 | ActivityCompat.requestPermissions(activity, new String[]{CAMERA_PERMISSION},
44 | CAMERA_PERMISSION_CODE);
45 | }
46 |
47 | /** Check to see if we need to show the rationale for this permission. */
48 | public static boolean shouldShowRequestPermissionRationale(Activity activity) {
49 | return ActivityCompat.shouldShowRequestPermissionRationale(activity, CAMERA_PERMISSION);
50 | }
51 |
52 | /** Launch Application Setting to grant permission. */
53 | public static void launchPermissionSettings(Activity activity) {
54 | Intent intent = new Intent();
55 | intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
56 | intent.setData(Uri.fromParts("package", activity.getPackageName(), null));
57 | activity.startActivity(intent);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/react-native-arcore/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/res/raw/object_fragment.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | precision mediump float;
17 |
18 | uniform sampler2D u_Texture;
19 |
20 | uniform vec4 u_LightingParameters;
21 | uniform vec4 u_MaterialParameters;
22 |
23 | varying vec3 v_ViewPosition;
24 | varying vec3 v_ViewNormal;
25 | varying vec2 v_TexCoord;
26 |
27 | void main() {
28 | // We support approximate sRGB gamma.
29 | const float kGamma = 0.4545454;
30 | const float kInverseGamma = 2.2;
31 |
32 | // Unpack lighting and material parameters for better naming.
33 | vec3 viewLightDirection = u_LightingParameters.xyz;
34 | float lightIntensity = u_LightingParameters.w;
35 |
36 | float materialAmbient = u_MaterialParameters.x;
37 | float materialDiffuse = u_MaterialParameters.y;
38 | float materialSpecular = u_MaterialParameters.z;
39 | float materialSpecularPower = u_MaterialParameters.w;
40 |
41 | // Normalize varying parameters, because they are linearly interpolated in the vertex shader.
42 | vec3 viewFragmentDirection = normalize(v_ViewPosition);
43 | vec3 viewNormal = normalize(v_ViewNormal);
44 |
45 | // Apply inverse SRGB gamma to the texture before making lighting calculations.
46 | // Flip the y-texture coordinate to address the texture from top-left.
47 | vec4 objectColor = texture2D(u_Texture, vec2(v_TexCoord.x, 1.0 - v_TexCoord.y));
48 | objectColor.rgb = pow(objectColor.rgb, vec3(kInverseGamma));
49 |
50 | // Ambient light is unaffected by the light intensity.
51 | float ambient = materialAmbient;
52 |
53 | // Approximate a hemisphere light (not a harsh directional light).
54 | float diffuse = lightIntensity * materialDiffuse *
55 | 0.5 * (dot(viewNormal, viewLightDirection) + 1.0);
56 |
57 | // Compute specular light.
58 | vec3 reflectedLightDirection = reflect(viewLightDirection, viewNormal);
59 | float specularStrength = max(0.0, dot(viewFragmentDirection, reflectedLightDirection));
60 | float specular = lightIntensity * materialSpecular *
61 | pow(specularStrength, materialSpecularPower);
62 |
63 | // Apply SRGB gamma before writing the fragment color.
64 | gl_FragColor.a = objectColor.a;
65 | gl_FragColor.rgb = pow(objectColor.rgb * (ambient + diffuse) + specular, vec3(kGamma));
66 | }
67 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Android ARCore in react native
2 |
3 |
4 |
5 | # react-native-arcore
6 |
7 | ## Getting started
8 |
9 | `$ npm install react-native-arcore --save`
10 |
11 | ### Mostly automatic installation
12 |
13 | `$ react-native link react-native-arcore`
14 |
15 | ### Manual installation
16 |
17 |
18 | #### Android
19 |
20 | 1. Open up `android /app/src/main/java/[...]/MainActivity.java`
21 | - Add `import com.reactlibrary.RNReactNativeArcorePackage;` to the imports at the top of the file
22 | - Add `new RNReactNativeArcorePackage()` to the list returned by the `getPackages()` method
23 | 2. Append the following lines to `android/settings.gradle`:
24 | ```
25 | include ':react-native-arcore'
26 | project(':react-native-arcore').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-arcore/android')
27 | ```
28 | 3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
29 | ```
30 | compile project(':react-native-arcore')
31 | ```
32 |
33 | ## Usage
34 |
35 |
36 |
37 | In Android Manifest file
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | Add above permissions
47 |
48 |
49 |
51 |
52 |
53 | Add above metadata under the application tag
54 |
55 |
56 | ```javascript
57 | import ARCORE from 'react-native-arcore';
58 |
59 |
60 |
61 | async requestCameraPermission() {
62 | try {
63 | const granted = await PermissionsAndroid.request(
64 | PermissionsAndroid.PERMISSIONS.CAMERA,
65 | {
66 | 'title': 'Cool Photo App Camera Permission',
67 | 'message': 'Cool Photo App needs access to your camera ' +
68 | 'so you can take awesome pictures.',
69 | },
70 | );
71 | if (granted === PermissionsAndroid.RESULTS.GRANTED) {
72 | } else {
73 | console.log(currentConsoleTag, "Camera permission denied");
74 | }
75 | } catch (err) {
76 | console.log(currentConsoleTag, "METHOD: requestCameraPermission", err);
77 | }
78 | }
79 |
80 | // Also request the Camera permission before showing the ARCORE
81 |
82 | _onPlaneDetectedEvent(result) {
83 | console.log(result);
84 | }
85 |
86 | _onPlanTappedevent(result) {
87 | console.log(result);
88 | }
89 |
90 | // TODO: What to do with the module?
91 | render() {
92 | return (
93 |
94 |
99 |
100 |
101 |
102 | );
103 | }
104 |
105 | ```
106 |
107 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/arutil/rendering/ShaderUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 | package com.reactlibrary.arutil.rendering;
16 |
17 | import android.content.Context;
18 | import android.opengl.GLES20;
19 | import android.util.Log;
20 | import java.io.BufferedReader;
21 | import java.io.IOException;
22 | import java.io.InputStream;
23 | import java.io.InputStreamReader;
24 |
25 | /**
26 | * Shader helper functions.
27 | */
28 | public class ShaderUtil {
29 | /**
30 | * Converts a raw text file, saved as a resource, into an OpenGL ES shader.
31 | *
32 | * @param type The type of shader we will be creating.
33 | * @param resId The resource ID of the raw text file about to be turned into a shader.
34 | * @return The shader object handler.
35 | */
36 | public static int loadGLShader(String tag, Context context, int type, int resId) {
37 | String code = readRawTextFile(context, resId);
38 | int shader = GLES20.glCreateShader(type);
39 | GLES20.glShaderSource(shader, code);
40 | GLES20.glCompileShader(shader);
41 |
42 | // Get the compilation status.
43 | final int[] compileStatus = new int[1];
44 | GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
45 |
46 | // If the compilation failed, delete the shader.
47 | if (compileStatus[0] == 0) {
48 | Log.e(tag, "Error compiling shader: " + GLES20.glGetShaderInfoLog(shader));
49 | GLES20.glDeleteShader(shader);
50 | shader = 0;
51 | }
52 |
53 | if (shader == 0) {
54 | throw new RuntimeException("Error creating shader.");
55 | }
56 |
57 | return shader;
58 | }
59 |
60 | /**
61 | * Checks if we've had an error inside of OpenGL ES, and if so what that error is.
62 | *
63 | * @param label Label to report in case of error.
64 | * @throws RuntimeException If an OpenGL error is detected.
65 | */
66 | public static void checkGLError(String tag, String label) {
67 | int lastError = GLES20.GL_NO_ERROR;
68 | // Drain the queue of all errors.
69 | int error;
70 | while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) {
71 | Log.e(tag, label + ": glError " + error);
72 | lastError = error;
73 | }
74 | if (lastError != GLES20.GL_NO_ERROR) {
75 | throw new RuntimeException(label + ": glError " + lastError);
76 | }
77 | }
78 |
79 | /**
80 | * Converts a raw text file into a string.
81 | *
82 | * @param resId The resource ID of the raw text file about to be turned into a shader.
83 | * @return The context of the text file, or null in case of error.
84 | */
85 | private static String readRawTextFile(Context context, int resId) {
86 | InputStream inputStream = context.getResources().openRawResource(resId);
87 | try {
88 | BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
89 | StringBuilder sb = new StringBuilder();
90 | String line;
91 | while ((line = reader.readLine()) != null) {
92 | sb.append(line).append("\n");
93 | }
94 | reader.close();
95 | return sb.toString();
96 | } catch (IOException e) {
97 | e.printStackTrace();
98 | }
99 | return null;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/arutil/rendering/DisplayRotationHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 | package com.reactlibrary.arutil.rendering;
16 |
17 | import android.app.Activity;
18 | import android.content.Context;
19 | import android.hardware.display.DisplayManager;
20 | import android.hardware.display.DisplayManager.DisplayListener;
21 | import android.view.Display;
22 | import android.view.WindowManager;
23 | import com.google.ar.core.Session;
24 |
25 | /**
26 | * Helper to track the display rotations. In particular, the 180 degree rotations are not notified
27 | * by the onSurfaceChanged() callback, and thus they require listening to the android display
28 | * events.
29 | */
30 | public class DisplayRotationHelper implements DisplayListener {
31 | private boolean mViewportChanged;
32 | private int mViewportWidth;
33 | private int mViewportHeight;
34 | private final Context mContext;
35 | private final Display mDisplay;
36 |
37 | /**
38 | * Constructs the DisplayRotationHelper but does not register the listener yet.
39 | *
40 | * @param context the Android {@link Context}.
41 | */
42 | public DisplayRotationHelper(Context context) {
43 | mContext = context;
44 | mDisplay = context.getSystemService(WindowManager.class).getDefaultDisplay();
45 | }
46 |
47 | /** Registers the display listener. Should be called from {@link Activity#onResume()}. */
48 | public void onResume() {
49 | mContext.getSystemService(DisplayManager.class).registerDisplayListener(this, null);
50 | }
51 |
52 | /** Unregisters the display listener. Should be called from {@link Activity#onPause()}. */
53 | public void onPause() {
54 | mContext.getSystemService(DisplayManager.class).unregisterDisplayListener(this);
55 | }
56 |
57 | /**
58 | * Records a change in surface dimensions. This will be later used by
59 | * {@link #updateSessionIfNeeded(Session)}. Should be called from
60 | * {@link android.opengl.GLSurfaceView.Renderer
61 | * #onSurfaceChanged(javax.microedition.khronos.opengles.GL10, int, int)}.
62 | *
63 | * @param width the updated width of the surface.
64 | * @param height the updated height of the surface.
65 | */
66 | public void onSurfaceChanged(int width, int height) {
67 | mViewportWidth = width;
68 | mViewportHeight = height;
69 | mViewportChanged = true;
70 | }
71 |
72 | /**
73 | * Updates the session display geometry if a change was posted either by
74 | * {@link #onSurfaceChanged(int, int)} call or by {@link #onDisplayChanged(int)} system
75 | * callback. This function should be called explicitly before each call to
76 | * {@link Session#update()}. This function will also clear the 'pending update'
77 | * (viewportChanged) flag.
78 | *
79 | * @param session the {@link Session} object to update if display geometry changed.
80 | */
81 | public void updateSessionIfNeeded(Session session) {
82 | if (mViewportChanged) {
83 | int displayRotation = mDisplay.getRotation();
84 | session.setDisplayGeometry(displayRotation, mViewportWidth, mViewportHeight);
85 | mViewportChanged = false;
86 | }
87 | }
88 |
89 | /**
90 | * Returns the current rotation state of android display.
91 | * Same as {@link Display#getRotation()}.
92 | */
93 | public int getRotation() {
94 | return mDisplay.getRotation();
95 | }
96 |
97 | @Override
98 | public void onDisplayAdded(int displayId) {}
99 |
100 | @Override
101 | public void onDisplayRemoved(int displayId) {}
102 |
103 | @Override
104 | public void onDisplayChanged(int displayId) {
105 | mViewportChanged = true;
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/react-native-arcore/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/arutil/rendering/PointCloudRenderer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 | package com.reactlibrary.arutil.rendering;
16 |
17 | import android.content.Context;
18 | import android.opengl.GLES20;
19 | import android.opengl.GLSurfaceView;
20 | import android.opengl.Matrix;
21 |
22 | import com.google.ar.core.PointCloud;
23 | import com.reactlibrary.R;
24 |
25 | import javax.microedition.khronos.egl.EGLConfig;
26 | import javax.microedition.khronos.opengles.GL10;
27 |
28 | /**
29 | * Renders a point cloud.
30 | */
31 | public class PointCloudRenderer {
32 | private static final String TAG = PointCloud.class.getSimpleName();
33 |
34 | private static final int BYTES_PER_FLOAT = Float.SIZE / 8;
35 | private static final int FLOATS_PER_POINT = 4; // X,Y,Z,confidence.
36 | private static final int BYTES_PER_POINT = BYTES_PER_FLOAT * FLOATS_PER_POINT;
37 | private static final int INITIAL_BUFFER_POINTS = 1000;
38 |
39 | private int mVbo;
40 | private int mVboSize;
41 |
42 | private int mProgramName;
43 | private int mPositionAttribute;
44 | private int mModelViewProjectionUniform;
45 | private int mColorUniform;
46 | private int mPointSizeUniform;
47 |
48 | private int mNumPoints = 0;
49 |
50 | // Keep track of the last point cloud rendered to avoid updating the VBO if point cloud
51 | // was not changed.
52 | private PointCloud mLastPointCloud = null;
53 |
54 | public PointCloudRenderer() {
55 | }
56 |
57 | /**
58 | * Allocates and initializes OpenGL resources needed by the plane renderer. Must be
59 | * called on the OpenGL thread, typically in
60 | * {@link GLSurfaceView.Renderer#onSurfaceCreated(GL10, EGLConfig)}.
61 | *
62 | * @param context Needed to access shader source.
63 | */
64 | public void createOnGlThread(Context context) {
65 | ShaderUtil.checkGLError(TAG, "before create");
66 |
67 | int[] buffers = new int[1];
68 | GLES20.glGenBuffers(1, buffers, 0);
69 | mVbo = buffers[0];
70 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);
71 |
72 | mVboSize = INITIAL_BUFFER_POINTS * BYTES_PER_POINT;
73 | GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, mVboSize, null, GLES20.GL_DYNAMIC_DRAW);
74 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
75 |
76 | ShaderUtil.checkGLError(TAG, "buffer alloc");
77 |
78 | int vertexShader = ShaderUtil.loadGLShader(TAG, context,
79 | GLES20.GL_VERTEX_SHADER, R.raw.point_cloud_vertex);
80 | int passthroughShader = ShaderUtil.loadGLShader(TAG, context,
81 | GLES20.GL_FRAGMENT_SHADER, R.raw.passthrough_fragment);
82 |
83 | mProgramName = GLES20.glCreateProgram();
84 | GLES20.glAttachShader(mProgramName, vertexShader);
85 | GLES20.glAttachShader(mProgramName, passthroughShader);
86 | GLES20.glLinkProgram(mProgramName);
87 | GLES20.glUseProgram(mProgramName);
88 |
89 | ShaderUtil.checkGLError(TAG, "program");
90 |
91 | mPositionAttribute = GLES20.glGetAttribLocation(mProgramName, "a_Position");
92 | mColorUniform = GLES20.glGetUniformLocation(mProgramName, "u_Color");
93 | mModelViewProjectionUniform = GLES20.glGetUniformLocation(
94 | mProgramName, "u_ModelViewProjection");
95 | mPointSizeUniform = GLES20.glGetUniformLocation(mProgramName, "u_PointSize");
96 |
97 | ShaderUtil.checkGLError(TAG, "program params");
98 | }
99 |
100 | /**
101 | * Updates the OpenGL buffer contents to the provided point. Repeated calls with the same
102 | * point cloud will be ignored.
103 | */
104 | public void update(PointCloud cloud) {
105 | if (mLastPointCloud == cloud) {
106 | // Redundant call.
107 | return;
108 | }
109 |
110 | ShaderUtil.checkGLError(TAG, "before update");
111 |
112 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);
113 | mLastPointCloud = cloud;
114 |
115 | // If the VBO is not large enough to fit the new point cloud, resize it.
116 | mNumPoints = mLastPointCloud.getPoints().remaining() / FLOATS_PER_POINT;
117 | if (mNumPoints * BYTES_PER_POINT > mVboSize) {
118 | while (mNumPoints * BYTES_PER_POINT > mVboSize) {
119 | mVboSize *= 2;
120 | }
121 | GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, mVboSize, null, GLES20.GL_DYNAMIC_DRAW);
122 | }
123 | GLES20.glBufferSubData(GLES20.GL_ARRAY_BUFFER, 0, mNumPoints * BYTES_PER_POINT,
124 | mLastPointCloud.getPoints());
125 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
126 |
127 | ShaderUtil.checkGLError(TAG, "after update");
128 | }
129 |
130 | /**
131 | * Renders the point cloud. ArCore point cloud is given in world space.
132 | *
133 | * @param cameraView the camera view matrix for this frame, typically from {@link
134 | * com.google.ar.core.Camera#getViewMatrix(float[], int)}.
135 | * @param cameraPerspective the camera projection matrix for this frame, typically from {@link
136 | * com.google.ar.core.Camera#getProjectionMatrix(float[], int, float, float)}.
137 | */
138 | public void draw(float[] cameraView, float[] cameraPerspective) {
139 | float[] modelViewProjection = new float[16];
140 | Matrix.multiplyMM(modelViewProjection, 0, cameraPerspective, 0, cameraView, 0);
141 |
142 | ShaderUtil.checkGLError(TAG, "Before draw");
143 |
144 | GLES20.glUseProgram(mProgramName);
145 | GLES20.glEnableVertexAttribArray(mPositionAttribute);
146 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);
147 | GLES20.glVertexAttribPointer(
148 | mPositionAttribute, 4, GLES20.GL_FLOAT, false, BYTES_PER_POINT, 0);
149 | GLES20.glUniform4f(mColorUniform, 31.0f / 255.0f, 188.0f / 255.0f, 210.0f / 255.0f, 1.0f);
150 | GLES20.glUniformMatrix4fv(mModelViewProjectionUniform, 1, false, modelViewProjection, 0);
151 | GLES20.glUniform1f(mPointSizeUniform, 5.0f);
152 |
153 | GLES20.glDrawArrays(GLES20.GL_POINTS, 0, mNumPoints);
154 | GLES20.glDisableVertexAttribArray(mPositionAttribute);
155 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
156 |
157 | ShaderUtil.checkGLError(TAG, "Draw");
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/JsonUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 | package com.reactlibrary;
16 |
17 | import com.facebook.react.bridge.ReadableArray;
18 | import com.facebook.react.bridge.ReadableMap;
19 | import com.facebook.react.bridge.ReadableMapKeySetIterator;
20 | import com.facebook.react.bridge.WritableArray;
21 | import com.facebook.react.bridge.WritableMap;
22 | import com.facebook.react.bridge.WritableNativeArray;
23 | import com.facebook.react.bridge.WritableNativeMap;
24 |
25 | import org.json.JSONArray;
26 | import org.json.JSONException;
27 | import org.json.JSONObject;
28 |
29 | import java.util.Iterator;
30 |
31 | /**
32 | * Shader helper functions.
33 | */
34 | public class JsonUtils {
35 |
36 |
37 | public static WritableMap createMapFromFloat(float[] values) {
38 |
39 | WritableMap eventMap = new WritableNativeMap();
40 | eventMap.putDouble("m11",values[0]);
41 | eventMap.putDouble("m12",values[1]);
42 | eventMap.putDouble("m13",values[2]);
43 | eventMap.putDouble("m14",values[3]);
44 |
45 | eventMap.putDouble("m21",values[4]);
46 | eventMap.putDouble("m22",values[5]);
47 | eventMap.putDouble("m23",values[6]);
48 | eventMap.putDouble("m24",values[7]);
49 |
50 | eventMap.putDouble("m31",values[8]);
51 | eventMap.putDouble("m32",values[9]);
52 | eventMap.putDouble("m33",values[10]);
53 | eventMap.putDouble("m34",values[11]);
54 |
55 | eventMap.putDouble("m41",values[12]);
56 | eventMap.putDouble("m42",values[13]);
57 | eventMap.putDouble("m43",values[14]);
58 | eventMap.putDouble("m44",values[15]);
59 | return eventMap;
60 |
61 | }
62 | private static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
63 | WritableMap map = new WritableNativeMap();
64 |
65 | Iterator iterator = jsonObject.keys();
66 | while (iterator.hasNext()) {
67 | String key = iterator.next();
68 | Object value = jsonObject.get(key);
69 | if (value instanceof JSONObject) {
70 | map.putMap(key, convertJsonToMap((JSONObject) value));
71 | } else if (value instanceof JSONArray) {
72 | map.putArray(key, convertJsonToArray((JSONArray) value));
73 | } else if (value instanceof Boolean) {
74 | map.putBoolean(key, (Boolean) value);
75 | } else if (value instanceof Integer) {
76 | map.putInt(key, (Integer) value);
77 | } else if (value instanceof Double) {
78 | map.putDouble(key, (Double) value);
79 | } else if (value instanceof String) {
80 | map.putString(key, (String) value);
81 | } else {
82 | map.putString(key, value.toString());
83 | }
84 | }
85 | return map;
86 | }
87 |
88 | private static WritableArray convertJsonToArray(JSONArray jsonArray) throws JSONException {
89 | WritableArray array = new WritableNativeArray();
90 |
91 | for (int i = 0; i < jsonArray.length(); i++) {
92 | Object value = jsonArray.get(i);
93 | if (value instanceof JSONObject) {
94 | array.pushMap(convertJsonToMap((JSONObject) value));
95 | } else if (value instanceof JSONArray) {
96 | array.pushArray(convertJsonToArray((JSONArray) value));
97 | } else if (value instanceof Boolean) {
98 | array.pushBoolean((Boolean) value);
99 | } else if (value instanceof Integer) {
100 | array.pushInt((Integer) value);
101 | } else if (value instanceof Double) {
102 | array.pushDouble((Double) value);
103 | } else if (value instanceof String) {
104 | array.pushString((String) value);
105 | } else {
106 | array.pushString(value.toString());
107 | }
108 | }
109 | return array;
110 | }
111 |
112 | private static JSONObject convertMapToJson(ReadableMap readableMap) throws JSONException {
113 | JSONObject object = new JSONObject();
114 | ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
115 | while (iterator.hasNextKey()) {
116 | String key = iterator.nextKey();
117 | switch (readableMap.getType(key)) {
118 | case Null:
119 | object.put(key, JSONObject.NULL);
120 | break;
121 | case Boolean:
122 | object.put(key, readableMap.getBoolean(key));
123 | break;
124 | case Number:
125 | object.put(key, readableMap.getDouble(key));
126 | break;
127 | case String:
128 | object.put(key, readableMap.getString(key));
129 | break;
130 | case Map:
131 | object.put(key, convertMapToJson(readableMap.getMap(key)));
132 | break;
133 | case Array:
134 | object.put(key, convertArrayToJson(readableMap.getArray(key)));
135 | break;
136 | }
137 | }
138 | return object;
139 | }
140 |
141 | private static JSONArray convertArrayToJson(ReadableArray readableArray) throws JSONException {
142 | JSONArray array = new JSONArray();
143 | for (int i = 0; i < readableArray.size(); i++) {
144 | switch (readableArray.getType(i)) {
145 | case Null:
146 | break;
147 | case Boolean:
148 | array.put(readableArray.getBoolean(i));
149 | break;
150 | case Number:
151 | array.put(readableArray.getDouble(i));
152 | break;
153 | case String:
154 | array.put(readableArray.getString(i));
155 | break;
156 | case Map:
157 | array.put(convertMapToJson(readableArray.getMap(i)));
158 | break;
159 | case Array:
160 | array.put(convertArrayToJson(readableArray.getArray(i)));
161 | break;
162 | }
163 | }
164 | return array;
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/arutil/rendering/BackgroundRenderer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 | package com.reactlibrary.arutil.rendering;
16 |
17 | import android.content.Context;
18 | import android.opengl.GLES11Ext;
19 | import android.opengl.GLES20;
20 | import android.opengl.GLSurfaceView;
21 |
22 | import com.google.ar.core.Frame;
23 | import com.google.ar.core.Session;
24 | import com.reactlibrary.R;
25 |
26 | import java.nio.ByteBuffer;
27 | import java.nio.ByteOrder;
28 | import java.nio.FloatBuffer;
29 |
30 | import javax.microedition.khronos.egl.EGLConfig;
31 | import javax.microedition.khronos.opengles.GL10;
32 |
33 |
34 | /**
35 | * This class renders the AR background from camera feed. It creates and hosts the texture
36 | * given to ARCore to be filled with the camera image.
37 | */
38 | public class BackgroundRenderer {
39 | private static final String TAG = BackgroundRenderer.class.getSimpleName();
40 |
41 | private static final int COORDS_PER_VERTEX = 3;
42 | private static final int TEXCOORDS_PER_VERTEX = 2;
43 | private static final int FLOAT_SIZE = 4;
44 |
45 | private FloatBuffer mQuadVertices;
46 | private FloatBuffer mQuadTexCoord;
47 | private FloatBuffer mQuadTexCoordTransformed;
48 |
49 | private int mQuadProgram;
50 |
51 | private int mQuadPositionParam;
52 | private int mQuadTexCoordParam;
53 | private int mTextureId = -1;
54 |
55 | public BackgroundRenderer() {
56 | }
57 |
58 | public int getTextureId() {
59 | return mTextureId;
60 | }
61 |
62 | /**
63 | * Allocates and initializes OpenGL resources needed by the background renderer. Must be
64 | * called on the OpenGL thread, typically in
65 | * {@link GLSurfaceView.Renderer#onSurfaceCreated(GL10, EGLConfig)}.
66 | *
67 | * @param context Needed to access shader source.
68 | */
69 | public void createOnGlThread(Context context) {
70 | // Generate the background texture.
71 | int[] textures = new int[1];
72 | GLES20.glGenTextures(1, textures, 0);
73 | mTextureId = textures[0];
74 | int textureTarget = GLES11Ext.GL_TEXTURE_EXTERNAL_OES;
75 | GLES20.glBindTexture(textureTarget, mTextureId);
76 | GLES20.glTexParameteri(textureTarget, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
77 | GLES20.glTexParameteri(textureTarget, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
78 | GLES20.glTexParameteri(textureTarget, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
79 | GLES20.glTexParameteri(textureTarget, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
80 |
81 | int numVertices = 4;
82 | if (numVertices != QUAD_COORDS.length / COORDS_PER_VERTEX) {
83 | throw new RuntimeException("Unexpected number of vertices in BackgroundRenderer.");
84 | }
85 |
86 | ByteBuffer bbVertices = ByteBuffer.allocateDirect(QUAD_COORDS.length * FLOAT_SIZE);
87 | bbVertices.order(ByteOrder.nativeOrder());
88 | mQuadVertices = bbVertices.asFloatBuffer();
89 | mQuadVertices.put(QUAD_COORDS);
90 | mQuadVertices.position(0);
91 |
92 | ByteBuffer bbTexCoords = ByteBuffer.allocateDirect(
93 | numVertices * TEXCOORDS_PER_VERTEX * FLOAT_SIZE);
94 | bbTexCoords.order(ByteOrder.nativeOrder());
95 | mQuadTexCoord = bbTexCoords.asFloatBuffer();
96 | mQuadTexCoord.put(QUAD_TEXCOORDS);
97 | mQuadTexCoord.position(0);
98 |
99 | ByteBuffer bbTexCoordsTransformed = ByteBuffer.allocateDirect(
100 | numVertices * TEXCOORDS_PER_VERTEX * FLOAT_SIZE);
101 | bbTexCoordsTransformed.order(ByteOrder.nativeOrder());
102 | mQuadTexCoordTransformed = bbTexCoordsTransformed.asFloatBuffer();
103 |
104 | int vertexShader = ShaderUtil.loadGLShader(TAG, context,
105 | GLES20.GL_VERTEX_SHADER, R.raw.screenquad_vertex);
106 | int fragmentShader = ShaderUtil.loadGLShader(TAG, context,
107 | GLES20.GL_FRAGMENT_SHADER, R.raw.screenquad_fragment_oes);
108 |
109 | mQuadProgram = GLES20.glCreateProgram();
110 | GLES20.glAttachShader(mQuadProgram, vertexShader);
111 | GLES20.glAttachShader(mQuadProgram, fragmentShader);
112 | GLES20.glLinkProgram(mQuadProgram);
113 | GLES20.glUseProgram(mQuadProgram);
114 |
115 | ShaderUtil.checkGLError(TAG, "Program creation");
116 |
117 | mQuadPositionParam = GLES20.glGetAttribLocation(mQuadProgram, "a_Position");
118 | mQuadTexCoordParam = GLES20.glGetAttribLocation(mQuadProgram, "a_TexCoord");
119 |
120 | ShaderUtil.checkGLError(TAG, "Program parameters");
121 | }
122 |
123 | /**
124 | * Draws the AR background image. The image will be drawn such that virtual content rendered
125 | * with the matrices provided by {@link com.google.ar.core.Camera#getViewMatrix(float[], int)}
126 | * and {@link com.google.ar.core.Camera#getProjectionMatrix(float[], int, float, float)} will
127 | * accurately follow static physical objects.
128 | * This must be called before drawing virtual content.
129 | *
130 | * @param frame The last {@code Frame} returned by {@link Session#update()}.
131 | */
132 | public void draw(Frame frame) {
133 | // If display rotation changed (also includes view size change), we need to re-query the uv
134 | // coordinates for the screen rect, as they may have changed as well.
135 | if (frame.hasDisplayGeometryChanged()) {
136 | frame.transformDisplayUvCoords(mQuadTexCoord, mQuadTexCoordTransformed);
137 | }
138 |
139 | // No need to test or write depth, the screen quad has arbitrary depth, and is expected
140 | // to be drawn first.
141 | GLES20.glDisable(GLES20.GL_DEPTH_TEST);
142 | GLES20.glDepthMask(false);
143 |
144 | GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureId);
145 |
146 | GLES20.glUseProgram(mQuadProgram);
147 |
148 | // Set the vertex positions.
149 | GLES20.glVertexAttribPointer(
150 | mQuadPositionParam, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, mQuadVertices);
151 |
152 | // Set the texture coordinates.
153 | GLES20.glVertexAttribPointer(mQuadTexCoordParam, TEXCOORDS_PER_VERTEX,
154 | GLES20.GL_FLOAT, false, 0, mQuadTexCoordTransformed);
155 |
156 | // Enable vertex arrays
157 | GLES20.glEnableVertexAttribArray(mQuadPositionParam);
158 | GLES20.glEnableVertexAttribArray(mQuadTexCoordParam);
159 |
160 | GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
161 |
162 | // Disable vertex arrays
163 | GLES20.glDisableVertexAttribArray(mQuadPositionParam);
164 | GLES20.glDisableVertexAttribArray(mQuadTexCoordParam);
165 |
166 | // Restore the depth state for further drawing.
167 | GLES20.glDepthMask(true);
168 | GLES20.glEnable(GLES20.GL_DEPTH_TEST);
169 |
170 | ShaderUtil.checkGLError(TAG, "Draw");
171 | }
172 |
173 | private static final float[] QUAD_COORDS = new float[]{
174 | -1.0f, -1.0f, 0.0f,
175 | -1.0f, +1.0f, 0.0f,
176 | +1.0f, -1.0f, 0.0f,
177 | +1.0f, +1.0f, 0.0f,
178 | };
179 |
180 | private static final float[] QUAD_TEXCOORDS = new float[]{
181 | 0.0f, 1.0f,
182 | 0.0f, 0.0f,
183 | 1.0f, 1.0f,
184 | 1.0f, 0.0f,
185 | };
186 | }
187 |
--------------------------------------------------------------------------------
/react-native-arcore/android/android.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/android.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
--------------------------------------------------------------------------------
/react-native-arcore/android/react-native-arcore.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/react-native-arcore/android/bin/react-native-arcore.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
--------------------------------------------------------------------------------
/react-native-arcore/android/src/main/java/com/reactlibrary/arutil/rendering/ObjectRenderer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 | package com.reactlibrary.arutil.rendering;
16 |
17 | import android.content.Context;
18 | import android.graphics.Bitmap;
19 | import android.graphics.BitmapFactory;
20 | import android.opengl.GLES20;
21 | import android.opengl.GLUtils;
22 | import android.opengl.Matrix;
23 |
24 | import com.reactlibrary.R;
25 |
26 | import java.io.IOException;
27 | import java.io.InputStream;
28 | import java.nio.ByteBuffer;
29 | import java.nio.ByteOrder;
30 | import java.nio.FloatBuffer;
31 | import java.nio.IntBuffer;
32 | import java.nio.ShortBuffer;
33 |
34 | import de.javagl.obj.Obj;
35 | import de.javagl.obj.ObjData;
36 | import de.javagl.obj.ObjReader;
37 | import de.javagl.obj.ObjUtils;
38 |
39 |
40 | /**
41 | * Renders an object loaded from an OBJ file in OpenGL.
42 | */
43 | public class ObjectRenderer {
44 | private static final String TAG = ObjectRenderer.class.getSimpleName();
45 |
46 | /**
47 | * Blend mode.
48 | *
49 | * @see #setBlendMode(BlendMode)
50 | */
51 | public enum BlendMode {
52 | /** Multiplies the destination color by the source alpha. */
53 | Shadow,
54 | /** Normal alpha blending. */
55 | Grid
56 | }
57 |
58 | private static final int COORDS_PER_VERTEX = 3;
59 |
60 | // Note: the last component must be zero to avoid applying the translational part of the matrix.
61 | private static final float[] LIGHT_DIRECTION = new float[] { 0.250f, 0.866f, 0.433f, 0.0f };
62 | private float[] mViewLightDirection = new float[4];
63 |
64 | // Object vertex buffer variables.
65 | private int mVertexBufferId;
66 | private int mVerticesBaseAddress;
67 | private int mTexCoordsBaseAddress;
68 | private int mNormalsBaseAddress;
69 | private int mIndexBufferId;
70 | private int mIndexCount;
71 |
72 | private int mProgram;
73 | private int[] mTextures = new int[1];
74 |
75 | // Shader location: model view projection matrix.
76 | private int mModelViewUniform;
77 | private int mModelViewProjectionUniform;
78 |
79 | // Shader location: object attributes.
80 | private int mPositionAttribute;
81 | private int mNormalAttribute;
82 | private int mTexCoordAttribute;
83 |
84 | // Shader location: texture sampler.
85 | private int mTextureUniform;
86 |
87 | // Shader location: environment properties.
88 | private int mLightingParametersUniform;
89 |
90 | // Shader location: material properties.
91 | private int mMaterialParametersUniform;
92 |
93 | private BlendMode mBlendMode = null;
94 |
95 | // Temporary matrices allocated here to reduce number of allocations for each frame.
96 | private float[] mModelMatrix = new float[16];
97 | private float[] mModelViewMatrix = new float[16];
98 | private float[] mModelViewProjectionMatrix = new float[16];
99 |
100 | // Set some default material properties to use for lighting.
101 | private float mAmbient = 0.3f;
102 | private float mDiffuse = 1.0f;
103 | private float mSpecular = 1.0f;
104 | private float mSpecularPower = 6.0f;
105 |
106 | public ObjectRenderer() {
107 | }
108 |
109 | /**
110 | * Creates and initializes OpenGL resources needed for rendering the model.
111 | *
112 | * @param context Context for loading the shader and below-named model and texture assets.
113 | * @param objAssetName Name of the OBJ file containing the model geometry.
114 | * @param diffuseTextureAssetName Name of the PNG file containing the diffuse texture map.
115 | */
116 | public void createOnGlThread(Context context, String objAssetName,
117 | String diffuseTextureAssetName) throws IOException {
118 | // Read the texture.
119 | Bitmap textureBitmap = BitmapFactory.decodeStream(
120 | context.getAssets().open(diffuseTextureAssetName));
121 |
122 | GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
123 | GLES20.glGenTextures(mTextures.length, mTextures, 0);
124 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]);
125 |
126 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
127 | GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_LINEAR);
128 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
129 | GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
130 | GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, textureBitmap, 0);
131 | GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);
132 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
133 |
134 | textureBitmap.recycle();
135 |
136 | ShaderUtil.checkGLError(TAG, "Texture loading");
137 |
138 | // Read the obj file.
139 | InputStream objInputStream = context.getAssets().open(objAssetName);
140 | Obj obj = ObjReader.read(objInputStream);
141 |
142 | // Prepare the Obj so that its structure is suitable for
143 | // rendering with OpenGL:
144 | // 1. Triangulate it
145 | // 2. Make sure that texture coordinates are not ambiguous
146 | // 3. Make sure that normals are not ambiguous
147 | // 4. Convert it to single-indexed data
148 | obj = ObjUtils.convertToRenderable(obj);
149 |
150 | // OpenGL does not use Java arrays. ByteBuffers are used instead to provide data in a format
151 | // that OpenGL understands.
152 |
153 | // Obtain the data from the OBJ, as direct buffers:
154 | IntBuffer wideIndices = ObjData.getFaceVertexIndices(obj, 3);
155 | FloatBuffer vertices = ObjData.getVertices(obj);
156 | FloatBuffer texCoords = ObjData.getTexCoords(obj, 2);
157 | FloatBuffer normals = ObjData.getNormals(obj);
158 |
159 | // Convert int indices to shorts for GL ES 2.0 compatibility
160 | ShortBuffer indices = ByteBuffer.allocateDirect(2 * wideIndices.limit())
161 | .order(ByteOrder.nativeOrder()).asShortBuffer();
162 | while (wideIndices.hasRemaining()) {
163 | indices.put((short) wideIndices.get());
164 | }
165 | indices.rewind();
166 |
167 | int[] buffers = new int[2];
168 | GLES20.glGenBuffers(2, buffers, 0);
169 | mVertexBufferId = buffers[0];
170 | mIndexBufferId = buffers[1];
171 |
172 | // Load vertex buffer
173 | mVerticesBaseAddress = 0;
174 | mTexCoordsBaseAddress = mVerticesBaseAddress + 4 * vertices.limit();
175 | mNormalsBaseAddress = mTexCoordsBaseAddress + 4 * texCoords.limit();
176 | final int totalBytes = mNormalsBaseAddress + 4 * normals.limit();
177 |
178 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVertexBufferId);
179 | GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, totalBytes, null, GLES20.GL_STATIC_DRAW);
180 | GLES20.glBufferSubData(
181 | GLES20.GL_ARRAY_BUFFER, mVerticesBaseAddress, 4 * vertices.limit(), vertices);
182 | GLES20.glBufferSubData(
183 | GLES20.GL_ARRAY_BUFFER, mTexCoordsBaseAddress, 4 * texCoords.limit(), texCoords);
184 | GLES20.glBufferSubData(
185 | GLES20.GL_ARRAY_BUFFER, mNormalsBaseAddress, 4 * normals.limit(), normals);
186 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
187 |
188 | // Load index buffer
189 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, mIndexBufferId);
190 | mIndexCount = indices.limit();
191 | GLES20.glBufferData(
192 | GLES20.GL_ELEMENT_ARRAY_BUFFER, 2 * mIndexCount, indices, GLES20.GL_STATIC_DRAW);
193 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
194 |
195 | ShaderUtil.checkGLError(TAG, "OBJ buffer load");
196 |
197 | final int vertexShader = ShaderUtil.loadGLShader(TAG, context,
198 | GLES20.GL_VERTEX_SHADER, R.raw.object_vertex);
199 | final int fragmentShader = ShaderUtil.loadGLShader(TAG, context,
200 | GLES20.GL_FRAGMENT_SHADER, R.raw.object_fragment);
201 |
202 | mProgram = GLES20.glCreateProgram();
203 | GLES20.glAttachShader(mProgram, vertexShader);
204 | GLES20.glAttachShader(mProgram, fragmentShader);
205 | GLES20.glLinkProgram(mProgram);
206 | GLES20.glUseProgram(mProgram);
207 |
208 | ShaderUtil.checkGLError(TAG, "Program creation");
209 |
210 | mModelViewUniform = GLES20.glGetUniformLocation(mProgram, "u_ModelView");
211 | mModelViewProjectionUniform =
212 | GLES20.glGetUniformLocation(mProgram, "u_ModelViewProjection");
213 |
214 | mPositionAttribute = GLES20.glGetAttribLocation(mProgram, "a_Position");
215 | mNormalAttribute = GLES20.glGetAttribLocation(mProgram, "a_Normal");
216 | mTexCoordAttribute = GLES20.glGetAttribLocation(mProgram, "a_TexCoord");
217 |
218 | mTextureUniform = GLES20.glGetUniformLocation(mProgram, "u_Texture");
219 |
220 | mLightingParametersUniform = GLES20.glGetUniformLocation(mProgram, "u_LightingParameters");
221 | mMaterialParametersUniform = GLES20.glGetUniformLocation(mProgram, "u_MaterialParameters");
222 |
223 | ShaderUtil.checkGLError(TAG, "Program parameters");
224 |
225 | Matrix.setIdentityM(mModelMatrix, 0);
226 | }
227 |
228 | /**
229 | * Selects the blending mode for rendering.
230 | *
231 | * @param blendMode The blending mode. Null indicates no blending (opaque rendering).
232 | */
233 | public void setBlendMode(BlendMode blendMode) {
234 | mBlendMode = blendMode;
235 | }
236 |
237 | /**
238 | * Updates the object model matrix and applies scaling.
239 | *
240 | * @param modelMatrix A 4x4 model-to-world transformation matrix, stored in column-major order.
241 | * @param scaleFactor A separate scaling factor to apply before the {@code modelMatrix}.
242 | * @see android.opengl.Matrix
243 | */
244 | public void updateModelMatrix(float[] modelMatrix, float scaleFactor) {
245 | float[] scaleMatrix = new float[16];
246 | Matrix.setIdentityM(scaleMatrix, 0);
247 | scaleMatrix[0] = scaleFactor;
248 | scaleMatrix[5] = scaleFactor;
249 | scaleMatrix[10] = scaleFactor;
250 | Matrix.multiplyMM(mModelMatrix, 0, modelMatrix, 0, scaleMatrix, 0);
251 | }
252 |
253 | /**
254 | * Sets the surface characteristics of the rendered model.
255 | *
256 | * @param ambient Intensity of non-directional surface illumination.
257 | * @param diffuse Diffuse (matte) surface reflectivity.
258 | * @param specular Specular (shiny) surface reflectivity.
259 | * @param specularPower Surface shininess. Larger values result in a smaller, sharper
260 | * specular highlight.
261 | */
262 | public void setMaterialProperties(
263 | float ambient, float diffuse, float specular, float specularPower) {
264 | mAmbient = ambient;
265 | mDiffuse = diffuse;
266 | mSpecular = specular;
267 | mSpecularPower = specularPower;
268 | }
269 |
270 | /**
271 | * Draws the model.
272 | *
273 | * @param cameraView A 4x4 view matrix, in column-major order.
274 | * @param cameraPerspective A 4x4 projection matrix, in column-major order.
275 | * @param lightIntensity Illumination intensity. Combined with diffuse and specular material
276 | * properties.
277 | * @see #setBlendMode(BlendMode)
278 | * @see #updateModelMatrix(float[], float)
279 | * @see #setMaterialProperties(float, float, float, float)
280 | * @see android.opengl.Matrix
281 | */
282 | public void draw(float[] cameraView, float[] cameraPerspective, float lightIntensity) {
283 |
284 | ShaderUtil.checkGLError(TAG, "Before draw");
285 |
286 | // Build the ModelView and ModelViewProjection matrices
287 | // for calculating object position and light.
288 | Matrix.multiplyMM(mModelViewMatrix, 0, cameraView, 0, mModelMatrix, 0);
289 | Matrix.multiplyMM(mModelViewProjectionMatrix, 0, cameraPerspective, 0, mModelViewMatrix, 0);
290 |
291 | GLES20.glUseProgram(mProgram);
292 |
293 | // Set the lighting environment properties.
294 | Matrix.multiplyMV(mViewLightDirection, 0, mModelViewMatrix, 0, LIGHT_DIRECTION, 0);
295 | normalizeVec3(mViewLightDirection);
296 | GLES20.glUniform4f(mLightingParametersUniform,
297 | mViewLightDirection[0], mViewLightDirection[1], mViewLightDirection[2], lightIntensity);
298 |
299 | // Set the object material properties.
300 | GLES20.glUniform4f(mMaterialParametersUniform, mAmbient, mDiffuse, mSpecular,
301 | mSpecularPower);
302 |
303 | // Attach the object texture.
304 | GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
305 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]);
306 | GLES20.glUniform1i(mTextureUniform, 0);
307 |
308 | // Set the vertex attributes.
309 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVertexBufferId);
310 |
311 | GLES20.glVertexAttribPointer(
312 | mPositionAttribute, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, mVerticesBaseAddress);
313 | GLES20.glVertexAttribPointer(
314 | mNormalAttribute, 3, GLES20.GL_FLOAT, false, 0, mNormalsBaseAddress);
315 | GLES20.glVertexAttribPointer(
316 | mTexCoordAttribute, 2, GLES20.GL_FLOAT, false, 0, mTexCoordsBaseAddress);
317 |
318 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
319 |
320 | // Set the ModelViewProjection matrix in the shader.
321 | GLES20.glUniformMatrix4fv(
322 | mModelViewUniform, 1, false, mModelViewMatrix, 0);
323 | GLES20.glUniformMatrix4fv(
324 | mModelViewProjectionUniform, 1, false, mModelViewProjectionMatrix, 0);
325 |
326 | // Enable vertex arrays
327 | GLES20.glEnableVertexAttribArray(mPositionAttribute);
328 | GLES20.glEnableVertexAttribArray(mNormalAttribute);
329 | GLES20.glEnableVertexAttribArray(mTexCoordAttribute);
330 |
331 | if (mBlendMode != null) {
332 | GLES20.glDepthMask(false);
333 | GLES20.glEnable(GLES20.GL_BLEND);
334 | switch (mBlendMode) {
335 | case Shadow:
336 | // Multiplicative blending function for Shadow.
337 | GLES20.glBlendFunc(GLES20.GL_ZERO, GLES20.GL_ONE_MINUS_SRC_ALPHA);
338 | break;
339 | case Grid:
340 | // Grid, additive blending function.
341 | GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
342 | break;
343 | }
344 | }
345 |
346 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, mIndexBufferId);
347 | GLES20.glDrawElements(GLES20.GL_TRIANGLES, mIndexCount, GLES20.GL_UNSIGNED_SHORT, 0);
348 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
349 |
350 | if (mBlendMode != null) {
351 | GLES20.glDisable(GLES20.GL_BLEND);
352 | GLES20.glDepthMask(true);
353 | }
354 |
355 | // Disable vertex arrays
356 | GLES20.glDisableVertexAttribArray(mPositionAttribute);
357 | GLES20.glDisableVertexAttribArray(mNormalAttribute);
358 | GLES20.glDisableVertexAttribArray(mTexCoordAttribute);
359 |
360 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
361 |
362 | ShaderUtil.checkGLError(TAG, "After draw");
363 | }
364 |
365 | private static void normalizeVec3(float[] v) {
366 | float reciprocalLength = 1.0f / (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
367 | v[0] *= reciprocalLength;
368 | v[1] *= reciprocalLength;
369 | v[2] *= reciprocalLength;
370 | }
371 | }
372 |
--------------------------------------------------------------------------------