1.0.18 • Published 5 years ago

threejs-raycast-selection v1.0.18

Weekly downloads
-
License
ISC
Repository
github
Last release
5 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

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago