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.
@@ -803,7 +803,7 @@ var init_Textures = __esm({
803
803
  });
804
804
 
805
805
  // src/Materials.ts
806
- import { Color, CustomBlending, DoubleSide, OneFactor, RepeatWrapping, FrontSide, MeshBasicMaterial, MeshStandardMaterial, ShaderChunk, ShaderMaterial, ZeroFactor } from "three";
806
+ import { Color, CustomBlending, DoubleSide, OneFactor, OneMinusSrcAlphaFactor, RepeatWrapping, FrontSide, MeshBasicMaterial, MeshStandardMaterial, ShaderChunk, ShaderMaterial } from "three";
807
807
  var _Materials, Materials;
808
808
  var init_Materials = __esm({
809
809
  "src/Materials.ts"() {
@@ -892,8 +892,15 @@ var init_Materials = __esm({
892
892
  material.blending = CustomBlending;
893
893
  material.blendSrc = OneFactor;
894
894
  material.blendDst = OneFactor;
895
- material.blendSrcAlpha = ZeroFactor;
896
- material.blendDstAlpha = OneFactor;
895
+ material.blendSrcAlpha = OneFactor;
896
+ material.blendDstAlpha = OneMinusSrcAlphaFactor;
897
+ material.onBeforeCompile = (shader) => {
898
+ shader.fragmentShader = shader.fragmentShader.replace(
899
+ "#include <dithering_fragment>",
900
+ "gl_FragColor.a = max(gl_FragColor.r, max(gl_FragColor.g, gl_FragColor.b));\n#include <dithering_fragment>"
901
+ );
902
+ };
903
+ material.customProgramCacheKey = () => "energy_swirl";
897
904
  material.color.set(8421504);
898
905
  break;
899
906
  case "water_mask":
@@ -2913,16 +2920,17 @@ var init_UVMapper = __esm({
2913
2920
  positions[textureKey] = [x, y];
2914
2921
  const [width, height] = sizes[textureKey];
2915
2922
  const sequence = frames[textureKey];
2916
- const drawFrame = (index) => {
2923
+ const getFrameData = (index) => {
2917
2924
  const columns = texture.width / width;
2918
- image.putData(texture.getSectionData(
2925
+ return texture.getSectionData(
2919
2926
  index % columns * width,
2920
2927
  Math.floor(index / columns) * height,
2921
2928
  width,
2922
2929
  height
2923
- ), x, y);
2930
+ );
2924
2931
  };
2925
- drawFrame(sequence?.[0].index ?? 0);
2932
+ const firstFrame = getFrameData(sequence?.[0].index ?? 0);
2933
+ image.putData(firstFrame, x, y);
2926
2934
  if (texture.hasTransparency) {
2927
2935
  hasTransparency = true;
2928
2936
  }
@@ -2930,13 +2938,28 @@ var init_UVMapper = __esm({
2930
2938
  hasAnimation = true;
2931
2939
  let t = 0;
2932
2940
  let f = 0;
2941
+ const interpolated = metaMap[textureKey]?.animation?.interpolate ? image.context.createImageData(width, height) : void 0;
2942
+ let currentFrame = firstFrame;
2943
+ let nextFrame = interpolated ? getFrameData(sequence[1].index) : firstFrame;
2933
2944
  animatorFunctions[textureKey] = () => {
2934
- if (++t < sequence[f].time) return false;
2935
- t = 0;
2936
- const previous = sequence[f].index;
2937
- f = (f + 1) % sequence.length;
2938
- if (sequence[f].index === previous) return false;
2939
- drawFrame(sequence[f].index);
2945
+ if (++t >= sequence[f].time) {
2946
+ t = 0;
2947
+ const previous = sequence[f].index;
2948
+ f = (f + 1) % sequence.length;
2949
+ if (interpolated) {
2950
+ currentFrame = nextFrame;
2951
+ nextFrame = getFrameData(sequence[(f + 1) % sequence.length].index);
2952
+ }
2953
+ if (sequence[f].index === previous) return false;
2954
+ image.putData(interpolated ? currentFrame : getFrameData(sequence[f].index), x, y);
2955
+ return true;
2956
+ }
2957
+ if (!interpolated || sequence[f].index === sequence[(f + 1) % sequence.length].index) return false;
2958
+ const progress = Math.floor(Math.fround(Math.fround(t / sequence[f].time) * 1e3)) / 1e3;
2959
+ for (let i = 0; i < interpolated.data.length; i++) {
2960
+ interpolated.data[i] = currentFrame.data[i] + (nextFrame.data[i] - currentFrame.data[i]) * progress;
2961
+ }
2962
+ image.putData(interpolated, x, y);
2940
2963
  return true;
2941
2964
  };
2942
2965
  }