Class MLSpatialMapper
Monobehaviour representing the Magic Leap Spatial mapper
Inherited Members
Namespace: UnityEngine .XR.MagicLeap
Assembly: UnityEngine.XR.MagicLeap.dll
Syntax
[AddComponentMenu("AR/Magic Leap/ML Spatial Mapper")]
[DisallowMultipleComponent]
public sealed class MLSpatialMapper : MonoBehaviour
Properties
batchSize
How many meshes to update per batch. Larger values are more efficient, but have higher latency.
Declaration
public int batchSize { get; set; }
Property Value
Type | Description |
---|---|
int |
computeNormals
When enabled, the system will compute the normals for the triangle vertices.
Declaration
public bool computeNormals { get; set; }
Property Value
Type | Description |
---|---|
bool |
currentMeshType
The current mesh type being surfaced by the subsystem provider.
Declaration
public MLSpatialMapper.MeshType currentMeshType { get; }
Property Value
Type | Description |
---|---|
MLSpatial |
density
Getter/Setter for the density property
Declaration
public float density { get; set; }
Property Value
Type | Description |
---|---|
float |
disconnectedComponentArea
Any component that is disconnected from the main mesh and which has an area less than this size will be removed.
Declaration
public float disconnectedComponentArea { get; set; }
Property Value
Type | Description |
---|---|
float |
fillHoleLength
Boundary distance (in meters) of holes you wish to have filled.
Declaration
public float fillHoleLength { get; set; }
Property Value
Type | Description |
---|---|
float |
levelOfDetail
TODO: Remove as this is no longer valid
Declaration
[Obsolete("Replaced by density")]
public MLSpatialMapper.LevelOfDetail levelOfDetail { get; set; }
Property Value
Type | Description |
---|---|
MLSpatial |
meshIdToGameObjectMap
A Dictionary
which maps mesh ids to their GameObject
s.
Declaration
public Dictionary<MeshId, GameObject> meshIdToGameObjectMap { get; }
Property Value
Type | Description |
---|---|
Dictionary<Mesh |
meshParent
The parent transform for generated meshes.
Declaration
public Transform meshParent { get; set; }
Property Value
Type | Description |
---|---|
Transform |
meshPrefab
Get or set the prefab which should be instantiated to create individual mesh instances. May have a mesh renderer and an optional mesh collider for physics.
Declaration
public GameObject meshPrefab { get; set; }
Property Value
Type | Description |
---|---|
Game |
meshQueueSize
Controls the number of meshes to queue for generation at once. Larger numbers will lead to higher CPU usage.
Declaration
public uint meshQueueSize { get; set; }
Property Value
Type | Description |
---|---|
uint |
meshType
Whether to generate a triangle mesh or point cloud points. TODO: Remove this method
Declaration
[Obsolete("Replaced by requestedMeshType and currentMeshType")]
public MLSpatialMapper.MeshType meshType { get; set; }
Property Value
Type | Description |
---|---|
MLSpatial |
planarize
When enabled, the system will planarize the returned mesh (planar regions will be smoothed out).
Declaration
public bool planarize { get; set; }
Property Value
Type | Description |
---|---|
bool |
pollingRate
How often to check for updates, in seconds. More frequent updates will increase CPU usage.
Declaration
public float pollingRate { get; set; }
Property Value
Type | Description |
---|---|
float |
removeMeshSkirt
When enabled, the mesh skirt (overlapping area between two mesh blocks) will be removed. This field is only valid when the Mesh Type is Blocks.
Declaration
public bool removeMeshSkirt { get; set; }
Property Value
Type | Description |
---|---|
bool |
requestVertexConfidence
When enabled, the system will generate confidence values for each vertex, ranging from 0-1.
Declaration
public bool requestVertexConfidence { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
requestedMeshType
Request Magic Leap to generate a triangle mesh or point cloud points.
Declaration
public MLSpatialMapper.MeshType requestedMeshType { get; set; }
Property Value
Type | Description |
---|---|
MLSpatial |
Methods
DensityToLevelOfDetail(float)
Step the Level of detail to Minimum, Medium and Maximum
Declaration
public static MLSpatialMapper.LevelOfDetail DensityToLevelOfDetail(float density)
Parameters
Type | Name | Description |
---|---|---|
float | density | float input value |
Returns
Type | Description |
---|---|
MLSpatial |
DestroyAllMeshes()
Destroy all mesh GameObject
s created by this MLSpatial
Declaration
public void DestroyAllMeshes()
LevelOfDetailToDensity(LevelOfDetail)
Convert a LevelOfDetail to a float, ranged between 0 and 1
Declaration
public static float LevelOfDetailToDensity(MLSpatialMapper.LevelOfDetail lod)
Parameters
Type | Name | Description |
---|---|---|
MLSpatial |
lod | Level of detail |
Returns
Type | Description |
---|---|
float | Float value between 0 and 1 |
RefreshAllMeshes()
'Refresh' all known meshes (meshes that are in mesh
Declaration
public void RefreshAllMeshes()
RefreshMesh(MeshId)
'Refresh' a single mesh. This forces the mesh to be regenerated with the current settings.
Declaration
public void RefreshMesh(MeshId meshId)
Parameters
Type | Name | Description |
---|---|---|
Mesh |
meshId | The |
TryGetConfidence(MeshId, List<float>)
Retrieve the confidence values associated with a mesh. Confidence values
range from 0..1. request
Declaration
public bool TryGetConfidence(MeshId meshId, List<float> confidenceOut)
Parameters
Type | Name | Description |
---|---|---|
Mesh |
meshId | The unique |
List<float> | confidenceOut | A |
Returns
Type | Description |
---|---|
bool | True if confidence values were successfully retrieved for the mesh with id |
See Also
Events
meshAdded
An event which is invoked whenever a new mesh is added
Declaration
public event Action<MeshId> meshAdded
Event Type
meshRemoved
An event which is invoked whenever an existing mesh is removed.
Declaration
public event Action<MeshId> meshRemoved
Event Type
meshUpdated
An event which is invoked whenever an existing mesh is updated (regenerated).
Declaration
public event Action<MeshId> meshUpdated