Three.js - how to detect what shape was selected? after drag

前端 未结 1 1165
礼貌的吻别
礼貌的吻别 2020-12-06 03:37

I made a canvas with shapes in it...the shapes are draggable. Everything seems to work fine...But now I\'m trying to figure out how can I detect what shape was selected/drag

1条回答
  •  -上瘾入骨i
    2020-12-06 04:05

    I found pretty simple solution...but I guess that's the way it always works :-) All you have to do for the detection is 2 things: First of all add another variable: var thisObject; After that you have to go to the onMouseDown() function. Right after the SELECTED = intersects[0].object; you have to write this thing:

     for(var i=0; i

    ...Now thisObject holds the index of the current shape (that was selected/dragged) in objects array...yeah that simple :-)

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