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;
// properties
string ScanPath;
bool FullResolutionEnabled;
string ScanTargetId;
int ScanRecordingFramerate;
bool EnableRaycastVisualization;
bool EnableVoxelVisualization;
bool UseEstimatedDepth;
// 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.
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.
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 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 and VoxelColors 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.
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: