Hello everyone.






How To enhance Spatial Mapping Quality


im new to hololens but i made a small app in which i would like to place some controls and elements to a real Object, lets say a telephone. The best thing would be to recognize the phone and attach my stage to the Object. right now im doing that manually but my holograms are not as fixed as i would like. Somehow Holograms in projects like Fragments or RoboGame seem to be glued to walls, they dont move but when i start my app it just dowsnt feel like that. how can i enhance that quality? Prescan? Or would it be a better Idea to skip enhancing and go to recognizing objects and attach everything to it?


  • Making sure your "space" is well scanned helps - and that HoloLens associates itself with the correct space. If you travel around a lot with the same HoloLens and carry a mobile hotspot with you that you connect to, the device can get "confused" at times that it is not finding the correct "space" right away. It typically self-corrects over time.
    You could take more ownership of the state of the spatial mapping in your program code and be more explicit about it, and do a pre-scan indeed.
    But what are the exact symptoms you are seeing?

  • Are you placing the objects using world anchors?

  • Hi, thank you for your fast response and sorry for my late answer, too many projects, not enought time. im not using world ancors. i used the code from the tutorials, which was enough right now.

        using UnityEngine;
        public class TapToPlaceParent : MonoBehaviour
            bool placing = false;
            // Called by GazeGestureManager when the user performs a Select gesture
            void OnSelect()
                // On each Select gesture, toggle whether the user is in placing mode.
                placing = !placing;
                // If the user is in placing mode, display the spatial mapping mesh.
                if (placing)
                    SpatialMapping.Instance.DrawVisualMeshes = true;
                // If the user is not in placing mode, hide the spatial mapping mesh.
                    SpatialMapping.Instance.DrawVisualMeshes = false;
            // Update is called once per frame
            void Update()
                // If the user is in placing mode,
                // update the placement to match the user's gaze.
                if (placing)
                    // Do a raycast into the world that will only hit the Spatial Mapping mesh.
                    var headPosition = Camera.main.transform.position;
                    var gazeDirection = Camera.main.transform.forward;
                    RaycastHit hitInfo;
                    if (Physics.Raycast(headPosition, gazeDirection, out hitInfo,
                        30.0f, SpatialMapping.PhysicsRaycastMask))
                        // Move this object's parent object to
                        // where the raycast hit the Spatial Mapping mesh.
                        this.transform.parent.position = hitInfo.point;
                        // Rotate this object's parent object to face the user.
                        Quaternion toQuat = Camera.main.transform.localRotation;
                        toQuat.x = 0;
                        toQuat.z = 0;
                        this.transform.parent.rotation = toQuat;
Sign In or Register to comment.