dist/ 为 Wallpaper Engine 网页壁纸「【崩坏:星穹铁道】昔涟」(workshopid 3604974793, version 2), 含两套预设 xilian / kv37,总计 105.1MB。本次提交不做任何修改,仅作为后续优化的对拍基线。
61 lines
1.3 KiB
JavaScript
61 lines
1.3 KiB
JavaScript
export default class SpineController {
|
|
constructor(containerId, config = {}) {
|
|
this.containerId = containerId;
|
|
this.config = {
|
|
alpha: true,
|
|
premultipliedAlpha: false,
|
|
showControls: false,
|
|
showLoading: false,
|
|
...config,
|
|
};
|
|
|
|
this.previousConfig = {};
|
|
|
|
this.container = document.getElementById(containerId);
|
|
this.player = undefined;
|
|
}
|
|
|
|
create() {
|
|
if (!this.player) {
|
|
const containerId = this.containerId;
|
|
const config = this.config;
|
|
this.player = new spine.SpinePlayer(containerId, config);
|
|
}
|
|
}
|
|
|
|
dispose() {
|
|
if (this.player) {
|
|
const container = this.container;
|
|
this.player.dispose();
|
|
container.innerHTML = "";
|
|
this.player = undefined;
|
|
}
|
|
}
|
|
|
|
adjustCanvas() {
|
|
if (this.player) {
|
|
const container = this.container;
|
|
const canvas = container.querySelector("canvas");
|
|
if (canvas) {
|
|
const rect = container.getBoundingClientRect();
|
|
canvas.style.width = "100%";
|
|
canvas.style.height = "100%";
|
|
canvas.width = rect.width;
|
|
canvas.height = rect.height;
|
|
}
|
|
}
|
|
}
|
|
|
|
changeConfig(newConfig = {}) {
|
|
if (this.player) {
|
|
this.previousConfig = this.config;
|
|
this.config = {
|
|
...this.config,
|
|
...newConfig,
|
|
};
|
|
this.dispose();
|
|
this.create();
|
|
}
|
|
}
|
|
}
|