threejs-raycast-selection v1.0.18
threejs-raycast-selection
Very simple package to get a threejs element from a raycast
Quick Start
import { Selection } from 'threejs-raycast-selection';
let selection = new Selection(camera);
selection.addSelectableObject(object);
let selectedElementData = selection.selectElement(mousePosNormalized);
let selectedMesh = selectedElementData.selectedElement;
let selectedMeshParent = selectedElementData.parent;
let raycastHitPoint = selectedElementData.intersectionPoint;
//Or
selection.subscribe('elementSelected', (params) => { this.elementSelected(params); });
params
{
selectedElement,
parent,
intersectionPoint
}
Classes
Functions
Selection
Kind: global class Version: 1 Author: jon
constructor(camera)
Creates an instance of Selection.
Kind: global function Access: public
Param | Type |
---|---|
camera | Camera |
selectElement(mousePosNormalized) ⇒ Object
Returns the element with the lowest userData.selectionIndex value in the intersections from a raycast
Kind: global function Returns: Object - The selected mesh, it's parent and the raycastHit point Access: public
Param | Type |
---|---|
mousePosNormalized | Vector2 |
addSelectableObject(object)
Adds an Object3d to the selection system, including all its children meshes
Kind: global function Access: public
Param | Type |
---|---|
object | Object3d |
removeSelectableObject(object)
Removes an Object3d from the selection system
Kind: global function Access: public
Param | Type |
---|---|
object | Object3d |
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago