1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-14 01:45:36 +02:00
This commit is contained in:
syuilo
2026-04-11 19:37:21 +09:00
parent 9fe161ec7c
commit 87828dc0ad
2 changed files with 12 additions and 4 deletions

View File

@@ -7,6 +7,10 @@ import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../engine.js';
import { createPlaneUvMapper, getPlaneUvIndexes } from '../utility.js';
const remap = (value: number, fromMin: number, fromMax: number, toMin: number, toMax: number) => {
return toMin + ((value - fromMin) / (fromMax - fromMin)) * (toMax - toMin);
};
export const poster = defineObject({
id: 'poster',
name: 'Poster',
@@ -61,8 +65,8 @@ export const poster = defineObject({
const srcWidth = tex.getSize().width;
const srcHeight = tex.getSize().height;
const srcAspect = srcWidth / srcHeight;
const targetWidth = options.width;
const targetHeight = options.height;
const targetWidth = remap(options.width, 0, 1, 2, 100); // 最小値(値を0にした場合)でのサイズは2cmで、最大値(値を1にした場合)でのサイズは100cmなので。比率の計算だから単位はなんでもいいけど、とにかく0が0にならない点を考慮させる必要がある
const targetHeight = remap(options.height, 0, 1, 2, 100); // 最小値(値を0にした場合)でのサイズは2cmで、最大値(値を1にした場合)でのサイズは100cmなので。比率の計算だから単位はなんでもいいけど、とにかく0が0にならない点を考慮させる必要がある
const targetAspect = targetWidth / targetHeight;
updateUv(srcAspect, targetAspect, options.fit);

View File

@@ -7,6 +7,10 @@ import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../engine.js';
import { createPlaneUvMapper, getPlaneUvIndexes } from '../utility.js';
const remap = (value: number, fromMin: number, fromMax: number, toMin: number, toMax: number) => {
return toMin + ((value - fromMin) / (fromMax - fromMin)) * (toMax - toMin);
};
export const tapestry = defineObject({
id: 'tapestry',
name: 'Tapestry',
@@ -63,8 +67,8 @@ export const tapestry = defineObject({
const srcWidth = tex.getSize().width;
const srcHeight = tex.getSize().height;
const srcAspect = srcWidth / srcHeight;
const targetWidth = options.width;
const targetHeight = options.height;
const targetWidth = remap(options.width, 0, 1, 2, 100); // 最小値(値を0にした場合)でのサイズは2cmで、最大値(値を1にした場合)でのサイズは100cmなので。比率の計算だから単位はなんでもいいけど、とにかく0が0にならない点を考慮させる必要がある
const targetHeight = remap(options.height, 0, 1, 2, 100); // 最小値(値を0にした場合)でのサイズは2cmで、最大値(値を1にした場合)でのサイズは100cmなので。比率の計算だから単位はなんでもいいけど、とにかく0が0にならない点を考慮させる必要がある
const targetAspect = targetWidth / targetHeight;
updateUv(srcAspect, targetAspect, options.fit);