mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-30 14:33:59 +02:00
Update pictureFrame.ts
This commit is contained in:
@@ -15,11 +15,6 @@ export const pictureFrame = defineObject({
|
|||||||
type: 'color',
|
type: 'color',
|
||||||
label: 'Frame color',
|
label: 'Frame color',
|
||||||
},
|
},
|
||||||
direction: {
|
|
||||||
type: 'enum',
|
|
||||||
label: 'Direction',
|
|
||||||
enum: ['vertical', 'horizontal'],
|
|
||||||
},
|
|
||||||
width: {
|
width: {
|
||||||
type: 'range',
|
type: 'range',
|
||||||
label: 'Width',
|
label: 'Width',
|
||||||
@@ -67,7 +62,6 @@ export const pictureFrame = defineObject({
|
|||||||
},
|
},
|
||||||
default: {
|
default: {
|
||||||
frameColor: [0.71, 0.58, 0.39],
|
frameColor: [0.71, 0.58, 0.39],
|
||||||
direction: 'vertical',
|
|
||||||
width: 0.5,
|
width: 0.5,
|
||||||
height: 0.5,
|
height: 0.5,
|
||||||
frameThickness: 0.5,
|
frameThickness: 0.5,
|
||||||
@@ -91,6 +85,8 @@ export const pictureFrame = defineObject({
|
|||||||
pictureMesh.rotationQuaternion = null;
|
pictureMesh.rotationQuaternion = null;
|
||||||
pictureMesh.markVerticesDataAsUpdatable(BABYLON.VertexBuffer.UVKind, true);
|
pictureMesh.markVerticesDataAsUpdatable(BABYLON.VertexBuffer.UVKind, true);
|
||||||
|
|
||||||
|
const pictureMaterial = findMaterial('__X_PICTURE__');
|
||||||
|
|
||||||
const uvs = pictureMesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
|
const uvs = pictureMesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
|
||||||
const ax = uvs[6];
|
const ax = uvs[6];
|
||||||
const ay = uvs[7];
|
const ay = uvs[7];
|
||||||
@@ -101,45 +97,12 @@ export const pictureFrame = defineObject({
|
|||||||
const dx = uvs[0];
|
const dx = uvs[0];
|
||||||
const dy = uvs[1];
|
const dy = uvs[1];
|
||||||
|
|
||||||
const applyDirection = () => {
|
|
||||||
if (options.direction === 'vertical') {
|
|
||||||
frameMesh.rotation.z = 0;
|
|
||||||
matMesh.rotation.z = 0;
|
|
||||||
coverMesh.rotation.z = 0;
|
|
||||||
pictureMesh.rotation.z = 0;
|
|
||||||
|
|
||||||
uvs[6] = ax;
|
|
||||||
uvs[7] = ay;
|
|
||||||
uvs[2] = bx;
|
|
||||||
uvs[3] = by;
|
|
||||||
uvs[4] = cx;
|
|
||||||
uvs[5] = cy;
|
|
||||||
uvs[0] = dx;
|
|
||||||
uvs[1] = dy;
|
|
||||||
} else if (options.direction === 'horizontal') {
|
|
||||||
frameMesh.rotation.z = -Math.PI / 2;
|
|
||||||
matMesh.rotation.z = -Math.PI / 2;
|
|
||||||
coverMesh.rotation.z = -Math.PI / 2;
|
|
||||||
pictureMesh.rotation.z = -Math.PI / 2;
|
|
||||||
|
|
||||||
uvs[6] = cy;
|
|
||||||
uvs[7] = cx;
|
|
||||||
uvs[2] = dy;
|
|
||||||
uvs[3] = dx;
|
|
||||||
uvs[4] = ay;
|
|
||||||
uvs[5] = ax;
|
|
||||||
uvs[0] = by;
|
|
||||||
uvs[1] = bx;
|
|
||||||
}
|
|
||||||
|
|
||||||
pictureMesh.updateVerticesData(BABYLON.VertexBuffer.UVKind, uvs);
|
|
||||||
};
|
|
||||||
|
|
||||||
//applyDirection();
|
|
||||||
|
|
||||||
const applyFit = () => {
|
const applyFit = () => {
|
||||||
const srcWidth = 1920;
|
const tex = pictureMaterial.albedoTexture;
|
||||||
const srcHeight = 1200;
|
if (tex == null) return;
|
||||||
|
|
||||||
|
const srcWidth = tex.getSize().width;
|
||||||
|
const srcHeight = tex.getSize().height;
|
||||||
const targetWidth = options.width * (1 - (options.matHThickness * MAT_THICKNESS_FACTOR));
|
const targetWidth = options.width * (1 - (options.matHThickness * MAT_THICKNESS_FACTOR));
|
||||||
const targetHeight = options.height * (1 - (options.matVThickness * MAT_THICKNESS_FACTOR));
|
const targetHeight = options.height * (1 - (options.matVThickness * MAT_THICKNESS_FACTOR));
|
||||||
|
|
||||||
@@ -238,8 +201,6 @@ export const pictureFrame = defineObject({
|
|||||||
|
|
||||||
applySize();
|
applySize();
|
||||||
|
|
||||||
const pictureMaterial = findMaterial('__X_PICTURE__');
|
|
||||||
|
|
||||||
const applyCustomPicture = () => {
|
const applyCustomPicture = () => {
|
||||||
if (options.customPicture != null) {
|
if (options.customPicture != null) {
|
||||||
const tex = new BABYLON.Texture(options.customPicture, room.scene, false, false);
|
const tex = new BABYLON.Texture(options.customPicture, room.scene, false, false);
|
||||||
@@ -248,6 +209,12 @@ export const pictureFrame = defineObject({
|
|||||||
|
|
||||||
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
||||||
pictureMaterial.albedoTexture = tex;
|
pictureMaterial.albedoTexture = tex;
|
||||||
|
|
||||||
|
applyFit();
|
||||||
|
|
||||||
|
tex.onLoadObservable.addOnce(() => {
|
||||||
|
applyFit();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5);
|
pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5);
|
||||||
pictureMaterial.albedoTexture = null;
|
pictureMaterial.albedoTexture = null;
|
||||||
@@ -296,3 +263,41 @@ export const pictureFrame = defineObject({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
const applyDirection = () => {
|
||||||
|
if (options.direction === 'vertical') {
|
||||||
|
frameMesh.rotation.z = 0;
|
||||||
|
matMesh.rotation.z = 0;
|
||||||
|
coverMesh.rotation.z = 0;
|
||||||
|
pictureMesh.rotation.z = 0;
|
||||||
|
|
||||||
|
uvs[6] = ax;
|
||||||
|
uvs[7] = ay;
|
||||||
|
uvs[2] = bx;
|
||||||
|
uvs[3] = by;
|
||||||
|
uvs[4] = cx;
|
||||||
|
uvs[5] = cy;
|
||||||
|
uvs[0] = dx;
|
||||||
|
uvs[1] = dy;
|
||||||
|
} else if (options.direction === 'horizontal') {
|
||||||
|
frameMesh.rotation.z = -Math.PI / 2;
|
||||||
|
matMesh.rotation.z = -Math.PI / 2;
|
||||||
|
coverMesh.rotation.z = -Math.PI / 2;
|
||||||
|
pictureMesh.rotation.z = -Math.PI / 2;
|
||||||
|
|
||||||
|
uvs[6] = cy;
|
||||||
|
uvs[7] = cx;
|
||||||
|
uvs[2] = dy;
|
||||||
|
uvs[3] = dx;
|
||||||
|
uvs[4] = ay;
|
||||||
|
uvs[5] = ax;
|
||||||
|
uvs[0] = by;
|
||||||
|
uvs[1] = bx;
|
||||||
|
}
|
||||||
|
|
||||||
|
pictureMesh.updateVerticesData(BABYLON.VertexBuffer.UVKind, uvs);
|
||||||
|
};
|
||||||
|
|
||||||
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user