NexusSocial / nexus-vr

Social VR Game
Apache License 2.0
19 stars 6 forks source link

Add plugin for interpolating arbitrary components #74

Open TheButlah opened 9 months ago

TheButlah commented 9 months ago

We should introduce a plugin that handles interpolation of data.

Rationale

We decided to move away from lightyear, which means that we will soon not have client side interpolation of transforms and other data. Depending on the client's bandwidth, they might not get a high framerate of data from the server, and when they do it will have jitter. This will result in kinda janky poses.

Triage

This does not block other work because even without interpolation, we could just directly sync data from the latest server updates into the ecs.

Proposed design

I think we would model this after other prior art in this space, such as lightyear and bevy_easings. We might even be able to directly use bevy_easings instead, as one of the bevy maintainers (mockersf) wrote it.

The main question I have with bevy_easings is if it supports multiple samples for interpolation.

A potential API if we don't use bevy_easings:

#[derive(Component)]
struct Interpolated<T: InterpolatedComponent> {
  samples: Vec<T>,
  timestamps: Vec<Duration>,
}

And then, the InterpolatedComponent trait should seek to use the easing functions and traits from the interpolation crate.