最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Threejs ray cast get coordinate of intersection - Stack Overflow

programmeradmin0浏览0评论

So, I have a plane, and I got raycast set up. What I want to do is get the coordinate of the intersection on the plane, thanks.

(Note: the color change is just to test if the raycast was actually working.)

Here is my code :

      raycaster.setFromCamera( mouse, camera );

      //calculate objects intersecting the picking ray
      var intersects = raycaster.intersectObjects( scene.children );

      for ( var i = 0; i < intersects.length; i++ ) {

        intersects[ i ].object.material.color.set( 0xff0000 );

      }

Cheers, Keegan.

So, I have a plane, and I got raycast set up. What I want to do is get the coordinate of the intersection on the plane, thanks.

(Note: the color change is just to test if the raycast was actually working.)

Here is my code :

      raycaster.setFromCamera( mouse, camera );

      //calculate objects intersecting the picking ray
      var intersects = raycaster.intersectObjects( scene.children );

      for ( var i = 0; i < intersects.length; i++ ) {

        intersects[ i ].object.material.color.set( 0xff0000 );

      }

Cheers, Keegan.

Share Improve this question edited Sep 23, 2015 at 2:06 WestLangley 105k11 gold badges287 silver badges283 bronze badges asked Sep 23, 2015 at 1:46 keearixkeearix 331 silver badge4 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

When using Raycaster, the value intersects[ i ].point is a Vector3() representing the world coordinates of the point of intersection.

Inspect intersects[ i ] in the console to see what else is returned.

three.js r.72

发布评论

评论列表(0)

  1. 暂无评论