Tentative fix for flickering with some custom animated textures

This commit is contained in:
Lukas Rieger (Blue) 2024-03-21 14:40:20 +01:00
parent a847e247e5
commit 6e8247ae3a
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6
2 changed files with 8 additions and 3 deletions

View File

@ -44,8 +44,10 @@ export class TextureAnimation {
this.frameImages = height / width; this.frameImages = height / width;
this.uniforms.animationFrameHeight.value = 1 / this.frameImages; this.uniforms.animationFrameHeight.value = 1 / this.frameImages;
this.frames = this.frameImages; this.frames = this.frameImages;
if (this.data.frames) { if (this.data.frames && this.data.frames.length > 0) {
this.frames = this.data.frames.length; this.frames = this.data.frames.length;
} else {
this.data.frames = null;
} }
} }

View File

@ -101,7 +101,7 @@ public class AnimationMeta {
} }
private void readFramesList(JsonReader in, AnimationMeta animationMeta) throws IOException { private void readFramesList(JsonReader in, AnimationMeta animationMeta) throws IOException {
animationMeta.frames = new ArrayList<>(); List<FrameMeta> frames = new ArrayList<>();
in.beginArray(); in.beginArray();
while (in.hasNext()) { while (in.hasNext()) {
@ -122,9 +122,12 @@ public class AnimationMeta {
in.endObject(); in.endObject();
} }
animationMeta.frames.add(new FrameMeta(index, time)); frames.add(new FrameMeta(index, time));
} }
in.endArray(); in.endArray();
if (!frames.isEmpty())
animationMeta.frames = frames;
} }
@Override @Override