If disabled, the Component will stop enacting its behavior.
ReadonlyisReturns true if this Component, its SceneObject, and all of that SceneObjects parents are enabled.
Used to access rotation tracking settings.
ReadonlysceneThe SceneObject this component is on.
Used to access surface tracking settings.
Helps to improve surface tracking accuracy while the target SceneObject is being moved.
ReadonlyuniqueReturns the WorldOptions object of this component, which can be used to control World Tracking settings.
ReadonlyworldReturns the World Tracking Capabilities of the current device.
Calculates a histogram of world mesh surfaces within a sphere at the given world position and radius. Only available when world mesh tracking is supported and enabled.
Creates a TrackedPoint at world position worldPos and world rotation worldRot.
When creating a TrackedPoint, the DeviceTracking component must be set to World mode.
Destroys the component.
Returns the actual DeviceTrackingMode being used. This may be different from the requested DeviceTrackingMode.
Exposes User DataReturns the 3D point cloud representing important features visible by the camera.
Returns the DeviceTrackingMode currently requested to be used. This may be different from the actual DeviceTrackingMode being used.
Returns the SceneObject the component is attached to.
Returns the Transform this component is attached to.
Returns the name of this object's type.
Performs a raycast against world meshes from a screen position. The ray starts at the camera's near plane and extends through the camera's far plane at the given screen coordinates.
Screen coordinates in normalized device coordinates ([0-1], [0-1]), where (0,0) is the top-left of the screen and (1,1) is the bottom-right
Array of TrackedMeshHitTestResult objects, sorted by distance from camera (nearest first). Returns an empty array if no meshes are hit.
World tracking mode//@input Component.DeviceTracking deviceTracking
// Prerequisites
script.deviceTracking.worldOptions.enableWorldMeshesTracking = true;
script.deviceTracking.requestDeviceTrackingMode(DeviceTrackingMode.World);
script.createEvent("TapEvent").bind(function (eventData) {
const screenPos = eventData.getTapPosition();
const results = script.deviceTracking.hitTestWorldMesh(screenPos);
if (results.length > 0) {
print("Hit position: " + results[0].position);
} else {
print("No surface found");
}
});
Returns whether the DeviceTrackingMode is supported.
Returns true if the object matches or derives from the passed in type.
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Performs a raycast against world meshes along a ray from world position from to world position to.
Returns detailed intersection information for each mesh surface hit by the ray.
Array of TrackedMeshHitTestResult objects, sorted by distance from from (nearest first).
Returns an empty array if no meshes are hit.
World tracking mode//@input Component.DeviceTracking deviceTracking
// Prerequisites
script.deviceTracking.worldOptions.enableWorldMeshesTracking = true;
script.deviceTracking.requestDeviceTrackingMode(DeviceTrackingMode.World);
script.createEvent("TapEvent").bind(function () {
const from = new vec3(0, 0, 0);
const to = new vec3(0, 0, -600);
const results = script.deviceTracking.raycastWorldMesh(from, to);
if (results.length > 0) {
print("Hit position: " + results[0].position);
} else {
print("No surface found");
}
});
Requests that a DeviceTrackingMode be used. This requested change may not happen immediately.
Resets the World Tracking origin to the point on the surface plane aligned with the screen position position.
Screen positions are represented in the range ([0-1], [0-1]), (0,0) being the top-left of the screen and (1,1) being the bottom-right.
Offsets the default position of the World Tracking surface origin by offset.
Avoid using a y value of zero in offset, because it may cause problems with tracking.
If used outside of Initialized or TurnOnEvent, you will need to call resetTracking() to apply the offset.
Note: calling resetTracking() will overwrite the x and z components of the offset.
Enables a SceneObject to align with the movements and orientation of the user's device. Provides tracking modes such as
Surface,Rotation, andWorld.Remarks
Usually added to SceneObject with Camera component.
If using
Surfacetracking mode, adding this to a SceneObject enables surface tracking for the scene, and moves the object to a position and rotation that matches the physical camera's pose in the world. Surface tracking can also be enhanced with native AR by enabling theUse Native ARoption in the Inspector panel, or through script by setting the component's SurfaceOptions.enhanceWithNativeAR property.If using
Rotationtracking mode, adding this to a SceneObject will apply the device's real world rotation to the object.If using
Worldtracking mode, adding this to a SceneObject enables native AR tracking for the scene, and moves the object to a position and rotation that matches the physical camera's pose in the world.See
Tracking Modes guide for more information.
Example
Set the surface tracking target.