minerender 2.1.0-alpha.64 → 2.1.0-alpha.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -893,8 +893,15 @@ var init_Materials = __esm({
893
893
  material.blending = import_three5.CustomBlending;
894
894
  material.blendSrc = import_three5.OneFactor;
895
895
  material.blendDst = import_three5.OneFactor;
896
- material.blendSrcAlpha = import_three5.ZeroFactor;
897
- material.blendDstAlpha = import_three5.OneFactor;
896
+ material.blendSrcAlpha = import_three5.OneFactor;
897
+ material.blendDstAlpha = import_three5.OneMinusSrcAlphaFactor;
898
+ material.onBeforeCompile = (shader) => {
899
+ shader.fragmentShader = shader.fragmentShader.replace(
900
+ "#include <dithering_fragment>",
901
+ "gl_FragColor.a = max(gl_FragColor.r, max(gl_FragColor.g, gl_FragColor.b));\n#include <dithering_fragment>"
902
+ );
903
+ };
904
+ material.customProgramCacheKey = () => "energy_swirl";
898
905
  material.color.set(8421504);
899
906
  break;
900
907
  case "water_mask":
@@ -2915,16 +2922,17 @@ var init_UVMapper = __esm({
2915
2922
  positions[textureKey] = [x, y];
2916
2923
  const [width, height] = sizes[textureKey];
2917
2924
  const sequence = frames[textureKey];
2918
- const drawFrame = (index) => {
2925
+ const getFrameData = (index) => {
2919
2926
  const columns = texture.width / width;
2920
- image.putData(texture.getSectionData(
2927
+ return texture.getSectionData(
2921
2928
  index % columns * width,
2922
2929
  Math.floor(index / columns) * height,
2923
2930
  width,
2924
2931
  height
2925
- ), x, y);
2932
+ );
2926
2933
  };
2927
- drawFrame(sequence?.[0].index ?? 0);
2934
+ const firstFrame = getFrameData(sequence?.[0].index ?? 0);
2935
+ image.putData(firstFrame, x, y);
2928
2936
  if (texture.hasTransparency) {
2929
2937
  hasTransparency = true;
2930
2938
  }
@@ -2932,13 +2940,28 @@ var init_UVMapper = __esm({
2932
2940
  hasAnimation = true;
2933
2941
  let t = 0;
2934
2942
  let f = 0;
2943
+ const interpolated = metaMap[textureKey]?.animation?.interpolate ? image.context.createImageData(width, height) : void 0;
2944
+ let currentFrame = firstFrame;
2945
+ let nextFrame = interpolated ? getFrameData(sequence[1].index) : firstFrame;
2935
2946
  animatorFunctions[textureKey] = () => {
2936
- if (++t < sequence[f].time) return false;
2937
- t = 0;
2938
- const previous = sequence[f].index;
2939
- f = (f + 1) % sequence.length;
2940
- if (sequence[f].index === previous) return false;
2941
- drawFrame(sequence[f].index);
2947
+ if (++t >= sequence[f].time) {
2948
+ t = 0;
2949
+ const previous = sequence[f].index;
2950
+ f = (f + 1) % sequence.length;
2951
+ if (interpolated) {
2952
+ currentFrame = nextFrame;
2953
+ nextFrame = getFrameData(sequence[(f + 1) % sequence.length].index);
2954
+ }
2955
+ if (sequence[f].index === previous) return false;
2956
+ image.putData(interpolated ? currentFrame : getFrameData(sequence[f].index), x, y);
2957
+ return true;
2958
+ }
2959
+ if (!interpolated || sequence[f].index === sequence[(f + 1) % sequence.length].index) return false;
2960
+ const progress = Math.floor(Math.fround(Math.fround(t / sequence[f].time) * 1e3)) / 1e3;
2961
+ for (let i = 0; i < interpolated.data.length; i++) {
2962
+ interpolated.data[i] = currentFrame.data[i] + (nextFrame.data[i] - currentFrame.data[i]) * progress;
2963
+ }
2964
+ image.putData(interpolated, x, y);
2942
2965
  return true;
2943
2966
  };
2944
2967
  }