mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-24 22:04:00 +02:00
wip
This commit is contained in:
@@ -88,6 +88,12 @@ export const pictureFrame = defineObject({
|
|||||||
const pictureMaterial = findMaterial('__X_PICTURE__');
|
const pictureMaterial = findMaterial('__X_PICTURE__');
|
||||||
|
|
||||||
const uvs = pictureMesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
|
const uvs = pictureMesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a(x,y)---b(x,y)
|
||||||
|
* | |
|
||||||
|
* c(x,y)---d(x,y)
|
||||||
|
*/
|
||||||
const ax = uvs[6];
|
const ax = uvs[6];
|
||||||
const ay = uvs[7];
|
const ay = uvs[7];
|
||||||
const bx = uvs[2];
|
const bx = uvs[2];
|
||||||
|
|||||||
@@ -53,6 +53,12 @@ export const poster = defineObject({
|
|||||||
const pinMeshes = findMeshes('__X_PIN__');
|
const pinMeshes = findMeshes('__X_PIN__');
|
||||||
|
|
||||||
const uvs = pictureMesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
|
const uvs = pictureMesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a(x,y)---b(x,y)
|
||||||
|
* | |
|
||||||
|
* c(x,y)---d(x,y)
|
||||||
|
*/
|
||||||
const ax = uvs[6];
|
const ax = uvs[6];
|
||||||
const ay = uvs[7];
|
const ay = uvs[7];
|
||||||
const bx = uvs[2];
|
const bx = uvs[2];
|
||||||
@@ -73,49 +79,19 @@ export const poster = defineObject({
|
|||||||
const targetHeight = options.height;
|
const targetHeight = options.height;
|
||||||
const targetAspect = targetWidth / targetHeight;
|
const targetAspect = targetWidth / targetHeight;
|
||||||
|
|
||||||
let newAx = ax;
|
const newAx = ax;
|
||||||
let newAy = ay;
|
const newAy = ay;
|
||||||
let newBx = bx;
|
const newBx = bx;
|
||||||
let newBy = by;
|
const newBy = by;
|
||||||
let newCx = cx;
|
const newCx = cx;
|
||||||
let newCy = cy;
|
const newCy = cy;
|
||||||
let newDx = dx;
|
const newDx = dx;
|
||||||
let newDy = dy;
|
const newDy = dy;
|
||||||
|
|
||||||
if (options.fit === 'cover') {
|
if (options.fit === 'cover') {
|
||||||
if (targetAspect > srcAspect) {
|
// TODO
|
||||||
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);
|
|
||||||
}
|
|
||||||
} else if (options.fit === 'contain') {
|
} else if (options.fit === 'contain') {
|
||||||
if (targetAspect > srcAspect) {
|
// TODO
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uvs[6] = newAx;
|
uvs[6] = newAx;
|
||||||
|
|||||||
Reference in New Issue
Block a user