Open ondave opened 2 years ago
The angle is not reversed, it is offset by 180 degrees. If the following data is used it is easier to see what is happening.
[
{position: [0, 1, 100000], angle: [0, 0, 0], color: [255, 0, 0]},
{position: [-1, 0, 100000], angle: [0, 90, 0], color: [0, 255, 0]},
{position: [0, 0, 100000], angle: [0, 0, 90], color: [0, 0, 255]}
];
My theory as to why this is happening is due to a different coordinate handedness between the coordinate systems. It is possible to fix this by shifting the yaw
(angle[1]
) angle by 180 degrees.
Due to the way the transform matrix is constructed (and trig identities) it is possible to apply this shift as a modification to the modelMatrix
in the vertex shader:
mat3 modelMatrix = instanceModelMatrix;
if (project_uProjectionMode == PROJECTION_MODE_GLOBE) {
// Globe mode uses opposite handedness, need to shift yaw by 180 to compensate
const vec3 yawShift = vec3(-1.0, -1.0, 1.0);
modelMatrix[0] *= yawShift;
modelMatrix[1] *= yawShift;
modelMatrix[2] *= yawShift;
}
@Pessimistress what do think of this approach?
Description
When using a SimpleMeshLayer, the orientation angle of a mesh model is reversed when in GlobeView.
Mapview
Globeview
Flavors
Expected Behavior
The same rendered angle in both views
Steps to Reproduce
Environment
Logs
No response