Andrew V Butt Sr 5 лет назад
Родитель
Сommit
1a3fb7cc35
2 измененных файлов с 16 добавлено и 0 удалено
  1. 7 0
      src/Bones/bone.ts
  2. 9 0
      src/Bones/skeleton.ts

+ 7 - 0
src/Bones/bone.ts

@@ -1140,4 +1140,11 @@ export class Bone extends Node {
 
 
         Vector3.TransformCoordinatesToRef(position, tmat, result);
         Vector3.TransformCoordinatesToRef(position, tmat, result);
     }
     }
+
+    /**
+     * Set the current local matrix as the restPose for this bone.
+     */
+    public setCurrentPoseAsRest(): void {
+        this.setRestPose(this.getLocalMatrix());
+    }
 }
 }

+ 9 - 0
src/Bones/skeleton.ts

@@ -880,4 +880,13 @@ export class Skeleton implements IAnimatable {
 
 
         bones.push(bone);
         bones.push(bone);
     }
     }
+
+    /**
+     * Set the current local matrix as the restPose for all bones in the skeleton.
+     */
+    public setCurrentPoseAsRest(): void {
+        this.bones.forEach((b) => {
+            b.setCurrentPoseAsRest();
+        });
+    }
 }
 }