minerender 2.1.0-alpha.65 → 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.
- package/dist/browser/index.js +26 -10
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +26 -10
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +26 -10
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.js +26 -10
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +26 -10
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -2920,16 +2920,17 @@ var init_UVMapper = __esm({
|
|
|
2920
2920
|
positions[textureKey] = [x, y];
|
|
2921
2921
|
const [width, height] = sizes[textureKey];
|
|
2922
2922
|
const sequence = frames[textureKey];
|
|
2923
|
-
const
|
|
2923
|
+
const getFrameData = (index) => {
|
|
2924
2924
|
const columns = texture.width / width;
|
|
2925
|
-
|
|
2925
|
+
return texture.getSectionData(
|
|
2926
2926
|
index % columns * width,
|
|
2927
2927
|
Math.floor(index / columns) * height,
|
|
2928
2928
|
width,
|
|
2929
2929
|
height
|
|
2930
|
-
)
|
|
2930
|
+
);
|
|
2931
2931
|
};
|
|
2932
|
-
|
|
2932
|
+
const firstFrame = getFrameData(sequence?.[0].index ?? 0);
|
|
2933
|
+
image.putData(firstFrame, x, y);
|
|
2933
2934
|
if (texture.hasTransparency) {
|
|
2934
2935
|
hasTransparency = true;
|
|
2935
2936
|
}
|
|
@@ -2937,13 +2938,28 @@ var init_UVMapper = __esm({
|
|
|
2937
2938
|
hasAnimation = true;
|
|
2938
2939
|
let t = 0;
|
|
2939
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;
|
|
2940
2944
|
animatorFunctions[textureKey] = () => {
|
|
2941
|
-
if (++t
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
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);
|
|
2947
2963
|
return true;
|
|
2948
2964
|
};
|
|
2949
2965
|
}
|