Interface for Entity3Ds or Object3Ds implementing feature picking.
Implementing this enables the object to provide additional data on its picked results via Instance.pickObjectsAt() with pickFeatures option.
pickFeatures
This interface uses several generic types:
TFeature
TResult
pickAt
TOptions
In case you are using a different type for TResult, you might want to also implement Pickable.
export interface PlyFeature { color: Color}export class MyMesh extends Mesh implements PickableFeatures<MyFeature> { public readonly isPickableFeatures = true; pickFeaturesFrom(pickedResult: PickResult<MyFeature>): MyFeature[] { if (this.geometry.hasAttribute('color') && pickedResult.face) { const colors = this.geometry.getAttribute('color').array; const face = pickedResult.face; const color = new Color( colors[face.a * 3], colors[face.a * 3 + 1], colors[face.a * 3 + 2] ); const result = [{ color }]; pickedResult.features = result; return result; } return []; }} Copy
export interface PlyFeature { color: Color}export class MyMesh extends Mesh implements PickableFeatures<MyFeature> { public readonly isPickableFeatures = true; pickFeaturesFrom(pickedResult: PickResult<MyFeature>): MyFeature[] { if (this.geometry.hasAttribute('color') && pickedResult.face) { const colors = this.geometry.getAttribute('color').array; const face = pickedResult.face; const color = new Color( colors[face.a * 3], colors[face.a * 3 + 1], colors[face.a * 3 + 2] ); const result = [{ color }]; pickedResult.features = result; return result; } return []; }}
export interface IFCFeature { ifcProperties: IFCProperty[],}export interface IFCPickResult extends PickResult<IFCFeature> { isIFCPickResult: true; entity: IfcEntity, object: FragmentMesh, features?: IFCFeature[];}export class IfcEntityextends Entity3Dimplements Pickable<IFCPickResult>, PickableFeatures<IFCFeature, IFCPickResult> { readonly isIfcEntity = true; readonly isPickableFeatures = true; pick(canvasCoords: Vector2, options?: PickObjectsAtOptions): IFCPickResult[] { return super.pick(canvasCoords, options).map((p) => ({ ...p, entity: this, object: p.object as FragmentMesh, isIFCPickResult: true, })); } pickFeaturesFrom(pickedResult: IFCPickResult): IFCFeature[] { const mesh = pickedResult.object; if (mesh.fragment && pickedResult.instanceId != undefined && pickedResult.face) { ... const result = [{ itemProperties }]; pickedResult.features = result; return result; } return []; }} Copy
export interface IFCFeature { ifcProperties: IFCProperty[],}export interface IFCPickResult extends PickResult<IFCFeature> { isIFCPickResult: true; entity: IfcEntity, object: FragmentMesh, features?: IFCFeature[];}export class IfcEntityextends Entity3Dimplements Pickable<IFCPickResult>, PickableFeatures<IFCFeature, IFCPickResult> { readonly isIfcEntity = true; readonly isPickableFeatures = true; pick(canvasCoords: Vector2, options?: PickObjectsAtOptions): IFCPickResult[] { return super.pick(canvasCoords, options).map((p) => ({ ...p, entity: this, object: p.object as FragmentMesh, isIFCPickResult: true, })); } pickFeaturesFrom(pickedResult: IFCPickResult): IFCFeature[] { const mesh = pickedResult.object; if (mesh.fragment && pickedResult.instanceId != undefined && pickedResult.face) { ... const result = [{ itemProperties }]; pickedResult.features = result; return result; } return []; }}
Readonly
Given a PickResult, returns and assigns its features.
Implementations must set pickedResult.features to the returned result.
pickedResult.features
Picked result
Optional
Options
Features
Interface for Entity3Ds or Object3Ds implementing feature picking.
Implementing this enables the object to provide additional data on its picked results via Instance.pickObjectsAt() with
pickFeatures
option.This interface uses several generic types:
TFeature
represents the type of additional data on picked results,TResult
represents the type of results returned via picking withpickAt
,TOptions
can define additional options for picking directly on this entity or on its features.In case you are using a different type for
TResult
, you might want to also implement Pickable.