The AR fragment brings in the required view layout and controllers for common AR features.
Nested Classes
Public Constructors
Public Methods
abstract String[] | getAdditionalPermissions
()
Returns an array of dangerous permissions that are required by the app in addition to
Manifest.permission.CAMERA, which is needed by ARCore.
|
ArSceneView | |
PlaneDiscoveryController | getPlaneDiscoveryController
()
Gets the plane discovery controller, which displays instructions for how to scan for planes.
|
TransformationSystem | getTransformationSystem
()
Gets the transformation system, which is used by
TransformableNode
for detecting
gestures and coordinating which node is selected. |
abstract boolean | |
View | |
void | onDestroy
()
|
void | |
void | onPause
()
|
void | onPeekTouch
( HitTestResult
hitTestResult, MotionEvent
motionEvent)
Called when a touch event is dispatched to a scene.
|
void | onRequestPermissionsResult
(int requestCode, String[]
permissions, int[] results)
Receives the results for permission requests.
|
void | onResume
()
|
void | |
void | setOnSessionInitializationListener
( BaseArFragment.OnSessionInitializationListener
onSessionInitializationListener)
Registers a callback to be invoked when the ARCore Session is initialized.
|
void | setOnTapArPlaneListener
( BaseArFragment.OnTapArPlaneListener
onTapArPlaneListener)
Registers a callback to be invoked when an ARCore Plane is tapped.
|
Protected Methods
Boolean | getCanRequestDangerousPermissions
()
If true,
requestDangerousPermissions()
returns without doing anything, if false
permissions will be requested |
abstract Config | |
abstract Set < Session.Feature > | |
abstract void | |
final void | |
TransformationSystem | |
void | onWindowFocusChanged
(boolean hasFocus)
|
void | |
final boolean | |
void | setCanRequestDangerousPermissions
( Boolean
canRequestDangerousPermissions)
If true,
requestDangerousPermissions()
returns without doing anything, if false
permissions will be requested |
void |
Inherited Methods
Public Constructors
public BaseArFragment ()
Public Methods
public abstract String[] getAdditionalPermissions ()
Returns an array of dangerous permissions that are required by the app in addition to Manifest.permission.CAMERA, which is needed by ARCore. If no additional permissions are needed, an empty array should be returned.
public ArSceneView getArSceneView ()
Gets the ArSceneView for this fragment.
public PlaneDiscoveryController getPlaneDiscoveryController ()
Gets the plane discovery controller, which displays instructions for how to scan for planes.
public TransformationSystem getTransformationSystem ()
Gets the transformation system, which is used by TransformableNode
for detecting
gestures and coordinating which node is selected.
public abstract boolean isArRequired ()
Returns true if this application is AR Required, false if AR Optional. This is called when initializing the application and the session.
public View onCreateView ( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Parameters
inflater |
---|
container |
savedInstanceState |
public void onDestroy ()
public void onDestroyView ()
public void onPause ()
public void onPeekTouch ( HitTestResult hitTestResult, MotionEvent motionEvent)
Called when a touch event is dispatched to a scene. The callback will be invoked before the Scene.OnTouchListener
is invoked. This is invoked even if the gesture was consumed, making
it possible to observe all motion events dispatched to the scene. This is called even if the
touch is not over a node, in which case getNode()
will be null.
Parameters
hitTestResult | represents the node that was touched |
---|---|
motionEvent | the motion event |
public void onRequestPermissionsResult (int requestCode, String[] permissions, int[] results)
Receives the results for permission requests.
Brings up a dialog to request permissions. The dialog can send the user to the Settings app, or finish the activity.
Parameters
requestCode |
---|
permissions |
results |
public void onResume ()
public void onUpdate ( FrameTime frameTime)
Called once per frame right before the Scene is updated.
Parameters
public void setOnSessionInitializationListener ( BaseArFragment.OnSessionInitializationListener onSessionInitializationListener)
Registers a callback to be invoked when the ARCore Session is initialized. The callback will only be invoked once after the Session is initialized and before it is resumed.
Parameters
public void setOnTapArPlaneListener ( BaseArFragment.OnTapArPlaneListener onTapArPlaneListener)
Registers a callback to be invoked when an ARCore Plane is tapped. The callback will only be
invoked if no Node
was tapped.
Parameters
Protected Methods
protected Boolean getCanRequestDangerousPermissions ()
If true, requestDangerousPermissions()
returns without doing anything, if false
permissions will be requested
protected abstract Config getSessionConfiguration ( Session session)
Parameters
protected abstract Set < Session.Feature > getSessionFeatures ()
Specifies additional features for creating an ARCore Session
. See Session.Feature
.
protected abstract void handleSessionException ( UnavailableException sessionException)
Parameters
protected final void initializeSession ()
Initializes the ARCore session. The CAMERA permission is checked before checking the installation state of ARCore. Once the permissions and installation are OK, the method #getSessionConfiguration(Session session) is called to get the session configuration to use. Sceneform requires that the ARCore session be updated using LATEST_CAMERA_IMAGE to avoid blocking while drawing. This mode is set on the configuration object returned from the subclass.
protected TransformationSystem makeTransformationSystem ()
Creates the transformation system used by this fragment. Can be overridden to create a custom transformation system.
protected void onWindowFocusChanged (boolean hasFocus)
Parameters
protected void requestDangerousPermissions ()
Starts the process of requesting dangerous permissions. This combines the CAMERA permission required of ARCore and any permissions returned from getAdditionalPermissions(). There is no specific processing on the result of the request, subclasses can override onRequestPermissionsResult() if additional processing is needed.
setCanRequestDangerousPermissions(Boolean)
can stop this function from doing
anything.
protected final boolean requestInstall ()
Throws
protected void setCanRequestDangerousPermissions ( Boolean canRequestDangerousPermissions)
If true, requestDangerousPermissions()
returns without doing anything, if false
permissions will be requested