Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions Cargo.lock

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

20 changes: 20 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"packages/modrinth-content-management",
"packages/modrinth-log",
"packages/modrinth-maxmind",
"packages/modrinth-skin-rendering",
"packages/modrinth-util",
"packages/neverbounce",
"packages/path-util",
Expand Down Expand Up @@ -101,6 +102,8 @@ flate2 = "1.1.10"
fs4 = { version = "1.1.0", default-features = false }
futures = "0.3.34"
futures-util = "0.3.34"
glam = "0.34.3"
gltf = "1.4.1"
governor = "0.10.4"
heck = "0.5.0"
hex = "0.4.3"
Expand Down Expand Up @@ -152,6 +155,7 @@ minecraft-meta-manifest = { path = "packages/minecraft-meta-manifest" }
minecraft-meta-model = { path = "packages/minecraft-meta-model" }
modrinth-content-management = { path = "packages/modrinth-content-management" }
modrinth-log = { path = "packages/modrinth-log" }
modrinth-skin-rendering = { path = "packages/modrinth-skin-rendering" }
modrinth-util = { path = "packages/modrinth-util" }
muralpay = { path = "packages/muralpay" }
murmur2 = "0.1.0"
Expand Down Expand Up @@ -342,6 +346,22 @@ tauri-utils = { git = "https://github.com/tauri-apps/tauri", rev = "7cc68e74ff69
# Toasty's unused SQLite driver conflicts with SQLx's native SQLite bindings.
toasty = { path = "packages/toasty" }

[profile.dev.package.fdeflate]
opt-level = 3

[profile.dev.package.flate2]
opt-level = 3

[profile.dev.package.miniz_oxide]
opt-level = 3

# Unoptimized, rendering one skin preview takes over a second
[profile.dev.package.modrinth-skin-rendering]
opt-level = 3

[profile.dev.package.png]
opt-level = 3

[profile.dev.package.sqlx-macros]
opt-level = 3

Expand Down
17 changes: 10 additions & 7 deletions apps/app-frontend/src/components/ui/skin/BakedSkinButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { SkinButton } from '@modrinth/ui'
import { useIntersectionObserver } from '@vueuse/core'
import { computed, ref, watch } from 'vue'

import { acquireSkinPreview, getSkinPreviewKey } from '@/helpers/rendering/skin-previews'
import type { Cape, Skin } from '@/helpers/skins'
import { renderSkinPreview } from '@/platform/app-lib/skins/commands'

const props = defineProps<{
skin: Skin
Expand All @@ -14,7 +14,12 @@ const props = defineProps<{
const button = ref<InstanceType<typeof SkinButton>>()
const visible = ref(false)
const url = ref<string>()
const key = computed(() => getSkinPreviewKey(props.skin))
const capeTexture = computed(
() => props.capes.find((cape) => cape.id === props.skin.cape_id)?.texture,
)
const key = computed(
() => `${props.skin.texture_key}+${props.skin.variant}+${capeTexture.value ?? 'no-cape'}`,
)

useIntersectionObserver(
button,
Expand All @@ -25,19 +30,17 @@ useIntersectionObserver(
)

watch(
[visible, key, () => props.capes],
[visible, key],
([isVisible], _, onCleanup) => {
url.value = undefined
if (!isVisible) return
const preview = acquireSkinPreview(props.skin, props.capes)
let active = true
onCleanup(() => {
active = false
preview.release()
})
void preview.promise
void renderSkinPreview(props.skin, capeTexture.value)
.then((result) => {
if (active) url.value = result?.forwards
if (active) url.value = result
})
.catch((error) => console.warn('Could not load skin preview', error))
},
Expand Down
2 changes: 2 additions & 0 deletions apps/app-frontend/src/components/ui/skin/EditSkinModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:variant="variant"
:texture-src="previewSkin || ''"
:ears-texture-src="uploadedTextureUrl?.original ?? currentSkin?.texture"
:ears-loader="getSkinEars"
:cape-src="selectedCapeTexture"
framing="modal"
:initial-rotation="Math.PI / 8"
Expand Down Expand Up @@ -159,6 +160,7 @@ import {
type SkinModel,
type SkinTextureUrl,
} from '@/helpers/skins.ts'
import { getSkinEars } from '@/platform/app-lib/skins/commands'

const CAPE_LIST_MAX_HEIGHT = 334
const messages = defineMessages({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ import {
set_default_user,
users,
} from '@/helpers/auth'
import { getPlayerHeadUrl } from '@/helpers/rendering/player-head'
import type { Skin } from '@/helpers/skins'
import { get_available_skins } from '@/helpers/skins'
import { renderSkinHead } from '@/platform/app-lib/skins/commands'

const { formatMessage } = useVIntl()
const { handleError } = injectNotificationManager()
Expand All @@ -143,17 +143,14 @@ let headRequest = 0

async function updateHeadUrl(skin: Skin | null) {
const request = ++headRequest
if (equippedHeadUrl.value) URL.revokeObjectURL(equippedHeadUrl.value)
equippedHeadUrl.value = undefined
if (!skin) return
const url = await getPlayerHeadUrl(skin)
if (request !== headRequest) URL.revokeObjectURL(url)
else equippedHeadUrl.value = url
const url = await renderSkinHead(skin)
if (request === headRequest) equippedHeadUrl.value = url
}

onUnmounted(() => {
headRequest++
if (equippedHeadUrl.value) URL.revokeObjectURL(equippedHeadUrl.value)
})

async function refreshValues() {
Expand Down
10 changes: 10 additions & 0 deletions apps/app-frontend/src/features/skins/legacy-preview-storage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** Skin previews used to be cached in IndexedDB. app-lib caches them on disk now. */
export function deleteLegacySkinPreviewStorage() {
for (const name of ['skin-previews', 'head-storage']) {
try {
indexedDB.deleteDatabase(name)
} catch (error) {
console.warn('Could not delete legacy skin preview storage', error)
}
}
}
Loading
Loading