support 22x17 capes, closing #4
This commit is contained in:
parent
95ed8186ab
commit
99fc6ee5bc
|
|
@ -132,16 +132,28 @@ class SkinViewer {
|
||||||
this.capeImg.crossOrigin = "";
|
this.capeImg.crossOrigin = "";
|
||||||
this.capeImg.onerror = () => console.error("Failed loading " + this.capeImg.src);
|
this.capeImg.onerror = () => console.error("Failed loading " + this.capeImg.src);
|
||||||
this.capeImg.onload = () => {
|
this.capeImg.onload = () => {
|
||||||
|
let isOldFormat = false;
|
||||||
if (this.capeImg.width !== 2 * this.capeImg.height) {
|
if (this.capeImg.width !== 2 * this.capeImg.height) {
|
||||||
|
if (this.capeImg.width * 17 == this.capeImg.height * 22) {
|
||||||
|
// width/height = 22/17
|
||||||
|
isOldFormat = true;
|
||||||
|
} else {
|
||||||
console.error("Bad cape size");
|
console.error("Bad cape size");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let capeContext = this.capeCanvas.getContext("2d");
|
||||||
|
if (isOldFormat) {
|
||||||
|
let width = this.capeImg.width * 64 / 22;
|
||||||
|
this.capeCanvas.width = width;
|
||||||
|
this.capeCanvas.height = width / 2;
|
||||||
|
} else {
|
||||||
this.capeCanvas.width = this.capeImg.width;
|
this.capeCanvas.width = this.capeImg.width;
|
||||||
this.capeCanvas.height = this.capeImg.height;
|
this.capeCanvas.height = this.capeImg.height;
|
||||||
let capeContext = this.capeCanvas.getContext("2d");
|
}
|
||||||
capeContext.clearRect(0, 0, this.capeCanvas.width, this.capeCanvas.height);
|
capeContext.clearRect(0, 0, this.capeCanvas.width, this.capeCanvas.height);
|
||||||
capeContext.drawImage(this.capeImg, 0, 0, this.capeCanvas.width, this.capeCanvas.height);
|
capeContext.drawImage(this.capeImg, 0, 0, this.capeImg.width, this.capeImg.height);
|
||||||
|
|
||||||
this.capeTexture.needsUpdate = true;
|
this.capeTexture.needsUpdate = true;
|
||||||
this.capeMaterial.needsUpdate = true;
|
this.capeMaterial.needsUpdate = true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue