0
私はthree.jsを使用しています。私のシーンで移動するには、軌道制御を使用していて、私はレイキャスターを使用しているオブジェクトを選択しています。 Raycasterは、クリックだけでなく、軌道制御で送信されます。したがって、オブジェクトが選択され、マウスリリース時にカメラを動かすと、別のオブジェクトが選択されます。軌道制御でカメラの動きを確認する方法はありますか?raycasterとthree.js軌道制御
や不要な選択を防止するための一般的な方法は何ですか?
function onMouseClick(event) {
// calculate mouse position in normalized device coordinates
// (-1 to +1) for both components
mouse.x = (event.clientX/canvasWidth) * 2 - 1;
mouse.y = - (event.clientY/window.innerHeight) * 2 + 1;
// update the picking ray with the camera and mouse position
raycaster.setFromCamera(mouse, camera);
// calculate objects intersecting the picking ray
var intersects = raycaster.intersectObjects(CentroLite.children, true);
if (intersects.length === 0){
intersects = raycaster.intersectObjects(millingTable.children, true);
}
SELECTED = intersects[0].object;
// DO SOMETHING
}
おかげ
私は正しく理解しています。左クリックでオブジェクトを選択し、左クリックでカメラを移動します。そうですか? –
はいそうです。私はマウスのリリースとマウスのリリースの間のカメラの変更を確認することができます。これは、マウスのリリース時に選択がトリガーされるためですが、軌道コントロール内のメソッドを期待していたためです。 – tinytree