mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-14 09:55:38 +02:00
wip
This commit is contained in:
@@ -227,10 +227,8 @@ onMounted(() => {
|
|||||||
position: [-35, 90, 175],
|
position: [-35, 90, 175],
|
||||||
rotation: [0, Math.PI, 0],
|
rotation: [0, Math.PI, 0],
|
||||||
options: {
|
options: {
|
||||||
bodyStyle: {
|
bodyStyle: 'color',
|
||||||
type: 'color',
|
bodyColor: [0.45, 0.8, 1],
|
||||||
value: [0.45, 0.8, 1],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
id: 'f3',
|
id: 'f3',
|
||||||
|
|||||||
@@ -63,21 +63,39 @@ type RoomObjectInstance<Options> = {
|
|||||||
|
|
||||||
export const WORLD_SCALE = 100;
|
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;
|
id: string;
|
||||||
defaultOptions: Options;
|
optionsSchema: OpSc;
|
||||||
|
defaultOptions: GetOptionsSchemaValues<OpSc>;
|
||||||
placement: 'top' | 'side' | 'bottom' | 'wall' | 'ceiling' | 'floor';
|
placement: 'top' | 'side' | 'bottom' | 'wall' | 'ceiling' | 'floor';
|
||||||
isChair?: boolean;
|
isChair?: boolean;
|
||||||
createInstance: (args: {
|
createInstance: (args: {
|
||||||
room: RoomEngine;
|
room: RoomEngine;
|
||||||
root: BABYLON.Mesh;
|
root: BABYLON.Mesh;
|
||||||
options: Options;
|
options: GetOptionsSchemaValues<OpSc>;
|
||||||
loaderResult: BABYLON.ISceneLoaderAsyncResult;
|
loaderResult: BABYLON.ISceneLoaderAsyncResult;
|
||||||
meshUpdated: () => void;
|
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;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,20 @@ import { get7segMeshesOfCurrentTime } from '../utility.js';
|
|||||||
|
|
||||||
export const tabletopDigitalClock = defineObject({
|
export const tabletopDigitalClock = defineObject({
|
||||||
id: 'tabletopDigitalClock',
|
id: 'tabletopDigitalClock',
|
||||||
defaultOptions: {
|
optionsSchema: {
|
||||||
bodyStyle: {
|
bodyStyle: {
|
||||||
|
type: 'select',
|
||||||
|
label: 'Body Style',
|
||||||
|
enum: ['color', 'wood'],
|
||||||
|
},
|
||||||
|
bodyColor: {
|
||||||
type: 'color',
|
type: 'color',
|
||||||
value: [0.45, 0.8, 0],
|
label: 'Body Color',
|
||||||
} as { type: 'color'; value: [number, number, number] } | { type: 'wood'; } | null,
|
},
|
||||||
|
},
|
||||||
|
defaultOptions: {
|
||||||
|
bodyStyle: 'color',
|
||||||
|
bodyColor: [0.45, 0.8, 0],
|
||||||
},
|
},
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
createInstance: ({ room, options, root }) => {
|
createInstance: ({ room, options, root }) => {
|
||||||
@@ -23,8 +32,8 @@ export const tabletopDigitalClock = defineObject({
|
|||||||
|
|
||||||
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
||||||
|
|
||||||
if (options.bodyStyle?.type === 'color') {
|
if (options.bodyStyle === 'color') {
|
||||||
const [r, g, b] = options.bodyStyle.value;
|
const [r, g, b] = options.bodyColor;
|
||||||
bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b);
|
bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user