1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-13 16:25:44 +02:00
This commit is contained in:
syuilo
2026-02-25 19:15:26 +09:00
parent 08667b4d35
commit a8456a45ab
11 changed files with 32 additions and 24 deletions

View File

@@ -110,6 +110,7 @@ type ObjectDef<OpSc extends OptionsSchema = OptionsSchema> = {
options: Readonly<GetOptionsSchemaValues<OpSc>>;
loaderResult: BABYLON.ISceneLoaderAsyncResult;
meshUpdated: () => void;
findMesh: (keyword: string) => BABYLON.Mesh;
}) => RoomObjectInstance<GetOptionsSchemaValues<OpSc>>;
};
@@ -861,6 +862,13 @@ export class RoomEngine {
meshUpdated: () => {
meshUpdated(this.objectMeshs.get(args.id)!.getChildMeshes() as BABYLON.Mesh[]);
},
findMesh: (keyword) => {
const mesh = root.getChildMeshes().find(m => m.name.includes(keyword));
if (mesh == null) {
throw new Error(`Mesh with keyword "${keyword}" not found for object ${args.type} (${args.id})`);
}
return mesh as BABYLON.Mesh;
},
});
this.objectInstances.set(args.id, objectInstance);

View File

@@ -21,8 +21,8 @@ export const a4Case = defineObject({
},
},
placement: 'top',
createInstance: ({ options, root }) => {
const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh;
createInstance: ({ options, findMesh }) => {
const bodyMesh = findMesh('__X_BODY__');
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
const applyColor = () => {

View File

@@ -26,11 +26,11 @@ export const aromaReedDiffuser = defineObject({
},
},
placement: 'top',
createInstance: ({ options, root }) => {
const bottleMesh = root.getChildMeshes().find(m => m.name.includes('__X_BOTTLE__')) as BABYLON.Mesh;
createInstance: ({ options, findMesh }) => {
const bottleMesh = findMesh('__X_BOTTLE__');
const bottleMaterial = bottleMesh.material as BABYLON.PBRMaterial;
const oilMesh = root.getChildMeshes().find(m => m.name.includes('__X_OIL__')) as BABYLON.Mesh;
const oilMesh = findMesh('__X_OIL__');
const oilMaterial = oilMesh.material as BABYLON.PBRMaterial;
const applyBottleColor = () => {

View File

@@ -21,8 +21,8 @@ export const bed = defineObject({
},
},
placement: 'floor',
createInstance: ({ options, root }) => {
const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh;
createInstance: ({ options, findMesh }) => {
const bodyMesh = findMesh('__X_BODY__');
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
const applyColor = () => {

View File

@@ -21,8 +21,8 @@ export const cactusS = defineObject({
},
},
placement: 'top',
createInstance: ({ options, root }) => {
const potMesh = root.getChildMeshes().find(m => m.name.includes('__X_POT__')) as BABYLON.Mesh;
createInstance: ({ options, findMesh }) => {
const potMesh = findMesh('__X_POT__');
const potMaterial = potMesh.material as BABYLON.PBRMaterial;
const applyPotColor = () => {

View File

@@ -27,11 +27,11 @@ export const chair = defineObject({
},
placement: 'floor',
isChair: true,
createInstance: ({ root, options }) => {
const primaryMesh = root.getChildMeshes().find(m => m.name.includes('__X_PRIMARY__')) as BABYLON.Mesh;
createInstance: ({ findMesh, options }) => {
const primaryMesh = findMesh('__X_PRIMARY__');
const primaryMaterial = primaryMesh.material as BABYLON.PBRMaterial;
const secondaryMesh = root.getChildMeshes().find(m => m.name.includes('__X_SECONDARY__')) as BABYLON.Mesh;
const secondaryMesh = findMesh('__X_SECONDARY__');
const secondaryMaterial = secondaryMesh.material as BABYLON.PBRMaterial;
const applyPrimaryColor = () => {

View File

@@ -21,8 +21,8 @@ export const colorBox = defineObject({
},
},
placement: 'floor',
createInstance: ({ options, root }) => {
const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh;
createInstance: ({ options, findMesh }) => {
const bodyMesh = findMesh('__X_BODY__');
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
const applyColor = () => {

View File

@@ -21,8 +21,8 @@ export const monitorSpeaker = defineObject({
},
},
placement: 'top',
createInstance: ({ options, root }) => {
const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh;
createInstance: ({ options, findMesh }) => {
const bodyMesh = findMesh('__X_BODY__');
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
const applyColor = () => {

View File

@@ -26,9 +26,9 @@ export const petBottle = defineObject({
},
},
placement: 'top',
createInstance: ({ root, options }) => {
const capMesh = root.getChildMeshes().find(m => m.name.includes('__X_CAP__')) as BABYLON.Mesh;
const liquidMesh = root.getChildMeshes().find(m => m.name.includes('__X_LIQUID__')) as BABYLON.Mesh;
createInstance: ({ findMesh, options }) => {
const capMesh = findMesh('__X_CAP__');
const liquidMesh = findMesh('__X_LIQUID__');
const applyWithCap = () => {
capMesh.setEnabled(options.withCap);

View File

@@ -26,11 +26,11 @@ export const speaker = defineObject({
},
},
placement: 'top',
createInstance: ({ options, root }) => {
const outerMesh = root.getChildMeshes().find(m => m.name.includes('__X_COVER__')) as BABYLON.Mesh;
createInstance: ({ options, findMesh }) => {
const outerMesh = findMesh('__X_COVER__');
const outerMaterial = outerMesh.material as BABYLON.PBRMaterial;
const innerMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh;
const innerMesh = findMesh('__X_BODY__');
const innerMaterial = innerMesh.material as BABYLON.PBRMaterial;
const applyOuterColor = () => {

View File

@@ -33,7 +33,7 @@ export const wallShelf = defineObject({
},
},
placement: 'side',
createInstance: ({ room, options, root }) => {
createInstance: ({ findMesh, options, root }) => {
const applyStyle = () => {
const aMeshes = root.getChildMeshes().filter(m => m.name.includes('__X_VARIATION_A__'));
const bMeshes = root.getChildMeshes().filter(m => m.name.includes('__X_VARIATION_B__'));
@@ -56,7 +56,7 @@ export const wallShelf = defineObject({
applyStyle();
const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh;
const bodyMesh = findMesh('__X_BODY__');
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
const bodyTexture = bodyMaterial.albedoTexture as BABYLON.Texture;