mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-14 01:45:36 +02:00
book
This commit is contained in:
Binary file not shown.
Binary file not shown.
BIN
packages/frontend/assets/room/objects/book/template.png
Normal file
BIN
packages/frontend/assets/room/objects/book/template.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 259 KiB |
@@ -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: {},
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user