From 98f74b0c7a966290ca1f34979207a2fa58ba6398 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Tue, 3 Mar 2026 16:09:51 +0900 Subject: [PATCH] wip --- .../src/utility/room/objects/pictureFrame.ts | 6 ++ .../src/utility/room/objects/poster.ts | 56 ++++++------------- 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/packages/frontend/src/utility/room/objects/pictureFrame.ts b/packages/frontend/src/utility/room/objects/pictureFrame.ts index 4208c9e348..6d01dc70d9 100644 --- a/packages/frontend/src/utility/room/objects/pictureFrame.ts +++ b/packages/frontend/src/utility/room/objects/pictureFrame.ts @@ -88,6 +88,12 @@ export const pictureFrame = defineObject({ const pictureMaterial = findMaterial('__X_PICTURE__'); const uvs = pictureMesh.getVerticesData(BABYLON.VertexBuffer.UVKind); + + /** + * a(x,y)---b(x,y) + * | | + * c(x,y)---d(x,y) + */ const ax = uvs[6]; const ay = uvs[7]; const bx = uvs[2]; diff --git a/packages/frontend/src/utility/room/objects/poster.ts b/packages/frontend/src/utility/room/objects/poster.ts index bdd761d2c6..51d809fabe 100644 --- a/packages/frontend/src/utility/room/objects/poster.ts +++ b/packages/frontend/src/utility/room/objects/poster.ts @@ -53,6 +53,12 @@ export const poster = defineObject({ const pinMeshes = findMeshes('__X_PIN__'); const uvs = pictureMesh.getVerticesData(BABYLON.VertexBuffer.UVKind); + + /** + * a(x,y)---b(x,y) + * | | + * c(x,y)---d(x,y) + */ const ax = uvs[6]; const ay = uvs[7]; const bx = uvs[2]; @@ -73,49 +79,19 @@ export const poster = defineObject({ const targetHeight = options.height; const targetAspect = targetWidth / targetHeight; - let newAx = ax; - let newAy = ay; - let newBx = bx; - let newBy = by; - let newCx = cx; - let newCy = cy; - let newDx = dx; - let newDy = dy; + const newAx = ax; + const newAy = ay; + const newBx = bx; + const newBy = by; + const newCx = cx; + const newCy = cy; + const newDx = dx; + const newDy = dy; if (options.fit === 'cover') { - if (targetAspect > srcAspect) { - const fitHeight = targetWidth / srcAspect; - const crop = (fitHeight - targetHeight) / fitHeight / 2; - newAy = ay + crop * (by - ay); - newBy = by - crop * (by - ay); - newCy = cy + crop * (dy - cy); - newDy = dy - crop * (dy - cy); - } else { - const fitWidth = targetHeight * srcAspect; - const crop = (fitWidth - targetWidth) / fitWidth / 2; - newAx = ax + crop * (bx - ax); - newBx = bx - crop * (bx - ax); - newCx = cx + crop * (dx - cx); - newDx = dx - crop * (dx - cx); - } + // TODO } else if (options.fit === 'contain') { - if (targetAspect > srcAspect) { - const fitWidth = targetHeight * srcAspect; - const crop = (fitWidth - targetWidth) / fitWidth / 2; - newAx = ax + crop * (bx - ax); - newBx = bx - crop * (bx - ax); - newCx = cx + crop * (dx - cx); - newDx = dx - crop * (dx - cx); - } else { - const fitHeight = targetWidth / srcAspect; - const crop = (fitHeight - targetHeight) / fitHeight / 2; - newAy = ay + crop * (by - ay); - newBy = by - crop * (by - ay); - newCy = cy + crop * (dy - cy); - newDy = dy - crop * (dy - cy); - } - } else if (options.fit === 'stretch') { - // do nothing + // TODO } uvs[6] = newAx;