🫁 Adds rest mode

This commit is contained in:
Rune Harlyk
2024-02-25 01:52:34 +01:00
committed by Rune Harlyk
parent 3e7918208a
commit 2d8137772a
2 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ export const jointNames = persistentStore('joint_names', []);
export const model = writable();
export const modes = ['idle', 'stand', 'walk'] as const;
export const modes = ['idle', 'rest', 'stand', 'walk'] as const;
export type Modes = (typeof modes)[number];
+7 -5
View File
@@ -226,21 +226,23 @@ const unpackMessageBuffer = (data) => {
};
};
const rest = {
const rest_stance = {
rotation: [0, 0, 0],
position: [0, 10, 0],
};
const idle = (client) => {
const idle = () => {};
const rest = (client) => {
for (let i = 0; i < 3; i++) {
client.clientState.model.position[i] = lerp(
client.clientState.model.position[i],
rest.position[i],
rest_stance.position[i],
0.01
);
client.clientState.model.rotation[i] = lerp(
client.clientState.model.rotation[i],
rest.rotation[i],
rest_stance.rotation[i],
0.01
);
}
@@ -309,7 +311,7 @@ const start_dynamics = (client) => {
client.tick = 0;
client.clientState.mode = "idle";
client.clientState.next_mode = "walk";
const modes = { idle, stand, walk };
const modes = { rest, idle, stand, walk };
client.id = setInterval(() => {
client.tick += 1;