mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-13 16:25:44 +02:00
wip
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user