1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-22 15:14:16 +02:00
This commit is contained in:
syuilo
2026-02-15 20:43:25 +09:00
parent d8d4b230b0
commit be67e75ef9
34 changed files with 789 additions and 310 deletions

View File

@@ -0,0 +1,35 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../engine.js';
export const book = defineObject({
id: 'book',
defaultOptions: {
variation: null as number | null,
},
placement: 'top',
createInstance: ({ room, o, root }) => {
return {
onInited: () => {
const mesh = root.getChildMeshes()[1] as BABYLON.Mesh;
mesh.markVerticesDataAsUpdatable(BABYLON.VertexBuffer.UVKind, true);
const index = o.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);
}
mesh.updateVerticesData(BABYLON.VertexBuffer.UVKind, uvs);
},
interactions: {},
};
},
});