Raycaster intersection distance to mesh wrong sometimes. Three.js 72dev

时间:2015-05-12 22:44:09

标签: three.js distance intersection raycasting

I'm trying to get a distance to intersection of a mesh. The mesh is a imported json loaded with ObjectLoader.

 Component{

        id:delegateimage
        Item{
            id:imageitem
            width:60
          height:70
         Rectangle{
                id:imagerec
                x:24
                y:10
                width: 66
                height:77
                border.color: "#7CC7FF"
                color: "transparent"
                border.width: 3
                radius: 2
                visible:true
                Image{
                    id : img
                    x: 4
                    y: 4
                    height : 69
                    visible: true
                   width : 59
                  function upload(){
                          for(var i = 0; i<fileDialog.fileUrls.length ; i++){
                           mod.append({"fileUrl": fileDialog.fileUrls[i].toString()})
                          img.source = fileDialog.fileUrl
                      }
                        }
  • I got it working, if I shrink the mesh before I export it. ( so I operate with coordinates <2.0.
  • Scaling the mesh gives issues to raycaster ( I updated the scenes matrixWorld. )

So bottom line is. I get the right y distance if the object is super small. If I resize and export it, then the measured distance gets messed up the farther away from center it goes.

http://s000.tinyupload.com/?file_id=51927245638674467144

on the left side the picture grass is near 0,0,0, the distance measured ( y ) is right. Farther away the distance gets wrong. If I shrink the object, everything is in place.

is this a bug perhaps?

1 个答案:

答案 0 :(得分:0)

哦,我在使用Raycaster时犯了一个错误。第二个参数就是方向。我把它设置为0,1,0并且有效。