web-ifc-viewer icon indicating copy to clipboard operation
web-ifc-viewer copied to clipboard

Change orbit point without moving the camera

Open eng-luciano-julien opened this issue 3 years ago • 5 comments

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);

eng-luciano-julien avatar Jul 16 '22 13:07 eng-luciano-julien

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?

alfiejfs avatar Aug 17 '22 14:08 alfiejfs

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.

eng-luciano-julien avatar Sep 01 '22 18:09 eng-luciano-julien

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);
}

eng-luciano-julien avatar Sep 03 '22 16:09 eng-luciano-julien