Three.js raycast produces empty intersects array

前端 未结 1 1217
青春惊慌失措
青春惊慌失措 2021-02-11 01:10

I\'m trying to detect when the user has clicked on a specific cube in my 3d scene I\'ve seen a few similar questions but none seem to have quite the same problem as me.

相关标签:
1条回答
  • 2021-02-11 01:45

    You need to pass in a single array of objects into

    var intersects = raycaster.intersectObjects( objects );
    

    If the objects array is hierarchal (i.e., one of the objects has a child), then you need to specify it this way:

    var intersects = raycaster.intersectObjects( objects, true );
    

    You can also pass in scene.children.

    This function will not work with your "cubes" data structure.

    three.js r.54

    0 讨论(0)
提交回复
热议问题