PickObject

initObjectPicking(callback, eventType, mouseDownUseTouchStartopt, allowedMouseButtonsopt)

Bind object picking functionality to the given mouse event, e.g. "mousemove", "mousedown", "dblclick". An additional listener for a touch event ("touchstart" or "touchend") is also registered.
Parameters:
Name Type Attributes Default Description
callback pickObjectCallback A callback function receiving the results of object picking.
eventType string The type of a MouseEvent, e.g. "mousemove", "mousedown", "dblclick".
mouseDownUseTouchStart boolean <optional>
false Use the "touchstart" (if true) or the "touchend" (if false) touch event for object picking for touch devices.
allowedMouseButtons Array.<number> <optional>
null The array representing mouse buttons allowed to trigger object picking. 0 - left mouse button, 1 - middle mouse button, 2 - right mouse button. "null" (by default) means that object picking will be triggered regardless of any mouse buttons pressed (useful for events that don't require button pressing, e.g. "mousemove"). [0, 1, 2] means that a mouse event caused by pressing any of those buttons will trigger object picking (useful for filtering out unwanted actions, e.g. usually clicking with the middle/right mouse buttons).

pickObjectCallback(intersects, event)

A function to use as a callback for the initObjectPicking function. It's supposed to handle the results of object picking.
Parameters:
Name Type Description
intersects Array.<Object> The array containing the results of object picking in the form of intersection data from raycasting. Has the same format as the result of the v3d.Raycaster's intersectObjects() method.
event MouseEvent | TouchEvent The event that was used for object picking.