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:
parent
572cd065ed
commit
eb595cdc3e
@ -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()
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user