mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-22 15:14:16 +02:00
wip
This commit is contained in:
35
packages/frontend/src/utility/room/objects/book.ts
Normal file
35
packages/frontend/src/utility/room/objects/book.ts
Normal 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: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user