mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-30 18:03:59 +02:00
wip
This commit is contained in:
@@ -110,6 +110,7 @@ type ObjectDef<OpSc extends OptionsSchema = OptionsSchema> = {
|
|||||||
options: Readonly<GetOptionsSchemaValues<OpSc>>;
|
options: Readonly<GetOptionsSchemaValues<OpSc>>;
|
||||||
loaderResult: BABYLON.ISceneLoaderAsyncResult;
|
loaderResult: BABYLON.ISceneLoaderAsyncResult;
|
||||||
meshUpdated: () => void;
|
meshUpdated: () => void;
|
||||||
|
findMesh: (keyword: string) => BABYLON.Mesh;
|
||||||
}) => RoomObjectInstance<GetOptionsSchemaValues<OpSc>>;
|
}) => RoomObjectInstance<GetOptionsSchemaValues<OpSc>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -861,6 +862,13 @@ export class RoomEngine {
|
|||||||
meshUpdated: () => {
|
meshUpdated: () => {
|
||||||
meshUpdated(this.objectMeshs.get(args.id)!.getChildMeshes() as BABYLON.Mesh[]);
|
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);
|
this.objectInstances.set(args.id, objectInstance);
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ export const a4Case = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
createInstance: ({ options, root }) => {
|
createInstance: ({ options, findMesh }) => {
|
||||||
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 bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
||||||
|
|
||||||
const applyColor = () => {
|
const applyColor = () => {
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ export const aromaReedDiffuser = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
createInstance: ({ options, root }) => {
|
createInstance: ({ options, findMesh }) => {
|
||||||
const bottleMesh = root.getChildMeshes().find(m => m.name.includes('__X_BOTTLE__')) as BABYLON.Mesh;
|
const bottleMesh = findMesh('__X_BOTTLE__');
|
||||||
const bottleMaterial = bottleMesh.material as BABYLON.PBRMaterial;
|
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 oilMaterial = oilMesh.material as BABYLON.PBRMaterial;
|
||||||
|
|
||||||
const applyBottleColor = () => {
|
const applyBottleColor = () => {
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ export const bed = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'floor',
|
placement: 'floor',
|
||||||
createInstance: ({ options, root }) => {
|
createInstance: ({ options, findMesh }) => {
|
||||||
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 bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
||||||
|
|
||||||
const applyColor = () => {
|
const applyColor = () => {
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ export const cactusS = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
createInstance: ({ options, root }) => {
|
createInstance: ({ options, findMesh }) => {
|
||||||
const potMesh = root.getChildMeshes().find(m => m.name.includes('__X_POT__')) as BABYLON.Mesh;
|
const potMesh = findMesh('__X_POT__');
|
||||||
const potMaterial = potMesh.material as BABYLON.PBRMaterial;
|
const potMaterial = potMesh.material as BABYLON.PBRMaterial;
|
||||||
|
|
||||||
const applyPotColor = () => {
|
const applyPotColor = () => {
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ export const chair = defineObject({
|
|||||||
},
|
},
|
||||||
placement: 'floor',
|
placement: 'floor',
|
||||||
isChair: true,
|
isChair: true,
|
||||||
createInstance: ({ root, options }) => {
|
createInstance: ({ findMesh, options }) => {
|
||||||
const primaryMesh = root.getChildMeshes().find(m => m.name.includes('__X_PRIMARY__')) as BABYLON.Mesh;
|
const primaryMesh = findMesh('__X_PRIMARY__');
|
||||||
const primaryMaterial = primaryMesh.material as BABYLON.PBRMaterial;
|
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 secondaryMaterial = secondaryMesh.material as BABYLON.PBRMaterial;
|
||||||
|
|
||||||
const applyPrimaryColor = () => {
|
const applyPrimaryColor = () => {
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ export const colorBox = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'floor',
|
placement: 'floor',
|
||||||
createInstance: ({ options, root }) => {
|
createInstance: ({ options, findMesh }) => {
|
||||||
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 bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
||||||
|
|
||||||
const applyColor = () => {
|
const applyColor = () => {
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ export const monitorSpeaker = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
createInstance: ({ options, root }) => {
|
createInstance: ({ options, findMesh }) => {
|
||||||
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 bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
||||||
|
|
||||||
const applyColor = () => {
|
const applyColor = () => {
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ export const petBottle = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
createInstance: ({ root, options }) => {
|
createInstance: ({ findMesh, options }) => {
|
||||||
const capMesh = root.getChildMeshes().find(m => m.name.includes('__X_CAP__')) as BABYLON.Mesh;
|
const capMesh = findMesh('__X_CAP__');
|
||||||
const liquidMesh = root.getChildMeshes().find(m => m.name.includes('__X_LIQUID__')) as BABYLON.Mesh;
|
const liquidMesh = findMesh('__X_LIQUID__');
|
||||||
|
|
||||||
const applyWithCap = () => {
|
const applyWithCap = () => {
|
||||||
capMesh.setEnabled(options.withCap);
|
capMesh.setEnabled(options.withCap);
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ export const speaker = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
createInstance: ({ options, root }) => {
|
createInstance: ({ options, findMesh }) => {
|
||||||
const outerMesh = root.getChildMeshes().find(m => m.name.includes('__X_COVER__')) as BABYLON.Mesh;
|
const outerMesh = findMesh('__X_COVER__');
|
||||||
const outerMaterial = outerMesh.material as BABYLON.PBRMaterial;
|
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 innerMaterial = innerMesh.material as BABYLON.PBRMaterial;
|
||||||
|
|
||||||
const applyOuterColor = () => {
|
const applyOuterColor = () => {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export const wallShelf = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'side',
|
placement: 'side',
|
||||||
createInstance: ({ room, options, root }) => {
|
createInstance: ({ findMesh, options, root }) => {
|
||||||
const applyStyle = () => {
|
const applyStyle = () => {
|
||||||
const aMeshes = root.getChildMeshes().filter(m => m.name.includes('__X_VARIATION_A__'));
|
const aMeshes = root.getChildMeshes().filter(m => m.name.includes('__X_VARIATION_A__'));
|
||||||
const bMeshes = root.getChildMeshes().filter(m => m.name.includes('__X_VARIATION_B__'));
|
const bMeshes = root.getChildMeshes().filter(m => m.name.includes('__X_VARIATION_B__'));
|
||||||
@@ -56,7 +56,7 @@ export const wallShelf = defineObject({
|
|||||||
|
|
||||||
applyStyle();
|
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 bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
||||||
const bodyTexture = bodyMaterial.albedoTexture as BABYLON.Texture;
|
const bodyTexture = bodyMaterial.albedoTexture as BABYLON.Texture;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user