web-ifc-viewer
web-ifc-viewer copied to clipboard
Change orbit point without moving the camera
Hi, I am trying to change the orbit point without moving the camera. With the following code it change correctly my orbit point but it messed functionalities like prePickIfcItem. The pre-selected item is near my mouse but not the correct one. Any ideia how to solve it?
const center = viewer.context.getCenter(mesh);
viewer.context.ifcCamera.cameraControls.setOrbitPoint(center.x, center.y, center.z);
We had a similar issue, but we opted to use setTargetinstead of setOrbitPoint, which isn't entirely the same but worked for what we wanted - does it work for you?
Hi @alfiejfs,
Sorry to take time to answer I was traveling.
The setTarget don't zoom but still moves the camera. The setOrbitPoint would be perfect if we solve the problem of prepickitem. The problem occur with prepickitem but not with pickitem. Maybe in some part the mouse position is not updated before used for raycasting.
I found a solution. Using updateMatrixWorld() before the raycast solves the bug.
function castRay(items) {
const camera = this.context.getCamera();
camera.updateMatrixWorld();
this.raycaster.setFromCamera(this.context.mouse.position, camera);
return this.raycaster.intersectObjects(items);
}