Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change orbit point without moving the camera #150

Open
eng-luciano-julien opened this issue Jul 16, 2022 · 5 comments
Open

Change orbit point without moving the camera #150

eng-luciano-julien opened this issue Jul 16, 2022 · 5 comments

Comments

@eng-luciano-julien
Copy link
Contributor

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);
@alfiejfs
Copy link

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?

@eng-luciano-julien
Copy link
Contributor Author

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
Copy link
Contributor Author

eng-luciano-julien commented Sep 3, 2022

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

@howkymike
Copy link

howkymike commented Jan 4, 2023

I also faced the same issue. Thank you @eng-luciano-julien for the solution. Is there any reason (performance?) why this proposed change was not updated in the raycaster.ts file?

@agviegas
Copy link
Collaborator

agviegas commented Jan 4, 2023

@howkymike lack of time! Luckily, from this year we will make a huge leap in the amount of resources available, so hopefully we'll get things done much faster :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants