fix: reset interpolator on change
This commit is contained in:
parent
29df4c3dcb
commit
b912fee2e7
|
@ -1,6 +1,6 @@
|
|||
export default class Interpolator {
|
||||
duration = 0;
|
||||
latest;
|
||||
latest = null;
|
||||
location = 0;
|
||||
penultimate;
|
||||
tracking = [];
|
||||
|
@ -94,7 +94,17 @@ const interpolate = (now) => {
|
|||
|
||||
onmessage = async (event) => {
|
||||
interpolator.accept(event.data);
|
||||
if (interpolator.penultimate && 'Tick' === event.data.type) {
|
||||
switch (event.data.type) {
|
||||
case 'EcsChange': {
|
||||
if (handle) {
|
||||
cancelAnimationFrame(handle)
|
||||
handle = null;
|
||||
}
|
||||
interpolator.latest = null;
|
||||
break;
|
||||
}
|
||||
case 'Tick': {
|
||||
if (interpolator.penultimate) {
|
||||
postMessage({
|
||||
type: 'Tick',
|
||||
payload: {
|
||||
|
@ -108,4 +118,7 @@ onmessage = async (event) => {
|
|||
handle = requestAnimationFrame(interpolate);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user