
###############
SnapPointPicker
###############

.. js:class:: cee.SnapPointPicker

   Helper class for implementing Snap-to features in an application
   
   To snap to a point on while checking if the point is visible (not obscured by the model(s)):
   
   .. code-block:: javascript
   
       // Get the ray at mouse position
      const ray = myViewer.rayFromCssCoordinate(myView, event.offsetX, event.offsetY);
      
      // Find the radius to use based on model extent
      const modelBoundingBox = myModel.getBoundingBox();
      const radius = modelBoundingBox.getExtent().getLength()/100;
      let closestPoint = null;
      
      // Snap to point, check if visible
      const snapPointPicker = new cee.SnapPointPicker(myView, ray, radius);
      const pointIndex = snapPointPicker.findClosestPoint(myHotSpots);
      
      if (pointIndex >= 0) {
          closestPoint = new cee.Vec3(myHotSpots[3*pointIndex], 
             myHotSpots[3*pointIndex + 1], myHotSpots[3*pointIndex + 2]);
      }
   
   To just find the closest point to the view, not checking the model if the point is visible:
   
   .. code-block:: javascript
   
      // Snap to closest point, not checking the model
      const pointIndex = cee.RaySphereIntersector.findClosestIntersectedSphereToRay(ray, radius, g.hotSpots);
      
      if (pointIndex >= 0) {
          closestPoint = new cee.Vec3(g.hotSpots[3*pointIndex], 
             g.hotSpots[3*pointIndex + 1], g.hotSpots[3*pointIndex + 2]);
      }
      
   
   
   Index
   =====
   
   .. rubric:: Constructors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~cee.SnapPointPicker.constructor`
   
   .. rubric:: Methods
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:meth:`~cee.SnapPointPicker.findClosestPoint`
   
   



.. rst-class:: kind-group kind-constructors

.. rubric:: Constructors
   :class: kind-group-title


.. js:method:: cee.SnapPointPicker.constructor

      .. rst-class:: sig-pretty-signature
      
         | SnapPointPicker(**view**\ : :js:class:`View <cee.View>`\ , **ray**\ : :js:class:`Ray <cee.Ray>`\ , **radius**\ : *number*\ ): :js:class:`SnapPointPicker <cee.SnapPointPicker>`
      
      **Parameters**
      
      
         **view**\ : :js:class:`View <cee.View>`
      
         **ray**\ : :js:class:`Ray <cee.Ray>`
      
         **radius**\ : *number*
      
      
      **Returns**\ : :js:class:`SnapPointPicker <cee.SnapPointPicker>`
      



.. rst-class:: kind-group kind-methods

.. rubric:: Methods
   :class: kind-group-title


.. js:method:: cee.SnapPointPicker.findClosestPoint

      .. rst-class:: sig-pretty-signature
      
         | findClosestPoint(**pointsArr**\ : *ArrayLike*\ ): *number*
      
      Find the point closest to the ray that is visible (not obscured by the model).
      
      The radius determines the maximum distance from the point in order to snap to it.
      
      The pointsArr array contains a number of points (sphere centers) in a 1d array: <s1.x, s1.y, s1.z, s2.x, s2.y, s2.z> ...
      
      Returns the index of the closest visible point. -1 if there was not hit.
      
      **Parameters**
      
      
         **pointsArr**\ : *ArrayLike*
      
      
      **Returns**\ : *number*
      




