Getting real world coordinates from Forge model - autodesk-forge

Is it possible to get the real world coordinates form the original model in the Forge viewer? It looks like when a model is loaded into the Viewer it is placed with the center of the model in the origin of the Viewer.

viewer.model.getData().globalOffset is what you are looking for:
Aligning Coordinate Systems in Autodesk Forge Viewer

Afaik, the Forge viewer centres the model. In other words, the origin of the viewer coordinate system is the centroid of the model. The scale of the model remains unchanged. As a result, you can transform the original model coordinates to Forge viewer and vice versa simply by adding or subtracting the model centroid.

Related

How do I convert between 2D paper space coordinates world 3D coordinates for AEC models in a forge viewer?

I'm following a blog post by Petr Broz with my published views from a Revit project in BIM 360, but I was wondering how I would convert between 2D coordinates and 3D world coordinates if my published 2D view is actually just a stand-alone floor plan view without being placed on any sheet.
I was trying to get the viewport but I realized the published view doesn't have any viewport in the model. So I cannot actually use those functions in the extension for viewports. Any advise would be greatly appreciated.
Unfortunately, it doesn't support floor plan view without placing the sheet, since there is some required information missing at this moment. We are still discussing this with our engineering team.
The current working path is creating a Revit Sheet view and placing the floor plan inside, see https://www.youtube.com/watch?v=smMap86YZUY
My mistake was manually trying to convert x,y,z coordinates by dividing them with the viewport scale, thus they couldn't align with 3D world coordinates.
By providing the correct model unitscale, I could get the transform with get3DTo2DMatrix().
viewport = viewportExt.getViewports(viewer.model)[0];
viewportXform viewport.get3DTo2DMatrix(viewer.model.getUnitScale());
// From foot to millimeters
x = x* 0.00328084;
y = y* 0.00328084;
z = z* 0.00328084;
var worldPt = new THREE.Vector3(x,y,z);
worldPt.applyMatrix4(viewportXform);

How to find out the location of x,y,z from every corner of the building?

Is there a method from Autodesk Forge to find out the location of each point from the corner of the building like the picture I attached?
In the context of Forge Model Derivative & Viewer, the geometries have been translated to mesh (triangles). It does not contain the information of face/edge, which means it does not tell which is corner of the shape. you may have to calculate which is the furthest vertex. This is a blog about how to get vertex
https://forge.autodesk.com/blog/show-mesh-triangles-data-hittest

How to add hotspot sphere in Autodesk Forge Viewer?

I want to add hotspot sphere to a 3D .nwd model which has to be viewed in Autodesk Forge Viewer. Please suggest how hotspot can be added to .nwd naviseworks file.
There are a couple of ways to add hotspots to a model in Forge Viewer:
by adding custom "point clouds" into the scene: https://forge.autodesk.com/blog/3d-markup-icons-and-info-card
by adding custom 3D geometry: https://forge.autodesk.com/en/docs/viewer/v7/developers_guide/advanced_options/custom-geometry/
by overlaying the 3D viewport with HTML elements; the Forge Digital Twin sample code shows how you can compute 2D positions from Forge model coordinates, specifically in the IssueExtension

Forge viewer model revit position

I'm loading multiple models into the viewer but the didn't keep their revit position. Is there a way to load a model at it revit position and rotation ?
Eason Kang solution did the job.
To align the model in their Revit position use globalOffset Property when you load the model inside the viewer.

Aligning Coordinate Systems in Autodesk Forge Viewer

I would like to display some reference lines in the viewer that are not shown by default when a drawing is uploaded to Forge.
I know the exact end points of the lines as they were defined in the model, however, it seems that the model in the viewer is translated so that 0,0 is in the center of the bounds.
Is there a way to get the transformation matrix that was applied to the model, so I can align the coordinates of my reference lines with the coordinates of the model in the viewer?
Use viewer.model.getData().globalOffset