当我用鼠标拖动它时,我正试图阻止一个物体穿过另一个物体。碰撞检测工作正常,我只需要防止形状被拖过其他形状。
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);
}
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);
}
答案 0 :(得分:0)
显然以下是有效的。我只需稍微调整一下坐标就可以正常工作了。
object.position.set(-7,-10,1);