style: fetch retro items in format avatar - avatar sandbox
This commit is contained in:
parent
fbb69d63ff
commit
b95cf5d9df
1 changed files with 38 additions and 30 deletions
|
|
@ -343,6 +343,44 @@ async function UpdateAvatar() {
|
|||
|
||||
const FormattedAvatar = structuredClone(Avatar)
|
||||
|
||||
if (RetroItems === null) {
|
||||
const RetroItemsPromise = Avatar.items.map(async (id) => {
|
||||
if (Math.abs(id) !== id) {
|
||||
Items = (await (await fetch('https://poly-upd-archival.pages.dev/data.json')).json())
|
||||
Object.values(Items).forEach((item, index) => {
|
||||
item.id = parseInt(Object.keys(Items)[index])
|
||||
item.thumbnail = 'https://poly-archive.pages.dev/assets/thumbnails/' + item.id + '.png'
|
||||
item.creator = {
|
||||
id: 1,
|
||||
name: "Polytoria"
|
||||
}
|
||||
if (item.asset === undefined) {
|
||||
item.asset = 'https://poly-upd-archival.pages.dev/glb/' + item.id + '.glb'
|
||||
}
|
||||
item.id = item.id*-1
|
||||
item.ribbon = 'retro'
|
||||
ItemCache[item.id] = item
|
||||
})
|
||||
|
||||
const PaginationItems = Object.values(Items)
|
||||
let Groups = []
|
||||
while (PaginationItems.length > 0) {
|
||||
Groups.push(PaginationItems.splice(0, 12));
|
||||
}
|
||||
|
||||
Items = {
|
||||
assets: Groups[Page - 1],
|
||||
pages: Groups.length
|
||||
}
|
||||
|
||||
RetroItems = Groups
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
await Promise.all(RetroItemsPromise)
|
||||
}
|
||||
|
||||
const AccessoryPromise = [...Avatar.items, Avatar.tool].filter((x) => x !== undefined && !x.toString().startsWith('http') && !x.toString().startsWith('data:')).map(async (x, index) => {
|
||||
if (ItemCache[x] === undefined) {
|
||||
try {
|
||||
|
|
@ -740,36 +778,6 @@ async function LoadItems() {
|
|||
return
|
||||
}
|
||||
console.log('Equipped Outfit: ', outfit)
|
||||
if (RetroItems === null) {
|
||||
Items = (await (await fetch('https://poly-upd-archival.pages.dev/data.json')).json())
|
||||
Object.values(Items).forEach((item, index) => {
|
||||
item.id = parseInt(Object.keys(Items)[index])
|
||||
item.thumbnail = 'https://poly-archive.pages.dev/assets/thumbnails/' + item.id + '.png'
|
||||
item.creator = {
|
||||
id: 1,
|
||||
name: "Polytoria"
|
||||
}
|
||||
if (item.asset === undefined) {
|
||||
item.asset = 'https://poly-upd-archival.pages.dev/glb/' + item.id + '.glb'
|
||||
}
|
||||
item.id = item.id*-1
|
||||
item.ribbon = 'retro'
|
||||
ItemCache[item.id] = item
|
||||
})
|
||||
|
||||
const PaginationItems = Object.values(Items)
|
||||
let Groups = []
|
||||
while (PaginationItems.length > 0) {
|
||||
Groups.push(PaginationItems.splice(0, 12));
|
||||
}
|
||||
|
||||
Items = {
|
||||
assets: Groups[Page - 1],
|
||||
pages: Groups.length
|
||||
}
|
||||
|
||||
RetroItems = Groups
|
||||
}
|
||||
Avatar = outfit.data
|
||||
UpdateAvatar()
|
||||
})
|
||||
|
|
|
|||
Reference in a new issue