2025-10-14 22:53:26 +08:00
|
|
|
|
import type { Core, ServiceContainer } from '@esengine/ecs-framework';
|
|
|
|
|
|
import { IEditorPlugin, EditorPluginCategory, PanelPosition } from '@esengine/editor-core';
|
|
|
|
|
|
import type { MenuItem, ToolbarItem, PanelDescriptor, ISerializer } from '@esengine/editor-core';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Scene Inspector 插件
|
|
|
|
|
|
*
|
|
|
|
|
|
* 提供场景层级视图和实体检视功能
|
|
|
|
|
|
*/
|
|
|
|
|
|
export class SceneInspectorPlugin implements IEditorPlugin {
|
2025-11-02 23:50:41 +08:00
|
|
|
|
readonly name = '@esengine/scene-inspector';
|
|
|
|
|
|
readonly version = '1.0.0';
|
|
|
|
|
|
readonly displayName = 'Scene Inspector';
|
|
|
|
|
|
readonly category = EditorPluginCategory.Inspector;
|
|
|
|
|
|
readonly description = 'Scene hierarchy and entity inspector';
|
|
|
|
|
|
readonly icon = '🔍';
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
async install(_core: Core, _services: ServiceContainer): Promise<void> {
|
|
|
|
|
|
}
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
async uninstall(): Promise<void> {
|
|
|
|
|
|
}
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
registerMenuItems(): MenuItem[] {
|
|
|
|
|
|
return [
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'view-scene-inspector',
|
|
|
|
|
|
label: 'Scene Inspector',
|
|
|
|
|
|
parentId: 'view',
|
|
|
|
|
|
onClick: () => {
|
|
|
|
|
|
},
|
|
|
|
|
|
shortcut: 'Ctrl+Shift+I',
|
|
|
|
|
|
order: 100
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'scene-create-entity',
|
|
|
|
|
|
label: 'Create Entity',
|
|
|
|
|
|
parentId: 'scene',
|
|
|
|
|
|
onClick: () => {
|
|
|
|
|
|
},
|
|
|
|
|
|
shortcut: 'Ctrl+N',
|
|
|
|
|
|
order: 10
|
|
|
|
|
|
}
|
|
|
|
|
|
];
|
|
|
|
|
|
}
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
registerToolbar(): ToolbarItem[] {
|
|
|
|
|
|
return [
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'toolbar-create-entity',
|
|
|
|
|
|
label: 'New Entity',
|
|
|
|
|
|
groupId: 'entity-tools',
|
|
|
|
|
|
icon: '➕',
|
|
|
|
|
|
onClick: () => {
|
|
|
|
|
|
},
|
|
|
|
|
|
order: 10
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'toolbar-delete-entity',
|
|
|
|
|
|
label: 'Delete Entity',
|
|
|
|
|
|
groupId: 'entity-tools',
|
|
|
|
|
|
icon: '🗑️',
|
|
|
|
|
|
onClick: () => {
|
|
|
|
|
|
},
|
|
|
|
|
|
order: 20
|
|
|
|
|
|
}
|
|
|
|
|
|
];
|
|
|
|
|
|
}
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
registerPanels(): PanelDescriptor[] {
|
|
|
|
|
|
return [
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'panel-scene-hierarchy',
|
|
|
|
|
|
title: 'Scene Hierarchy',
|
|
|
|
|
|
position: PanelPosition.Left,
|
|
|
|
|
|
defaultSize: 250,
|
|
|
|
|
|
resizable: true,
|
|
|
|
|
|
closable: false,
|
|
|
|
|
|
icon: '📋',
|
|
|
|
|
|
order: 10
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'panel-entity-inspector',
|
|
|
|
|
|
title: 'Entity Inspector',
|
|
|
|
|
|
position: PanelPosition.Right,
|
|
|
|
|
|
defaultSize: 300,
|
|
|
|
|
|
resizable: true,
|
|
|
|
|
|
closable: false,
|
|
|
|
|
|
icon: '🔎',
|
|
|
|
|
|
order: 10
|
|
|
|
|
|
}
|
|
|
|
|
|
];
|
|
|
|
|
|
}
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
getSerializers(): ISerializer[] {
|
|
|
|
|
|
return [
|
|
|
|
|
|
{
|
|
|
|
|
|
serialize: (data: any) => {
|
|
|
|
|
|
const json = JSON.stringify(data);
|
|
|
|
|
|
const encoder = new TextEncoder();
|
|
|
|
|
|
return encoder.encode(json);
|
|
|
|
|
|
},
|
|
|
|
|
|
deserialize: (data: Uint8Array) => {
|
|
|
|
|
|
const decoder = new TextDecoder();
|
|
|
|
|
|
const json = decoder.decode(data);
|
|
|
|
|
|
return JSON.parse(json);
|
|
|
|
|
|
},
|
|
|
|
|
|
getSupportedType: () => 'scene'
|
|
|
|
|
|
}
|
|
|
|
|
|
];
|
|
|
|
|
|
}
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
async onEditorReady(): Promise<void> {
|
|
|
|
|
|
}
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
async onProjectOpen(projectPath: string): Promise<void> {
|
|
|
|
|
|
}
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
async onProjectClose(): Promise<void> {
|
|
|
|
|
|
}
|
2025-10-14 22:53:26 +08:00
|
|
|
|
}
|