├── .circleci └── config.yml ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .husky ├── .npmignore ├── commit-msg └── pre-commit ├── .yarnrc ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── android ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── models │ │ ├── DragonAttenuation.glb │ │ ├── Rabbit.glb │ │ ├── Video.glb │ │ ├── backdrop.glb │ │ ├── cube.glb │ │ ├── dargon_backdrop.glb │ │ ├── dragon.glb │ │ ├── face.glb │ │ └── fox.glb │ └── textures │ │ ├── face.png │ │ └── freckles.png │ ├── java │ ├── com │ │ └── reactnativesceneform │ │ │ ├── ModuleWithEmitter.java │ │ │ ├── NoARViewMain.java │ │ │ ├── SceneformPackage.java │ │ │ ├── manager │ │ │ ├── AugmentedFacesViewManager.java │ │ │ ├── NoARViewManager.java │ │ │ └── SceneformViewManager.java │ │ │ ├── module │ │ │ ├── AugmentedFacesViewModule.java │ │ │ ├── NoARViewModule.java │ │ │ └── SceneformViewModule.java │ │ │ ├── scene │ │ │ ├── ARScene.java │ │ │ ├── AugmentedFacesScene.java │ │ │ ├── FaceModel.java │ │ │ ├── LocationMarker.java │ │ │ ├── Model.java │ │ │ └── NoARScene.java │ │ │ └── utils │ │ │ ├── HelperFuncions.java │ │ │ ├── ModelManager.java │ │ │ └── VideoRecorder.java │ └── uk │ │ └── co │ │ └── appoly │ │ └── arcorelocation │ │ ├── LocationMarker.java │ │ ├── LocationScene.java │ │ ├── rendering │ │ ├── LocationNode.java │ │ └── LocationNodeRender.java │ │ ├── sensor │ │ ├── DeviceLocation.java │ │ ├── DeviceLocationChanged.java │ │ └── DeviceOrientation.java │ │ └── utils │ │ ├── ARLocationPermissionHelper.java │ │ ├── KalmanLatLong.java │ │ └── LocationUtils.java │ └── res │ ├── drawable │ ├── anchor.png │ ├── annotation.png │ ├── sceneform_hand_phone.png │ └── sceneform_plane.png │ └── layout │ ├── activity_main.xml │ ├── anchor.xml │ ├── augmented_faces.xml │ ├── augmented_images.xml │ ├── backgroundview.xml │ └── view_model_title.xml ├── babel.config.js ├── docs ├── AUGMENTED_FACES.md ├── SCENEFORMVIEW.md ├── TYPES.md ├── face.gif ├── location.gif ├── placing.gif └── resolving.gif ├── example ├── android │ ├── app │ │ ├── build.gradle │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── reactnativesceneform │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── reactnativesceneform │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.tsx ├── ios │ ├── File.swift │ ├── Podfile │ ├── SceneformExample-Bridging-Header.h │ ├── SceneformExample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── SceneformExample.xcscheme │ ├── SceneformExample.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── SceneformExample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m ├── metro.config.js ├── package-lock.json ├── package.json └── src │ └── App.tsx ├── ios ├── Sceneform.xcodeproj │ └── project.pbxproj └── SceneformViewManager.m ├── package-lock.json ├── package.json ├── react-native-sceneform.podspec ├── scripts └── bootstrap.js ├── src ├── ARScene │ └── index.js ├── AugmentedFacesScene │ └── index.js ├── NoARScene │ └── index.js ├── __tests__ │ └── index.test.tsx └── index.js ├── tsconfig.build.json └── tsconfig.json /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | executors: 4 | default: 5 | docker: 6 | - image: circleci/node:10 7 | working_directory: ~/project 8 | 9 | commands: 10 | attach_project: 11 | steps: 12 | - attach_workspace: 13 | at: ~/project 14 | 15 | jobs: 16 | install-dependencies: 17 | executor: default 18 | steps: 19 | - checkout 20 | - attach_project 21 | - restore_cache: 22 | keys: 23 | - dependencies-{{ checksum "package.json" }} 24 | - dependencies- 25 | - restore_cache: 26 | keys: 27 | - dependencies-example-{{ checksum "example/package.json" }} 28 | - dependencies-example- 29 | - run: 30 | name: Install dependencies 31 | command: | 32 | yarn install --cwd example --frozen-lockfile 33 | yarn install --frozen-lockfile 34 | - save_cache: 35 | key: dependencies-{{ checksum "package.json" }} 36 | paths: node_modules 37 | - save_cache: 38 | key: dependencies-example-{{ checksum "example/package.json" }} 39 | paths: example/node_modules 40 | - persist_to_workspace: 41 | root: . 42 | paths: . 43 | 44 | lint: 45 | executor: default 46 | steps: 47 | - attach_project 48 | - run: 49 | name: Lint files 50 | command: | 51 | yarn lint 52 | 53 | typescript: 54 | executor: default 55 | steps: 56 | - attach_project 57 | - run: 58 | name: Typecheck files 59 | command: | 60 | yarn typescript 61 | 62 | unit-tests: 63 | executor: default 64 | steps: 65 | - attach_project 66 | - run: 67 | name: Run unit tests 68 | command: | 69 | yarn test --coverage 70 | - store_artifacts: 71 | path: coverage 72 | destination: coverage 73 | 74 | build-package: 75 | executor: default 76 | steps: 77 | - attach_project 78 | - run: 79 | name: Build package 80 | command: | 81 | yarn prepare 82 | 83 | workflows: 84 | build-and-test: 85 | jobs: 86 | - install-dependencies 87 | - lint: 88 | requires: 89 | - install-dependencies 90 | - typescript: 91 | requires: 92 | - install-dependencies 93 | - unit-tests: 94 | requires: 95 | - install-dependencies 96 | - build-package: 97 | requires: 98 | - install-dependencies 99 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | indent_style = space 10 | indent_size = 2 11 | 12 | end_of_line = lf 13 | charset = utf-8 14 | trim_trailing_whitespace = true 15 | insert_final_newline = true 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | # specific for windows script files 3 | *.bat text eol=crlf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # XDE 6 | .expo/ 7 | 8 | # VSCode 9 | .vscode/ 10 | jsconfig.json 11 | 12 | # Xcode 13 | # 14 | build/ 15 | *.pbxuser 16 | !default.pbxuser 17 | *.mode1v3 18 | !default.mode1v3 19 | *.mode2v3 20 | !default.mode2v3 21 | *.perspectivev3 22 | !default.perspectivev3 23 | xcuserdata 24 | *.xccheckout 25 | *.moved-aside 26 | DerivedData 27 | *.hmap 28 | *.ipa 29 | *.xcuserstate 30 | project.xcworkspace 31 | 32 | # Android/IJ 33 | # 34 | .classpath 35 | .cxx 36 | .gradle 37 | .idea 38 | .project 39 | .settings 40 | local.properties 41 | android.iml 42 | 43 | # Cocoapods 44 | # 45 | example/ios/Pods 46 | 47 | # node.js 48 | # 49 | node_modules/ 50 | npm-debug.log 51 | yarn-debug.log 52 | yarn-error.log 53 | 54 | # BUCK 55 | buck-out/ 56 | \.buckd/ 57 | android/app/libs 58 | android/keystores/debug.keystore 59 | 60 | # Expo 61 | .expo/* 62 | 63 | # generated by bob 64 | lib/ 65 | -------------------------------------------------------------------------------- /.husky/.npmignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn commitlint -E HUSKY_GIT_PARAMS 5 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn lint && yarn typescript 5 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | # Override Yarn command so we can automatically setup the repo on running `yarn` 2 | 3 | yarn-path "scripts/bootstrap.js" 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. 4 | 5 | ## Development workflow 6 | 7 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package: 8 | 9 | ```sh 10 | yarn 11 | ``` 12 | 13 | > While it's possible to use [`npm`](https://github.com/npm/cli), the tooling is built around [`yarn`](https://classic.yarnpkg.com/), so you'll have an easier time if you use `yarn` for development. 14 | 15 | While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app. 16 | 17 | To start the packager: 18 | 19 | ```sh 20 | yarn example start 21 | ``` 22 | 23 | To run the example app on Android: 24 | 25 | ```sh 26 | yarn example android 27 | ``` 28 | 29 | To run the example app on iOS: 30 | 31 | ```sh 32 | yarn example ios 33 | ``` 34 | 35 | Make sure your code passes TypeScript and ESLint. Run the following to verify: 36 | 37 | ```sh 38 | yarn typescript 39 | yarn lint 40 | ``` 41 | 42 | To fix formatting errors, run the following: 43 | 44 | ```sh 45 | yarn lint --fix 46 | ``` 47 | 48 | Remember to add tests for your change if possible. Run the unit tests by: 49 | 50 | ```sh 51 | yarn test 52 | ``` 53 | 54 | To edit the Objective-C files, open `example/ios/SceneformExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-sceneform`. 55 | 56 | To edit the Kotlin files, open `example/android` in Android studio and find the source files at `reactnativesceneform` under `Android`. 57 | 58 | ### Commit message convention 59 | 60 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages: 61 | 62 | - `fix`: bug fixes, e.g. fix crash due to deprecated method. 63 | - `feat`: new features, e.g. add new method to the module. 64 | - `refactor`: code refactor, e.g. migrate from class components to hooks. 65 | - `docs`: changes into documentation, e.g. add usage example for the module.. 66 | - `test`: adding or updating tests, e.g. add integration tests using detox. 67 | - `chore`: tooling changes, e.g. change CI config. 68 | 69 | Our pre-commit hooks verify that your commit message matches this format when committing. 70 | 71 | ### Linting and tests 72 | 73 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/) 74 | 75 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing. 76 | 77 | Our pre-commit hooks verify that the linter and tests pass when committing. 78 | 79 | ### Publishing to npm 80 | 81 | We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc. 82 | 83 | To publish new versions, run the following: 84 | 85 | ```sh 86 | yarn release 87 | ``` 88 | 89 | ### Scripts 90 | 91 | The `package.json` file contains various scripts for common tasks: 92 | 93 | - `yarn bootstrap`: setup project by installing all dependencies and pods. 94 | - `yarn typescript`: type-check files with TypeScript. 95 | - `yarn lint`: lint files with ESLint. 96 | - `yarn test`: run unit tests with Jest. 97 | - `yarn example start`: start the Metro server for the example app. 98 | - `yarn example android`: run the example app on Android. 99 | - `yarn example ios`: run the example app on iOS. 100 | 101 | ### Sending a pull request 102 | 103 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github). 104 | 105 | When you're sending a pull request: 106 | 107 | - Prefer small pull requests focused on one change. 108 | - Verify that linters and tests are passing. 109 | - Review the documentation to make sure it looks good. 110 | - Follow the pull request template when opening a pull request. 111 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue. 112 | 113 | ## Code of Conduct 114 | 115 | ### Our Pledge 116 | 117 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. 118 | 119 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. 120 | 121 | ### Our Standards 122 | 123 | Examples of behavior that contributes to a positive environment for our community include: 124 | 125 | - Demonstrating empathy and kindness toward other people 126 | - Being respectful of differing opinions, viewpoints, and experiences 127 | - Giving and gracefully accepting constructive feedback 128 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience 129 | - Focusing on what is best not just for us as individuals, but for the overall community 130 | 131 | Examples of unacceptable behavior include: 132 | 133 | - The use of sexualized language or imagery, and sexual attention or 134 | advances of any kind 135 | - Trolling, insulting or derogatory comments, and personal or political attacks 136 | - Public or private harassment 137 | - Publishing others' private information, such as a physical or email 138 | address, without their explicit permission 139 | - Other conduct which could reasonably be considered inappropriate in a 140 | professional setting 141 | 142 | ### Enforcement Responsibilities 143 | 144 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. 145 | 146 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. 147 | 148 | ### Scope 149 | 150 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. 151 | 152 | ### Enforcement 153 | 154 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly. 155 | 156 | All community leaders are obligated to respect the privacy and security of the reporter of any incident. 157 | 158 | ### Enforcement Guidelines 159 | 160 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: 161 | 162 | #### 1. Correction 163 | 164 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. 165 | 166 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. 167 | 168 | #### 2. Warning 169 | 170 | **Community Impact**: A violation through a single incident or series of actions. 171 | 172 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. 173 | 174 | #### 3. Temporary Ban 175 | 176 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. 177 | 178 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. 179 | 180 | #### 4. Permanent Ban 181 | 182 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. 183 | 184 | **Consequence**: A permanent ban from any sort of public interaction within the community. 185 | 186 | ### Attribution 187 | 188 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, 189 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 190 | 191 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). 192 | 193 | [homepage]: https://www.contributor-covenant.org 194 | 195 | For answers to common questions about this code of conduct, see the FAQ at 196 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. 197 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Eduardo Dorantes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Discord Server 2 | Join us on [Discord](https://discord.gg/UbNDDBTNqb) if you need a hand or just want to talk about Sceneform and AR. 3 | 4 | ### Features 5 | 6 | - Remote and local assets 7 | - Augmented Faces 8 | - Cloud anchors 9 | - Plane detection 10 | - Feature quality indicator 11 | - Depth API 12 | - Location anchors 13 | - Video recording 14 | - Screenshots 15 | 16 | # react-native-sceneform 17 | 18 | ![](https://raw.githubusercontent.com/kboy-silvergym/ARCore-Kotlin-Sampler/master/readmeImages/sceneform.jpg) 19 | 20 | | Location markers | Augmented Faces | Object placing | Cloud anchors | 21 | |--|--|--|--| 22 | |![](https://raw.githubusercontent.com/SceneView/react-native-sceneform/master/docs/location.gif)|![](https://raw.githubusercontent.com/SceneView/react-native-sceneform/master/docs/face.gif)|![](https://raw.githubusercontent.com/SceneView/react-native-sceneform/master/docs/placing.gif)|![](https://raw.githubusercontent.com/SceneView/react-native-sceneform/master/docs/resolving.gif)| 23 | 24 | # Requirements 25 | 26 | This package requires your app to target Android SDK 24 at least and react-native 0.66+ 27 | 28 | Also, this package does not handle permissions, be sure to request: 29 | 30 | - CAMERA: for AR view. 31 | - WRITE_EXTERNAL_STORAGE: for screenshots. 32 | - RECORD_AUDIO: for recording video. 33 | - ACCESS_FINE_LOCATION/ACCESS_COARSE_LOCATION: for location-based AR. 34 | 35 | # Installation 36 | 37 | - Install from npm running `npm install --save @sceneview/react-native-sceneform` 38 | - Add the following to your AndroidManifest.xml inside the Application node. 39 | ```xml 40 | 41 | ``` 42 | - In your app/build.gradle, set your minSdkVersion to 24. 43 | 44 | If you are going to use Cloud Anchors, be sure to add your API Key to the AndroidManifest or to sign your application in the Google Cloud Platform console (keyless auth) 45 | 46 | # Loading the library 47 | 48 | `import { SceneformView, AugmentedFacesView } from 'react-native-sceneform';` 49 | 50 | # Components and Definitions 51 | 52 | ### » [SceneformView](./docs/SCENEFORMVIEW.md) 53 | ### » [AugmentedFacesView](./docs/AUGMENTED_FACES.md) 54 | ### » [Type Definitions](./docs/TYPES.md) 55 | 56 | # Examples 57 | 58 | #### » [Augmented Faces](https://github.com/doranteseduardo/augmented-faces-demo) 59 | 60 | # To do 61 | 62 | - Augmented images 63 | - No-AR view (3D model viewer) 64 | - Runtime renderable creation 65 | - Custom lights 66 | - Animation manipulation (currently animations are played automatically) 67 | - Depth toggling 68 | 69 | # Credits 70 | 71 | [ARCore-Location](https://github.com/appoly/ARCore-Location) 72 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | if (project == rootProject) { 3 | repositories { 4 | google() 5 | mavenCentral() 6 | jcenter() 7 | } 8 | 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.6.0' 11 | } 12 | } 13 | } 14 | 15 | apply plugin: 'com.android.library' 16 | 17 | def safeExtGet(prop, fallback) { 18 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 19 | } 20 | 21 | android { 22 | compileSdkVersion safeExtGet('Sceneform_compileSdkVersion', 29) 23 | defaultConfig { 24 | minSdkVersion safeExtGet('Sceneform_minSdkVersion', 24) 25 | targetSdkVersion safeExtGet('Sceneform_targetSdkVersion', 29) 26 | versionCode 1 27 | versionName "1.0" 28 | 29 | } 30 | 31 | buildTypes { 32 | release { 33 | minifyEnabled false 34 | } 35 | } 36 | lintOptions { 37 | disable 'GradleCompatible' 38 | } 39 | compileOptions { 40 | sourceCompatibility JavaVersion.VERSION_1_8 41 | targetCompatibility JavaVersion.VERSION_1_8 42 | } 43 | } 44 | 45 | repositories { 46 | mavenLocal() 47 | maven { 48 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 49 | url("$rootDir/../node_modules/react-native/android") 50 | } 51 | google() 52 | mavenCentral() 53 | jcenter() 54 | } 55 | 56 | dependencies { 57 | //noinspection GradleDynamicVersion 58 | implementation "com.facebook.react:react-native:+" // From node_modules 59 | implementation("com.gorisse.thomas.sceneform:sceneform:1.20.1"); 60 | implementation 'androidx.appcompat:appcompat:1.1.0' 61 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 62 | implementation 'com.google.android.material:material:1.2.0-alpha02' 63 | implementation 'com.google.guava:guava:27.0.1-android' 64 | } 65 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | ## For more details on how to configure your build environment visit 2 | # http://www.gradle.org/docs/current/userguide/build_environment.html 3 | # 4 | # Specifies the JVM arguments used for the daemon process. 5 | # The setting is particularly useful for tweaking memory settings. 6 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 7 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 8 | # 9 | # When configured, Gradle will run in incubating parallel mode. 10 | # This option should only be used with decoupled projects. More details, visit 11 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 12 | # org.gradle.parallel=true 13 | #Sat Nov 06 21:45:37 CST 2021 14 | android.useAndroidX=true 15 | android.enableJetifier=true 16 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/settings.gradle -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /android/src/main/assets/models/DragonAttenuation.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/assets/models/DragonAttenuation.glb -------------------------------------------------------------------------------- /android/src/main/assets/models/Rabbit.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/assets/models/Rabbit.glb -------------------------------------------------------------------------------- /android/src/main/assets/models/Video.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/assets/models/Video.glb -------------------------------------------------------------------------------- /android/src/main/assets/models/backdrop.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/assets/models/backdrop.glb -------------------------------------------------------------------------------- /android/src/main/assets/models/cube.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/assets/models/cube.glb -------------------------------------------------------------------------------- /android/src/main/assets/models/dargon_backdrop.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/assets/models/dargon_backdrop.glb -------------------------------------------------------------------------------- /android/src/main/assets/models/dragon.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/assets/models/dragon.glb -------------------------------------------------------------------------------- /android/src/main/assets/models/face.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/assets/models/face.glb -------------------------------------------------------------------------------- /android/src/main/assets/models/fox.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/assets/models/fox.glb -------------------------------------------------------------------------------- /android/src/main/assets/textures/face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/assets/textures/face.png -------------------------------------------------------------------------------- /android/src/main/assets/textures/freckles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/assets/textures/freckles.png -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/ModuleWithEmitter.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform; 2 | 3 | import com.facebook.react.bridge.ReactContext; 4 | import com.facebook.react.bridge.WritableMap; 5 | import com.facebook.react.modules.core.DeviceEventManagerModule; 6 | 7 | public class ModuleWithEmitter { 8 | public static final String EMIT_GET_NAME = "EMIT_GET_NAME"; 9 | public static final String EMIT_GET_PATH_FILE_SCREEN_SHORT = "EMIT_GET_PATH_FILE_SCREEN_SHORT"; 10 | 11 | public static final String ON_SESSION_CREATE = "onSessionCreate"; 12 | public static final String ON_ANCHOR_CREATE = "onAnchorCreate"; 13 | public static final String ON_ANCHOR_RESOLVE = "onAnchorResolve"; 14 | public static final String ON_TAP_PLANE = "onTapPlane"; 15 | public static final String ON_FEATURE_MAP_QUALITY_CHANGE = "onFeatureMapQualityChange"; 16 | public static final String ON_ANCHOR_HOST = "onAnchorHost"; 17 | //public static final String ON_AUGMENTED_FACE_MODEL_READY = "onAugmentedFaceModelReady"; 18 | 19 | public static void sendEvent(ReactContext context, String name, WritableMap body) { 20 | if (context != null) { 21 | context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(name, body); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/NoARViewMain.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform; 2 | 3 | import android.app.Activity; 4 | import android.graphics.Color; 5 | import android.os.Build; 6 | import android.view.ViewGroup; 7 | import android.widget.LinearLayout; 8 | 9 | import androidx.annotation.RequiresApi; 10 | 11 | import com.reactnativesceneform.scene.ARScene; 12 | import com.facebook.react.uimanager.ThemedReactContext; 13 | import com.reactnativesceneform.scene.NoARScene; 14 | 15 | public class NoARViewMain extends LinearLayout { 16 | private Activity mActivity; 17 | private NoARScene arCoreView; 18 | 19 | @RequiresApi(api = Build.VERSION_CODES.N) 20 | public NoARViewMain(ThemedReactContext context) { 21 | super(context); 22 | //mActivity = activity; 23 | this.setOrientation(LinearLayout.VERTICAL); 24 | this.setBackgroundColor(Color.TRANSPARENT); 25 | arCoreView = new NoARScene(context); 26 | setLayoutParams(new android.view.ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 27 | ViewGroup.LayoutParams.MATCH_PARENT)); 28 | this.addView(arCoreView); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/SceneformPackage.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform; 2 | 3 | import com.facebook.react.ReactPackage; 4 | import com.facebook.react.bridge.NativeModule; 5 | import com.facebook.react.bridge.ReactApplicationContext; 6 | import com.facebook.react.uimanager.ViewManager; 7 | import com.reactnativesceneform.manager.AugmentedFacesViewManager; 8 | import com.reactnativesceneform.manager.NoARViewManager; 9 | import com.reactnativesceneform.manager.SceneformViewManager; 10 | import com.reactnativesceneform.module.AugmentedFacesViewModule; 11 | import com.reactnativesceneform.module.NoARViewModule; 12 | import com.reactnativesceneform.module.SceneformViewModule; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | public class SceneformPackage implements ReactPackage { 18 | @Override 19 | public List createNativeModules(ReactApplicationContext reactContext) { 20 | List modules = new ArrayList<>(); 21 | modules.add(new SceneformViewModule(reactContext)); 22 | modules.add(new AugmentedFacesViewModule(reactContext)); 23 | modules.add(new NoARViewModule(reactContext)); 24 | return modules; 25 | } 26 | 27 | @Override 28 | public List createViewManagers(ReactApplicationContext reactContext) { 29 | List managers = new ArrayList<>(); 30 | managers.add(new SceneformViewManager()); 31 | managers.add(new AugmentedFacesViewManager()); 32 | managers.add(new NoARViewManager()); 33 | return managers; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/manager/AugmentedFacesViewManager.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.manager; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.facebook.react.uimanager.SimpleViewManager; 6 | import com.facebook.react.uimanager.ThemedReactContext; 7 | import com.facebook.react.uimanager.annotations.ReactProp; 8 | import com.reactnativesceneform.scene.AugmentedFacesScene; 9 | 10 | public class AugmentedFacesViewManager extends SimpleViewManager { 11 | public static final String REACT_CLASS = "SceneformAugmentedFacesView"; 12 | 13 | @Override 14 | @NonNull 15 | public String getName() { 16 | return REACT_CLASS; 17 | } 18 | 19 | @Override 20 | @NonNull 21 | public AugmentedFacesScene createViewInstance(ThemedReactContext reactContext) { 22 | return new AugmentedFacesScene(reactContext); 23 | } 24 | 25 | @ReactProp(name = "setAugmentedFace") 26 | public void setAugmentedFace(AugmentedFacesScene view, int index){ 27 | if(index > -1) { 28 | view.setAugmentedFace(index); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/manager/NoARViewManager.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.manager; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.facebook.react.uimanager.SimpleViewManager; 6 | import com.facebook.react.uimanager.ThemedReactContext; 7 | import com.facebook.react.uimanager.annotations.ReactProp; 8 | import com.reactnativesceneform.NoARViewMain; 9 | import com.reactnativesceneform.scene.NoARScene; 10 | 11 | public class NoARViewManager extends SimpleViewManager { 12 | public static final String REACT_CLASS = "SceneformNoARView"; 13 | 14 | @Override 15 | @NonNull 16 | public String getName() { 17 | return REACT_CLASS; 18 | } 19 | 20 | @Override 21 | @NonNull 22 | public NoARViewMain createViewInstance(ThemedReactContext reactContext) { 23 | return new NoARViewMain(reactContext); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/manager/SceneformViewManager.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.manager; 2 | 3 | import android.graphics.Color; 4 | import android.view.View; 5 | 6 | import androidx.annotation.NonNull; 7 | 8 | import com.facebook.react.bridge.ReadableArray; 9 | import com.facebook.react.uimanager.SimpleViewManager; 10 | import com.facebook.react.uimanager.ThemedReactContext; 11 | import com.facebook.react.uimanager.annotations.ReactProp; 12 | import com.reactnativesceneform.scene.ARScene; 13 | 14 | public class SceneformViewManager extends SimpleViewManager { 15 | public static final String REACT_CLASS = "SceneformView"; 16 | 17 | @Override 18 | @NonNull 19 | public String getName() { 20 | return REACT_CLASS; 21 | } 22 | 23 | @Override 24 | @NonNull 25 | public ARScene createViewInstance(ThemedReactContext reactContext) { 26 | return new ARScene(reactContext); 27 | } 28 | 29 | @ReactProp(name="viewMode") 30 | public void viewMode(ARScene view, boolean host){ 31 | view.setCurrentMode(host); 32 | } 33 | 34 | @ReactProp(name="discoverMode") 35 | public void discoverMode(ARScene view, boolean objects){ 36 | view.setDiscoverMode(objects); 37 | } 38 | 39 | @ReactProp(name="locationMarkers") 40 | public void setLocationMarkers(ARScene view, ReadableArray data){ 41 | view.setLocationMarkers(data); 42 | } 43 | 44 | @ReactProp(name="displayPlanes") 45 | public void displayPlanes(ARScene view, boolean visible){ 46 | view.setPlaneVisibility(visible); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/module/AugmentedFacesViewModule.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.module; 2 | 3 | import android.os.Build; 4 | import android.util.Log; 5 | import android.view.View; 6 | 7 | import androidx.annotation.RequiresApi; 8 | 9 | import com.reactnativesceneform.scene.ARScene; 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.facebook.react.bridge.ReadableMap; 15 | import com.facebook.react.uimanager.UIManagerModule; 16 | import com.reactnativesceneform.scene.AugmentedFacesScene; 17 | 18 | public class AugmentedFacesViewModule extends ReactContextBaseJavaModule { 19 | 20 | @RequiresApi(api = Build.VERSION_CODES.N) 21 | public AugmentedFacesViewModule(ReactApplicationContext context) { 22 | super(context); 23 | } 24 | 25 | @Override 26 | public String getName() { 27 | return "SceneformAugmentedFacesModule"; 28 | } 29 | 30 | @ReactMethod 31 | public void addFaceModel(final int viewTag, String model, String texture, Promise promise) { 32 | //Log.d("FaceModel", "Adding model to scene"); 33 | UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); 34 | uiManager.addUIBlock(nativeViewHierarchyManager -> { 35 | View sceneView = nativeViewHierarchyManager.resolveView(viewTag); 36 | ((AugmentedFacesScene) sceneView).addFace(model, texture, promise); 37 | }); 38 | } 39 | 40 | @ReactMethod 41 | public void takeSnapshot(final int viewTag, Promise promise){ 42 | UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); 43 | uiManager.addUIBlock(nativeViewHierarchyManager -> { 44 | View sceneView = nativeViewHierarchyManager.resolveView(viewTag); 45 | ((AugmentedFacesScene) sceneView).takeScreenshot(promise); 46 | }); 47 | } 48 | 49 | @ReactMethod 50 | public void startVideoRecording(final int viewTag, Promise promise){ 51 | UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); 52 | uiManager.addUIBlock(nativeViewHierarchyManager -> { 53 | View sceneView = nativeViewHierarchyManager.resolveView(viewTag); 54 | ((AugmentedFacesScene) sceneView).startVideoRecording(promise); 55 | }); 56 | } 57 | 58 | @ReactMethod 59 | public void stopVideoRecording(final int viewTag, Promise promise){ 60 | UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); 61 | uiManager.addUIBlock(nativeViewHierarchyManager -> { 62 | View sceneView = nativeViewHierarchyManager.resolveView(viewTag); 63 | ((AugmentedFacesScene) sceneView).stopVideoRecording(promise); 64 | }); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/module/NoARViewModule.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.module; 2 | 3 | import android.os.Build; 4 | 5 | import androidx.annotation.RequiresApi; 6 | 7 | import com.facebook.react.bridge.ReactApplicationContext; 8 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 9 | 10 | public class NoARViewModule extends ReactContextBaseJavaModule { 11 | @RequiresApi(api = Build.VERSION_CODES.N) 12 | public NoARViewModule(ReactApplicationContext context) { 13 | super(context); 14 | } 15 | 16 | @Override 17 | public String getName() { 18 | return "SceneformNoARModule"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/module/SceneformViewModule.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.module; 2 | 3 | import android.os.Build; 4 | import android.util.Log; 5 | import android.view.View; 6 | 7 | import androidx.annotation.RequiresApi; 8 | 9 | import com.reactnativesceneform.scene.ARScene; 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.facebook.react.bridge.ReadableMap; 15 | import com.facebook.react.uimanager.UIManagerModule; 16 | 17 | public class SceneformViewModule extends ReactContextBaseJavaModule { 18 | 19 | @RequiresApi(api = Build.VERSION_CODES.N) 20 | public SceneformViewModule(ReactApplicationContext context) { 21 | super(context); 22 | } 23 | 24 | @Override 25 | public String getName() { 26 | return "SceneformModule"; 27 | } 28 | 29 | @ReactMethod 30 | public void addObject(final int viewTag, ReadableMap object){ 31 | //Log.e("TESTING", "Getting anchor from common module"); 32 | UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); 33 | uiManager.addUIBlock(nativeViewHierarchyManager -> { 34 | View sceneView = nativeViewHierarchyManager.resolveView(viewTag); 35 | ((ARScene) sceneView).addObject(object); 36 | }); 37 | } 38 | 39 | @ReactMethod 40 | public void takeSnapshot(final int viewTag, Promise promise){ 41 | UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); 42 | uiManager.addUIBlock(nativeViewHierarchyManager -> { 43 | View sceneView = nativeViewHierarchyManager.resolveView(viewTag); 44 | ((ARScene) sceneView).takeScreenshot(promise); 45 | }); 46 | } 47 | 48 | @ReactMethod 49 | public void resolveCloudAnchor(final int viewTag, String anchorId){ 50 | UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); 51 | uiManager.addUIBlock(nativeViewHierarchyManager -> { 52 | View sceneView = nativeViewHierarchyManager.resolveView(viewTag); 53 | ((ARScene) sceneView).resolveCloudAnchor(anchorId); 54 | }); 55 | } 56 | 57 | @ReactMethod 58 | public void hostCloudAnchor(final int viewTag, int planeIndex){ 59 | //Log.e("TESTING", "Getting anchor from common module"); 60 | UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); 61 | uiManager.addUIBlock(nativeViewHierarchyManager -> { 62 | View sceneView = nativeViewHierarchyManager.resolveView(viewTag); 63 | ((ARScene) sceneView).hostCloudAnchor(planeIndex); 64 | }); 65 | } 66 | 67 | @ReactMethod 68 | public void startVideoRecording(final int viewTag, Promise promise){ 69 | //Log.e("TESTING", "Getting anchor from common module"); 70 | UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); 71 | uiManager.addUIBlock(nativeViewHierarchyManager -> { 72 | View sceneView = nativeViewHierarchyManager.resolveView(viewTag); 73 | ((ARScene) sceneView).startVideoRecording(promise); 74 | }); 75 | } 76 | 77 | @ReactMethod 78 | public void stopVideoRecording(final int viewTag, Promise promise){ 79 | //Log.e("TESTING", "Getting anchor from common module"); 80 | UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); 81 | uiManager.addUIBlock(nativeViewHierarchyManager -> { 82 | View sceneView = nativeViewHierarchyManager.resolveView(viewTag); 83 | ((ARScene) sceneView).stopVideoRecording(promise); 84 | }); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/scene/AugmentedFacesScene.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.scene; 2 | 3 | import static com.reactnativesceneform.utils.HelperFuncions.checkIsSupportedDeviceOrFinish; 4 | import static com.reactnativesceneform.utils.HelperFuncions.saveBitmapToDisk; 5 | import android.annotation.SuppressLint; 6 | import android.graphics.Bitmap; 7 | import android.media.CamcorderProfile; 8 | import android.net.Uri; 9 | import android.os.Handler; 10 | import android.os.HandlerThread; 11 | import android.util.Log; 12 | import android.view.PixelCopy; 13 | import android.widget.FrameLayout; 14 | import android.widget.Toast; 15 | import androidx.appcompat.app.AppCompatActivity; 16 | 17 | import com.facebook.react.bridge.Arguments; 18 | import com.facebook.react.bridge.Promise; 19 | import com.facebook.react.bridge.WritableMap; 20 | import com.facebook.react.uimanager.ThemedReactContext; 21 | import com.google.ar.core.AugmentedFace; 22 | import com.google.ar.sceneform.ArSceneView; 23 | import com.google.ar.sceneform.FrameTime; 24 | import com.google.ar.sceneform.rendering.ModelRenderable; 25 | import com.google.ar.sceneform.rendering.Renderable; 26 | import com.google.ar.sceneform.rendering.RenderableInstance; 27 | import com.google.ar.sceneform.rendering.Texture; 28 | import com.google.ar.sceneform.ux.ArFrontFacingFragment; 29 | import com.google.ar.sceneform.ux.AugmentedFaceNode; 30 | import com.reactnativesceneform.R; 31 | import com.reactnativesceneform.utils.VideoRecorder; 32 | 33 | import java.io.IOException; 34 | import java.util.ArrayList; 35 | import java.util.HashMap; 36 | import java.util.HashSet; 37 | import java.util.List; 38 | import java.util.Objects; 39 | import java.util.Set; 40 | import java.util.concurrent.CompletableFuture; 41 | 42 | @SuppressLint("ViewConstructor") 43 | public class AugmentedFacesScene extends FrameLayout { 44 | public ThemedReactContext context; 45 | public ArFrontFacingFragment arFragment; 46 | 47 | private final Set> loaders = new HashSet<>(); 48 | private Texture faceTexture; 49 | private ModelRenderable faceModel; 50 | private boolean initialised = false; 51 | private boolean mIsRecording = false; 52 | private VideoRecorder mVideoRecorder; 53 | 54 | private final HashMap facesNodes = new HashMap<>(); 55 | public final List mFaces = new ArrayList(); 56 | 57 | public AugmentedFacesScene(ThemedReactContext context) { 58 | super(context); 59 | this.context = context; 60 | if(!initialised) { 61 | init(); 62 | } 63 | } 64 | 65 | public void init() { 66 | if (!checkIsSupportedDeviceOrFinish((AppCompatActivity) Objects.requireNonNull(context.getCurrentActivity()))) { 67 | return; 68 | } 69 | inflate((AppCompatActivity) context.getCurrentActivity(), R.layout.augmented_faces, this); 70 | arFragment = (ArFrontFacingFragment) ((AppCompatActivity) context.getCurrentActivity()).getSupportFragmentManager().findFragmentById(R.id.augmentedFacesFragment); 71 | assert arFragment != null; 72 | arFragment.getArSceneView().setCameraStreamRenderPriority(Renderable.RENDER_PRIORITY_FIRST); 73 | arFragment.setOnAugmentedFaceUpdateListener(this::onAugmentedFaceTrackingUpdate); 74 | arFragment.getArSceneView().getScene().addOnUpdateListener(this::onUpdateListener); 75 | mVideoRecorder = new VideoRecorder(); 76 | mVideoRecorder.setSceneView(arFragment.getArSceneView()); 77 | int orientation = getResources().getConfiguration().orientation; 78 | mVideoRecorder.setVideoQuality(CamcorderProfile.QUALITY_480P, orientation); 79 | initialised = true; 80 | } 81 | 82 | private void onUpdateListener(FrameTime frameTime) { 83 | for(FaceModel model : mFaces){ 84 | model.onUpdate(); 85 | } 86 | } 87 | 88 | public void setAugmentedFace(int index){ 89 | FaceModel model = mFaces.get(index); 90 | if(model != null){ 91 | faceModel = model.faceModel.makeCopy(); 92 | faceTexture = model.faceTexture; 93 | clearScene(); 94 | } 95 | } 96 | 97 | public void addFace(String modelUrl, String textureUrl, Promise promise){ 98 | FaceModel model = new FaceModel(this); 99 | if(!modelUrl.equals("")){ 100 | model.loadModel(modelUrl); 101 | } 102 | if(!textureUrl.equals("")){ 103 | model.loadTexture(textureUrl); 104 | } 105 | model.setPromise(promise); 106 | mFaces.add(model); 107 | //Log.d("FaceModel", "Index: " + (mFaces.indexOf(model))); 108 | } 109 | 110 | private void clearScene(){ 111 | for(AugmentedFace augmentedFace : facesNodes.keySet()){ 112 | AugmentedFaceNode existingFaceNode = facesNodes.get(augmentedFace); 113 | if(existingFaceNode != null) { 114 | arFragment.getArSceneView().getScene().removeChild(existingFaceNode); 115 | } 116 | facesNodes.remove(augmentedFace); 117 | } 118 | } 119 | 120 | public void onAugmentedFaceTrackingUpdate(AugmentedFace augmentedFace) { 121 | if (faceModel == null) { 122 | return; 123 | } 124 | 125 | AugmentedFaceNode existingFaceNode = facesNodes.get(augmentedFace); 126 | if(existingFaceNode != null){ 127 | 128 | } 129 | 130 | switch (augmentedFace.getTrackingState()) { 131 | case TRACKING: 132 | if (existingFaceNode == null) { 133 | AugmentedFaceNode faceNode = new AugmentedFaceNode(augmentedFace); 134 | RenderableInstance modelInstance = faceNode.setFaceRegionsRenderable(faceModel); 135 | modelInstance.setShadowCaster(false); 136 | modelInstance.setShadowReceiver(true); 137 | if(faceTexture != null) { 138 | faceNode.setFaceMeshTexture(faceTexture); 139 | } 140 | arFragment.getArSceneView().getScene().addChild(faceNode); 141 | facesNodes.put(augmentedFace, faceNode); 142 | } 143 | break; 144 | case STOPPED: 145 | if (existingFaceNode != null) { 146 | arFragment.getArSceneView().getScene().removeChild(existingFaceNode); 147 | } 148 | facesNodes.remove(augmentedFace); 149 | break; 150 | } 151 | } 152 | 153 | public void takeScreenshot(Promise promise) { 154 | ArSceneView view = arFragment.getArSceneView(); 155 | final Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), 156 | Bitmap.Config.ARGB_8888); 157 | final HandlerThread handlerThread = new HandlerThread("PixelCopier"); 158 | handlerThread.start(); 159 | PixelCopy.request(view, bitmap, (copyResult) -> { 160 | if (copyResult == PixelCopy.SUCCESS) { 161 | try { 162 | saveBitmapToDisk(context, bitmap, promise); 163 | } catch (IOException e) { 164 | promise.reject("Create screenshot error"); 165 | } 166 | } 167 | handlerThread.quitSafely(); 168 | }, new Handler(handlerThread.getLooper())); 169 | } 170 | 171 | @Override 172 | protected void onDetachedFromWindow() { 173 | super.onDetachedFromWindow(); 174 | ((AppCompatActivity) Objects.requireNonNull(context.getCurrentActivity())).getSupportFragmentManager().beginTransaction().remove(arFragment).commitAllowingStateLoss(); 175 | Thread threadPause = new Thread() { 176 | @Override 177 | public void run() { 178 | try { 179 | sleep(100); 180 | Objects.requireNonNull(arFragment.getArSceneView().getSession()).pause(); 181 | } catch (Exception e) { 182 | e.printStackTrace(); 183 | } 184 | } 185 | }; 186 | Thread thread = new Thread() { 187 | @Override 188 | public void run() { 189 | try { 190 | threadPause.start(); 191 | sleep(500); 192 | Objects.requireNonNull(arFragment.getArSceneView().getSession()).close(); 193 | } catch (Exception e) { 194 | e.printStackTrace(); 195 | } finally { 196 | Log.e("END_", "Finish"); 197 | } 198 | } 199 | }; 200 | thread.start(); 201 | } 202 | 203 | public void startVideoRecording(Promise promise) { 204 | if(arFragment != null && arFragment.getArSceneView().getSession() != null && !mIsRecording){ 205 | mIsRecording = mVideoRecorder.onToggleRecord(); 206 | WritableMap event = Arguments.createMap(); 207 | if(mIsRecording){ 208 | event.putBoolean("recording", true); 209 | promise.resolve(event); 210 | } 211 | else{ 212 | promise.reject("recording", "false"); 213 | } 214 | } 215 | } 216 | 217 | public void stopVideoRecording(Promise promise) { 218 | if(arFragment != null && arFragment.getArSceneView().getSession() != null && mIsRecording){ 219 | mIsRecording = mVideoRecorder.onToggleRecord(); 220 | String videoPath = mVideoRecorder.getVideoPath().getAbsolutePath(); 221 | 222 | WritableMap event = Arguments.createMap(); 223 | event.putString("path", videoPath); 224 | promise.resolve(event); 225 | } 226 | } 227 | 228 | } 229 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/scene/FaceModel.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.scene; 2 | 3 | import android.net.Uri; 4 | import android.util.Log; 5 | import android.widget.Toast; 6 | 7 | import com.facebook.react.bridge.Promise; 8 | import com.google.ar.core.AugmentedFace; 9 | import com.google.ar.sceneform.rendering.ModelRenderable; 10 | import com.google.ar.sceneform.rendering.Texture; 11 | 12 | import java.util.HashSet; 13 | import java.util.Set; 14 | import java.util.concurrent.CompletableFuture; 15 | 16 | public class FaceModel { 17 | private final Set> loaders = new HashSet<>(); 18 | public Texture faceTexture; 19 | public ModelRenderable faceModel; 20 | private AugmentedFacesScene mParent; 21 | private boolean ready = false; 22 | private Promise promise; 23 | private boolean error = false; 24 | private boolean hasTexture = false; 25 | 26 | public FaceModel(AugmentedFacesScene parent){ 27 | mParent = parent; 28 | } 29 | 30 | public void setPromise(Promise mpromise){ 31 | promise = mpromise; 32 | } 33 | 34 | public void loadTexture(String url){ 35 | hasTexture = true; 36 | loaders.add(Texture.builder() 37 | .setSource(mParent.context, Uri.parse(url)) 38 | .setUsage(Texture.Usage.COLOR_MAP) 39 | .build() 40 | .thenAccept(texture -> faceTexture = texture) 41 | .exceptionally(throwable -> { 42 | Toast.makeText(mParent.context, "Unable to load texture", Toast.LENGTH_LONG).show(); 43 | return null; 44 | })); 45 | } 46 | 47 | public void loadModel(String url){ 48 | loaders.add(ModelRenderable.builder() 49 | .setSource(mParent.context, Uri.parse(url)) 50 | .setIsFilamentGltf(true) 51 | .build() 52 | .thenAccept(model -> faceModel = model) 53 | .exceptionally(throwable -> { 54 | Toast.makeText(mParent.context, "Unable to load renderable", Toast.LENGTH_LONG).show(); 55 | return null; 56 | })); 57 | } 58 | 59 | public void onUpdate(){ 60 | if(faceModel != null && (faceTexture != null && hasTexture || !hasTexture && faceTexture == null) && !ready && !error) { 61 | ready = true; 62 | int index = mParent.mFaces.indexOf(this); 63 | promise.resolve(index); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/scene/LocationMarker.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.scene; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.widget.TextView; 6 | import android.widget.Toast; 7 | import androidx.appcompat.app.AppCompatActivity; 8 | import com.facebook.react.uimanager.ThemedReactContext; 9 | import com.google.ar.sceneform.Node; 10 | import com.google.ar.sceneform.rendering.ViewRenderable; 11 | import com.reactnativesceneform.R; 12 | import com.reactnativesceneform.utils.ModelManager; 13 | import java.lang.ref.WeakReference; 14 | import uk.co.appoly.arcorelocation.LocationScene; 15 | 16 | public class LocationMarker { 17 | private Activity mActivity; 18 | private ThemedReactContext mContext; 19 | private ARScene mParent; 20 | private ModelManager mModelManager; 21 | private String mTitle; 22 | private double mLng; 23 | private double mLat; 24 | private ViewRenderable viewRenderable; 25 | private LocationScene mLocationScene; 26 | private Node mNode; 27 | private uk.co.appoly.arcorelocation.LocationMarker mLocationMarker; 28 | private boolean isAnchor = false; 29 | 30 | public LocationMarker(ARScene parent){ 31 | mParent = parent; 32 | mContext = parent.context; 33 | mActivity = (AppCompatActivity) mContext.getCurrentActivity(); 34 | mModelManager = parent.mModelManager; 35 | mLocationScene = parent.locationScene; 36 | 37 | mNode = new Node(); 38 | //mNode.setRenderable(viewRenderable); 39 | Context c = mContext; 40 | mNode.setOnTapListener((v, event) -> { 41 | Toast.makeText( 42 | c, "Touched.", Toast.LENGTH_LONG) 43 | .show(); 44 | }); 45 | } 46 | 47 | public void setTitle(String title){ 48 | mTitle = title; 49 | } 50 | 51 | public void setPos(double lng, double lat){ 52 | mLng = lng; 53 | mLat = lat; 54 | } 55 | 56 | public void setType(boolean anchor){ 57 | isAnchor = anchor; 58 | } 59 | 60 | public void create(){ 61 | WeakReference weakActivity = new WeakReference<>(mParent); 62 | if(!isAnchor){ 63 | ViewRenderable.builder() 64 | .setView(mContext.getCurrentActivity(), R.layout.view_model_title) 65 | .build() 66 | .thenAccept(viewRenderable -> { 67 | ARScene activity = weakActivity.get(); 68 | if (activity != null) { 69 | ((TextView)viewRenderable.getView()).setText(mTitle); 70 | this.viewRenderable = viewRenderable; 71 | mNode.setRenderable(viewRenderable); 72 | place(); 73 | } 74 | }) 75 | .exceptionally(throwable -> { 76 | return null; 77 | }); 78 | } 79 | else{ 80 | ViewRenderable.builder() 81 | .setView(mContext.getCurrentActivity(), R.layout.anchor) 82 | .build() 83 | .thenAccept(viewRenderable -> { 84 | ARScene activity = weakActivity.get(); 85 | if (activity != null) { 86 | this.viewRenderable = viewRenderable; 87 | mNode.setRenderable(viewRenderable); 88 | place(); 89 | } 90 | }) 91 | .exceptionally(throwable -> { 92 | return null; 93 | }); 94 | } 95 | } 96 | 97 | public void place(){ 98 | //Log.d("LocationMarker", "Placing "+mTitle+" at: "+mLng+" - "+mLat); 99 | mLocationMarker = new uk.co.appoly.arcorelocation.LocationMarker(mLng, mLat, mNode); 100 | mParent.locationScene.mLocationMarkers.add(mLocationMarker); 101 | } 102 | 103 | public uk.co.appoly.arcorelocation.LocationMarker getMarker(){ 104 | return mLocationMarker; 105 | } 106 | 107 | //setTitle 108 | //setPos 109 | //create 110 | } 111 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/scene/Model.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.scene; 2 | 3 | import android.net.Uri; 4 | import android.widget.Toast; 5 | import com.facebook.react.uimanager.ThemedReactContext; 6 | import com.google.ar.core.Anchor; 7 | import com.google.ar.core.TrackingState; 8 | import com.google.ar.sceneform.AnchorNode; 9 | import com.google.ar.sceneform.FrameTime; 10 | import com.google.ar.sceneform.math.Vector3; 11 | import com.google.ar.sceneform.rendering.ModelRenderable; 12 | import com.google.ar.sceneform.rendering.Renderable; 13 | import com.google.ar.sceneform.ux.ArFragment; 14 | import com.google.ar.sceneform.ux.TransformableNode; 15 | import com.reactnativesceneform.utils.ModelManager; 16 | import java.lang.ref.WeakReference; 17 | 18 | public class Model { 19 | private final ThemedReactContext mContext; 20 | private final ARScene mParent; 21 | private String mModelUri; 22 | private Anchor mAnchor; 23 | private TransformableNode mNode; 24 | 25 | public Model(ARScene parent){ 26 | mParent = parent; 27 | mContext = parent.context; 28 | } 29 | 30 | public void setSource(String uri){ 31 | mModelUri = uri; 32 | } 33 | 34 | public void setAnchor(Anchor anchor){ 35 | mAnchor = anchor; 36 | } 37 | 38 | public void place(){ 39 | if(mModelUri == null || mAnchor == null){ 40 | return; 41 | } 42 | ArFragment arFragment = mParent.arFragment; 43 | AnchorNode anchorNode = new AnchorNode(mAnchor); 44 | anchorNode.setParent(arFragment.getArSceneView().getScene()); 45 | mNode = new TransformableNode(arFragment.getTransformationSystem()); 46 | mNode.setParent(anchorNode); 47 | } 48 | 49 | public void onUpdate(FrameTime frame){ 50 | TrackingState state = ((AnchorNode)mNode.getParent()).getAnchor().getTrackingState(); 51 | mNode.setEnabled(state == TrackingState.TRACKING); 52 | mNode.onUpdate(frame); 53 | } 54 | 55 | public void updateModel(Renderable renderable){ 56 | mNode.setRenderable(renderable) 57 | .animate(true).start(); 58 | } 59 | 60 | public void fetchModel(){ 61 | WeakReference weakActivity = new WeakReference<>(mParent); 62 | ModelRenderable.builder() 63 | .setSource(mContext, Uri.parse(mModelUri)) 64 | .setIsFilamentGltf(true) 65 | .setAsyncLoadEnabled(true) 66 | .build() 67 | .thenAccept(renderable -> { 68 | ARScene activity = weakActivity.get(); 69 | if (activity != null) { 70 | if(mNode != null){ 71 | this.updateModel(renderable); 72 | } 73 | } 74 | }) 75 | .exceptionally(throwable -> { 76 | Toast.makeText( 77 | mContext, "Unable to load model", Toast.LENGTH_LONG).show(); 78 | return null; 79 | }); 80 | } 81 | 82 | public Anchor getAnchor(){ 83 | return mAnchor; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/scene/NoARScene.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.scene; 2 | 3 | import static com.reactnativesceneform.utils.HelperFuncions.checkIsSupportedDeviceOrFinish; 4 | import static com.reactnativesceneform.utils.HelperFuncions.saveBitmapToDisk; 5 | import android.annotation.SuppressLint; 6 | import android.graphics.Bitmap; 7 | import android.media.CamcorderProfile; 8 | import android.net.Uri; 9 | import android.os.Handler; 10 | import android.os.HandlerThread; 11 | import android.util.Log; 12 | import android.view.PixelCopy; 13 | import android.view.ViewGroup; 14 | import android.widget.FrameLayout; 15 | import android.widget.Toast; 16 | import androidx.appcompat.app.AppCompatActivity; 17 | 18 | import com.facebook.react.bridge.Arguments; 19 | import com.facebook.react.bridge.Promise; 20 | import com.facebook.react.bridge.WritableMap; 21 | import com.facebook.react.uimanager.ThemedReactContext; 22 | import com.google.ar.core.AugmentedFace; 23 | import com.google.ar.sceneform.ArSceneView; 24 | import com.google.ar.sceneform.FrameTime; 25 | import com.google.ar.sceneform.Node; 26 | import com.google.ar.sceneform.SceneView; 27 | import com.google.ar.sceneform.math.Quaternion; 28 | import com.google.ar.sceneform.math.Vector3; 29 | import com.google.ar.sceneform.rendering.ModelRenderable; 30 | import com.google.ar.sceneform.rendering.Renderable; 31 | import com.google.ar.sceneform.rendering.RenderableInstance; 32 | import com.google.ar.sceneform.rendering.Texture; 33 | import com.google.ar.sceneform.ux.ArFrontFacingFragment; 34 | import com.google.ar.sceneform.ux.AugmentedFaceNode; 35 | import com.reactnativesceneform.R; 36 | import com.reactnativesceneform.utils.VideoRecorder; 37 | 38 | import java.io.IOException; 39 | import java.util.ArrayList; 40 | import java.util.HashMap; 41 | import java.util.HashSet; 42 | import java.util.List; 43 | import java.util.Objects; 44 | import java.util.Set; 45 | import java.util.concurrent.CompletableFuture; 46 | import java.util.concurrent.ExecutionException; 47 | 48 | @SuppressLint("ViewConstructor") 49 | public class NoARScene extends FrameLayout { 50 | public ThemedReactContext context; 51 | private final Set> loaders = new HashSet<>(); 52 | private SceneView backgroundSceneView; 53 | private SceneView transparentSceneView; 54 | private boolean initialised = false; 55 | 56 | public NoARScene(ThemedReactContext context) { 57 | super(context); 58 | this.context = context; 59 | if(!initialised) { 60 | init(); 61 | } 62 | } 63 | 64 | public void init() { 65 | inflate((AppCompatActivity) context.getCurrentActivity(), R.layout.backgroundview, this); 66 | backgroundSceneView = findViewById(R.id.backgroundSceneView); 67 | transparentSceneView = findViewById(R.id.transparentSceneView); 68 | transparentSceneView.setTransparent(true); 69 | initialised = true; 70 | loadModels(); 71 | } 72 | 73 | public void loadModels() { 74 | CompletableFuture dragon = ModelRenderable 75 | .builder() 76 | .setSource(context 77 | , Uri.parse("models/dragon.glb")) 78 | .setIsFilamentGltf(true) 79 | .setAsyncLoadEnabled(true) 80 | .build(); 81 | 82 | CompletableFuture backdrop = ModelRenderable 83 | .builder() 84 | .setSource(context 85 | , Uri.parse("models/backdrop.glb")) 86 | .setIsFilamentGltf(true) 87 | .setAsyncLoadEnabled(true) 88 | .build(); 89 | 90 | 91 | CompletableFuture.allOf(dragon, backdrop) 92 | .handle((ok, ex) -> { 93 | try { 94 | Node modelNode1 = new Node(); 95 | modelNode1.setRenderable(dragon.get()); 96 | modelNode1.setLocalScale(new Vector3(0.3f, 0.3f, 0.3f)); 97 | modelNode1.setLocalRotation(Quaternion.multiply( 98 | Quaternion.axisAngle(new Vector3(1f, 0f, 0f), 45), 99 | Quaternion.axisAngle(new Vector3(0f, 1f, 0f), 75))); 100 | modelNode1.setLocalPosition(new Vector3(0f, 0f, -1.0f)); 101 | backgroundSceneView.getScene().addChild(modelNode1); 102 | 103 | Node modelNode2 = new Node(); 104 | modelNode2.setRenderable(backdrop.get()); 105 | modelNode2.setLocalScale(new Vector3(0.3f, 0.3f, 0.3f)); 106 | modelNode2.setLocalRotation(Quaternion.multiply( 107 | Quaternion.axisAngle(new Vector3(1f, 0f, 0f), 45), 108 | Quaternion.axisAngle(new Vector3(0f, 1f, 0f), 75))); 109 | modelNode2.setLocalPosition(new Vector3(0f, 0f, -1.0f)); 110 | backgroundSceneView.getScene().addChild(modelNode2); 111 | 112 | Node modelNode3 = new Node(); 113 | modelNode3.setRenderable(dragon.get()); 114 | modelNode3.setLocalScale(new Vector3(0.3f, 0.3f, 0.3f)); 115 | modelNode3.setLocalRotation(Quaternion.axisAngle(new Vector3(0f, 1f, 0f), 35)); 116 | modelNode3.setLocalPosition(new Vector3(0f, 0f, -1.0f)); 117 | transparentSceneView.getScene().addChild(modelNode3); 118 | 119 | Node modelNode4 = new Node(); 120 | modelNode4.setRenderable(backdrop.get()); 121 | modelNode4.setLocalScale(new Vector3(0.3f, 0.3f, 0.3f)); 122 | modelNode4.setLocalRotation(Quaternion.axisAngle(new Vector3(0f, 1f, 0f), 35)); 123 | modelNode4.setLocalPosition(new Vector3(0f, 0f, -1.0f)); 124 | transparentSceneView.getScene().addChild(modelNode4); 125 | } catch (InterruptedException | ExecutionException ignore) { 126 | Log.e("NoARView", ignore.toString()); 127 | } 128 | return null; 129 | }); 130 | } 131 | 132 | @Override 133 | protected void onDetachedFromWindow() { 134 | super.onDetachedFromWindow(); 135 | 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/utils/HelperFuncions.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.utils; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.app.ActivityManager; 6 | import android.content.Context; 7 | import android.graphics.Bitmap; 8 | import android.os.Build; 9 | import android.os.Handler; 10 | import android.os.HandlerThread; 11 | import android.util.Log; 12 | import android.view.PixelCopy; 13 | import android.widget.Toast; 14 | 15 | import androidx.annotation.RequiresApi; 16 | 17 | import com.facebook.react.bridge.Arguments; 18 | import com.facebook.react.bridge.Promise; 19 | import com.facebook.react.bridge.WritableMap; 20 | import com.facebook.react.uimanager.ThemedReactContext; 21 | import com.google.ar.core.Frame; 22 | import com.google.ar.core.Pose; 23 | import com.google.ar.sceneform.ArSceneView; 24 | import com.google.ar.sceneform.math.Vector3; 25 | import com.google.ar.sceneform.ux.ArFragment; 26 | 27 | import java.io.File; 28 | import java.io.FileOutputStream; 29 | import java.io.IOException; 30 | import java.text.SimpleDateFormat; 31 | import java.util.Calendar; 32 | 33 | public class HelperFuncions { 34 | 35 | public static boolean checkIsSupportedDeviceOrFinish(final Activity activity) { 36 | String openGlVersionString = 37 | ((ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE)) 38 | .getDeviceConfigurationInfo() 39 | .getGlEsVersion(); 40 | if (Double.parseDouble(openGlVersionString) < 3.0) { 41 | Log.e("ArCoreView", "ArCore requires OpenGL ES 3.0 later"); 42 | Toast.makeText(activity, "ArCore requires OpenGL ES 3.0 or later", Toast.LENGTH_LONG) 43 | .show(); 44 | activity.finish(); 45 | return false; 46 | } 47 | return true; 48 | } 49 | 50 | public static void takeScreenshot(ArSceneView view, ThemedReactContext context, Promise promise) { 51 | //ArSceneView view = arFragment.getArSceneView(); 52 | final Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), 53 | Bitmap.Config.ARGB_8888); 54 | final HandlerThread handlerThread = new HandlerThread("PixelCopier"); 55 | handlerThread.start(); 56 | PixelCopy.request(view, bitmap, (copyResult) -> { 57 | if (copyResult == PixelCopy.SUCCESS) { 58 | try { 59 | saveBitmapToDisk(context, bitmap, promise); 60 | } catch (IOException e) { 61 | promise.reject("Create screenshot error"); 62 | } 63 | } 64 | handlerThread.quitSafely(); 65 | }, new Handler(handlerThread.getLooper())); 66 | } 67 | 68 | public static void saveBitmapToDisk(ThemedReactContext context, Bitmap bitmap, Promise promise) throws IOException { 69 | File imageScreen = new File(context.getDir("images", Context.MODE_PRIVATE).toString()); 70 | Calendar c = Calendar.getInstance(); 71 | @SuppressLint("SimpleDateFormat") SimpleDateFormat df = new SimpleDateFormat("HH.mm.ss dd-MM-yyyy"); 72 | String formattedDate = df.format(c.getTime()); 73 | 74 | File mediaFile = new File(imageScreen, "AVRScreenshot" + formattedDate + ".jpeg"); 75 | 76 | FileOutputStream fileOutputStream = new FileOutputStream(mediaFile); 77 | bitmap.compress(Bitmap.CompressFormat.JPEG, 70, fileOutputStream); 78 | fileOutputStream.flush(); 79 | fileOutputStream.close(); 80 | WritableMap event = Arguments.createMap(); 81 | event.putString("path", mediaFile.getPath()); 82 | promise.resolve(event); 83 | } 84 | 85 | @SuppressLint("SetTextI18n") 86 | public void calcDistanceToObject() { 87 | /* 88 | Frame frame = arFragment.getArSceneView().getArFrame(); 89 | assert frame != null; 90 | Pose camera = frame.getCamera().getPose(); 91 | Vector3 objectMatrix = anchorNodeDelete.getWorldPosition(); 92 | Double distance = calculateDistance(objectMatrix, camera); 93 | */ 94 | } 95 | 96 | public Double calculateDistance(Vector3 objectPose0, Pose objectPose1) { 97 | return calculateDistance( 98 | objectPose0.x - objectPose1.tx(), 99 | objectPose0.y - objectPose1.ty(), 100 | objectPose0.z - objectPose1.tz() 101 | ); 102 | } 103 | 104 | public Double calculateDistance(Float x, Float y, Float z) { 105 | return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2)); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/utils/ModelManager.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.utils; 2 | 3 | import android.net.Uri; 4 | import android.widget.Toast; 5 | 6 | import com.reactnativesceneform.scene.ARScene; 7 | import com.reactnativesceneform.scene.Model; 8 | import com.facebook.react.uimanager.ThemedReactContext; 9 | import com.google.ar.sceneform.rendering.ModelRenderable; 10 | import com.google.ar.sceneform.rendering.Renderable; 11 | 12 | import java.lang.ref.WeakReference; 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | 16 | public class ModelManager { 17 | public Map cachedModels = new HashMap<>(); 18 | private ARScene mParent; 19 | private ThemedReactContext mContext; 20 | 21 | public ModelManager(ARScene parent){ 22 | mParent = parent; 23 | mContext = parent.context; 24 | } 25 | /* 26 | public void load(String uri, Model modelParent){ 27 | Renderable cachedModel = cachedModels.get(uri); 28 | if(cachedModel == null){ 29 | WeakReference weakActivity = new WeakReference<>(mParent); 30 | ModelRenderable.builder() 31 | .setSource(mContext, Uri.parse(uri)) 32 | .setIsFilamentGltf(true) 33 | .setAsyncLoadEnabled(true) 34 | .build() 35 | .thenAccept(model -> { 36 | ARScene activity = weakActivity.get(); 37 | if (activity != null) { 38 | cachedModels.put(uri, model); 39 | modelParent.updateModel(model); 40 | } 41 | }) 42 | .exceptionally(throwable -> { 43 | Toast.makeText( 44 | mContext, "Unable to load model", Toast.LENGTH_LONG).show(); 45 | return null; 46 | }); 47 | } 48 | else{ 49 | modelParent.updateModel(cachedModel); 50 | } 51 | } 52 | 53 | */ 54 | } 55 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativesceneform/utils/VideoRecorder.java: -------------------------------------------------------------------------------- 1 | package com.reactnativesceneform.utils; 2 | 3 | import android.content.res.Configuration; 4 | import android.media.CamcorderProfile; 5 | import android.media.MediaRecorder; 6 | import android.os.Environment; 7 | import android.util.Log; 8 | import android.util.Size; 9 | import android.view.Surface; 10 | import com.google.ar.sceneform.SceneView; 11 | import java.io.File; 12 | import java.io.IOException; 13 | 14 | /** 15 | * Video Recorder class handles recording the contents of a SceneView. It uses MediaRecorder to 16 | * encode the video. The quality settings can be set explicitly or simply use the CamcorderProfile 17 | * class to select a predefined set of parameters. 18 | */ 19 | public class VideoRecorder { 20 | private static final String TAG = "VideoRecorder"; 21 | private static final int DEFAULT_BITRATE = 1000000; 22 | private static final int DEFAULT_FRAMERATE = 30; 23 | 24 | // recordingVideoFlag is true when the media recorder is capturing video. 25 | private boolean recordingVideoFlag; 26 | 27 | private MediaRecorder mediaRecorder; 28 | 29 | private Size videoSize; 30 | 31 | private SceneView sceneView; 32 | private int videoCodec; 33 | private File videoDirectory; 34 | private String videoBaseName; 35 | private File videoPath; 36 | private int bitRate = DEFAULT_BITRATE; 37 | private int frameRate = DEFAULT_FRAMERATE; 38 | private Surface encoderSurface; 39 | 40 | private static final int[] FALLBACK_QUALITY_LEVELS = { 41 | CamcorderProfile.QUALITY_HIGH, 42 | CamcorderProfile.QUALITY_2160P, 43 | CamcorderProfile.QUALITY_1080P, 44 | CamcorderProfile.QUALITY_720P, 45 | CamcorderProfile.QUALITY_480P 46 | }; 47 | 48 | public VideoRecorder() { 49 | recordingVideoFlag = false; 50 | } 51 | 52 | public File getVideoPath() { 53 | return videoPath; 54 | } 55 | 56 | public void setBitRate(int bitRate) { 57 | this.bitRate = bitRate; 58 | } 59 | 60 | public void setFrameRate(int frameRate) { 61 | this.frameRate = frameRate; 62 | } 63 | 64 | public void setSceneView(SceneView sceneView) { 65 | this.sceneView = sceneView; 66 | } 67 | 68 | /** 69 | * Toggles the state of video recording. 70 | * 71 | * @return true if recording is now active. 72 | */ 73 | public boolean onToggleRecord() { 74 | if (recordingVideoFlag) { 75 | stopRecordingVideo(); 76 | } else { 77 | startRecordingVideo(); 78 | } 79 | return recordingVideoFlag; 80 | } 81 | 82 | private void startRecordingVideo() { 83 | if (mediaRecorder == null) { 84 | mediaRecorder = new MediaRecorder(); 85 | } 86 | 87 | try { 88 | buildFilename(); 89 | setUpMediaRecorder(); 90 | } catch (IOException e) { 91 | Log.e(TAG, "Exception setting up recorder", e); 92 | return; 93 | } 94 | 95 | // Set up Surface for the MediaRecorder 96 | encoderSurface = mediaRecorder.getSurface(); 97 | 98 | sceneView.startMirroringToSurface( 99 | encoderSurface, 0, 0, videoSize.getWidth(), videoSize.getHeight()); 100 | 101 | recordingVideoFlag = true; 102 | } 103 | 104 | private void buildFilename() { 105 | if (videoDirectory == null) { 106 | videoDirectory = 107 | new File( 108 | Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) 109 | + "/VideoRecorder"); 110 | } 111 | if (videoBaseName == null || videoBaseName.isEmpty()) { 112 | videoBaseName = "video"; 113 | } 114 | videoPath = 115 | new File( 116 | videoDirectory, videoBaseName + Long.toHexString(System.currentTimeMillis()) + ".mp4"); 117 | File dir = videoPath.getParentFile(); 118 | if (!dir.exists()) { 119 | dir.mkdirs(); 120 | } 121 | } 122 | 123 | private void stopRecordingVideo() { 124 | // UI 125 | recordingVideoFlag = false; 126 | 127 | if (encoderSurface != null) { 128 | sceneView.stopMirroringToSurface(encoderSurface); 129 | encoderSurface = null; 130 | } 131 | // Stop recording 132 | mediaRecorder.stop(); 133 | mediaRecorder.reset(); 134 | } 135 | 136 | private void setUpMediaRecorder() throws IOException { 137 | 138 | mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE); 139 | mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); 140 | 141 | mediaRecorder.setOutputFile(videoPath.getAbsolutePath()); 142 | mediaRecorder.setVideoEncodingBitRate(bitRate); 143 | mediaRecorder.setVideoFrameRate(frameRate); 144 | mediaRecorder.setVideoSize(videoSize.getWidth(), videoSize.getHeight()); 145 | mediaRecorder.setVideoEncoder(videoCodec); 146 | 147 | mediaRecorder.prepare(); 148 | 149 | try { 150 | mediaRecorder.start(); 151 | } catch (IllegalStateException e) { 152 | Log.e(TAG, "Exception starting capture: " + e.getMessage(), e); 153 | } 154 | } 155 | 156 | public void setVideoSize(int width, int height) { 157 | videoSize = new Size(width, height); 158 | } 159 | 160 | public void setVideoQuality(int quality, int orientation) { 161 | CamcorderProfile profile = null; 162 | if (CamcorderProfile.hasProfile(quality)) { 163 | profile = CamcorderProfile.get(quality); 164 | } 165 | if (profile == null) { 166 | // Select a quality that is available on this device. 167 | for (int level : FALLBACK_QUALITY_LEVELS) { 168 | if (CamcorderProfile.hasProfile(level)) { 169 | profile = CamcorderProfile.get(level); 170 | break; 171 | } 172 | } 173 | } 174 | if (orientation == Configuration.ORIENTATION_LANDSCAPE) { 175 | setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight); 176 | } else { 177 | setVideoSize(profile.videoFrameHeight, profile.videoFrameWidth); 178 | } 179 | setVideoCodec(profile.videoCodec); 180 | setBitRate(profile.videoBitRate); 181 | setFrameRate(profile.videoFrameRate); 182 | } 183 | 184 | public void setVideoCodec(int videoCodec) { 185 | this.videoCodec = videoCodec; 186 | } 187 | 188 | public boolean isRecording() { 189 | return recordingVideoFlag; 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /android/src/main/java/uk/co/appoly/arcorelocation/LocationMarker.java: -------------------------------------------------------------------------------- 1 | package uk.co.appoly.arcorelocation; 2 | 3 | import com.google.ar.sceneform.AnchorNode; 4 | import com.google.ar.sceneform.Node; 5 | 6 | import uk.co.appoly.arcorelocation.rendering.LocationNode; 7 | import uk.co.appoly.arcorelocation.rendering.LocationNodeRender; 8 | 9 | /** 10 | * Created by John on 02/03/2018. 11 | */ 12 | 13 | public class LocationMarker { 14 | 15 | // Location in real-world terms 16 | public double longitude; 17 | public double latitude; 18 | 19 | // Location in AR terms 20 | public LocationNode anchorNode; 21 | 22 | // Node to render 23 | public Node node; 24 | 25 | // Called on each frame if not null 26 | private LocationNodeRender renderEvent; 27 | private float scaleModifier = 1F; 28 | private float height = 0F; 29 | private int onlyRenderWhenWithin = Integer.MAX_VALUE; 30 | private ScalingMode scalingMode = ScalingMode.FIXED_SIZE_ON_SCREEN; 31 | private float gradualScalingMinScale = 0.5F; 32 | private float gradualScalingMaxScale = 1F; 33 | 34 | public LocationMarker(double longitude, double latitude, Node node) { 35 | this.longitude = longitude; 36 | this.latitude = latitude; 37 | this.node = node; 38 | } 39 | 40 | public float getGradualScalingMinScale() { 41 | return gradualScalingMinScale; 42 | } 43 | 44 | public void setGradualScalingMinScale(float gradualScalingMinScale) { 45 | this.gradualScalingMinScale = gradualScalingMinScale; 46 | } 47 | 48 | public float getGradualScalingMaxScale() { 49 | return gradualScalingMaxScale; 50 | } 51 | 52 | public void setGradualScalingMaxScale(float gradualScalingMaxScale) { 53 | this.gradualScalingMaxScale = gradualScalingMaxScale; 54 | } 55 | 56 | /** 57 | * Only render this marker when within [onlyRenderWhenWithin] metres 58 | * 59 | * @return - metres or -1 60 | */ 61 | public int getOnlyRenderWhenWithin() { 62 | return onlyRenderWhenWithin; 63 | } 64 | 65 | /** 66 | * Only render this marker when within [onlyRenderWhenWithin] metres 67 | * 68 | * @param onlyRenderWhenWithin - metres 69 | */ 70 | public void setOnlyRenderWhenWithin(int onlyRenderWhenWithin) { 71 | this.onlyRenderWhenWithin = onlyRenderWhenWithin; 72 | } 73 | 74 | /** 75 | * Height based on camera height 76 | * 77 | * @return - height in metres 78 | */ 79 | public float getHeight() { 80 | return height; 81 | } 82 | 83 | /** 84 | * Height based on camera height 85 | * 86 | * @param height - height in metres 87 | */ 88 | public void setHeight(float height) { 89 | this.height = height; 90 | } 91 | 92 | /** 93 | * How the markers should scale 94 | * 95 | * @return - ScalingMode 96 | */ 97 | public ScalingMode getScalingMode() { 98 | return scalingMode; 99 | } 100 | 101 | /** 102 | * Whether the marker should scale, regardless of distance. 103 | * 104 | * @param scalingMode - ScalingMode.X 105 | */ 106 | public void setScalingMode(ScalingMode scalingMode) { 107 | this.scalingMode = scalingMode; 108 | } 109 | 110 | /** 111 | * Scale multiplier 112 | * 113 | * @return - multiplier 114 | */ 115 | public float getScaleModifier() { 116 | return scaleModifier; 117 | } 118 | 119 | /** 120 | * Scale multiplier 121 | * 122 | * @param scaleModifier - multiplier 123 | */ 124 | public void setScaleModifier(float scaleModifier) { 125 | this.scaleModifier = scaleModifier; 126 | } 127 | 128 | /** 129 | * Called on each frame 130 | * 131 | * @return - LocationNodeRender (event) 132 | */ 133 | public LocationNodeRender getRenderEvent() { 134 | return renderEvent; 135 | } 136 | 137 | /** 138 | * Called on each frame. 139 | */ 140 | public void setRenderEvent(LocationNodeRender renderEvent) { 141 | this.renderEvent = renderEvent; 142 | } 143 | 144 | public enum ScalingMode { 145 | FIXED_SIZE_ON_SCREEN, 146 | NO_SCALING, 147 | GRADUAL_TO_MAX_RENDER_DISTANCE, 148 | GRADUAL_FIXED_SIZE 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /android/src/main/java/uk/co/appoly/arcorelocation/rendering/LocationNode.java: -------------------------------------------------------------------------------- 1 | package uk.co.appoly.arcorelocation.rendering; 2 | 3 | import com.google.ar.core.Anchor; 4 | import com.google.ar.sceneform.AnchorNode; 5 | import com.google.ar.sceneform.FrameTime; 6 | import com.google.ar.sceneform.HitTestResult; 7 | import com.google.ar.sceneform.Node; 8 | import com.google.ar.sceneform.collision.Ray; 9 | import com.google.ar.sceneform.math.Quaternion; 10 | import com.google.ar.sceneform.math.Vector3; 11 | 12 | import java.util.ArrayList; 13 | 14 | import uk.co.appoly.arcorelocation.LocationMarker; 15 | import uk.co.appoly.arcorelocation.LocationScene; 16 | import uk.co.appoly.arcorelocation.utils.LocationUtils; 17 | 18 | public class LocationNode extends AnchorNode { 19 | 20 | private String TAG = "LocationNode"; 21 | 22 | private LocationMarker locationMarker; 23 | private LocationNodeRender renderEvent; 24 | private int distance; 25 | private double distanceInAR; 26 | private float scaleModifier = 1F; 27 | private float height = 0F; 28 | private float gradualScalingMinScale = 0.8F; 29 | private float gradualScalingMaxScale = 1.4F; 30 | 31 | private LocationMarker.ScalingMode scalingMode = LocationMarker.ScalingMode.FIXED_SIZE_ON_SCREEN; 32 | private LocationScene locationScene; 33 | 34 | public LocationNode(Anchor anchor, LocationMarker locationMarker, LocationScene locationScene) { 35 | super(anchor); 36 | this.locationMarker = locationMarker; 37 | this.locationScene = locationScene; 38 | } 39 | 40 | public float getHeight() { 41 | return height; 42 | } 43 | 44 | public void setHeight(float height) { 45 | this.height = height; 46 | } 47 | 48 | public float getScaleModifier() { 49 | return scaleModifier; 50 | } 51 | 52 | public void setScaleModifier(float scaleModifier) { 53 | this.scaleModifier = scaleModifier; 54 | } 55 | 56 | public LocationMarker getLocationMarker() { 57 | return locationMarker; 58 | } 59 | 60 | public LocationNodeRender getRenderEvent() { 61 | return renderEvent; 62 | } 63 | 64 | public void setRenderEvent(LocationNodeRender renderEvent) { 65 | this.renderEvent = renderEvent; 66 | } 67 | 68 | public int getDistance() { 69 | return distance; 70 | } 71 | 72 | public double getDistanceInAR() { 73 | return distanceInAR; 74 | } 75 | 76 | public void setDistance(int distance) { 77 | this.distance = distance; 78 | } 79 | 80 | public void setDistanceInAR(double distanceInAR) { 81 | this.distanceInAR = distanceInAR; 82 | } 83 | 84 | public LocationMarker.ScalingMode getScalingMode() { 85 | return scalingMode; 86 | } 87 | 88 | public void setScalingMode(LocationMarker.ScalingMode scalingMode) { 89 | this.scalingMode = scalingMode; 90 | } 91 | 92 | @Override 93 | public void onUpdate(FrameTime frameTime) { 94 | 95 | // Typically, getScene() will never return null because onUpdate() is only called when the node 96 | // is in the scene. 97 | // However, if onUpdate is called explicitly or if the node is removed from the scene on a 98 | // different thread during onUpdate, then getScene may be null. 99 | 100 | 101 | for (Node n : getChildren()) { 102 | if (getScene() == null) { 103 | return; 104 | } 105 | 106 | Vector3 cameraPosition = getScene().getCamera().getWorldPosition(); 107 | Vector3 nodePosition = n.getWorldPosition(); 108 | 109 | // Compute the difference vector between the camera and anchor 110 | float dx = cameraPosition.x - nodePosition.x; 111 | float dy = cameraPosition.y - nodePosition.y; 112 | float dz = cameraPosition.z - nodePosition.z; 113 | 114 | // Compute the straight-line distance. 115 | double distanceInAR = Math.sqrt(dx * dx + dy * dy + dz * dz); 116 | setDistanceInAR(distanceInAR); 117 | 118 | if (locationScene.shouldOffsetOverlapping()) { 119 | if (locationScene.mArSceneView.getScene().overlapTestAll(n).size() > 0) { 120 | setHeight(getHeight() + 1.2F); 121 | } 122 | } 123 | 124 | if (locationScene.shouldRemoveOverlapping()) { 125 | Ray ray = new Ray(); 126 | ray.setOrigin(cameraPosition); 127 | 128 | float xDelta = (float) (distanceInAR * Math.sin(Math.PI / 15)); //12 degrees 129 | Vector3 cameraLeft = getScene().getCamera().getLeft().normalized(); 130 | 131 | Vector3 left = Vector3.add(nodePosition, cameraLeft.scaled(xDelta)); 132 | Vector3 center = nodePosition; 133 | Vector3 right = Vector3.add(nodePosition, cameraLeft.scaled(-xDelta)); 134 | 135 | boolean isOverlapping = isOverlapping(n, ray, left, cameraPosition) 136 | || isOverlapping(n, ray, center, cameraPosition) 137 | || isOverlapping(n, ray, right, cameraPosition); 138 | 139 | if (isOverlapping) { 140 | setEnabled(false); 141 | } else { 142 | setEnabled(true); 143 | } 144 | } 145 | } 146 | 147 | if (!locationScene.minimalRefreshing()) 148 | scaleAndRotate(); 149 | 150 | 151 | if (renderEvent != null) { 152 | if (this.isTracking() && this.isActive() && this.isEnabled()) 153 | renderEvent.render(this); 154 | } 155 | } 156 | 157 | private boolean isOverlapping(Node n, Ray ray, Vector3 target, Vector3 cameraPosition) { 158 | Vector3 nodeDirection = Vector3.subtract(target, cameraPosition); 159 | ray.setDirection(nodeDirection); 160 | 161 | ArrayList hitTestResults = locationScene.mArSceneView.getScene().hitTestAll(ray); 162 | if (hitTestResults.size() > 0) { 163 | 164 | HitTestResult closestHit = null; 165 | for (HitTestResult hit : hitTestResults) { 166 | //Get the closest hit on enabled Node 167 | if (hit.getNode() != null && hit.getNode().isEnabled()) { 168 | closestHit = hit; 169 | break; 170 | } 171 | } 172 | 173 | // if closest hit is not the current node, it is hidden behind another node that is closer 174 | return closestHit != null && closestHit.getNode() != n; 175 | } 176 | return false; 177 | } 178 | 179 | public void scaleAndRotate() { 180 | for (Node n : getChildren()) { 181 | int markerDistance = (int) Math.ceil( 182 | LocationUtils.distance( 183 | locationMarker.latitude, 184 | locationScene.deviceLocation.currentBestLocation.getLatitude(), 185 | locationMarker.longitude, 186 | locationScene.deviceLocation.currentBestLocation.getLongitude(), 187 | 0, 188 | 0) 189 | ); 190 | setDistance(markerDistance); 191 | 192 | // Limit the distance of the Anchor within the scene. 193 | // Prevents uk.co.appoly.arcorelocation.rendering issues. 194 | int renderDistance = markerDistance; 195 | if (renderDistance > locationScene.getDistanceLimit()) 196 | renderDistance = locationScene.getDistanceLimit(); 197 | 198 | float scale = 1F; 199 | final Vector3 cameraPosition = getScene().getCamera().getWorldPosition(); 200 | Vector3 direction = Vector3.subtract(cameraPosition, n.getWorldPosition()); 201 | 202 | switch (scalingMode) { 203 | case FIXED_SIZE_ON_SCREEN: 204 | scale = (float) Math.sqrt(direction.x * direction.x 205 | + direction.y * direction.y + direction.z * direction.z); 206 | break; 207 | case GRADUAL_TO_MAX_RENDER_DISTANCE: 208 | float scaleDifference = gradualScalingMaxScale - gradualScalingMinScale; 209 | scale = (gradualScalingMinScale + ((locationScene.getDistanceLimit() - markerDistance) * (scaleDifference / locationScene.getDistanceLimit()))) * renderDistance; 210 | break; 211 | case GRADUAL_FIXED_SIZE: 212 | scale = (float) Math.sqrt(direction.x * direction.x 213 | + direction.y * direction.y + direction.z * direction.z); 214 | float gradualScale = gradualScalingMaxScale - gradualScalingMinScale; 215 | gradualScale = gradualScalingMaxScale - (gradualScale / renderDistance * markerDistance); 216 | scale *= Math.max(gradualScale, gradualScalingMinScale); 217 | break; 218 | } 219 | 220 | scale *= scaleModifier; 221 | 222 | //Log.d("LocationScene", "scale " + scale); 223 | n.setWorldPosition(new Vector3(n.getWorldPosition().x, getHeight(), n.getWorldPosition().z)); 224 | Quaternion lookRotation = Quaternion.lookRotation(direction, Vector3.up()); 225 | n.setWorldRotation(lookRotation); 226 | n.setWorldScale(new Vector3(scale, scale, scale)); 227 | } 228 | } 229 | 230 | public float getGradualScalingMinScale() { 231 | return gradualScalingMinScale; 232 | } 233 | 234 | public void setGradualScalingMinScale(float gradualScalingMinScale) { 235 | this.gradualScalingMinScale = gradualScalingMinScale; 236 | } 237 | 238 | public float getGradualScalingMaxScale() { 239 | return gradualScalingMaxScale; 240 | } 241 | 242 | public void setGradualScalingMaxScale(float gradualScalingMaxScale) { 243 | this.gradualScalingMaxScale = gradualScalingMaxScale; 244 | } 245 | } 246 | -------------------------------------------------------------------------------- /android/src/main/java/uk/co/appoly/arcorelocation/rendering/LocationNodeRender.java: -------------------------------------------------------------------------------- 1 | package uk.co.appoly.arcorelocation.rendering; 2 | 3 | public interface LocationNodeRender { 4 | void render(LocationNode node); 5 | } 6 | -------------------------------------------------------------------------------- /android/src/main/java/uk/co/appoly/arcorelocation/sensor/DeviceLocationChanged.java: -------------------------------------------------------------------------------- 1 | package uk.co.appoly.arcorelocation.sensor; 2 | 3 | import android.location.Location; 4 | 5 | /** 6 | * Created by johnwedgbury on 01/06/2018. 7 | */ 8 | 9 | 10 | public interface DeviceLocationChanged { 11 | void onChange(Location location); 12 | } 13 | -------------------------------------------------------------------------------- /android/src/main/java/uk/co/appoly/arcorelocation/sensor/DeviceOrientation.java: -------------------------------------------------------------------------------- 1 | package uk.co.appoly.arcorelocation.sensor; 2 | 3 | import android.content.Context; 4 | import android.hardware.Sensor; 5 | import android.hardware.SensorEvent; 6 | import android.hardware.SensorEventListener; 7 | import android.hardware.SensorManager; 8 | import android.util.Log; 9 | import android.view.Surface; 10 | import android.view.WindowManager; 11 | 12 | /** 13 | * Created by John on 02/03/2018. 14 | */ 15 | 16 | public class DeviceOrientation implements SensorEventListener { 17 | 18 | public float pitch; 19 | public float roll; 20 | private WindowManager windowManager; 21 | private SensorManager mSensorManager; 22 | private float orientation = 0f; 23 | 24 | public DeviceOrientation(Context context) { 25 | mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); 26 | windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); 27 | } 28 | 29 | /** 30 | * Gets the device orientation in degrees from the azimuth (clockwise) 31 | * 32 | * @return orientation [0-360] in degrees 33 | */ 34 | public float getOrientation() { 35 | return orientation; 36 | } 37 | 38 | @Override 39 | public void onSensorChanged(SensorEvent event) { 40 | 41 | switch (event.sensor.getType()) { 42 | case Sensor.TYPE_GAME_ROTATION_VECTOR: 43 | case Sensor.TYPE_ROTATION_VECTOR: 44 | processSensorOrientation(event.values); 45 | break; 46 | default: 47 | Log.e("DeviceOrientation", "Sensor event type not supported"); 48 | break; 49 | } 50 | } 51 | 52 | @SuppressWarnings("SuspiciousNameCombination") 53 | private void processSensorOrientation(float[] rotation) { 54 | float[] rotationMatrix = new float[9]; 55 | SensorManager.getRotationMatrixFromVector(rotationMatrix, rotation); 56 | final int worldAxisX; 57 | final int worldAxisY; 58 | 59 | switch (windowManager.getDefaultDisplay().getRotation()) { 60 | case Surface.ROTATION_90: 61 | worldAxisX = SensorManager.AXIS_Z; 62 | worldAxisY = SensorManager.AXIS_MINUS_X; 63 | break; 64 | case Surface.ROTATION_180: 65 | worldAxisX = SensorManager.AXIS_MINUS_X; 66 | worldAxisY = SensorManager.AXIS_MINUS_Z; 67 | break; 68 | case Surface.ROTATION_270: 69 | worldAxisX = SensorManager.AXIS_MINUS_Z; 70 | worldAxisY = SensorManager.AXIS_X; 71 | break; 72 | case Surface.ROTATION_0: 73 | default: 74 | worldAxisX = SensorManager.AXIS_X; 75 | worldAxisY = SensorManager.AXIS_Z; 76 | break; 77 | } 78 | float[] adjustedRotationMatrix = new float[9]; 79 | SensorManager.remapCoordinateSystem(rotationMatrix, worldAxisX, 80 | worldAxisY, adjustedRotationMatrix); 81 | 82 | // azimuth/pitch/roll 83 | float[] orientation = new float[3]; 84 | SensorManager.getOrientation(adjustedRotationMatrix, orientation); 85 | 86 | this.orientation = ((float) Math.toDegrees(orientation[0]) + 360f) % 360f; 87 | } 88 | 89 | @Override 90 | public void onAccuracyChanged(Sensor sensor, int accuracy) { 91 | if (accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) { 92 | Log.w("DeviceOrientation", "Orientation compass unreliable"); 93 | } 94 | } 95 | 96 | public void resume() { 97 | mSensorManager.registerListener(this, 98 | mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR), 99 | SensorManager.SENSOR_DELAY_NORMAL); 100 | } 101 | 102 | public void pause() { 103 | mSensorManager.unregisterListener(this); 104 | } 105 | } -------------------------------------------------------------------------------- /android/src/main/java/uk/co/appoly/arcorelocation/utils/ARLocationPermissionHelper.java: -------------------------------------------------------------------------------- 1 | package uk.co.appoly.arcorelocation.utils; 2 | 3 | import android.Manifest; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.content.pm.PackageManager; 7 | import android.net.Uri; 8 | import android.provider.Settings; 9 | import androidx.core.app.ActivityCompat; 10 | import androidx.core.content.ContextCompat; 11 | 12 | public final class ARLocationPermissionHelper { 13 | private static final int PERMISSION_CODE = 0; 14 | private static final String CAMERA_PERMISSION = Manifest.permission.CAMERA; 15 | private static final String LOCATION_PERMISSION = Manifest.permission.ACCESS_FINE_LOCATION; 16 | 17 | /** 18 | * Check to see we have the necessary permissions for this app. 19 | */ 20 | public static boolean hasPermission(Activity activity) { 21 | return ContextCompat.checkSelfPermission(activity, CAMERA_PERMISSION) 22 | == PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(activity, LOCATION_PERMISSION) 23 | == PackageManager.PERMISSION_GRANTED; 24 | } 25 | 26 | /** 27 | * Check to see we have the necessary permissions for this app, and ask for them if we don't. 28 | */ 29 | public static void requestPermission(Activity activity) { 30 | ActivityCompat.requestPermissions(activity, new String[]{CAMERA_PERMISSION, LOCATION_PERMISSION}, 31 | PERMISSION_CODE); 32 | } 33 | 34 | /** Check to see if we need to show the rationale for this permission. */ 35 | public static boolean shouldShowRequestPermissionRationale(Activity activity) { 36 | return ActivityCompat.shouldShowRequestPermissionRationale(activity, CAMERA_PERMISSION) || ActivityCompat.shouldShowRequestPermissionRationale(activity, LOCATION_PERMISSION); 37 | } 38 | 39 | /** Launch Application Setting to grant permission. */ 40 | public static void launchPermissionSettings(Activity activity) { 41 | Intent intent = new Intent(); 42 | intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); 43 | intent.setData(Uri.fromParts("package", activity.getPackageName(), null)); 44 | activity.startActivity(intent); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /android/src/main/java/uk/co/appoly/arcorelocation/utils/KalmanLatLong.java: -------------------------------------------------------------------------------- 1 | package uk.co.appoly.arcorelocation.utils; 2 | 3 | /** 4 | * Created by johnwedgbury on 01/06/2018. 5 | */ 6 | 7 | public class KalmanLatLong { 8 | private final float MinAccuracy = 1; 9 | 10 | private float Q_metres_per_second; 11 | private long TimeStamp_milliseconds; 12 | private double lat; 13 | private double lng; 14 | private float variance; // P matrix. Negative means object uninitialised. 15 | // NB: units irrelevant, as long as same units used 16 | // throughout 17 | public int consecutiveRejectCount; 18 | 19 | public KalmanLatLong(float Q_metres_per_second) { 20 | this.Q_metres_per_second = Q_metres_per_second; 21 | variance = -1; 22 | consecutiveRejectCount = 0; 23 | } 24 | 25 | public long get_TimeStamp() { 26 | return TimeStamp_milliseconds; 27 | } 28 | 29 | public double get_lat() { 30 | return lat; 31 | } 32 | 33 | public double get_lng() { 34 | return lng; 35 | } 36 | 37 | public float get_accuracy() { 38 | return (float) Math.sqrt(variance); 39 | } 40 | 41 | public void SetState(double lat, double lng, float accuracy, 42 | long TimeStamp_milliseconds) { 43 | this.lat = lat; 44 | this.lng = lng; 45 | variance = accuracy * accuracy; 46 | this.TimeStamp_milliseconds = TimeStamp_milliseconds; 47 | } 48 | 49 | // / 50 | // / Kalman filter processing for lattitude and longitude 51 | // / 52 | // / new measurement of 53 | // lattidude 54 | // / new measurement of longitude 55 | // / measurement of 1 standard deviation error in 56 | // metres 57 | // / time of measurement 58 | // / new state 59 | public void Process(double lat_measurement, double lng_measurement, 60 | float accuracy, long TimeStamp_milliseconds, float Q_metres_per_second) { 61 | this.Q_metres_per_second = Q_metres_per_second; 62 | 63 | if (accuracy < MinAccuracy) 64 | accuracy = MinAccuracy; 65 | if (variance < 0) { 66 | // if variance < 0, object is unitialised, so initialise with 67 | // current values 68 | this.TimeStamp_milliseconds = TimeStamp_milliseconds; 69 | lat = lat_measurement; 70 | lng = lng_measurement; 71 | variance = accuracy * accuracy; 72 | } else { 73 | // else apply Kalman filter methodology 74 | 75 | long TimeInc_milliseconds = TimeStamp_milliseconds 76 | - this.TimeStamp_milliseconds; 77 | if (TimeInc_milliseconds > 0) { 78 | // time has moved on, so the uncertainty in the current position 79 | // increases 80 | variance += TimeInc_milliseconds * Q_metres_per_second 81 | * Q_metres_per_second / 1000; 82 | this.TimeStamp_milliseconds = TimeStamp_milliseconds; 83 | // TO DO: USE VELOCITY INFORMATION HERE TO GET A BETTER ESTIMATE 84 | // OF CURRENT POSITION 85 | } 86 | 87 | // Kalman gain matrix K = Covarariance * Inverse(Covariance + 88 | // MeasurementVariance) 89 | // NB: because K is dimensionless, it doesn't matter that variance 90 | // has different units to lat and lng 91 | float K = variance / (variance + accuracy * accuracy); 92 | // apply K 93 | lat += K * (lat_measurement - lat); 94 | lng += K * (lng_measurement - lng); 95 | // new Covarariance matrix is (IdentityMatrix - K) * Covarariance 96 | variance = (1 - K) * variance; 97 | } 98 | } 99 | 100 | public int getConsecutiveRejectCount() { 101 | return consecutiveRejectCount; 102 | } 103 | 104 | public void setConsecutiveRejectCount(int consecutiveRejectCount) { 105 | this.consecutiveRejectCount = consecutiveRejectCount; 106 | } 107 | 108 | 109 | } -------------------------------------------------------------------------------- /android/src/main/java/uk/co/appoly/arcorelocation/utils/LocationUtils.java: -------------------------------------------------------------------------------- 1 | package uk.co.appoly.arcorelocation.utils; 2 | 3 | /** 4 | * Created by John on 02/03/2018. 5 | */ 6 | 7 | public class LocationUtils { 8 | 9 | /** 10 | * Bearing in degrees between two coordinates. 11 | * [0-360] Clockwise 12 | * 13 | * @param lat1 14 | * @param lon1 15 | * @param lat2 16 | * @param lon2 17 | * @return 18 | */ 19 | public static double bearing(double lat1, double lon1, double lat2, double lon2) { 20 | double latitude1 = Math.toRadians(lat1); 21 | double latitude2 = Math.toRadians(lat2); 22 | double longDiff = Math.toRadians(lon2 - lon1); 23 | double y = Math.sin(longDiff) * Math.cos(latitude2); 24 | double x = Math.cos(latitude1) * Math.sin(latitude2) - Math.sin(latitude1) * Math.cos(latitude2) * Math.cos(longDiff); 25 | 26 | return (Math.toDegrees(Math.atan2(y, x)) + 360) % 360; 27 | } 28 | 29 | /** 30 | * Distance in metres between two coordinates 31 | * 32 | * @param lat1 33 | * @param lat2 34 | * @param lon1 35 | * @param lon2 36 | * @param el1 - Elevation 1 37 | * @param el2 - Elevation 2 38 | * @return 39 | */ 40 | public static double distance(double lat1, double lat2, double lon1, 41 | double lon2, double el1, double el2) { 42 | 43 | final int R = 6371; // Radius of the earth 44 | 45 | double latDistance = Math.toRadians(lat2 - lat1); 46 | double lonDistance = Math.toRadians(lon2 - lon1); 47 | double a = Math.sin(latDistance / 2) * Math.sin(latDistance / 2) 48 | + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) 49 | * Math.sin(lonDistance / 2) * Math.sin(lonDistance / 2); 50 | double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); 51 | double distance = R * c * 1000; // convert to meters 52 | 53 | double height = el1 - el2; 54 | 55 | distance = Math.pow(distance, 2) + Math.pow(height, 2); 56 | 57 | return Math.sqrt(distance); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/anchor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/res/drawable/anchor.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/annotation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/res/drawable/annotation.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/sceneform_hand_phone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/res/drawable/sceneform_hand_phone.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/sceneform_plane.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/android/src/main/res/drawable/sceneform_plane.png -------------------------------------------------------------------------------- /android/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 16 | 21 | 22 | 25 | 26 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /android/src/main/res/layout/anchor.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | -------------------------------------------------------------------------------- /android/src/main/res/layout/augmented_faces.xml: -------------------------------------------------------------------------------- 1 | 16 | 21 | 22 | 25 | 26 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /android/src/main/res/layout/augmented_images.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /android/src/main/res/layout/backgroundview.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | 18 | 19 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /android/src/main/res/layout/view_model_title.xml: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /docs/AUGMENTED_FACES.md: -------------------------------------------------------------------------------- 1 | ## AugmentedFacesView 2 | 3 | ### Props, Methods and Events 4 | 5 | The AugmentedFacesView supports the following props: 6 | 7 | | name | values | 8 | | :------------ | :------------ | 9 | | setAugmentedFace | `index` returned by the `addAugmentedFace` method. Use -1 as starting value. | 10 | 11 | 12 | It also supports the following methods: 13 | 14 | | name | params | return | 15 | | :------------ | :------------ | :------------ | 16 | | addAugmentedFace | `AugmentedFaceModel` | `Promise` returning an `index` to be used by the `setAugmentedFace` prop | 17 | | takeScreenshot | | `Screenshot` promise | 18 | | startVideoRecording | | boolean promise | 19 | | stopVideoRecording | | `VideoRecording` promise | 20 | 21 | [Example](https://github.com/doranteseduardo/augmented-faces-demo) -------------------------------------------------------------------------------- /docs/SCENEFORMVIEW.md: -------------------------------------------------------------------------------- 1 | # SceneformView 2 | 3 | ### Props, Methods and Events 4 | 5 | The `SceneformView` component supports the following props: 6 | 7 | | name | values | default | required | 8 | | :------------ | :------------ | :------------ | :------------ | 9 | | viewMode | `true` for hosting, `false` for resolving | `false` | no | 10 | | discoverMode | `true` for cloud anchors, `false` for location anchors | `true` | no | 11 | | locationMarkers | `LocationMarker`[] | [] | no | 12 | | displayPlanes | boolean | `true` | no | 13 | 14 | Also, supports the following methods: 15 | 16 | | name | params | return | 17 | | :------------ | :------------ | :------------ | 18 | | addObject | `Model` | void | 19 | | hostCloudAnchor | `Plane` | void | 20 | | resolveCloudAnchor | `CloudAnchorId` | void | 21 | | takeScreenshot | | `Screenshot` promise | 22 | | startVideoRecording | | boolean promise | 23 | | stopVideoRecording | | `VideoRecording` promise | 24 | 25 | The following events are supported: 26 | 27 | | name | description | returns | 28 | | :------------ | :------------ | :------------ | 29 | | onSessionCreate | Triggered when a sceneform session has been initialised | | 30 | | onTapPlane | Triggered when the user taps a plane | `Plane` | 31 | | onAnchorResolve | Triggered when a cloud anchor has been resolved | `CloudAnchor` | 32 | | onAnchorHost | Triggered when a cloud anchor has been hosted correctly | `CloudAnchor` | 33 | | onFeatureMapQualityChange | Triggered when the feature map quality changes (HOSTING ONLY) | `FeatureMapQuality` | 34 | 35 | Example 36 | ```js 37 | this.sceneformview = c} 39 | style={{width: '100%', height: '100%'}} 40 | onTapPlane={(event) => { 41 | this.sceneformview.addObject({name: "models/Rabbit.glb", anchorId: event.planeId, isCloudAnchor: false}); 42 | }} 43 | /> 44 | ``` -------------------------------------------------------------------------------- /docs/TYPES.md: -------------------------------------------------------------------------------- 1 | # Type definitions 2 | 3 | ### AugmentedFaceModel 4 | 5 | An `AugmentedFaceModel` is a structure meant to be used by the `addAugmentedFace` method. It has two properties: 6 | 7 | - **model**: `URL`/`path` (inside android's assets folder) referencing a GLB object. 8 | - **texture**: (nullable) `URL`/`path` (inside android's assets folder) referencing an image object. 9 | 10 | Example: 11 | `{model: 'models/fox.glb', texture: 'textures/freckles.png'}` 12 | 13 | ------------ 14 | 15 | ### Plane 16 | 17 | A plane is any touchable surface discovered in the AR session. 18 | When the user taps on a plane it is automatically saved and an index is sent back to the bridge via the `onTapPlane` event. 19 | 20 | You can access the value using `event.planeId`. 21 | It can be used to host a cloud anchor or to place objects on tap. 22 | 23 | ------------ 24 | 25 | ### CloudAnchor 26 | 27 | It is a simple structure containing the CloudAnchorId in the `event.anchorId` value. 28 | 29 | ------------ 30 | 31 | ### FeatureMapQuality 32 | 33 | The FeatureMapQuality is an indicator used to get sure there is enough quality in the environment scan previous to host an anchor. 34 | 35 | It is a value from 0 to 2 indicating the quality: 36 | 37 | - 0: Insufficient 38 | - 1: Sufficient 39 | - 2: Good 40 | 41 | You can access the value via `event.quality` 42 | Host the anchor when the event returns at least 1. 43 | 44 | ------------ 45 | 46 | ### VideoRecording 47 | 48 | After `stopVideoRecording` is called (`startVideoRecording` must be called first), the video is copied into storage and its path is returned when the promise fulfills. 49 | 50 | You can get the path via `response.path` 51 | 52 | ------------ 53 | 54 | ### Screenshot 55 | 56 | When `takeScreenshot` is called, the session's current view is copied into a bitmap and saved as a JPEG image. When the promise fulfills you can access the image via `response.path` 57 | 58 | ------------ 59 | 60 | ### Model 61 | 62 | The `addObject` method is used to insert a renderable into scene, it supports a `Model` object described as follows: 63 | 64 | - **name**: It must be an URL pointing to a glb asset. 65 | - **anchorId**: It can be a CloudAnchorId or a PlaneId (returned by onTapPlane) 66 | - **isCloudAnchor**: `boolean`, if true then the `anchorId` value will be taken as a CloudAnchorId and the session will attempt to resolve it, triggering `onAnchorResolve` if succeed. Otherwise, if `false` , `anchorId` will be taken as `Plane` and the object will be attached to it. 67 | 68 | ------------ 69 | 70 | ### LocationMarker 71 | 72 | A location marker is placed calculating its real world position related to the user location. 73 | There are two types of tags currently supported, showing a label or a simple one with an icon. 74 | 75 | The location marker structure is: 76 | 77 | - **title**: `String` , it is the label to be shown by the marker. 78 | - **lat**: `Double`, the latitude value. 79 | - **lng**: `Double`, the longitude value. 80 | - **isAnchor**: `boolean`, if `false` the title is shown in the marker, if `true` then the icon marker is used. 81 | 82 | ------------ 83 | 84 | ### CloudAnchorId 85 | A `String` value returned by the `onAnchorHost` event, you can use it to resolve the same anchor lately or share it with friends to get the same experience. -------------------------------------------------------------------------------- /docs/face.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/docs/face.gif -------------------------------------------------------------------------------- /docs/location.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/docs/location.gif -------------------------------------------------------------------------------- /docs/placing.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/docs/placing.gif -------------------------------------------------------------------------------- /docs/resolving.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/docs/resolving.gif -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // https://reactnative.dev/docs/performance#enable-the-ram-format 22 | * bundleCommand: "ram-bundle", 23 | * 24 | * // whether to bundle JS and assets in debug mode 25 | * bundleInDebug: false, 26 | * 27 | * // whether to bundle JS and assets in release mode 28 | * bundleInRelease: true, 29 | * 30 | * // whether to bundle JS and assets in another build variant (if configured). 31 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 32 | * // The configuration property can be in the following formats 33 | * // 'bundleIn${productFlavor}${buildType}' 34 | * // 'bundleIn${buildType}' 35 | * // bundleInFreeDebug: true, 36 | * // bundleInPaidRelease: true, 37 | * // bundleInBeta: true, 38 | * 39 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 40 | * // for SceneformExample: to disable dev mode in the staging build type (if configured) 41 | * devDisabledInStaging: true, 42 | * // The configuration property can be in the following formats 43 | * // 'devDisabledIn${productFlavor}${buildType}' 44 | * // 'devDisabledIn${buildType}' 45 | * 46 | * // the root of your project, i.e. where "package.json" lives 47 | * root: "../../", 48 | * 49 | * // where to put the JS bundle asset in debug mode 50 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 51 | * 52 | * // where to put the JS bundle asset in release mode 53 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 54 | * 55 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 56 | * // require('./image.png')), in debug mode 57 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 58 | * 59 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 60 | * // require('./image.png')), in release mode 61 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 62 | * 63 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 64 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 65 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 66 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 67 | * // for SceneformExample, you might want to remove it from here. 68 | * inputExcludes: ["android/**", "ios/**"], 69 | * 70 | * // override which node gets called and with what additional arguments 71 | * nodeExecutableAndArgs: ["node"], 72 | * 73 | * // supply additional arguments to the packager 74 | * extraPackagerArgs: [] 75 | * ] 76 | */ 77 | 78 | project.ext.react = [ 79 | enableHermes: false, // clean and rebuild if changing 80 | entryFile: "index.tsx", 81 | ] 82 | 83 | apply from: "../../node_modules/react-native/react.gradle" 84 | 85 | /** 86 | * Set this to true to create two separate APKs instead of one: 87 | * - An APK that only works on ARM devices 88 | * - An APK that only works on x86 devices 89 | * The advantage is the size of the APK is reduced by about 4MB. 90 | * Upload all the APKs to the Play Store and people will download 91 | * the correct one based on the CPU architecture of their device. 92 | */ 93 | def enableSeparateBuildPerCPUArchitecture = false 94 | 95 | /** 96 | * Run Proguard to shrink the Java bytecode in release builds. 97 | */ 98 | def enableProguardInReleaseBuilds = false 99 | 100 | /** 101 | * The preferred build flavor of JavaScriptCore. 102 | * 103 | * For SceneformExample, to use the international variant, you can use: 104 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 105 | * 106 | * The international variant includes ICU i18n library and necessary data 107 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 108 | * give correct results when using with locales other than en-US. Note that 109 | * this variant is about 6MiB larger per architecture than default. 110 | */ 111 | def jscFlavor = 'org.webkit:android-jsc:+' 112 | 113 | /** 114 | * Whether to enable the Hermes VM. 115 | * 116 | * This should be set on project.ext.react and mirrored here. If it is not set 117 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode 118 | * and the benefits of using Hermes will therefore be sharply reduced. 119 | */ 120 | def enableHermes = project.ext.react.get("enableHermes", false); 121 | 122 | android { 123 | compileSdkVersion rootProject.ext.compileSdkVersion 124 | 125 | compileOptions { 126 | sourceCompatibility JavaVersion.VERSION_1_8 127 | targetCompatibility JavaVersion.VERSION_1_8 128 | } 129 | 130 | defaultConfig { 131 | applicationId "com.example.reactnativesceneform" 132 | minSdkVersion rootProject.ext.minSdkVersion 133 | targetSdkVersion rootProject.ext.targetSdkVersion 134 | versionCode 1 135 | versionName "1.0" 136 | } 137 | splits { 138 | abi { 139 | reset() 140 | enable enableSeparateBuildPerCPUArchitecture 141 | universalApk false // If true, also generate a universal APK 142 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 143 | } 144 | } 145 | signingConfigs { 146 | debug { 147 | storeFile file('debug.keystore') 148 | storePassword 'android' 149 | keyAlias 'androiddebugkey' 150 | keyPassword 'android' 151 | } 152 | } 153 | buildTypes { 154 | debug { 155 | signingConfig signingConfigs.debug 156 | } 157 | release { 158 | // Caution! In production, you need to generate your own keystore file. 159 | // see https://reactnative.dev/docs/signed-apk-android. 160 | signingConfig signingConfigs.debug 161 | minifyEnabled enableProguardInReleaseBuilds 162 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 163 | } 164 | } 165 | // applicationVariants are e.g. debug, release 166 | applicationVariants.all { variant -> 167 | variant.outputs.each { output -> 168 | // For each separate APK per architecture, set a unique version code as described here: 169 | // https://developer.android.com/studio/build/configure-apk-splits.html 170 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 171 | def abi = output.getFilter(OutputFile.ABI) 172 | if (abi != null) { // null for the universal-debug, universal-release variants 173 | output.versionCodeOverride = 174 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 175 | } 176 | 177 | } 178 | } 179 | } 180 | 181 | dependencies { 182 | implementation fileTree(dir: "libs", include: ["*.jar"]) 183 | //noinspection GradleDynamicVersion 184 | implementation "com.facebook.react:react-native:+" // From node_modules 185 | 186 | 187 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" 188 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { 189 | exclude group:'com.facebook.fbjni' 190 | } 191 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { 192 | exclude group:'com.facebook.flipper' 193 | exclude group:'com.squareup.okhttp3', module:'okhttp' 194 | } 195 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { 196 | exclude group:'com.facebook.flipper' 197 | } 198 | 199 | if (enableHermes) { 200 | def hermesPath = "../../node_modules/hermes-engine/android/"; 201 | debugImplementation files(hermesPath + "hermes-debug.aar") 202 | releaseImplementation files(hermesPath + "hermes-release.aar") 203 | } else { 204 | implementation jscFlavor 205 | } 206 | 207 | implementation project(':reactnativesceneform') 208 | } 209 | 210 | // Run this once to be able to run the application with BUCK 211 | // puts all compile dependencies into folder libs for BUCK to use 212 | task copyDownloadableDepsToLibs(type: Copy) { 213 | from configurations.compile 214 | into 'libs' 215 | } 216 | 217 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 218 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/example/android/app/debug.keystore -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/debug/java/com/example/reactnativesceneform/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.example.reactnativesceneform; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | public class ReactNativeFlipper { 28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 29 | if (FlipperUtils.shouldEnableFlipper(context)) { 30 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 31 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 32 | client.addPlugin(new ReactFlipperPlugin()); 33 | client.addPlugin(new DatabasesFlipperPlugin(context)); 34 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 35 | client.addPlugin(CrashReporterPlugin.getInstance()); 36 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 37 | NetworkingModule.setCustomClientBuilder( 38 | new NetworkingModule.CustomClientBuilder() { 39 | @Override 40 | public void apply(OkHttpClient.Builder builder) { 41 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 42 | } 43 | }); 44 | client.addPlugin(networkFlipperPlugin); 45 | client.start(); 46 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 47 | // Hence we run if after all native modules have been initialized 48 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 49 | if (reactContext == null) { 50 | reactInstanceManager.addReactInstanceEventListener( 51 | new ReactInstanceManager.ReactInstanceEventListener() { 52 | @Override 53 | public void onReactContextInitialized(ReactContext reactContext) { 54 | reactInstanceManager.removeReactInstanceEventListener(this); 55 | reactContext.runOnNativeModulesQueueThread( 56 | new Runnable() { 57 | @Override 58 | public void run() { 59 | client.addPlugin(new FrescoFlipperPlugin()); 60 | } 61 | }); 62 | } 63 | }); 64 | } else { 65 | client.addPlugin(new FrescoFlipperPlugin()); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 14 | 17 | 20 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/reactnativesceneform/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.reactnativesceneform; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "SceneformExample"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/reactnativesceneform/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.reactnativesceneform; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import com.facebook.react.PackageList; 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactNativeHost; 8 | import com.facebook.react.ReactPackage; 9 | import com.facebook.react.ReactInstanceManager; 10 | import com.facebook.soloader.SoLoader; 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.util.List; 13 | import com.reactnativesceneform.SceneformPackage; 14 | 15 | public class MainApplication extends Application implements ReactApplication { 16 | 17 | private final ReactNativeHost mReactNativeHost = 18 | new ReactNativeHost(this) { 19 | @Override 20 | public boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | @SuppressWarnings("UnnecessaryLocalVariable") 27 | List packages = new PackageList(this).getPackages(); 28 | // Packages that cannot be autolinked yet can be added manually here, for SceneformExample: 29 | // packages.add(new MyReactNativePackage()); 30 | packages.add(new SceneformPackage()); 31 | return packages; 32 | } 33 | 34 | @Override 35 | protected String getJSMainModuleName() { 36 | return "index"; 37 | } 38 | }; 39 | 40 | @Override 41 | public ReactNativeHost getReactNativeHost() { 42 | return mReactNativeHost; 43 | } 44 | 45 | @Override 46 | public void onCreate() { 47 | super.onCreate(); 48 | SoLoader.init(this, /* native exopackage */ false); 49 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); // Remove this line if you don't want Flipper enabled 50 | } 51 | 52 | /** 53 | * Loads Flipper in React Native templates. 54 | * 55 | * @param context 56 | */ 57 | private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 58 | if (BuildConfig.DEBUG) { 59 | try { 60 | /* 61 | We use reflection here to pick up the class that initializes Flipper, 62 | since Flipper library is not available in release mode 63 | */ 64 | Class aClass = Class.forName("com.example.reactnativesceneform.ReactNativeFlipper"); 65 | aClass 66 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 67 | .invoke(null, context, reactInstanceManager); 68 | } catch (ClassNotFoundException e) { 69 | e.printStackTrace(); 70 | } catch (NoSuchMethodException e) { 71 | e.printStackTrace(); 72 | } catch (IllegalAccessException e) { 73 | e.printStackTrace(); 74 | } catch (InvocationTargetException e) { 75 | e.printStackTrace(); 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Sceneform Example 3 | 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | minSdkVersion = 24 6 | compileSdkVersion = 29 7 | targetSdkVersion = 29 8 | } 9 | repositories { 10 | google() 11 | mavenCentral() 12 | jcenter() 13 | } 14 | dependencies { 15 | classpath("com.android.tools.build:gradle:3.6.0") 16 | 17 | // NOTE: Do not place your application dependencies here; they belong 18 | // in the individual module build.gradle files 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | mavenLocal() 25 | maven { 26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 27 | url("$rootDir/../node_modules/react-native/android") 28 | } 29 | maven { 30 | // Android JSC is installed from npm 31 | url("$rootDir/../node_modules/jsc-android/dist") 32 | } 33 | 34 | google() 35 | mavenCentral() 36 | jcenter() 37 | maven { url 'https://www.jitpack.io' } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useAndroidX=true 21 | android.enableJetifier=true 22 | FLIPPER_VERSION=0.54.0 23 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SceneView/sceneform-reactnative/81a5e17cdc5f16379640992e12a4547bcb24af3b/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem http://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'SceneformExample' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | 5 | include ':reactnativesceneform' 6 | project(':reactnativesceneform').projectDir = new File(rootProject.projectDir, '../../android') 7 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SceneformExample", 3 | "displayName": "Sceneform Example" 4 | } 5 | -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const pak = require('../package.json'); 3 | 4 | module.exports = { 5 | presets: ['module:metro-react-native-babel-preset'], 6 | plugins: [ 7 | [ 8 | 'module-resolver', 9 | { 10 | extensions: ['.tsx', '.ts', '.js', '.json'], 11 | alias: { 12 | [pak.name]: path.join(__dirname, '..', pak.source), 13 | }, 14 | }, 15 | ], 16 | ], 17 | }; 18 | -------------------------------------------------------------------------------- /example/index.tsx: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | import App from './src/App'; 3 | import { name as appName } from './app.json'; 4 | 5 | AppRegistry.registerComponent(appName, () => App); 6 | -------------------------------------------------------------------------------- /example/ios/File.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // SceneformExample 4 | // 5 | 6 | import Foundation 7 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'SceneformExample' do 7 | config = use_native_modules! 8 | 9 | use_react_native!(:path => config["reactNativePath"]) 10 | 11 | pod 'react-native-sceneform', :path => '../..' 12 | 13 | # Enables Flipper. 14 | # 15 | # Note that if you have use_frameworks! enabled, Flipper will not work and 16 | # you should disable these next few lines. 17 | use_flipper!({ 'Flipper' => '0.80.0' }) 18 | post_install do |installer| 19 | flipper_post_install(installer) 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /example/ios/SceneformExample-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | -------------------------------------------------------------------------------- /example/ios/SceneformExample.xcodeproj/xcshareddata/xcschemes/SceneformExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 81 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /example/ios/SceneformExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/SceneformExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/SceneformExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (nonatomic, strong) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /example/ios/SceneformExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import "AppDelegate.h" 9 | 10 | #import 11 | #import 12 | #import 13 | 14 | #ifdef FB_SONARKIT_ENABLED 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | static void InitializeFlipper(UIApplication *application) { 22 | FlipperClient *client = [FlipperClient sharedClient]; 23 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 24 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 25 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 26 | [client addPlugin:[FlipperKitReactPlugin new]]; 27 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 28 | [client start]; 29 | } 30 | #endif 31 | 32 | @implementation AppDelegate 33 | 34 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 35 | { 36 | #ifdef FB_SONARKIT_ENABLED 37 | InitializeFlipper(application); 38 | #endif 39 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 40 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 41 | moduleName:@"SceneformExample" 42 | initialProperties:nil]; 43 | 44 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 45 | 46 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 47 | UIViewController *rootViewController = [UIViewController new]; 48 | rootViewController.view = rootView; 49 | self.window.rootViewController = rootViewController; 50 | [self.window makeKeyAndVisible]; 51 | return YES; 52 | } 53 | 54 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 55 | { 56 | #if DEBUG 57 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 58 | #else 59 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 60 | #endif 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /example/ios/SceneformExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /example/ios/SceneformExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/SceneformExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | Sceneform Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | NSExceptionDomains 32 | 33 | localhost 34 | 35 | NSExceptionAllowsInsecureHTTPLoads 36 | 37 | 38 | 39 | 40 | NSLocationWhenInUseUsageDescription 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | UIViewControllerBasedStatusBarAppearance 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /example/ios/SceneformExample/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /example/ios/SceneformExample/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const blacklist = require('metro-config/src/defaults/blacklist'); 3 | const escape = require('escape-string-regexp'); 4 | const pak = require('../package.json'); 5 | 6 | const root = path.resolve(__dirname, '..'); 7 | 8 | const modules = Object.keys({ 9 | ...pak.peerDependencies, 10 | }); 11 | 12 | module.exports = { 13 | projectRoot: __dirname, 14 | watchFolders: [root], 15 | 16 | // We need to make sure that only one version is loaded for peerDependencies 17 | // So we blacklist them at the root, and alias them to the versions in example's node_modules 18 | resolver: { 19 | blacklistRE: blacklist( 20 | modules.map( 21 | (m) => 22 | new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`) 23 | ) 24 | ), 25 | 26 | extraNodeModules: modules.reduce((acc, name) => { 27 | acc[name] = path.join(__dirname, 'node_modules', name); 28 | return acc; 29 | }, {}), 30 | }, 31 | 32 | transformer: { 33 | getTransformOptions: async () => ({ 34 | transform: { 35 | experimentalImportSupport: false, 36 | inlineRequires: true, 37 | }, 38 | }), 39 | }, 40 | }; 41 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-sceneform-example", 3 | "description": "Example app for react-native-sceneform", 4 | "version": "0.0.1", 5 | "private": true, 6 | "scripts": { 7 | "android": "react-native run-android", 8 | "ios": "react-native run-ios", 9 | "start": "react-native start" 10 | }, 11 | "dependencies": { 12 | "react": "16.13.1", 13 | "react-native": "0.64.1" 14 | }, 15 | "devDependencies": { 16 | "@babel/core": "^7.12.10", 17 | "@babel/runtime": "^7.12.5", 18 | "babel-plugin-module-resolver": "^4.0.0", 19 | "metro-react-native-babel-preset": "^0.64.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React, { useRef } from 'react'; 2 | import { StyleSheet, View, TouchableOpacity } from 'react-native'; 3 | import { SceneformView, ModelViewer, AugmentedFacesView } from '../../src'; 4 | 5 | const App = () => { 6 | const sceneformView = useRef(null); 7 | 8 | return ( 9 | 10 | { 14 | sceneformView.current.addObject({name: "models/Rabbit.glb", anchorId: event.planeId, isCloudAnchor: false}); 15 | }} 16 | /> 17 | 18 | ); 19 | } 20 | 21 | const styles = StyleSheet.create({ 22 | container: { 23 | flex: 1 24 | } 25 | }); 26 | 27 | export default App; -------------------------------------------------------------------------------- /ios/Sceneform.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 11 | 5E555C0D2413F4C50049A1A2 /* Sceneform.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* Sceneform.m */; }; 12 | 13 | /* End PBXBuildFile section */ 14 | 15 | /* Begin PBXCopyFilesBuildPhase section */ 16 | 58B511D91A9E6C8500147676 /* CopyFiles */ = { 17 | isa = PBXCopyFilesBuildPhase; 18 | buildActionMask = 2147483647; 19 | dstPath = "include/$(PRODUCT_NAME)"; 20 | dstSubfolderSpec = 16; 21 | files = ( 22 | ); 23 | runOnlyForDeploymentPostprocessing = 0; 24 | }; 25 | /* End PBXCopyFilesBuildPhase section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 134814201AA4EA6300B7C361 /* libSceneform.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSceneform.a; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | 30 | B3E7B5881CC2AC0600A0062D /* Sceneform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sceneform.h; sourceTree = ""; }; 31 | B3E7B5891CC2AC0600A0062D /* Sceneform.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Sceneform.m; sourceTree = ""; }; 32 | 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | 58B511D81A9E6C8500147676 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | ); 41 | runOnlyForDeploymentPostprocessing = 0; 42 | }; 43 | /* End PBXFrameworksBuildPhase section */ 44 | 45 | /* Begin PBXGroup section */ 46 | 134814211AA4EA7D00B7C361 /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 134814201AA4EA6300B7C361 /* libSceneform.a */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 58B511D21A9E6C8500147676 = { 55 | isa = PBXGroup; 56 | children = ( 57 | 58 | B3E7B5881CC2AC0600A0062D /* Sceneform.h */, 59 | B3E7B5891CC2AC0600A0062D /* Sceneform.m */, 60 | 61 | 134814211AA4EA7D00B7C361 /* Products */, 62 | ); 63 | sourceTree = ""; 64 | }; 65 | /* End PBXGroup section */ 66 | 67 | /* Begin PBXNativeTarget section */ 68 | 58B511DA1A9E6C8500147676 /* Sceneform */ = { 69 | isa = PBXNativeTarget; 70 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Sceneform" */; 71 | buildPhases = ( 72 | 58B511D71A9E6C8500147676 /* Sources */, 73 | 58B511D81A9E6C8500147676 /* Frameworks */, 74 | 58B511D91A9E6C8500147676 /* CopyFiles */, 75 | ); 76 | buildRules = ( 77 | ); 78 | dependencies = ( 79 | ); 80 | name = Sceneform; 81 | productName = RCTDataManager; 82 | productReference = 134814201AA4EA6300B7C361 /* libSceneform.a */; 83 | productType = "com.apple.product-type.library.static"; 84 | }; 85 | /* End PBXNativeTarget section */ 86 | 87 | /* Begin PBXProject section */ 88 | 58B511D31A9E6C8500147676 /* Project object */ = { 89 | isa = PBXProject; 90 | attributes = { 91 | LastUpgradeCheck = 0920; 92 | ORGANIZATIONNAME = Facebook; 93 | TargetAttributes = { 94 | 58B511DA1A9E6C8500147676 = { 95 | CreatedOnToolsVersion = 6.1.1; 96 | }; 97 | }; 98 | }; 99 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Sceneform" */; 100 | compatibilityVersion = "Xcode 3.2"; 101 | developmentRegion = English; 102 | hasScannedForEncodings = 0; 103 | knownRegions = ( 104 | English, 105 | en, 106 | ); 107 | mainGroup = 58B511D21A9E6C8500147676; 108 | productRefGroup = 58B511D21A9E6C8500147676; 109 | projectDirPath = ""; 110 | projectRoot = ""; 111 | targets = ( 112 | 58B511DA1A9E6C8500147676 /* Sceneform */, 113 | ); 114 | }; 115 | /* End PBXProject section */ 116 | 117 | /* Begin PBXSourcesBuildPhase section */ 118 | 58B511D71A9E6C8500147676 /* Sources */ = { 119 | isa = PBXSourcesBuildPhase; 120 | buildActionMask = 2147483647; 121 | files = ( 122 | 123 | B3E7B58A1CC2AC0600A0062D /* Sceneform.m in Sources */, 124 | 125 | ); 126 | runOnlyForDeploymentPostprocessing = 0; 127 | }; 128 | /* End PBXSourcesBuildPhase section */ 129 | 130 | /* Begin XCBuildConfiguration section */ 131 | 58B511ED1A9E6C8500147676 /* Debug */ = { 132 | isa = XCBuildConfiguration; 133 | buildSettings = { 134 | ALWAYS_SEARCH_USER_PATHS = NO; 135 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 136 | CLANG_CXX_LIBRARY = "libc++"; 137 | CLANG_ENABLE_MODULES = YES; 138 | CLANG_ENABLE_OBJC_ARC = YES; 139 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 140 | CLANG_WARN_BOOL_CONVERSION = YES; 141 | CLANG_WARN_COMMA = YES; 142 | CLANG_WARN_CONSTANT_CONVERSION = YES; 143 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 144 | CLANG_WARN_EMPTY_BODY = YES; 145 | CLANG_WARN_ENUM_CONVERSION = YES; 146 | CLANG_WARN_INFINITE_RECURSION = YES; 147 | CLANG_WARN_INT_CONVERSION = YES; 148 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 149 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 150 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 151 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 152 | CLANG_WARN_STRICT_PROTOTYPES = YES; 153 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 154 | CLANG_WARN_UNREACHABLE_CODE = YES; 155 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 156 | COPY_PHASE_STRIP = NO; 157 | ENABLE_STRICT_OBJC_MSGSEND = YES; 158 | ENABLE_TESTABILITY = YES; 159 | GCC_C_LANGUAGE_STANDARD = gnu99; 160 | GCC_DYNAMIC_NO_PIC = NO; 161 | GCC_NO_COMMON_BLOCKS = YES; 162 | GCC_OPTIMIZATION_LEVEL = 0; 163 | GCC_PREPROCESSOR_DEFINITIONS = ( 164 | "DEBUG=1", 165 | "$(inherited)", 166 | ); 167 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 168 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 169 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 170 | GCC_WARN_UNDECLARED_SELECTOR = YES; 171 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 172 | GCC_WARN_UNUSED_FUNCTION = YES; 173 | GCC_WARN_UNUSED_VARIABLE = YES; 174 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 175 | MTL_ENABLE_DEBUG_INFO = YES; 176 | ONLY_ACTIVE_ARCH = YES; 177 | SDKROOT = iphoneos; 178 | }; 179 | name = Debug; 180 | }; 181 | 58B511EE1A9E6C8500147676 /* Release */ = { 182 | isa = XCBuildConfiguration; 183 | buildSettings = { 184 | ALWAYS_SEARCH_USER_PATHS = NO; 185 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 186 | CLANG_CXX_LIBRARY = "libc++"; 187 | CLANG_ENABLE_MODULES = YES; 188 | CLANG_ENABLE_OBJC_ARC = YES; 189 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 190 | CLANG_WARN_BOOL_CONVERSION = YES; 191 | CLANG_WARN_COMMA = YES; 192 | CLANG_WARN_CONSTANT_CONVERSION = YES; 193 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 194 | CLANG_WARN_EMPTY_BODY = YES; 195 | CLANG_WARN_ENUM_CONVERSION = YES; 196 | CLANG_WARN_INFINITE_RECURSION = YES; 197 | CLANG_WARN_INT_CONVERSION = YES; 198 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 199 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 200 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 201 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 202 | CLANG_WARN_STRICT_PROTOTYPES = YES; 203 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 204 | CLANG_WARN_UNREACHABLE_CODE = YES; 205 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 206 | COPY_PHASE_STRIP = YES; 207 | ENABLE_NS_ASSERTIONS = NO; 208 | ENABLE_STRICT_OBJC_MSGSEND = YES; 209 | GCC_C_LANGUAGE_STANDARD = gnu99; 210 | GCC_NO_COMMON_BLOCKS = YES; 211 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 212 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 213 | GCC_WARN_UNDECLARED_SELECTOR = YES; 214 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 215 | GCC_WARN_UNUSED_FUNCTION = YES; 216 | GCC_WARN_UNUSED_VARIABLE = YES; 217 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 218 | MTL_ENABLE_DEBUG_INFO = NO; 219 | SDKROOT = iphoneos; 220 | VALIDATE_PRODUCT = YES; 221 | }; 222 | name = Release; 223 | }; 224 | 58B511F01A9E6C8500147676 /* Debug */ = { 225 | isa = XCBuildConfiguration; 226 | buildSettings = { 227 | HEADER_SEARCH_PATHS = ( 228 | "$(inherited)", 229 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 230 | "$(SRCROOT)/../../../React/**", 231 | "$(SRCROOT)/../../react-native/React/**", 232 | ); 233 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 234 | OTHER_LDFLAGS = "-ObjC"; 235 | PRODUCT_NAME = Sceneform; 236 | SKIP_INSTALL = YES; 237 | 238 | }; 239 | name = Debug; 240 | }; 241 | 58B511F11A9E6C8500147676 /* Release */ = { 242 | isa = XCBuildConfiguration; 243 | buildSettings = { 244 | HEADER_SEARCH_PATHS = ( 245 | "$(inherited)", 246 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 247 | "$(SRCROOT)/../../../React/**", 248 | "$(SRCROOT)/../../react-native/React/**", 249 | ); 250 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 251 | OTHER_LDFLAGS = "-ObjC"; 252 | PRODUCT_NAME = Sceneform; 253 | SKIP_INSTALL = YES; 254 | 255 | }; 256 | name = Release; 257 | }; 258 | /* End XCBuildConfiguration section */ 259 | 260 | /* Begin XCConfigurationList section */ 261 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Sceneform" */ = { 262 | isa = XCConfigurationList; 263 | buildConfigurations = ( 264 | 58B511ED1A9E6C8500147676 /* Debug */, 265 | 58B511EE1A9E6C8500147676 /* Release */, 266 | ); 267 | defaultConfigurationIsVisible = 0; 268 | defaultConfigurationName = Release; 269 | }; 270 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Sceneform" */ = { 271 | isa = XCConfigurationList; 272 | buildConfigurations = ( 273 | 58B511F01A9E6C8500147676 /* Debug */, 274 | 58B511F11A9E6C8500147676 /* Release */, 275 | ); 276 | defaultConfigurationIsVisible = 0; 277 | defaultConfigurationName = Release; 278 | }; 279 | /* End XCConfigurationList section */ 280 | }; 281 | rootObject = 58B511D31A9E6C8500147676 /* Project object */; 282 | } 283 | -------------------------------------------------------------------------------- /ios/SceneformViewManager.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface SceneformViewManager : RCTViewManager 4 | @end 5 | 6 | @implementation SceneformViewManager 7 | 8 | RCT_EXPORT_MODULE(SceneformView) 9 | 10 | - (UIView *)view 11 | { 12 | return [[UIView alloc] init]; 13 | } 14 | 15 | RCT_CUSTOM_VIEW_PROPERTY(color, NSString, UIView) 16 | { 17 | [view setBackgroundColor:[self hexStringToColor:json]]; 18 | } 19 | 20 | - hexStringToColor:(NSString *)stringToConvert 21 | { 22 | NSString *noHashString = [stringToConvert stringByReplacingOccurrencesOfString:@"#" withString:@""]; 23 | NSScanner *stringScanner = [NSScanner scannerWithString:noHashString]; 24 | 25 | unsigned hex; 26 | if (![stringScanner scanHexInt:&hex]) return nil; 27 | int r = (hex >> 16) & 0xFF; 28 | int g = (hex >> 8) & 0xFF; 29 | int b = (hex) & 0xFF; 30 | 31 | return [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:1.0f]; 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@sceneview/react-native-sceneform", 3 | "version": "0.2.0", 4 | "description": "Sceneform for React Native", 5 | "main": "lib\\commonjs\\index.js", 6 | "module": "lib\\module\\index.js", 7 | "types": "lib/typescript/index.d.ts", 8 | "react-native": "src\\index.js", 9 | "source": "src/index", 10 | "files": [ 11 | "src", 12 | "lib", 13 | "!**/__tests__", 14 | "!**/__fixtures__", 15 | "!**/__mocks__", 16 | "android", 17 | "ios", 18 | "cpp", 19 | "react-native-sceneform.podspec", 20 | "!lib/typescript/example", 21 | "!android/build", 22 | "!ios/build" 23 | ], 24 | "scripts": { 25 | "test": "jest", 26 | "typescript": "tsc --noEmit", 27 | "lint": "eslint \"**/*.{js,ts,tsx}\"", 28 | "prepare": "bob build", 29 | "release": "release-it", 30 | "example": "yarn --cwd example", 31 | "pods": "cd example && pod-install --quiet", 32 | "bootstrap": "yarn example && yarn && yarn pods" 33 | }, 34 | "keywords": [ 35 | "react-native", 36 | "ios", 37 | "android" 38 | ], 39 | "repository": { 40 | "type": "git", 41 | "url": "git+https://github.com/doranteseduardo/react-native-sceneform.git" 42 | }, 43 | "author": "Eduardo Dorantes (https://github.com/doranteseduardo)", 44 | "license": "MIT", 45 | "bugs": { 46 | "url": "https://github.com/doranteseduardo/react-native-sceneform/issues" 47 | }, 48 | "homepage": "https://github.com/doranteseduardo/react-native-sceneform#readme", 49 | "publishConfig": { 50 | "registry": "https://registry.npmjs.org/" 51 | }, 52 | "devDependencies": { 53 | "@commitlint/config-conventional": "^11.0.0", 54 | "@react-native-community/eslint-config": "^2.0.0", 55 | "@release-it/conventional-changelog": "^2.0.0", 56 | "@types/jest": "^26.0.0", 57 | "@types/react": "^16.9.19", 58 | "@types/react-native": "0.62.13", 59 | "commitlint": "^11.0.0", 60 | "eslint": "^7.2.0", 61 | "eslint-config-prettier": "^7.0.0", 62 | "eslint-plugin-prettier": "^3.1.3", 63 | "husky": "^6.0.0", 64 | "jest": "^26.0.1", 65 | "pod-install": "^0.1.0", 66 | "prettier": "^2.0.5", 67 | "react": "16.13.1", 68 | "react-native": "0.64.1", 69 | "react-native-builder-bob": "^0.18.2", 70 | "release-it": "^14.2.2", 71 | "typescript": "^4.1.3" 72 | }, 73 | "peerDependencies": { 74 | "react": "*", 75 | "react-native": "*" 76 | }, 77 | "jest": { 78 | "preset": "react-native", 79 | "modulePathIgnorePatterns": [ 80 | "/example/node_modules", 81 | "/lib/" 82 | ] 83 | }, 84 | "commitlint": { 85 | "extends": [ 86 | "@commitlint/config-conventional" 87 | ] 88 | }, 89 | "release-it": { 90 | "git": { 91 | "commitMessage": "chore: release ${version}", 92 | "tagName": "v${version}" 93 | }, 94 | "npm": { 95 | "publish": true 96 | }, 97 | "github": { 98 | "release": true 99 | }, 100 | "plugins": { 101 | "@release-it/conventional-changelog": { 102 | "preset": "angular" 103 | } 104 | } 105 | }, 106 | "eslintConfig": { 107 | "root": true, 108 | "extends": [ 109 | "@react-native-community", 110 | "prettier" 111 | ], 112 | "rules": { 113 | "prettier/prettier": [ 114 | "error", 115 | { 116 | "quoteProps": "consistent", 117 | "singleQuote": true, 118 | "tabWidth": 2, 119 | "trailingComma": "es5", 120 | "useTabs": false 121 | } 122 | ] 123 | } 124 | }, 125 | "eslintIgnore": [ 126 | "node_modules/", 127 | "lib/" 128 | ], 129 | "prettier": { 130 | "quoteProps": "consistent", 131 | "singleQuote": true, 132 | "tabWidth": 2, 133 | "trailingComma": "es5", 134 | "useTabs": false 135 | }, 136 | "react-native-builder-bob": { 137 | "source": "src", 138 | "output": "lib", 139 | "targets": [ 140 | "commonjs", 141 | "module", 142 | "aar" 143 | ] 144 | }, 145 | "directories": { 146 | "example": "example", 147 | "lib": "lib" 148 | }, 149 | "dependencies": { 150 | 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /react-native-sceneform.podspec: -------------------------------------------------------------------------------- 1 | require "json" 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, "package.json"))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = "react-native-sceneform" 7 | s.version = package["version"] 8 | s.summary = package["description"] 9 | s.homepage = package["homepage"] 10 | s.license = package["license"] 11 | s.authors = package["author"] 12 | 13 | s.platforms = { :ios => "10.0" } 14 | s.source = { :git => "https://github.com/doranteseduardo/react-native-sceneform.git", :tag => "#{s.version}" } 15 | 16 | s.source_files = "ios/**/*.{h,m,mm}" 17 | 18 | s.dependency "React-Core" 19 | end 20 | -------------------------------------------------------------------------------- /scripts/bootstrap.js: -------------------------------------------------------------------------------- 1 | const os = require('os'); 2 | const path = require('path'); 3 | const child_process = require('child_process'); 4 | 5 | const root = path.resolve(__dirname, '..'); 6 | const args = process.argv.slice(2); 7 | const options = { 8 | cwd: process.cwd(), 9 | env: process.env, 10 | stdio: 'inherit', 11 | encoding: 'utf-8', 12 | }; 13 | 14 | if (os.type() === 'Windows_NT') { 15 | options.shell = true 16 | } 17 | 18 | let result; 19 | 20 | if (process.cwd() !== root || args.length) { 21 | // We're not in the root of the project, or additional arguments were passed 22 | // In this case, forward the command to `yarn` 23 | result = child_process.spawnSync('yarn', args, options); 24 | } else { 25 | // If `yarn` is run without arguments, perform bootstrap 26 | result = child_process.spawnSync('yarn', ['bootstrap'], options); 27 | } 28 | 29 | process.exitCode = result.status; 30 | -------------------------------------------------------------------------------- /src/ARScene/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import React from 'react'; 3 | import { requireNativeComponent, View, DeviceEventEmitter, NativeModules, findNodeHandle } from 'react-native'; 4 | import PropTypes from 'prop-types'; 5 | 6 | class SceneformView extends React.Component { 7 | constructor() { 8 | super(); 9 | this.NativeArView = undefined; 10 | this.onChange = this.onChange.bind(this); 11 | this.subscriptions = []; 12 | this.state = { 13 | recording: false 14 | } 15 | this.mounted = false; 16 | } 17 | 18 | onChange(event) { 19 | if(event.nativeEvent.onAnchorResolve){ 20 | if (!this.props.onAnchorResolve) { return; } 21 | this.props.onAnchorResolve({ onAnchorResolve: event.nativeEvent}); 22 | } 23 | if(event.nativeEvent.onSessionCreate){ 24 | if(!this.props.onSessionCreate){ return; } 25 | this.props.onSessionCreate({ onSessionCreate: event.nativeEvent}); 26 | } 27 | if(event.nativeEvent.onTapPlane){ 28 | if(!this.props.onTapPlane){ return; } 29 | this.props.onTapPlane({ onTapPlane: event.nativeEvent}); 30 | } 31 | if(event.nativeEvent.onFeatureMapQualityChange){ 32 | if(!this.props.onFeatureMapQualityChange){ return; } 33 | this.props.onFeatureMapQualityChange({ onFeatureMapQualityChange: event.nativeEvent}); 34 | } 35 | if(event.nativeEvent.onAnchorHost){ 36 | if(!this.props.onAnchorHost){ return; } 37 | this.props.onAnchorHost({ onAnchorHost: event.nativeEvent}); 38 | } 39 | } 40 | 41 | componentDidMount() { 42 | this.mounted = true; 43 | if (this.props.onAnchorResolve) { 44 | let sub = DeviceEventEmitter.addListener('onAnchorResolve', this.props.onAnchorResolve); 45 | this.subscriptions.push(sub); 46 | } 47 | if(this.props.onSessionCreate){ 48 | let sub = DeviceEventEmitter.addListener("onSessionCreate", this.props.onSessionCreate); 49 | this.subscriptions.push(sub); 50 | } 51 | if(this.props.onTapPlane){ 52 | let sub = DeviceEventEmitter.addListener("onTapPlane", this.props.onTapPlane); 53 | this.subscriptions.push(sub); 54 | } 55 | if(this.props.onAnchorHost){ 56 | let sub = DeviceEventEmitter.addListener("onAnchorHost", this.props.onAnchorHost); 57 | this.subscriptions.push(sub); 58 | } 59 | if(this.props.onFeatureMapQualityChange){ 60 | let sub = DeviceEventEmitter.addListener("onFeatureMapQualityChange", this.props.onFeatureMapQualityChange); 61 | this.subscriptions.push(sub); 62 | } 63 | } 64 | 65 | componentWillUnmount() { 66 | this.subscriptions.forEach(sub => sub.remove()); 67 | this.subscriptions = []; 68 | this.mounted = false; 69 | } 70 | 71 | /** 72 | * 73 | * @param {Model} model 74 | */ 75 | // {anchorId, name, isCloudAnchor?} 76 | addObject = (model) => { 77 | NativeModules.SceneformModule.addObject(findNodeHandle(this), model); 78 | } 79 | 80 | takeScreenshot = () => { 81 | return NativeModules.SceneformModule.takeSnapshot(findNodeHandle(this)); 82 | } 83 | 84 | hostCloudAnchor = (anchorId) => { 85 | NativeModules.SceneformModule.hostCloudAnchor(findNodeHandle(this), parseInt(anchorId)); 86 | } 87 | 88 | resolveCloudAnchor = (anchorId) => { 89 | NativeModules.SceneformModule.resolveCloudAnchor(findNodeHandle(this), anchorId); 90 | } 91 | 92 | startVideoRecording = async () => { 93 | if(this.state.recording){ 94 | throw 'Video is already recording'; 95 | } 96 | const recording = await NativeModules.SceneformModule.startVideoRecording(findNodeHandle(this)); 97 | if(recording){ 98 | this.setState({recording: true}, () => { 99 | return true; 100 | }); 101 | } 102 | else{ 103 | return false; 104 | } 105 | } 106 | 107 | stopVideoRecording = () => { 108 | if(!this.state.recording){ 109 | throw 'Video is not recording'; 110 | } 111 | return NativeModules.SceneformModule.stopVideoRecording(findNodeHandle(this)); 112 | } 113 | 114 | render() { 115 | return this.NativeArView = c} {...this.props} onChange={this.onChange}/> 116 | } 117 | } 118 | 119 | SceneformView.propTypes = { 120 | ...View.propTypes, 121 | viewMode: PropTypes.oneOf(['host', 'resolve']), 122 | onAnchorHost: PropTypes.func, 123 | onAnchorResolve: PropTypes.func, 124 | onSessionCreate: PropTypes.func, 125 | displayPointCloud: PropTypes.bool, 126 | displayPlanes: PropTypes.bool 127 | 128 | }; 129 | 130 | const NativeArView = requireNativeComponent('SceneformView', SceneformView, { 131 | nativeOnly: { onChange: true } 132 | }); 133 | 134 | module.exports = SceneformView; -------------------------------------------------------------------------------- /src/AugmentedFacesScene/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import React from 'react'; 3 | import { requireNativeComponent, View, DeviceEventEmitter, NativeModules, findNodeHandle } from 'react-native'; 4 | import PropTypes from 'prop-types'; 5 | 6 | class AugmentedFacesView extends React.Component { 7 | constructor() { 8 | super(); 9 | this.NativeArView = undefined; 10 | this.onChange = this.onChange.bind(this); 11 | this.subscriptions = []; 12 | this.mounted = false; 13 | this.state = { 14 | recording: false 15 | } 16 | } 17 | 18 | onChange(event) { 19 | 20 | } 21 | 22 | componentDidMount() { 23 | this.mounted = true; 24 | } 25 | 26 | componentWillUnmount() { 27 | this.subscriptions.forEach(sub => sub.remove()); 28 | this.subscriptions = []; 29 | this.mounted = false; 30 | } 31 | 32 | addAugmentedFace = ({model, texture}) => { 33 | const mModel = model; 34 | if(!model){ 35 | throw 'At least a model source is required'; 36 | } 37 | const mTexture = texture || ''; 38 | // returns an index; 39 | console.log("Adding object to scene", model, texture) 40 | return NativeModules.SceneformAugmentedFacesModule.addFaceModel(findNodeHandle(this), mModel, mTexture); 41 | } 42 | 43 | takeScreenshot = () => { 44 | return NativeModules.SceneformAugmentedFacesModule.takeSnapshot(findNodeHandle(this)); 45 | } 46 | 47 | startVideoRecording = async () => { 48 | if(this.state.recording){ 49 | throw 'Video is already recording'; 50 | } 51 | const recording = await NativeModules.SceneformAugmentedFacesModule.startVideoRecording(findNodeHandle(this)); 52 | if(recording){ 53 | this.setState({recording: true}, () => { 54 | return true; 55 | }); 56 | } 57 | else{ 58 | return false; 59 | } 60 | } 61 | 62 | stopVideoRecording = () => { 63 | if(!this.state.recording){ 64 | throw 'Video is not recording'; 65 | } 66 | return NativeModules.SceneformAugmentedFacesModule.stopVideoRecording(findNodeHandle(this)); 67 | } 68 | 69 | render() { 70 | return this.NativeArView = c} {...this.props} onChange={this.onChange}/> 71 | } 72 | } 73 | 74 | AugmentedFacesView.propTypes = { 75 | ...View.propTypes, 76 | }; 77 | 78 | const NativeArView = requireNativeComponent('SceneformAugmentedFacesView', AugmentedFacesView, { 79 | nativeOnly: { onChange: true } 80 | }); 81 | 82 | module.exports = AugmentedFacesView; -------------------------------------------------------------------------------- /src/NoARScene/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import React from 'react'; 3 | import { requireNativeComponent, View, DeviceEventEmitter, NativeModules, findNodeHandle } from 'react-native'; 4 | import PropTypes from 'prop-types'; 5 | 6 | class NoARScene extends React.Component { 7 | constructor() { 8 | super(); 9 | this.NativeArView = undefined; 10 | this.onChange = this.onChange.bind(this); 11 | this.subscriptions = []; 12 | this.mounted = false; 13 | this.state = { 14 | recording: false 15 | } 16 | } 17 | 18 | onChange(event) { 19 | 20 | } 21 | 22 | componentDidMount() { 23 | this.mounted = true; 24 | } 25 | 26 | componentWillUnmount() { 27 | this.subscriptions.forEach(sub => sub.remove()); 28 | this.subscriptions = []; 29 | this.mounted = false; 30 | } 31 | 32 | render() { 33 | return this.NativeArView = c} {...this.props} onChange={this.onChange}/> 34 | } 35 | } 36 | 37 | NoARScene.propTypes = { 38 | ...View.propTypes, 39 | }; 40 | 41 | const NativeArView = requireNativeComponent('SceneformNoARView', NoARScene, { 42 | nativeOnly: { onChange: true } 43 | }); 44 | 45 | module.exports = NoARScene; -------------------------------------------------------------------------------- /src/__tests__/index.test.tsx: -------------------------------------------------------------------------------- 1 | it.todo('write a test'); 2 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import ARScene from './ARScene'; 2 | import AugmentedFacesScene from './AugmentedFacesScene'; 3 | import NoARScene from './NoARScene'; 4 | 5 | export { 6 | ARScene as SceneformView, 7 | AugmentedFacesScene as AugmentedFacesView, 8 | NoARScene as ModelViewer 9 | } -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "extends": "./tsconfig", 4 | "exclude": ["example"] 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./", 4 | "paths": { 5 | "react-native-sceneform": ["./src/index"] 6 | }, 7 | "allowUnreachableCode": false, 8 | "allowUnusedLabels": false, 9 | "esModuleInterop": true, 10 | "importsNotUsedAsValues": "error", 11 | "forceConsistentCasingInFileNames": true, 12 | "jsx": "react", 13 | "lib": ["esnext"], 14 | "module": "esnext", 15 | "moduleResolution": "node", 16 | "noFallthroughCasesInSwitch": true, 17 | "noImplicitReturns": true, 18 | "noImplicitUseStrict": false, 19 | "noStrictGenericChecks": false, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "resolveJsonModule": true, 23 | "skipLibCheck": true, 24 | "strict": true, 25 | "target": "esnext" 26 | } 27 | } 28 | --------------------------------------------------------------------------------