Skip to content

Commit

Permalink
fix yaw, pitch, roll
Browse files Browse the repository at this point in the history
  • Loading branch information
bertt committed Jun 10, 2024
1 parent 6ec7fd2 commit 89e5b67
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/TileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ private static byte[] GetGpuGlb(object model, List<Instance> positions, bool Use
m4.M13 = forward.X;
m4.M23 = forward.Y;
m4.M33 = forward.Z;

var instanceQuaternion = Quaternion.CreateFromYawPitchRoll((float)p.Yaw, (float)p.Pitch, (float)p.Roll);
var res = Quaternion.CreateFromRotationMatrix(m4);

var position = new Vector3((float)p1.X, (float)p1.Y, (float)p1.Z);
Expand All @@ -147,12 +149,9 @@ private static byte[] GetGpuGlb(object model, List<Instance> positions, bool Use

var position2 = position - translation;

// todo: use quaternion for yaw/pitch/roll
// var quaternion = Quaternion.CreateFromYawPitchRoll((float)p.Yaw, (float)p.Pitch, (float)p.Roll);

var transformation = new AffineTransform(
scale,
new Quaternion(-res.X, -res.Z, res.Y, res.W),
new Quaternion(-res.X, -res.Z, res.Y, res.W) * instanceQuaternion,
position2);
var json = "{\"_FEATURE_ID_0\":" + pointId + "}";
sceneBuilder.AddRigidMesh(meshBuilder, transformation).WithExtras(JsonNode.Parse(json));
Expand Down

0 comments on commit 89e5b67

Please sign in to comment.