forked from noxious/server
Removed extra lines that made no differenec
This commit is contained in:
parent
54c75896f9
commit
3b0138130b
@ -46,22 +46,10 @@ export default class SpriteUpdateEvent {
|
||||
|
||||
try {
|
||||
const parsedSpriteActions = validateSpriteActions(data.spriteActions)
|
||||
// First, process sprites to get dimensions
|
||||
const processedActions = await processSprites(parsedSpriteActions)
|
||||
|
||||
// Find the maximum dimensions across all actions
|
||||
const maxFrameWidth = Math.max(...processedActions.map(action => action.frameWidth))
|
||||
const maxFrameHeight = Math.max(...processedActions.map(action => action.frameHeight))
|
||||
|
||||
// Update all actions to use the maximum dimensions
|
||||
const normalizedActions = processedActions.map(action => ({
|
||||
...action,
|
||||
frameWidth: maxFrameWidth,
|
||||
frameHeight: maxFrameHeight
|
||||
}))
|
||||
|
||||
await updateDatabase(data.id, data.name, normalizedActions)
|
||||
await saveSpritesToDisk(data.id, normalizedActions)
|
||||
await updateDatabase(data.id, data.name, processedActions)
|
||||
await saveSpritesToDisk(data.id, processedActions)
|
||||
|
||||
callback(true)
|
||||
} catch (error) {
|
||||
@ -141,6 +129,7 @@ export default class SpriteUpdateEvent {
|
||||
|
||||
await Promise.all(
|
||||
processedActions.map(async ({ action, buffersWithDimensions, frameWidth, frameHeight }) => {
|
||||
// Get and validate all frame dimensions first
|
||||
const frames = await Promise.all(
|
||||
buffersWithDimensions.map(async ({ buffer }) => {
|
||||
const metadata = await sharp(buffer).metadata()
|
||||
@ -163,9 +152,10 @@ export default class SpriteUpdateEvent {
|
||||
.composite(
|
||||
frames.map(({ buffer, width, height }, index) => ({
|
||||
input: buffer,
|
||||
// Center horizontally and vertically in the frame
|
||||
// Center horizontally based on the exact middle of each frame
|
||||
left: (index * frameWidth) + ((frameWidth - width) >> 1),
|
||||
top: 0,
|
||||
// Calculate vertical position to center in the available space
|
||||
top: 0
|
||||
}))
|
||||
)
|
||||
.png()
|
||||
|
Loading…
x
Reference in New Issue
Block a user