1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-20 15:15:37 +02:00
This commit is contained in:
syuilo
2026-02-19 19:05:26 +09:00
parent 6a08231591
commit 376bb328df
3 changed files with 39 additions and 14 deletions

View File

@@ -63,21 +63,39 @@ type RoomObjectInstance<Options> = {
export const WORLD_SCALE = 100;
type ObjectDef<Options extends Record<string, any>> = {
type ColorOptionSchema = {
type: 'color';
label: string;
};
type SelectOptionSchema = {
type: 'select';
label: string;
enum: string[];
};
type OptionsSchema = Record<string, ColorOptionSchema | SelectOptionSchema>;
type GetOptionsSchemaValues<T extends OptionsSchema> = {
[K in keyof T]: T[K] extends ColorOptionSchema ? [number, number, number] : T[K] extends SelectOptionSchema ? T[K]['enum'][number] : never;
};
type ObjectDef<OpSc extends OptionsSchema> = {
id: string;
defaultOptions: Options;
optionsSchema: OpSc;
defaultOptions: GetOptionsSchemaValues<OpSc>;
placement: 'top' | 'side' | 'bottom' | 'wall' | 'ceiling' | 'floor';
isChair?: boolean;
createInstance: (args: {
room: RoomEngine;
root: BABYLON.Mesh;
options: Options;
options: GetOptionsSchemaValues<OpSc>;
loaderResult: BABYLON.ISceneLoaderAsyncResult;
meshUpdated: () => void;
}) => RoomObjectInstance<Options>;
}) => RoomObjectInstance<GetOptionsSchemaValues<OpSc>>;
};
export function defineObject<Options extends Record<string, any>>(def: ObjectDef<Options>): ObjectDef<Options> {
export function defineObject<const OpSc extends OptionsSchema>(def: ObjectDef<OpSc>): ObjectDef<OpSc> {
return def;
}