Перейти к основному содержанию

Class: Picker

Около 1 мин

Class: Picker

A Tool for manual user picking points on faces and vertices and finding their coordinates and normal.

Constructors

constructor

new Picker(renderManager): Picker

Parameters

NameTypeDescription
renderManagerRenderManagerBaseRenderManagerBase instance.

Returns

Picker

Properties

additionalObjects

additionalObjects: Set<Mesh<BufferGeometry<NormalBufferAttributes>, Material | Material[], Object3DEventMap> | InstancedMesh<BufferGeometry<NormalBufferAttributes>, Material | Material[], InstancedMeshEventMap> | Line<BufferGeometry<NormalBufferAttributes>, Material | Material[], Object3DEventMap>>

Additional objects with picking capability.


hasIntersection

hasIntersection: boolean

Is there a intersection with picking ray and vertex or face.


intersectionType

intersectionType: PickerIntersectionType

The type of active intersection.


isBlockSelection

isBlockSelection: boolean

Whether the selection of elements during picking is locked or not.


rayFaceNormal

rayFaceNormal: Vector3

The normal of the face on which the rayPoint is located.


rayPoint

rayPoint: Vector3

The point on vertex or face from the picking ray.

Methods

dispose

dispose(): void

Destroy picker and release all events.

Returns

void


endPicking

endPicking(isCanceled?): boolean

End picking action.

Parameters

NameTypeDescription
isCanceled?booleanAction result. Will be passed to the callbacks.

Returns

boolean

True if picking has been ended successfully.


onBeforeEnd

onBeforeEnd(callback): this

Add callback for end picking event. Callback stores only for one picking session called by startPicking.

Parameters

NameTypeDescription
callback(isCanceled: boolean) => boolean | voidCallback function. The callback must return true, false, or undefined. If the callback returns false, the "end picking" operation will be aborted and the picker will remain active.

Returns

this


onEnd

onEnd(callback): this

Add callback for end picking event. Callback stores only for one picking session called by startPicking.

Parameters

NameTypeDescription
callback(isCanceled: boolean) => voidCallback function.

Returns

this


onPick

onPick(callback): this

Add callback for 'pick' event. Callback stores only for one picking session called by startPicking. If callback returns false then 'end' event will chanceled.

Parameters

NameTypeDescription
callback(intersectionType: PickerIntersectionType, rayPoint: Vector3, rayFaceNormal: Vector3) => voidCallback function.

Returns

this


setMessage

setMessage(message): this

Set optional message for user during the picking process. The message is active only for one picking session called by startPicking.

Parameters

NameTypeDescription
messagestringHint message.

Returns

this


startPicking

startPicking(blockSelection?, stopAtClick?, snapToPoints?, snapToLines?): Picker

Starts picking action.

Parameters

NameTypeDescription
blockSelection?booleanBlock selection of elements during picking or not.
stopAtClick?booleanStop picking after the first click or continue onward.
snapToPoints?booleanSnap to vertices or on faces.
snapToLines?booleanSnap to vertices on lines.

Returns

Picker

Picker instance if picking started successfully or undefined if not.