Rockernaap
Rockernaap

Reputation: 143

Forge viewer: Zoom in on a asset inside a room (front of the asset)

I am using the JS forge viewer.

I am trying to select a asset in a building and then zoom in on it with the camera inside the room where the asset is. I am trying to use

let boundingBox = this.viewer.utilities.getBoundingBox(false); this.viewer.navigation.fitBounds(false, boundingBox, true);

But this will zoom in but not the right direction (from outside to be precise) enter image description here

Is it possible to automaticly detect the front of a asset, rotate the camera to this and then zoom in?

Upvotes: 0

Views: 569

Answers (1)

Eason Kang
Eason Kang

Reputation: 7070

Apologizing for a long waiting. It has been confirmed by the dev team, Revit room won't be translated in the translation procedure of the Model Derivative service. Therefore, room related functions or APIs will not supported by the Forge Viewer currently.

Besides, we found your API request, zoom in on a asset inside a room, would only appropriate for the BIM app developed with the Forge tech., and there might be many different kinds of use case based on this request. So, it's hard to design a general function or API for your request in the Forge Viewer. Therefore, it might be not supported in the future releases of the Forge Viewer.

However, we encourage developers like you to implement this feature by yourself, and here is a workaround for you:

  1. Open your Revit project with room elements only via the Navisworks, and upload to Forge for translation, use this result as the secondary model of your viewer app as well. [Here is some info. about the room from my colleague (link)].
  2. Convert fragments of the selected asset in your app into a pure THREE.Geometry. [Here is a example to access mesh info. of the Forge Viewer (link)].
  3. Compute BoundingSphere of the THREE.Geometry from the step. 2, and treat the sphere center as the central point of the selected asset.
  4. Do Three.js raytracing with room geometries from the BoundingSphere center to find some rays without any obstruction between the camera and the selected asset. [Here is a example that shows how to use Three.js raytracing with the Forge Viewer (link)].
  5. Treat rays got from the step. 4 as the sight lines.
  6. Pick a desired sight line from the step. 5 to re-calculate position, target and pivot of the camera.


P.S. Since this is just a workaround, not the formal solution. You would have to use it on your own risk.

Upvotes: 1

Related Questions