xBimTeam / XbimWebUI

Web components for xBIM Toolkit
http://xbimteam.github.io/XbimWebUI/
Other
202 stars 121 forks source link

[Question] I need to zoom back to previous state #454

Closed cuong-nguyen closed 3 months ago

cuong-nguyen commented 3 months ago

Hi, I am new to the library and not sure what to do. I have a model which contains building (with doors, windows,...) I want to be able to select any of them and then zoom in on them which I can achieve. But now I need to go back to previous state before zooming (on a button clicked). Can you share how would I do that?

Before zoom

Screenshot 2024-07-22 at 17 24 54

After zoom (click on yellow part above)

Screenshot 2024-07-22 at 17 25 27

Thanks.

andyward commented 3 months ago

You should check out Viewpoint.GetViewpoint() and Viewpoint.SetViewpoint() as documented here. There's a working example here

Essentially this creates a BCF representation of the current state of model, which can be used to restore the viewer state later. As it's just a JSON structure you can store the viewpoint however you like before recalling it.

cuong-nguyen commented 3 months ago

Thank you for a quick reply. I should have mentioned that I am still on the xViewer not the latest Viewer (I have to maintain the app) and Viewpoint does not exist. Is it possible to achieve same thing with xViewer?

andyward commented 3 months ago

You should just be able to store and recall the matrix/camera settings to achieve something similar. I think they were called mvMatrix and pMatrix on the xViewer

cuong-nguyen commented 3 months ago

You should just be able to store and recall the matrix/camera settings to achieve something similar. I think they were called mvMatrix and pMatrix on the xViewer

Appreciate it. I will give it a try.