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-10 14:35:17 +09:00
parent dc59fd4edb
commit 11119ab046
7 changed files with 53 additions and 16 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 KiB

After

Width:  |  Height:  |  Size: 259 KiB

View File

@@ -15,29 +15,59 @@ export const book = defineObject({
label: 'Variation',
enum: [0, 1],
},
width: {
type: 'range',
label: 'Width',
min: 0,
max: 1,
step: 0.01,
},
height: {
type: 'range',
label: 'Height',
min: 0,
max: 1,
step: 0.01,
},
thickness: {
type: 'range',
label: 'thickness',
min: 0,
max: 1,
step: 0.01,
},
},
default: {
variation: 0,
width: 0.07,
height: 0.07,
thickness: 0.1,
},
},
placement: 'top',
createInstance: ({ options, root }) => {
createInstance: ({ options, model }) => {
const bodyMesh = model.findMesh('__X_BODY__');
const applySize = () => {
bodyMesh.morphTargetManager!.getTargetByName('Width')!.influence = options.width;
bodyMesh.morphTargetManager!.getTargetByName('Height')!.influence = options.height;
bodyMesh.morphTargetManager!.getTargetByName('Thickness')!.influence = options.thickness;
model.updated();
};
applySize();
return {
onInited: () => {
const mesh = root.getChildMeshes()[1] as BABYLON.Mesh;
mesh.markVerticesDataAsUpdatable(BABYLON.VertexBuffer.UVKind, true);
const index = options.variation ?? 0;
const x = index % 8;
const y = Math.floor(index / 8);
const uvs = mesh.getVerticesData(BABYLON.VertexBuffer.UVKind)!;
for (let i = 0; i < uvs.length / 2; i++) {
const u = uvs[i * 2];
const v = uvs[i * 2 + 1];
uvs[i * 2] = (u / 8) + (x / 8);
uvs[i * 2 + 1] = (v / 8) + (y / 8);
},
onOptionsUpdated: ([k, v]) => {
switch (k) {
case 'width':
case 'height':
case 'thickness':
applySize();
break;
}
mesh.updateVerticesData(BABYLON.VertexBuffer.UVKind, uvs);
},
interactions: {},
};

View File

@@ -16,13 +16,20 @@ export const randomBooks = defineObject({
name: 'randomBooks',
options: {
schema: {
plainCover: {
type: 'boolean',
label: 'Plain cover',
},
},
default: {
plainCover: false,
},
},
placement: 'top',
createInstance: ({ options, model }) => {
createInstance: ({ options, model, scene }) => {
const bodyMesh = model.findMesh('__X_BODY__');
const tex = new BABYLON.Texture('/client-assets/room/objects/random-books/texture.png', scene, false, false);
bodyMesh.material.albedoTexture = tex;
const count = 10;
@@ -34,7 +41,7 @@ export const randomBooks = defineObject({
mesh.morphTargetManager = bodyMesh.morphTargetManager.clone();
mesh.markVerticesDataAsUpdatable(BABYLON.VertexBuffer.UVKind, true);
const index = Math.floor(Math.random() * 8);
const index = Math.floor(Math.random() * 15);
const x = index % 8;
const y = Math.floor(index / 8);