Feature/detect skin variant on fileinput (#3999)

* chaged detection algorithm, and added skin variant deteciton on fileinput

* Update skins.ts

removed leftover logs

* removed pnpm lock changes. Simplyfied the transparency check in skin variant detection

* fully reverted lock.yaml. my bad.

---------

Co-authored-by: Bronchiopator <70262842+Bronchiopator@users.noreply.github.com>
This commit is contained in:
Silcean 2025-07-16 12:43:30 +02:00 committed by GitHub
parent 572cd065ed
commit eb595cdc3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 9 deletions

View File

@ -118,6 +118,7 @@ import {
type Cape, type Cape,
type SkinModel, type SkinModel,
get_normalized_skin_texture, get_normalized_skin_texture,
determineModelType,
} from '@/helpers/skins.ts' } from '@/helpers/skins.ts'
import { handleError } from '@/store/notifications' import { handleError } from '@/store/notifications'
import { import {
@ -253,7 +254,7 @@ async function showNew(e: MouseEvent, skinTextureUrl: string) {
mode.value = 'new' mode.value = 'new'
currentSkin.value = null currentSkin.value = null
uploadedTextureUrl.value = skinTextureUrl uploadedTextureUrl.value = skinTextureUrl
variant.value = 'CLASSIC' variant.value = await determineModelType(skinTextureUrl)
selectedCape.value = undefined selectedCape.value = undefined
visibleCapeList.value = [] visibleCapeList.value = []
initVisibleCapeList() initVisibleCapeList()

View File

@ -62,16 +62,14 @@ export async function determineModelType(texture: string): Promise<'SLIM' | 'CLA
context.drawImage(image, 0, 0) context.drawImage(image, 0, 0)
const armX = 44 const armX = 54
const armY = 16 const armY = 20
const armWidth = 4 const armWidth = 2
const armHeight = 12 const armHeight = 12
const imageData = context.getImageData(armX, armY, armWidth, armHeight).data const imageData = context.getImageData(armX, armY, armWidth, armHeight).data
for (let index = 1; index <= imageData.length; index++) {
for (let y = 0; y < armHeight; y++) { //every fourth value in RGBA is the alpha channel
const alphaIndex = (3 + y * armWidth) * 4 + 3 if (index % 4 == 0 && imageData[index - 1] !== 0) {
if (imageData[alphaIndex] !== 0) {
resolve('CLASSIC') resolve('CLASSIC')
return return
} }