Class ScenePicking

The ScenePicking class exposes high-level functionality for convenient picking and drag-selecting of objects in a camera viewport.

Hierarchy

  • FrameworkObject
    • ScenePicking

Constructors

  • Creates a new scene selection manager.

    Parameters

    • camera: Camera

      Camera into which to render the selection overlay, and perform picking from.

    • gizmoDrawSettings: Immutable<GizmoDrawSettings>

      Settings that control how are pickable gizmos drawn.

    • OptionalisInternalConstructor: boolean

    Returns ScenePicking

Accessors

Methods

  • Begin a drag selection, internally this records the selection when the drag operation starts.

    Parameters

    • initialSelection: SceneObject[]

      The initial selection to start the drag selection with.

    • updateSceneCache: boolean

      True to perform an update of the scene cache, required in most cases.

    • isCacheUpdateBlocking: boolean

      True to perform the update of the scene cache in a blocking manner, this is required when picking begins immediately.

    Returns void

  • End a drag selection, clears internal state set by BeginDragSelection.

    Returns void

  • Try to get cached scene object data at given location.

    Parameters

    • pointerPosition: Immutable<Vector2>

      Pointer position relative to the camera viewport, in pixels.

    • isBlockingCall: boolean

      Perform blocking readback of object MeshData.

    Returns ScenePickInformation

    Information about the scene picking

    The SnapData might not be valid unless the data is already cached. If SnapData is required use getCachedSnapSampleForPosition instead.

  • Try to get cached object data with snapping information at given location.

    Parameters

    • pointerPosition: Immutable<Vector2>

      Pointer position relative to the camera viewport, in pixels.

    • isBlockingCall: boolean

      Perform blocking readback of object MeshData.

    Returns ScenePickInformation

    Information about the scene picking

    Snap samples require an expensive read-back of mesh data, so this method should only be used when snap information is actually required. Otherwise use getCachedSampleForPosition.

  • Get all intersection points between a line and the meshes of a scene object.

    Parameters

    Returns Intersection[]

    All the intersections between the line and the object, if any.

  • Attempts to acquire pick data for the provided pointerPosition.

    Parameters

    • pointerPosition: Immutable<Vector2>

      Position of the pointer relative to the scene camera viewport.

    • ignoreSceneObjects: SceneObject[]

      Optional set of objects to ignore during scene picking.

    • requireSnapData: boolean

      True to require snap data, false to only get object/component info.

    Returns ScenePickInformation

    Information about the the snap.

    This is a slow API that should only be used for single-shot request. For continous requests, it's better to call updateCacheAsync and use getCachedSampleForPosition instead.

    Enabling requireSnapData incurs a significant performance cost as it requires reading back mesh data from the GPU.

  • Attempts to select a scene object under the pointer position.

    Parameters

    • pointerPos: Immutable<Vector2>

      Position of the pointer relative to the scene camera viewport.

    • isAdditive: boolean

      Should this selection add to the existing selection, or replace it.

    • ignoreSceneObjects: SceneObject[]

      Optional set of objects to ignore during scene picking.

    Returns SceneObject

    This is a slow API that should only be used for single-shot request. For continous requests, it's better to call updateCacheAsync and use getCachedSampleForPosition instead.

  • Selects a scene object in the specified area. Rebuilds selection cache if needed.

    Parameters

    • pointerPos: Immutable<Vector2>

      Position of the pointer relative to the scene camera viewport.

    • area: Immutable<Vector2>

      Size of the in which objects will be selected, in pixels and relative to

    • isAdditive: boolean

      Should this selection add and remove to the existing selection, or replace it.

    • addOnly: boolean

      Should this selection only add to the existing selection, when additive is true.

    • ignoreSceneObjects: SceneObject[]

      Optional set of objects to ignore during scene picking.

    • blockingCall: boolean

      Is the function blocking until the results are available.

    Returns SceneObject[]

  • Schedules a blocking update of cache containing object IDs and positions in given camera view.

    Parameters

    • ignoreSceneObjects: SceneObject[]

      A list of objects that should be ignored during scene picking.

    • OptionaldrawGizmos: boolean

      Should gizmos be included.

    • OptionalintersectionRay: Immutable<Ray>

      If specified, only objects that AABB intersect the picking ray will be included in the cache.

    Returns void

    Prefer to use updateCacheAsync instead, unless you specifically need a blocking call.

  • Schedules an asynchronous update of cache containing object IDs and positions in given camera view.

    Parameters

    • OptionalignoreSceneObjects: SceneObject[]

      A list of objects that should be ignored during scene picking.

    • OptionaldrawGizmos: boolean

      Should gizmos be included.

    • OptionalintersectionRay: Immutable<Ray>

      If specified, only objects that AABB intersect the picking ray will be included in the cache.

    Returns void