Files
shacraft-core/client/player-interpolation.js
Emil c7e86663d8
MVP checks / mvp (push) Canceled after 0s
Expand voxel gameplay, lighting, full-height streaming and world imports
Add shared Rust/WASM physics, worker meshing and diagnostics, 64-chunk full-height streaming, atlas texture support, and baseline world import. Document the current implementation and include the supplied in-game lobby screenshot.
2026-09-17 02:10:53 +03:00

22 lines
802 B
JavaScript

/** Separate the last server pose from the pose currently drawn on screen. */
export function updateRemotePlayer(previous, packet, instant = false) {
const preserve = previous && !instant;
const targetYaw = packet.yaw ?? 0;
return {
...packet,
position: preserve ? previous.position : [...packet.position],
target: [...packet.position],
yaw: preserve ? previous.yaw : targetYaw,
targetYaw,
};
}
export function smoothRemotePlayer(player, blend) {
for (let axis = 0; axis < 3; axis++)
player.position[axis] +=
(player.target[axis] - player.position[axis]) * blend;
// Follow the shortest arc, including when server angles cross ±π or 2π.
const delta = player.targetYaw - player.yaw;
player.yaw += Math.atan2(Math.sin(delta), Math.cos(delta)) * blend;
}