xBimTeam / XbimWebUI

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

Upgrading from xViewer to Viewer #355

Closed kolmar1991 closed 1 year ago

kolmar1991 commented 3 years ago

Hi! I'm trying to update xbim library in my project. I have a couple minor problems.

  1. New version displays different colours. I was trying to manipulate brightness, gamma and contrast. None of them gave me a result which was in previous version. Are there any others parameters to achieve desired effect?
  2. In old version camera was always focused on a full project. In a new version project is out of camera or camera seems to be in random place. Is there a method to place full project in a camera?
  3. In previous project there was a method setCameraTarget which focused view on particular element. Is there similar method in the newest version in Viewer? I would be very appreciate for help.

New one:

Screenshot 2021-07-03 at 17 44 21

Old one:

Screenshot 2021-07-03 at 17 44 30

Best regards!

martin1cerny commented 3 years ago

Hi @kolmar1991

  1. The new version is using different shader algorithm, which makes the scene more bright. There is not a way to go back to the appearance of the previous generation of the viewer. Looking at your screenshots, I would think that the new one looks better, but that is subjective judgment of course. Do you have any specific use case where you need to maintain exactly the same look?
  2. Just call viewer.zoomTo() and the viewer will zoom to the full extent of the model
  3. This new generation of the viewer is getting a lot more precise position of the used interaction in 3D space and we use that for navigation automatically. So, view is zooming to the pointer and orbiting around the click point. Do you have a specific use case where you would like to set the rotation origin manually? It wouldn't be too hard to put it back.
kolmar1991 commented 3 years ago

Hi Martin, Thank you very much for the response and sorry for my delay.

  1. I understand. I might get used to the old appearance and that's why I'm complaining ;) .
  2. zoomTo() works great, thank you!
  3. It makes sense. It also looks great and I noticed that it is possible to specify not only id but model number which is awesome! However I have a one problem. I'm trying to invoke zoomTo on 'loaded' event this way: this.viewer.on('loaded', event => { this.viewer.zoomTo(74810); }) I'm getting following error: Error: Orthographic view height has to be a positive number at t.set (xbim-viewer.min.bundle.js:1) at Function.t.findView (xbim-viewer.min.bundle.js:1) at t.zoomTo (xbim-viewer.min.bundle.js:1)

If I invoke zoomTo later (e.g. using button) it works perfect. In previous version xViewer it worked fine.

martin1cerny commented 3 years ago

loaded event is probably fired before camera properties are initialised from the model values. I'll try to have a look at it, but it won't be immediate as I have too many other things to do. But it should be an easy one to find and fix. The loaded event is fired here and the exception is being thrown here.

Any contributions are most welcome.

kolmar1991 commented 3 years ago

Thank you Martin. I don't feel a javascript expert however I will try to look at it if I find time in the next weekend.

kolmar1991 commented 3 years ago

Hi @martin1cerny , I wasn't able to fix the issue. However, I was able to find a workaround which might be helpful while looking for a bug. Calling 'viewer.zoomTo()' and then calling 'viewer.zoomTo(4329)' doesn't cause any exception and it zooms the element perfectly.

martin1cerny commented 3 years ago

You may want to set more optional arguments to speed up your initial navigation:

viewer.zoomTo(4329, undefined, false, false);

This will disable animation for the initial navigation and will not try to figure out the best visibility angle for the view. Which is where it fails now, because some values are not properly initialised before the first draw.