A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(editor): generic inspection-source channel for the shared Inspector
esenginebe17d56ecd6e
diff --git a/desktop/src/i18n/messages/sequencer.ts b/desktop/src/i18n/messages/sequencer.tsindex 08fcf7d3e..ee1cc58dc 100644--- a/desktop/src/i18n/messages/sequencer.ts+++ b/desktop/src/i18n/messages/sequencer.ts@@ -63,6 +63,11 @@ export const sequencerMessages = defineMessages({'seq.clipSettings': { en: 'Clip settings', zh: '剪辑设置' },'seq.durationS': { en: 'Duration (s)', zh: '时长(秒)' },'seq.frameRateFps': { en: 'Frame rate (fps)', zh: '帧率(fps)' },+ 'seq.insp.timeline': { en: 'Timeline', zh: '时间轴' },+ 'seq.timelineClip': { en: 'Timeline', zh: '时间轴' },+ 'seq.field.duration': { en: 'Duration', zh: '持续时间' },+ 'seq.field.fps': { en: 'FPS', zh: '帧率' },+ 'seq.field.wrap': { en: 'Wrap Mode', zh: '循环模式' },'seq.wrap.once': { en: 'Once', zh: '单次' },'seq.wrap.loop': { en: 'Loop', zh: '循环' },'seq.wrap.pingPong': { en: 'Ping-pong', zh: '往返' },diff --git a/desktop/src/panels/Details.tsx b/desktop/src/panels/Details.tsxindex 998a1951e..4b2b91f35 100644--- a/desktop/src/panels/Details.tsx+++ b/desktop/src/panels/Details.tsx@@ -85,7 +85,7 @@ import { SearchField } from '@/components/SearchField';import { Select } from '@/components/Select';import { Segmented, type SegmentedOption } from '@/components/Segmented';import { AddComponentMenu } from '@/components/AddComponentMenu';-import type { InspectorComponent, InspectorField, InspectorFieldValue, EntityId, NodeKind, EnumOption, AssetType, GradientValue, GradientStop, CurveValue, CurveKey, DimensionValue } from '@/types';+import type { InspectorComponent, InspectorField, InspectorFieldValue, EntityId, NodeKind, EnumOption, AssetType, GradientValue, GradientStop, CurveValue, CurveKey, DimensionValue, InspectSource } from '@/types';const AXES = ['x', 'y', 'z'];@@ -2733,6 +2733,43 @@ function FolderInspector({ path }: { path: string }) {);}+// A generic editor-pushed inspection source (an open timeline's clip settings,+// a track, a slice…) rendered through the same ComponentSection engine as+// entities and materials. Lives on the source's own subscribe/getRevision;+// edits route through source.write. The one shared inspector, no bespoke panel.+function SourceInspector({ source }: { source: InspectSource }) {+ useSyncExternalStore(source.subscribe, source.getRevision);+ const [collapsed, setCollapsed] = useState<Set<string>>(new Set());+ const toggle = (name: string) =>+ setCollapsed((s) => {+ const n = new Set(s);+ n.has(name) ? n.delete(name) : n.add(name);+ return n;+ });+ const components = source.build();+ return (+ <div className="insp">+ <div className="ent-head">+ <div className="ent-row1">+ <div className="ent-name">{source.title}</div>+ </div>+ </div>+ <div className="insp-body">+ {components.map((comp) => (+ <ComponentSection+ key={comp.name}+ entities={[]}+ comp={comp}+ collapsed={collapsed.has(comp.name)}+ onToggle={() => toggle(comp.name)}+ write={source.write}+ />+ ))}+ </div>+ </div>+ );+}+// Dispatcher: the live game inspector during PIE, the edit inspector otherwise.export function Details() {const inspectWorld = useEditorStore((s) => s.inspectWorld);@@ -2747,6 +2784,7 @@ function EditorDetails() {const selectedId = useSelection((s) => s.selectedId);const selectedIds = useSelection((s) => s.selectedIds);const selectedAsset = useSelection((s) => s.selectedAsset);+ const inspectSource = useSelection((s) => s.inspectSource);const selectedFolder = useOutliner((s) => s.selectedFolder);const ready = engine.status === 'ready' && selectedId != null;@@ -2805,6 +2843,12 @@ function EditorDetails() {return <FolderInspector path={selectedFolder} />;}+ // Editor-context inspection source (e.g. the open timeline's clip settings) is+ // the fallback — shown only when nothing else is selected, never overriding one.+ if (selectedId == null && inspectSource) {+ return <SourceInspector source={inspectSource} />;+ }+if (!entity || selectedId == null) {return (<div className="insp">diff --git a/desktop/src/panels/Sequencer.tsx b/desktop/src/panels/Sequencer.tsxindex 5468d6839..89d596f8f 100644--- a/desktop/src/panels/Sequencer.tsx+++ b/desktop/src/panels/Sequencer.tsx@@ -22,6 +22,7 @@ import { animatableFieldsFor } from '@/engine/schema';import { TimelineDocument } from '@/timeline/TimelineDocument';import { createAnimationClip } from '@/timeline/openClip';import { TimelineCommands } from '@/timeline/TimelineCommands';+import { buildTimelineComponents, makeTimelineWrite } from '@/timeline/timelineInspectorModel';import { useSequencerStore } from '@/store/sequencerStore';import { useSelection } from '@/store/selectionStore';import { SceneModel } from '@/engine/SceneModel';@@ -109,6 +110,27 @@ export function Sequencer() {useSyncExternalStore(TimelineDocument.subscribe, TimelineDocument.getRevision);const asset = TimelineDocument.asset;+ // Push the open timeline's clip settings (duration / fps / wrap) into the ONE+ // shared Details inspector via the generic inspection-source channel — a+ // fallback, so an entity/asset selection still wins. Cleared on close/unmount.+ const timelineOpen = !!asset;+ const timelinePath = TimelineDocument.meta.filePath;+ useEffect(() => {+ const sel = useSelection.getState();+ if (timelineOpen) {+ sel.setInspectSource({+ title: timelinePath?.split('/').pop() ?? t('seq.timelineClip'),+ subscribe: TimelineDocument.subscribe,+ getRevision: TimelineDocument.getRevision,+ build: () => buildTimelineComponents(TimelineDocument.asset!, TimelineDocument.meta.fps),+ write: makeTimelineWrite(),+ });+ } else {+ sel.setInspectSource(null);+ }+ return () => { useSelection.getState().setInspectSource(null); };+ }, [timelineOpen, timelinePath]);+if (!asset) return <div className="seq"><EmptyState /></div>;return <SequencerBody />;diff --git a/desktop/src/store/selectionStore.ts b/desktop/src/store/selectionStore.tsindex 5a859169f..05fe052e1 100644--- a/desktop/src/store/selectionStore.ts+++ b/desktop/src/store/selectionStore.ts@@ -3,7 +3,7 @@import { create } from 'zustand';import { SceneModel, SceneModelImpl } from '@/engine/SceneModel';import { PerfMonitor } from '@/engine/PerfMonitor';-import type { EntityId } from '@/types';+import type { EntityId, InspectSource } from '@/types';/*** Entity selection — model-anchored.@@ -36,6 +36,14 @@ interface SelectionState {selectMany: (ids: EntityId[], primary: EntityId) => void;/** Select an asset (or clear with null); clears any entity selection. */selectAsset: (path: string | null) => void;+ /**+ * An editor-context inspection source (the open timeline's clip settings, a+ * track…), shown in Details as a FALLBACK when nothing else is selected — it+ * never overrides an entity/asset/folder. The owning editor sets it on open+ * and clears it (null) on close/unmount.+ */+ inspectSource: InspectSource | null;+ setInspectSource: (src: InspectSource | null) => void;/** Remove one id from the selection (despawn self-healing). */dropId: (id: EntityId) => void;}@@ -54,6 +62,8 @@ export function createSelectionStore(model: SceneModelImpl) {selectedId: null,selectedIds: new Set<EntityId>(),selectedAsset: null,+ inspectSource: null,+ setInspectSource: (inspectSource) => set({ inspectSource }),// 'select' zone captures the synchronous subscriber work a selection triggers.select: (selectedId) =>diff --git a/desktop/src/timeline/timelineInspectorModel.ts b/desktop/src/timeline/timelineInspectorModel.tsnew file mode 100644index 000000000..2ffd2a71a--- /dev/null+++ b/desktop/src/timeline/timelineInspectorModel.ts@@ -0,0 +1,59 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file timelineInspectorModel.ts+ * @brief The open .estimeline's clip-level settings (duration / fps / wrap+ * mode) as shared-inspector components, pushed through the generic+ * inspection-source channel so they render in the one Details panel —+ * no bespoke Sequencer property panel. `duration`/`wrapMode` are asset+ * state (undoable via TimelineCommands); `fps` is editor display+ * metadata on the document. Same contract as the entity/material/clip+ * inspectors: one ComponentSection engine renders it.+ */+import type { TimelineAsset } from 'esengine';+import { WrapMode } from 'esengine';+import type { InspectorComponent, InspectorFieldType, GradientValue, CurveValue, DimensionValue } from '@/types';+import { TimelineCommands } from './TimelineCommands';+import { TimelineDocument } from './TimelineDocument';+import { t } from '@/i18n';++export function buildTimelineComponents(asset: TimelineAsset, fps: number): InspectorComponent[] {+ return [+ {+ name: 'Timeline',+ label: t('seq.insp.timeline'),+ fields: [+ { key: 'duration', label: t('seq.field.duration'), type: 'number', value: asset.duration, min: 0, step: 0.1, unit: 's' },+ { key: 'fps', label: t('seq.field.fps'), type: 'number', value: fps, min: 1, max: 240, step: 1 },+ {+ key: 'wrapMode',+ label: t('seq.field.wrap'),+ type: 'enum',+ value: asset.wrapMode,+ options: [+ { label: t('seq.wrap.once'), value: WrapMode.Once },+ { label: t('seq.wrap.loop'), value: WrapMode.Loop },+ { label: t('seq.wrap.pingPong'), value: WrapMode.PingPong },+ ],+ },+ ],+ },+ ];+}++/** A FieldWrite routing timeline clip-setting edits to the document/commands. */+export function makeTimelineWrite() {+ return (key: string, _type: InspectorFieldType, value: number | boolean | string | number[] | GradientValue | CurveValue | DimensionValue): void => {+ switch (key) {+ case 'duration':+ TimelineCommands.setDuration(value as number);+ break;+ case 'fps':+ TimelineDocument.setFps(value as number);+ break;+ case 'wrapMode':+ TimelineCommands.setWrapMode(value as WrapMode);+ break;+ }+ };+}diff --git a/desktop/src/types.ts b/desktop/src/types.tsindex 71b6cc5b5..74cdb3ef2 100644--- a/desktop/src/types.ts+++ b/desktop/src/types.ts@@ -149,6 +149,22 @@ export interface InspectorComponent {notice?: string;}+/**+ * A generic inspection source an editor pushes so its own sub-object selection+ * (an open timeline's clip settings, a track, a tileset slice…) renders in the+ * one shared Details inspector — no bespoke property panel. Consulted as a+ * FALLBACK: an entity/asset/folder selection always wins over it.+ * `subscribe`/`getRevision` drive a live re-render on the source's own edits;+ * `build` yields the components and `write` routes edits back to the source doc.+ */+export interface InspectSource {+ title: string;+ subscribe: (onChange: () => void) => () => void;+ getRevision: () => number;+ build: () => InspectorComponent[];+ write: (key: string, type: InspectorFieldType, value: number | boolean | string | number[] | GradientValue | CurveValue | DimensionValue) => void;+}+export type AssetType =| 'folder'| 'scene'