问题
I am placing marker objects on a model using data taken from drone surveys. I have access to high accuracy GPS data and also omega/phi/kappa rotation data.
The goal is to move the viewer camera into position when I select a photo, so that we get a fairly good view of that part of the model from the photo.
So far, we are working with a single model and I want to verify that I'm using the transforms correctly so that this works with other models. Also, I need to match camera orientation using omega/phi/kappa, and I want to know if I also need to transform orientation data.
The model comes from Revit originally.
Here are the various transforms I have found so far using NOP_VIEWER.model.getData()
.
- GlobalOffset (Vector3)
- placementWithOffset (Matrix4) - seems to be just the inverse of GlobalOffset as a matrix?
- placementTransform (Matrix4) - generally undefined, I've seen some hints that this is a user defined matrix.
- refPointTransform (Matrix4)
Also, there are some transforms in the NOP_VIEWER.model.getData().metadata
:
- metadata.georeference.positionLL84 (Array[3]) - this is where the model's GPS coords are stored
- metadata.georeference.refPointLMV (Array[3]) - no idea what this is, and it has huge and seemingly random values on many models. For example, on my current model it is
[-17746143.211481072, -6429345.318822183, 27.360225423452952]
- metadata.[custom values].angleToTrueNorth - I guess this is specifying whether the model is aligned to true or magnetic north?
- metadata.[custom values].refPointTransform - (Array[12]) - data used to create the
refPointTransform
matrix above
I have been able to get the position data into viewer space using these steps:
- Use the
Autodesk.geolocation
extensionlonLatToLmv
function to convert lon/lat/alt to viewer coords. - Take the converted data and apply various transforms until it is correctly positioned in model space.
const gpsPosition = new THREE.Vector3(
longitude,
latitude,
altitude,
);
const position = viewer
.getExtension('Autodesk.Geolocation')
.lonLatToLmv(gpsPosition);
const data = viewer.model.getData();
const globalOffset = data.globalOffset;
const refPointTransform = data.refPointTransform;
const angleToTrueNorth = THREE.Math.degToRad(
data.metadata['custom values'].angleToTrueNorth
);
// applying the transform
position.add(globalOffset)
position.applyMatrix4(refPointTransform);
// finally, rotate the position based on angle to true north.
const quaterion = new THREE.Quaternion().setFromEuler(
new THREE.Euler(0, 0, -angleToTrueNorth),
);
position.applyQuaternion(quaterion);
Questions:
- do I need to apply some transforms to rotation data as well?
- Am I applying the transforms correctly?
EDIT: figured out that the data.refPointTransform
matrix already encodes the angleToTrueNorth
, so I'm clearly doing something wrong in applying that twice.
I don't currently have access to the drone photo data specifying whether they are aligned to true or magnetic north, I assume it's true north though.
回答1:
The geo-positioning params you've discovered are internal and shouldn't be used directly, especially since different input file formats (Revit, IFC, Navisworks, etc) may output this information in different forms. Using the geolocation extension (as you do in your example code) and its method lonLatToLmv
should give you the final lat/long/alt value mapped into the scene coordinate system. If it doesn't, please send us a sample file and the snippet of your code to forge (dot) help (at) autodesk (dot) com
and we will investigate it on our end.
As far as the various xform properties you found:
- globalOffset is sometimes defined on the model when the vertex data of the model is moved close to origin to avoid precision issues
- placementWithOffset is internally computed by applying globalOffset to placementTransform
- placementTransform is an optional parameter that can be passed in when loading a model; the transformation will be applied to all xforms of individual elements in the model
- refPointTransform is another type of metadata that can sometimes be defined on models (typically converted from AEC designs) when globalOffset is not sufficient
来源:https://stackoverflow.com/questions/59907199/place-a-custom-object-into-viewer-space-using-gps-coords