@tomiaa/live2d
Version:
34 lines (33 loc) • 956 B
JavaScript
import { ResizeHelper as s } from "../utils/resize.js";
class l {
/**
* 调整模型尺寸和位置
*/
static resize(c, t, i, u, y, z) {
var r, g, n, x;
const e = s.calculateWidth(u, y), h = s.calculateHeight(
e,
i,
z
);
c.view.style.width = `${e}px`, c.view.style.height = `${h}px`, c.renderer.resize(e, h);
const a = s.calculateModelScale(
t.width,
t.height,
e,
h
);
t.width *= a, t.height *= a;
const w = s.getCustomScale(i.scale);
t.width *= ((r = i.stretch) == null ? void 0 : r.width) || 1, t.height *= ((g = i.stretch) == null ? void 0 : g.height) || 1, t.scale = new window.PIXI.Point(
t.scale.x * w.x,
t.scale.y * w.y
), t.position = new window.PIXI.Point(
e - t.width + (((n = i.position) == null ? void 0 : n.x) || 0),
h - t.height + (((x = i.position) == null ? void 0 : x.y) || 0)
);
}
}
export {
l as ResizeManager
};