【问题标题】:Prevent one shape from being mouse dragged through another THREE.js防止一个形状被鼠标拖过另一个 THREE.js
【发布时间】:2018-06-13 11:39:02
【问题描述】:

当我用鼠标拖动一个对象时,我试图阻止它穿过另一个对象。碰撞检测正在工作,我只需要防止该形状被拖过另一个形状。

setForCollision: function(symbol){

let cube = new THREE.Box3().setFromObject(this.centerCube[1]);//shape is fixed in place
let cube1      = new THREE.Box3().setFromObject(symbol);//dragging with mouse

if(cube1.isIntersectionBox(cube)){
    console.log(shapes touched);
    //I tried repositioning. It repositions it but doesn't really stop me from dragging it. Any suggestions?
    symbol.position.set(0,0,0);


}

【问题讨论】:

    标签: three.js collision-detection


    【解决方案1】:

    显然下面的工作。我只需要稍微调整一下坐标就可以了。

    object.position.set(-7,-10,1);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多