From 89e5b67a76bcaadf78baa055269bf8c552c584b9 Mon Sep 17 00:00:00 2001 From: Bert Temme Date: Mon, 10 Jun 2024 17:57:30 +0200 Subject: [PATCH] fix yaw, pitch, roll --- src/TileHandler.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/TileHandler.cs b/src/TileHandler.cs index 706d7c5..7143bc0 100644 --- a/src/TileHandler.cs +++ b/src/TileHandler.cs @@ -135,6 +135,8 @@ private static byte[] GetGpuGlb(object model, List 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); @@ -147,12 +149,9 @@ private static byte[] GetGpuGlb(object model, List 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));