Skip to main content

class ARScanningManager

(Niantic.Lightship.AR.Scanning.ARScanningManager)

Overview

A manager for recording scans of the AR scene for Playback. The recording will start when the manager is enabled. Use SaveScan() to stop and save the recording into the ScanPath.

	class ARScanningManager: SubsystemLifecycleManager< XRScanningSubsystem, XRScanningSubsystemDescriptor, XRScanningSubsystem.Provider > {
public:
// fields

NativeArray<Vector3> VoxelPositions => _voxelPositions;
NativeArray<Color32> VoxelColors => _voxelColors;
NativeArray<Vector3> VoxelNormals => _voxelNormals;
float LatestVoxelSize => _latestVoxelSize;

// properties

string ScanPath;
bool FullResolutionEnabled;
int FullResolutionFramerate;
string ScanTargetId;
int ScanRecordingFramerate;
bool EnableRaycastVisualization;
bool EnableVoxelVisualization;
bool UseEstimatedDepth;
float MinimumVoxelSize;
float NearDepth;
float FarDepth;

// methods

Texture2D GetRaycastColorTexture();
Texture2D GetRaycastNormalTexture();
Texture2D GetRaycastPositionTexture();
ScanStore GetScanStore();
async Task SaveScan();
async Task DiscardScan();
string GetCurrentScanId();
void RequestVoxelUpdate();
bool TryGetVoxelBuffer();

protected:
// methods

override void OnBeforeStart();
override void OnDisable();
};

Detailed Documentation

A manager for recording scans of the AR scene for Playback. The recording will start when the manager is enabled. Use SaveScan() to stop and save the recording into the ScanPath.

Fields

VoxelPositions

NativeArray<Vector3> VoxelPositions => _voxelPositions

The positions of voxels scanned with the camera. Each entry in the array corresponds to an entry in VoxelColors at the same index. These values can only be updated when EnableVoxelVisualization is true and scanning is in the XRScanningState.Started state. Call RequestVoxelUpdate to update the underlying map, and then call TryGetVoxelBuffer to populate with the latest values.

VoxelColors

NativeArray<Color32> VoxelColors => _voxelColors

The color of each voxel. Each entry in the array corresponds to an entry in VoxelPositions at the same index. These values can only be updated when EnableVoxelVisualization is true and scanning is in the XRScanningState.Started state. Call RequestVoxelUpdate to update the underlying map, and then call TryGetVoxelBuffer to populate with the latest values.

VoxelNormals

NativeArray<Vector3> VoxelNormals => _voxelNormals

The normal vector of each voxel. Each entry in the array corresponds to an entry in VoxelPositions at the same index. These values can only be updated when EnableVoxelVisualization is true and scanning is in the XRScanningState.Started state. Call RequestVoxelUpdate to update the underlying map, and then call TryGetVoxelBuffer to populate with the latest values.

LatestVoxelSize

float LatestVoxelSize => _latestVoxelSize

The size of the voxels in VoxelPositions, in meters. The voxel visualizer attempts to use the voxel size requested by the MinimumVoxelSize parameter. As the number of voxels grows, the voxel visualizer periodically doubles the voxel size to keep memory use in check. This value should be used for rendering the voxels with the correct dimensions.

Properties

ScanPath

string ScanPath

The scan path to store the scan data. If an absolute path is provided (starting with '/', '', or a drive name), the directory must be writable, and the application must have permissions to write to the folder. Otherwise, the path will be interpreted as relative to Application.persistentDataPath.

FullResolutionEnabled

bool FullResolutionEnabled

Record full resolution images for scan reconstruction. Must be set before scanning starts to take effect.

FullResolutionFramerate

int FullResolutionFramerate

The framerate for full resolution frame recording. A framerate of zero means the system will use the default framerate of 2 FPS. Must be set before scanning starts to take effect.

ScanTargetId

string ScanTargetId

The scan target ID. Must be set before scanning starts to take effect.

ScanRecordingFramerate

int ScanRecordingFramerate

The scan recording framerate. A framerate of zero means the system will use the default framerate of 15 FPS. Must be set before scanning starts to take effect.

EnableRaycastVisualization

bool EnableRaycastVisualization

Enable raycast visualization for scanning. Required to access the raycast textures. The data will be available from the GetRaycastColorTexture, GetRaycastNormalTexture and GetRaycastPositionTexture methods. Must be set before scanning starts to take effect.

EnableVoxelVisualization

bool EnableVoxelVisualization

Enable voxel visualization for scanning. Required to compute voxels. RequestVoxelUpdate must be called to asynchronously compute the voxel buffers. Then, TryGetVoxelBuffer can be called to get the voxel buffers. After TryGetVoxelBuffer returns true, the voxel data will be available in the VoxelPositions, VoxelColors and LatestVoxelSize fields. Must be set before scanning starts to take effect.

UseEstimatedDepth

bool UseEstimatedDepth

Record Niantic depth data if the device does not support platform depth such as lidar. If platform depth is present, it will be used instead of Niantic depth.

MinimumVoxelSize

float MinimumVoxelSize

The minimum size of voxels for voxel visualization, in meters. This parameter sets the initial resolution of the voxel grid used for voxel visualization (see EnableVoxelVisualization. Smaller values result in higher resolution but require more memory and computation. The actual voxel size may be larger due to memory constraints, so this is only a minimum value. Refer to LatestVoxelSize for the correct dimensions when rendering voxels. Must be set before scanning starts to take effect.

NearDepth

float NearDepth

The near depth plane for depth range, in meters. This parameter controls the closest distance at which depth data will be integrated. Objects closer than this distance will not be visible in visualization or reconstruction. Must be set before scanning starts to take effect.

FarDepth

float FarDepth

The far depth plane for depth range, in meters. This parameter controls the farthest distance at which depth data will be integrated. Objects farther than this distance will not be visible in visualization or reconstruction. Must be set before scanning starts to take effect.

Methods

GetRaycastColorTexture

Texture2D GetRaycastColorTexture()

Read the current raycast color texture.

The color texture for raycast visualization, if configured and ready. Otherwise, null.

GetRaycastNormalTexture

Texture2D GetRaycastNormalTexture()

Read the current raycast normal texture.

The normal texture for raycast visualization, if configured and ready. Otherwise, null.

GetRaycastPositionTexture

Texture2D GetRaycastPositionTexture()

Read the current raycast position texture.

The position texture for raycast visualization, if configured and ready. Otherwise, null.

SaveScan

async Task SaveScan()

Save the current scan. This stops any further recording immediately, and the coroutine finishes when the saving is fully complete.

Do not disable the component or exit the app when this is in progress. The scan will not be saved correctly if this process is interrupted.

    Returns:

    

DiscardScan

async Task DiscardScan()

Discard the current scan. This stops further recording immediately, and the coroutine finishes when all existing data is deleted.

    Returns:

    

GetCurrentScanId

string GetCurrentScanId()

Returns the current scanID. The result is only present when scan is in progress.

    Returns: