only raycast meshes
This commit is contained in:
parent
ac4a8d8c5a
commit
85d25386c7
1 changed files with 15 additions and 6 deletions
|
|
@ -35,6 +35,15 @@ xrf.interactiveGroup = function(THREE,renderer,camera){
|
||||||
// Pointer Events
|
// Pointer Events
|
||||||
const element = renderer.domElement;
|
const element = renderer.domElement;
|
||||||
|
|
||||||
|
const getAllMeshes = (scene) => {
|
||||||
|
let objects = []
|
||||||
|
xrf.scene.traverse( (n) => {
|
||||||
|
if( !n.material || n.type != 'Mesh' ) return
|
||||||
|
objects.push(n)
|
||||||
|
})
|
||||||
|
return objects
|
||||||
|
}
|
||||||
|
|
||||||
function onPointerEvent( event ) {
|
function onPointerEvent( event ) {
|
||||||
|
|
||||||
//event.stopPropagation();
|
//event.stopPropagation();
|
||||||
|
|
@ -46,8 +55,8 @@ xrf.interactiveGroup = function(THREE,renderer,camera){
|
||||||
|
|
||||||
raycaster.setFromCamera( _pointer, camera );
|
raycaster.setFromCamera( _pointer, camera );
|
||||||
|
|
||||||
let objects = scope.raycastAll ? xrf.scene.children : scope.objects
|
let objects = scope.raycastAll ? getAllMeshes(xrf.scene) : scope.objects
|
||||||
const intersects = raycaster.intersectObjects( objects, scope.raycastAll );
|
const intersects = raycaster.intersectObjects( objects, false )
|
||||||
|
|
||||||
if ( intersects.length > 0 ) {
|
if ( intersects.length > 0 ) {
|
||||||
|
|
||||||
|
|
@ -96,14 +105,14 @@ xrf.interactiveGroup = function(THREE,renderer,camera){
|
||||||
raycaster.ray.origin.setFromMatrixPosition( controller.matrixWorld );
|
raycaster.ray.origin.setFromMatrixPosition( controller.matrixWorld );
|
||||||
raycaster.ray.direction.set( 0, 0, - 1 ).applyMatrix4( tempMatrix );
|
raycaster.ray.direction.set( 0, 0, - 1 ).applyMatrix4( tempMatrix );
|
||||||
|
|
||||||
let objects = scope.raycastAll ? xrf.scene.children : scope.objects
|
let objects = scope.raycastAll ? getAllMeshes(xrf.scene) : scope.objects
|
||||||
const intersections = raycaster.intersectObjects( objects, scope.raycastAll );
|
const intersects = raycaster.intersectObjects( objects, false )
|
||||||
|
|
||||||
if ( intersections.length > 0 ) {
|
if ( intersects.length > 0 ) {
|
||||||
|
|
||||||
console.log(object.name)
|
console.log(object.name)
|
||||||
|
|
||||||
const intersection = intersections[ 0 ];
|
const intersection = intersects[ 0 ];
|
||||||
|
|
||||||
object = intersection.object;
|
object = intersection.object;
|
||||||
const uv = intersection.uv;
|
const uv = intersection.uv;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue