0
我使用three.js。要在我的場景中移動,我正在使用軌道控制並選擇我使用raycaster的對象。 Raycaster是通過點擊發送的,以及軌道控制。所以如果選擇一個對象,並且在鼠標釋放時移動相機,另一個對象將被選中。有沒有辦法在軌道控制中檢查相機的移動。three.js軌道控制與raycaster
或者什麼是防止不需要的選擇的常用方法?
這是我的選擇處理程序:
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