mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-08-04 14:26:17 +00:00
wip
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 34 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
@@ -884,8 +884,16 @@ export class RoomEngine {
|
||||
},
|
||||
findMaterial: (keyword) => {
|
||||
for (const m of root.getChildMeshes()) {
|
||||
if (m.material != null && m.material.name.includes(keyword)) {
|
||||
if (m.material == null) continue;
|
||||
if (m.material.name.includes(keyword)) {
|
||||
return m.material as BABYLON.PBRMaterial;
|
||||
} else if ((m.material as BABYLON.MultiMaterial).subMaterials != null) {
|
||||
for (const sm of (m.material as BABYLON.MultiMaterial).subMaterials) {
|
||||
if (sm == null) continue;
|
||||
if (sm.name.includes(keyword)) {
|
||||
return sm as BABYLON.PBRMaterial;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error(`Material with keyword "${keyword}" not found for object ${args.type} (${args.id})`);
|
||||
|
||||
@@ -3,19 +3,40 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import * as BABYLON from '@babylonjs/core';
|
||||
import { defineObject } from '../engine.js';
|
||||
|
||||
export const books = defineObject({
|
||||
id: 'books',
|
||||
name: 'Books',
|
||||
options: {
|
||||
schema: {},
|
||||
default: {},
|
||||
schema: {
|
||||
variation: {
|
||||
type: 'enum',
|
||||
label: 'Variation',
|
||||
enum: ['A', 'B', 'C', 'D', 'E'],
|
||||
},
|
||||
},
|
||||
default: {
|
||||
variation: 'A',
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
mergeMeshes: ['__X_BOOK_1__', '__X_BOOK_2__', '__X_BOOK_3__', '__X_BOOK_4__', '__X_BOOK_5__', '__X_BOOK_6__', '__X_BOOK_7__', '__X_BOOK_8__', '__X_BOOK_9__', '__X_BOOK_10__'],
|
||||
createInstance: ({ findMesh, root }) => {
|
||||
console.log(root.getChildMeshes().map((m) => m.name));
|
||||
createInstance: ({ room, options, findMesh, findMaterial }) => {
|
||||
const coverMaterial = findMaterial('__X_COVER__');
|
||||
|
||||
const applyVariation = () => {
|
||||
const coverTexture =
|
||||
options.variation === 'A' ? new BABYLON.Texture('/client-assets/room/objects/books/textures/a.png', room.scene, false, false) :
|
||||
options.variation === 'B' ? new BABYLON.Texture('/client-assets/room/objects/books/textures/b.png', room.scene, false, false) :
|
||||
options.variation === 'C' ? new BABYLON.Texture('/client-assets/room/objects/books/textures/c.png', room.scene, false, false) :
|
||||
options.variation === 'D' ? new BABYLON.Texture('/client-assets/room/objects/books/textures/d.png', room.scene, false, false) :
|
||||
new BABYLON.Texture('/client-assets/room/objects/books/textures/e.png', room.scene, false, false);
|
||||
coverMaterial.albedoTexture = coverTexture;
|
||||
};
|
||||
|
||||
applyVariation();
|
||||
|
||||
const bookMeshes = [
|
||||
findMesh('__X_BOOK_1__'),
|
||||
@@ -36,6 +57,9 @@ export const books = defineObject({
|
||||
}
|
||||
|
||||
return {
|
||||
onOptionsUpdated: ([k, v]) => {
|
||||
applyVariation();
|
||||
},
|
||||
interactions: {},
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user