From 517d5063c81328d5e05e5e6c35bc12b68824540e Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 19 Apr 2024 07:16:31 -0400 Subject: [PATCH] Utilize the new api --- source/player_model/init.ts | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/source/player_model/init.ts b/source/player_model/init.ts index 11c2ff90..91f304e2 100644 --- a/source/player_model/init.ts +++ b/source/player_model/init.ts @@ -1,6 +1,9 @@ namespace playerModel { type AnimationStation = animationStation.AnimationStation; + const getPlayerAnimationProgress = animationStation.getPlayerAnimationProgress; + const setPlayerAnimationProgress = animationStation.setPlayerAnimationProgress; + const Quaternion = utility.Quaternion; /* character.b3d bone documentation, tree view. -------------------------------------------- @@ -12,9 +15,31 @@ namespace playerModel { -Leg_Right */ + //! Begin debugging mess !!! + + let rotationStart = new Quaternion(vector.create3d(0, 0, 0)); + let rotationEnd = new Quaternion(vector.create3d(0, math.pi, 0)); + let workerRotation = new Quaternion(vector.create3d(0, 0, 0)); + let workerVec = vector.create3d(0, 0, 0); + minetest.register_globalstep((delta: number) => { for (let player of minetest.get_connected_players()) { - print(player.get_player_name()); + let animationProgress = getPlayerAnimationProgress(player); + animationProgress += delta; + setPlayerAnimationProgress(player, animationProgress); + print(animationProgress); + + rotationStart.slerp(rotationEnd, animationProgress, workerRotation); + workerRotation.toVec3(workerVec); + + player.set_bone_override("Head", { + rotation: { + vec: workerVec, + interpolation: 1, + absolute: false, + } + }); + } }); @@ -22,14 +47,11 @@ namespace playerModel { //! End this debug mess!!! minetest.register_on_joinplayer((player: ObjectRef) => { - - player.set_properties({ mesh: "character.b3d", textures: ["character.png"], visual: EntityVisual.mesh, visual_size: vector.create3d(1, 1, 1) }); - }); } \ No newline at end of file