Skip to content

Commit a7fd73e

Browse files
committed
use 3d skin instead of image
1 parent 7046d6b commit a7fd73e

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

skin/src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@ const url = new URL(window.location.href);
55
const uuid = url.searchParams.get('uuid');
66

77
if (uuid && uuid.length === 32) {
8+
const w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
9+
const h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
10+
canvas.width = w;
11+
canvas.height = h;
812
drawSkin3D(canvas, uuid, true);
913
}

web/src/components/PlayerPage.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
</div>
1212
</div>
1313
<div class="row">
14-
<div class="col-sm-12 col-md-3 col-lg-2">
14+
<div class="col-sm-12 col-md-3 col-lg-2 skin-container">
1515
<div class="panel panel-default">
1616
<div class="panel-body">
17-
<img :src="`/static/data/${uuid}/body.png`" :alt="`${player.data.playername}'s model`" class="img-rounded">
17+
<img v-if="!isCanvasSupported" :src="`/static/data/${uuid}/body.png`" :alt="`${player.data.playername}'s model`" class="img-rounded">
18+
<iframe v-if="isCanvasSupported" :src="`/static/skin/index.html?uuid=${uuid}`" class="skin" />
1819
</div>
1920
</div>
2021
</div>
@@ -102,6 +103,12 @@ export default {
102103
this.uuid = uuid;
103104
},
104105
},
106+
computed: {
107+
isCanvasSupported() {
108+
const elem = document.createElement('canvas');
109+
return !!(elem.getContext && elem.getContext('2d'));
110+
},
111+
},
105112
mounted() {
106113
const timer = setInterval(() => {
107114
this.progress += 20;
@@ -119,3 +126,14 @@ export default {
119126
},
120127
};
121128
</script>
129+
130+
<style scoped>
131+
.skin {
132+
width: 100%;
133+
height: 285px;
134+
border: none;
135+
}
136+
.panel-body {
137+
padding: 0;
138+
}
139+
</style>

0 commit comments

Comments
 (0)