diff semiconginev2/gltf.nim @ 1253:c4f98eb4bb05

fix: a few things
author sam <sam@basx.dev>
date Fri, 26 Jul 2024 23:39:24 +0700
parents 01e9f41d35b1
children b0f4c8ccd49a
line wrap: on
line diff
--- a/semiconginev2/gltf.nim	Fri Jul 26 23:04:01 2024 +0700
+++ b/semiconginev2/gltf.nim	Fri Jul 26 23:39:24 2024 +0700
@@ -233,31 +233,32 @@
   if "matrix" in node:
     for i in 0 ..< node["matrix"].len:
       result.transform[i] = node["matrix"][i].getFloat()
+    result.transform = result.transform.Transposed()
+  else:
+    var (t, r, s) = (Unit4, Unit4, Unit4)
+    if "translation" in node:
+      t = Translate(
+        float32(node["translation"][0].getFloat()),
+        float32(node["translation"][1].getFloat()),
+        float32(node["translation"][2].getFloat())
+      )
+    if "rotation" in node:
+      t = Rotate(
+        float32(node["rotation"][3].getFloat()),
+        NewVec3f(
+          float32(node["rotation"][0].getFloat()),
+          float32(node["rotation"][1].getFloat()),
+          float32(node["rotation"][2].getFloat())
+        )
+      )
+    if "scale" in node:
+      t = Scale(
+        float32(node["scale"][0].getFloat()),
+        float32(node["scale"][1].getFloat()),
+        float32(node["scale"][2].getFloat())
+      )
 
-  var (t, r, s) = (Unit4, Unit4, Unit4)
-  if "translation" in node:
-    t = Translate(
-      float32(node["translation"][0].getFloat()),
-      float32(node["translation"][1].getFloat()),
-      float32(node["translation"][2].getFloat())
-    )
-  if "rotation" in node:
-    t = Rotate(
-      float32(node["rotation"][3].getFloat()),
-      NewVec3f(
-        float32(node["rotation"][0].getFloat()),
-        float32(node["rotation"][1].getFloat()),
-        float32(node["rotation"][2].getFloat())
-      )
-    )
-  if "scale" in node:
-    t = Scale(
-      float32(node["scale"][0].getFloat()),
-      float32(node["scale"][1].getFloat()),
-      float32(node["scale"][2].getFloat())
-    )
-
-  result.transform = t * r * s * result.transform
+    result.transform = t * r * s
 
 proc ReadglTF*[TMesh, TMaterial](
   stream: Stream,