1.0.18 • Published 4 years ago

threejs-raycast-selection v1.0.18

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

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

ParamType
cameraCamera

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

ParamType
mousePosNormalizedVector2

addSelectableObject(object)

Adds an Object3d to the selection system, including all its children meshes

Kind: global function Access: public

ParamType
objectObject3d

removeSelectableObject(object)

Removes an Object3d from the selection system

Kind: global function Access: public

ParamType
objectObject3d
1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago