Demonstrate how to use surface tracking.
How to Use¶
Move the cube on the surface with on finger. Two finger pinch will scale the cube and two finger horizontal move will rotate the cube.
How It Works¶
Setup SurfaceTarget to be tracked¶
SurfaceTrackerFrameFilter can track only one surface, which can be created and setup in the scene,
There is not much configurations on SurfaceTarget. Objects need to show on the surface should be put under SurfaceTarget.
Surface tracking can be turned on or off using SurfaceTrackerFrameFilter.enabled. You can turn the tracking off when it is not used to save performance, it will not turn off the camera or any other tracking features.
Move object on surface¶
You can put object in one location where SurfaceTracker will track continuously. Put objects in other location may look like the objects are not tracked.
When you want to move object to other parts of the surface, you can change the location SurfaceTracker tracks using SurfaceTracker.alignTargetToCameraImagePoint. In this way, you will see objects move on the surface. But the camera will not move in a continuous way because surface tracking do not keep real world scale, so object size outside the surface node may not be stable.
SurfaceTracker is not designed to be a VIO system, so in case you find the object or the camera behaves strange, you may take a look at MotionTracking sample which behaves like ARCore and ARKit.
var viewPoint = new Vector2(touch.position.x / Screen.width, touch.position.y / Screen.height);
var coord = Session.ImageCoordinatesFromScreenCoordinates(viewPoint);
if (tracker && tracker.Tracker != null && coord.OnSome)
In ARSession.ARCenterMode.SessionOrigin the camera will move automatically when the device moves, and the WorldRoot stay. In ARSession.ARCenterMode.Camera, the camera do not automatically move when the device moves. For other center modes, please reference Center mode.