mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-31 23:14:19 +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',
|
label: 'Variation',
|
||||||
enum: [0, 1],
|
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: {
|
default: {
|
||||||
variation: 0,
|
variation: 0,
|
||||||
|
width: 0.07,
|
||||||
|
height: 0.07,
|
||||||
|
thickness: 0.1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'top',
|
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 {
|
return {
|
||||||
onInited: () => {
|
onInited: () => {
|
||||||
const mesh = root.getChildMeshes()[1] as BABYLON.Mesh;
|
},
|
||||||
mesh.markVerticesDataAsUpdatable(BABYLON.VertexBuffer.UVKind, true);
|
onOptionsUpdated: ([k, v]) => {
|
||||||
const index = options.variation ?? 0;
|
switch (k) {
|
||||||
const x = index % 8;
|
case 'width':
|
||||||
const y = Math.floor(index / 8);
|
case 'height':
|
||||||
|
case 'thickness':
|
||||||
const uvs = mesh.getVerticesData(BABYLON.VertexBuffer.UVKind)!;
|
applySize();
|
||||||
for (let i = 0; i < uvs.length / 2; i++) {
|
break;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
mesh.updateVerticesData(BABYLON.VertexBuffer.UVKind, uvs);
|
|
||||||
},
|
},
|
||||||
interactions: {},
|
interactions: {},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,13 +16,20 @@ export const randomBooks = defineObject({
|
|||||||
name: 'randomBooks',
|
name: 'randomBooks',
|
||||||
options: {
|
options: {
|
||||||
schema: {
|
schema: {
|
||||||
|
plainCover: {
|
||||||
|
type: 'boolean',
|
||||||
|
label: 'Plain cover',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
default: {
|
default: {
|
||||||
|
plainCover: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
createInstance: ({ options, model }) => {
|
createInstance: ({ options, model, scene }) => {
|
||||||
const bodyMesh = model.findMesh('__X_BODY__');
|
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;
|
const count = 10;
|
||||||
|
|
||||||
@@ -34,7 +41,7 @@ export const randomBooks = defineObject({
|
|||||||
mesh.morphTargetManager = bodyMesh.morphTargetManager.clone();
|
mesh.morphTargetManager = bodyMesh.morphTargetManager.clone();
|
||||||
mesh.markVerticesDataAsUpdatable(BABYLON.VertexBuffer.UVKind, true);
|
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 x = index % 8;
|
||||||
const y = Math.floor(index / 8);
|
const y = Math.floor(index / 8);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user