I was looking for a convenient way to create a sprite using the camera position while walking in the Viewer.
I used this to get camera position.
const pos = NOP_VIEWER.navigation.getPosition(); //save current camera position
Then put (X,Y,Z) to styledefinition => and create Sprite.
But the coordinate from camera position and the coordinate of DataVisualization Extension use to create Sprite not same.
How can I convert them to the same coordinate ?
Related
I want to find a 3D position coordinates (X, Y, Z) of a moving object.
I have a training set of pictures (frames from video) with a known ground truth XYZ position of an object.
The goal is to detect the object in the the input video and draw overlay with bounding edges and XYZ coordinates in real time 30fps.
Video stream is captured from a single fixed camera. Camera axis are not aligned with a world coordinate system (it's tilted and rotated). There will be maximum one object in a frame.
Is there existing models that can do it? Where can i start from?
We have a web application where we let the users draw SVG shapes on top of the Autodesk Viewer. We can translate the on-screen coordinates to the drawing using the worldToClient and the clientToWorld functions and it works beautifully, the shapes scale and move around with the drawing.
We also let the users update update the drawing by uploading new versions of it, and this has turned into a problem where the center coordinate (0,0) will change when the drawing has changed. That means that the SVG shapes will have the wrong positions when used with the new version of the drawing. It seems to me like somewhere in the translation the original positions of the .dwg files are ignored and a new center coordinate is computed from the content.
Our current workaround is for the users to draw a square frame around the drawings that they wish to use in this way. If all changes happen within that square the center will not move with new versions.
Does anyone have any thoughts, ideas, or experiences on how to solve this without the users needing to edit the drawings?
When using viewer.clientToWorld and viewer.worldToClient with 2D drawings, the "world" typically means page dimensions. In your case, the two DXF files you provided had the same page dimensions, and the content in each DXF file was scaled to fit the entire page. That's why the "world" coordinates between the two DXF files didn't match.
Luckily, when converting DXF files, the Forge Model Derivative service also exports the "source to logical" transformation which I believe defines the conversion from the original coordinates to the page coordinates. When you compute the inverse of that transformation, you should be able to convert from page coordinates back to the source coordinates, and those are the ones you should store with your markups. The conversion into the source coordinates might look something like this:
const res = viewer.clientToWorld(ev.clientX, ev.clientY);
if (res && res.point) {
console.log('page coords', res.point);
const sourceToLogicalXform = viewer.model.getData().metadata?.page_dimensions?.source_to_logical_xform;
if (sourceToLogicalXform) {
const sourceToLogical = new THREE.Matrix4().fromArray(sourceToLogicalXform).transpose();
const logicalToSource = new THREE.Matrix4().getInverse(sourceToLogical);
console.log('source coords', res.point.clone().applyMatrix4(logicalToSource));
}
}
I want to snapp points in the model and retrieve their coordinates. I found the below code in Forge blog
this.points = [];
const result = this.snapper.getSnapResult();
const { SnapType } = Autodesk.Viewing.MeasureCommon;
switch (result.geomType) {
case SnapType.SNAP_VERTEX:
case SnapType.SNAP_MIDPOINT:
case SnapType.SNAP_INTERSECTION:
this.points.push(result.getGeometry());
Now Im able to get the coordinates of vertex and midpoints, but I want to actully get the coordinates of any snapped point of a Brep-line for instance. How is this possible ?
You're probably referring to this blog post, right? The SnapType enumeration used in the blog lists all the types of snapping types the tool can detect. Other types you would probably have to detect yourself, for example, by shooting a ray to the scene based on the camera position and mouse cursor position, and finding whatever object of interest are nearby.
I have a THREE.Vector3 with location x, y, z of a mesh in the viewer. How can I get a corresponding 2D point on canvas? I would like to place something x, y at the same location where the 3D model is located in the viewer.
Check the worldToClient(point) method (part of Autodesk.Viewing.Viewer3D), the point parameters is a THREE.Vector3 point in world space coordinates. Below is a piece of the documentation.
Calculates the pixel position in client space coordinates of a point
in world space. See also clientToWorld().
I have a sprite which helps the user draw a custom shape? i want to tile the surface how can that be achieved?
Use EarCutting for Triangulation.
Convert your 2D points to 3D points for(Away3D).
Use the points to build custom Mesh.
Bingo!!
> The tricky part is to calculate the UV for the texture