Interface PickingFeatureAttachmentItem

The PickingFeatureAttachmentItem interface defines a feature result of a pick request.

This interface defines the given feature picked, its closest pick point and the number of pixels inside the selection (always 1). It is included in the PickingAttachment interface of the InfiniteEngineInterfaceSignal.Picked signal event. It is obtained from a InfiniteEngineInterface.pickAt call.

For performance reason, no feature pick is obtained from InfiniteEngineInterface.pickRect or InfiniteEngineInterface.pickFromRay calls.

The FeatureItem object must not be retained by the application, as it is reused as soon as a new feature pick is requested.

/** 
* Sample to illustrate the creation and display of a `feature` from a pick result.
*/
import {
FeatureItem, FeatureManagerInterface, InfiniteEngineInterface, InfiniteEngineInterfaceSignal,
InfiniteEvent, PickingAttachment, PickingFeatureAttachmentItem, Vector3
} from 'generated_files/documentation/appinfiniteapi';

// created previously
let lInfiniteEngine : InfiniteEngineInterface;

// retrieve the `feature` manager
const lFeatureManager : FeatureManagerInterface = lInfiniteEngine.getFeatureManager();

// We pick a rectangle if big enough, else only a point
const startPicking = (pEvent : MouseEvent): void =>
{
// pick the last point
lInfiniteEngine.pickAt(pEvent.offsetX, pEvent.offsetY, false);
};

const lView : HTMLElement | undefined = lInfiniteEngine.getView();
if(lView)
{
// on left click => pick
lView.addEventListener('click', startPicking);
}
else
{
console.log('Cannot register pick since no 3d view is available');
}

// What to do on pick ?
const onPicking = (pEvent : InfiniteEvent, _pCallbackData) : void =>
{
const lAttachment: PickingAttachment = <PickingAttachment>pEvent.attachments;
// care only about 3d geometries (no line, point, box)
const lFeaturesAttachment: PickingFeatureAttachmentItem[] | undefined = lAttachment.features;
if (lFeaturesAttachment === undefined || lFeaturesAttachment.length === 0)
{
return;
}
const lFeature : FeatureItem = lFeaturesAttachment[0].feature;
const lPickedPosition : Vector3 = lFeaturesAttachment[0].position;
console.log('3d picked position is', JSON.stringify(lPickedPosition));
const lFeaturePointApplicationId : number = lFeatureManager.createApplicationFeatureFromFeature(
lFeature
);
if(lFeaturePointApplicationId <= 0)
{
console.log('feature creation failed');
}
};

// and bind the callback on pick result
lInfiniteEngine.addEventListener(InfiniteEngineInterfaceSignal.Picked, onPicking);

Events

interface PickingFeatureAttachmentItem {
    feature: ArcOfCircleFeaturePickResult | LineFeaturePickResult | PointFeaturePickResult | OOBBFeaturePickResult;
    hits: number;
    instanceId: number;
    normal?: Vector3;
    position: Vector3;
}

Hierarchy (view full)

Properties

The feature that was picked.

If instanceId is 0, then the feature is the one of the feature that was created with the application.

If instanceId is not 0, then the feature is an internal feature.

NB: DO NOT keep reference to this object, as this object is reused by the infinite api.

hits: number

The number of pixels which hit the given element (geometry/box/line/point).

In case of single pick, this is 1, this may be more in case of a rectangular pick.

instanceId: number

The geometric instance id / instance id / primitive instance id / annotation id of the picked element (geometry/box/line/point/annotation).

normal?: Vector3

The optional normal of the picked element at the picked point.

The normal is only available in case of a geometric pick and with a single pick or a ray pick.

position: Vector3

The closest 3D position of the picked element.

Indeed, in case of a rectangle pick, multiple pixels may pick the same element (geometry/box/line/point). The position is the one of the closest pixel.