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/node/index.mjs
CHANGED
|
@@ -3006,16 +3006,17 @@ var init_UVMapper = __esm({
|
|
|
3006
3006
|
positions[textureKey] = [x, y];
|
|
3007
3007
|
const [width, height] = sizes[textureKey];
|
|
3008
3008
|
const sequence = frames[textureKey];
|
|
3009
|
-
const
|
|
3009
|
+
const getFrameData = (index) => {
|
|
3010
3010
|
const columns = texture.width / width;
|
|
3011
|
-
|
|
3011
|
+
return texture.getSectionData(
|
|
3012
3012
|
index % columns * width,
|
|
3013
3013
|
Math.floor(index / columns) * height,
|
|
3014
3014
|
width,
|
|
3015
3015
|
height
|
|
3016
|
-
)
|
|
3016
|
+
);
|
|
3017
3017
|
};
|
|
3018
|
-
|
|
3018
|
+
const firstFrame = getFrameData(sequence?.[0].index ?? 0);
|
|
3019
|
+
image.putData(firstFrame, x, y);
|
|
3019
3020
|
if (texture.hasTransparency) {
|
|
3020
3021
|
hasTransparency = true;
|
|
3021
3022
|
}
|
|
@@ -3023,13 +3024,28 @@ var init_UVMapper = __esm({
|
|
|
3023
3024
|
hasAnimation = true;
|
|
3024
3025
|
let t = 0;
|
|
3025
3026
|
let f = 0;
|
|
3027
|
+
const interpolated = metaMap[textureKey]?.animation?.interpolate ? image.context.createImageData(width, height) : void 0;
|
|
3028
|
+
let currentFrame = firstFrame;
|
|
3029
|
+
let nextFrame = interpolated ? getFrameData(sequence[1].index) : firstFrame;
|
|
3026
3030
|
animatorFunctions[textureKey] = () => {
|
|
3027
|
-
if (++t
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3031
|
+
if (++t >= sequence[f].time) {
|
|
3032
|
+
t = 0;
|
|
3033
|
+
const previous = sequence[f].index;
|
|
3034
|
+
f = (f + 1) % sequence.length;
|
|
3035
|
+
if (interpolated) {
|
|
3036
|
+
currentFrame = nextFrame;
|
|
3037
|
+
nextFrame = getFrameData(sequence[(f + 1) % sequence.length].index);
|
|
3038
|
+
}
|
|
3039
|
+
if (sequence[f].index === previous) return false;
|
|
3040
|
+
image.putData(interpolated ? currentFrame : getFrameData(sequence[f].index), x, y);
|
|
3041
|
+
return true;
|
|
3042
|
+
}
|
|
3043
|
+
if (!interpolated || sequence[f].index === sequence[(f + 1) % sequence.length].index) return false;
|
|
3044
|
+
const progress = Math.floor(Math.fround(Math.fround(t / sequence[f].time) * 1e3)) / 1e3;
|
|
3045
|
+
for (let i = 0; i < interpolated.data.length; i++) {
|
|
3046
|
+
interpolated.data[i] = currentFrame.data[i] + (nextFrame.data[i] - currentFrame.data[i]) * progress;
|
|
3047
|
+
}
|
|
3048
|
+
image.putData(interpolated, x, y);
|
|
3033
3049
|
return true;
|
|
3034
3050
|
};
|
|
3035
3051
|
}
|