Skip to content

Commit

Permalink
1.4.12 | add cape params to embed
Browse files Browse the repository at this point in the history
  • Loading branch information
InventivetalentDev committed Apr 16, 2023
1 parent 39828b3 commit f037d04
Show file tree
Hide file tree
Showing 14 changed files with 493 additions and 408 deletions.
194 changes: 105 additions & 89 deletions dist/all.js

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions dist/all.min.js

Large diffs are not rendered by default.

194 changes: 105 additions & 89 deletions dist/entity.js

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions dist/entity.min.js

Large diffs are not rendered by default.

194 changes: 105 additions & 89 deletions dist/gui.js

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions dist/gui.min.js

Large diffs are not rendered by default.

194 changes: 105 additions & 89 deletions dist/model.js

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions dist/model.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/skin.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/skin.min.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions embed/skin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
skin.data Skin Data (Base64)
skin.name Skin Username
cape Set this param to enable capes - Cape type from capes.dev or direct link to cape data
cape.user Cape username / uuid
cape.url Cape URL
cape.data Cape Data (Base64)
controls enable/disable controls
controls.zoom enable/disable zoom controls
controls.rotate enable/disable rotation controls
Expand Down Expand Up @@ -81,6 +86,16 @@
return;
}

if (params.get("cape")) {
renderParams.cape = params.get("cape");
} else if (params.get("cape.user")) {
renderParams.capeUser = params.get("cape.user");
} else if (params.get("cape.url")) {
renderParams.capeUrl = params.get("cape.url")
} else if (params.get("cape.data")) {
renderParams.capeData = params.get("cape.data");
}

if (params.get("skin.slim")) {
renderParams.slim = params.get("skin.slim") === "true";
}
Expand Down
6 changes: 2 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minerender",
"version": "1.4.11",
"version": "1.4.12",
"description": "",
"main": "src/combined/index.js",
"scripts": {
Expand Down
18 changes: 15 additions & 3 deletions src/skin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class SkinRender extends Render {
skinRender._skinImage.crossOrigin = "anonymous";
skinRender._capeImage = new Image();
skinRender._capeImage.crossOrigin = "anonymous";
let hasCape = texture.cape !== undefined || texture.capeUrl !== undefined || texture.capeData !== undefined || texture.mineskin !== undefined;
let hasCape = texture.cape !== undefined || texture.capeUser !== undefined || texture.capeUrl !== undefined || texture.capeData !== undefined || texture.mineskin !== undefined;
let slim = false;
let skinLoaded = false;
let capeLoaded = false;
Expand Down Expand Up @@ -270,10 +270,16 @@ class SkinRender extends Render {
if (texture.cape.length > 36) { // Likely either a cape ID or URL
let capeDataUrl = texture.cape.startsWith("http") ? texture.cape : "https://api.capes.dev/get/" + texture.cape;
getJSON(capeDataUrl, function (err, data) {
if (err) return console.log(err);
if (err) {
console.log("failed to get capes.dev")
skinRender._capeImage.onload(); // avoid getting stuck
return console.log(err);
}
if (data.exists) {
texture._capeType = data.type;
skinRender._capeImage.src = data.imageUrls.base.full;
} else {
skinRender._capeImage.onload(); // avoid getting stuck
}
})
} else { // Type
Expand All @@ -290,11 +296,17 @@ class SkinRender extends Render {
capeLoadUrl += "/" + texture.cape; // append type

getJSON(capeLoadUrl, function (err, data) {
if (err) return console.log(err);
if (err) {
console.log("failed to get capes.dev")
skinRender._capeImage.onload(); // avoid getting stuck
return console.log(err);
}
// Should be a single object of the requested type
if (data.exists) {
texture._capeType = data.type;
skinRender._capeImage.src = data.imageUrls.base.full;
} else {
skinRender._capeImage.onload(); // avoid getting stuck
}
})
}
Expand Down

0 comments on commit f037d04

Please sign in to comment.