@aura3d/editor-runtime 1.3.3 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +36 -5
- package/src/AnimationSceneEditor.ts +0 -368
- package/src/AssetDropZone.ts +0 -144
- package/src/CameraPathEditor.ts +0 -223
- package/src/Command.ts +0 -11
- package/src/CommandHistory.ts +0 -136
- package/src/CurveEditor.ts +0 -152
- package/src/DiagnosticsOverlayModel.ts +0 -85
- package/src/EditorPluginHost.ts +0 -106
- package/src/EditorRuntime.ts +0 -349
- package/src/EditorStateModel.ts +0 -336
- package/src/EpisodeReviewPanel.ts +0 -236
- package/src/EventTrackEditor.ts +0 -169
- package/src/Gizmo.ts +0 -101
- package/src/HierarchyModel.ts +0 -57
- package/src/InspectorModel.ts +0 -71
- package/src/KeyframeEditor.ts +0 -214
- package/src/LocalizationAccessibilityFixtures.ts +0 -368
- package/src/MaterialVariantWorkflow.ts +0 -101
- package/src/MultiUserReviewWorkflow.ts +0 -229
- package/src/NonlinearAnimationEditor.ts +0 -262
- package/src/PickingService.ts +0 -174
- package/src/PlayModeBridge.ts +0 -27
- package/src/PrefabRegistry.ts +0 -164
- package/src/ProjectSerializer.ts +0 -200
- package/src/PropertyPanel.ts +0 -82
- package/src/RenderQueuePanel.ts +0 -106
- package/src/RotateGizmo.ts +0 -35
- package/src/ScaleGizmo.ts +0 -40
- package/src/SceneOutliner.ts +0 -78
- package/src/Selection.ts +0 -63
- package/src/ShaderGraphModel.ts +0 -254
- package/src/StaticExportRuntime.ts +0 -322
- package/src/TimelineEditorController.ts +0 -525
- package/src/TimelineModel.ts +0 -466
- package/src/TimelineRuntimeBridge.ts +0 -280
- package/src/TimelineTrackTypes.ts +0 -89
- package/src/TimelineUI.ts +0 -153
- package/src/TranslateGizmo.ts +0 -39
- package/src/VisualReviewDashboard.ts +0 -87
- package/src/commands/CreateNodeCommand.ts +0 -23
- package/src/commands/DeleteNodeCommand.ts +0 -74
- package/src/commands/ReparentNodeCommand.ts +0 -55
- package/src/commands/SetPropertyCommand.ts +0 -47
- package/src/commands/TransformCommand.ts +0 -107
- package/src/index.ts +0 -140
- package/tests/editor-runtime.test.ts +0 -1087
- package/tsconfig.json +0 -7
package/src/EditorPluginHost.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
export interface EditorPanelContribution {
|
|
2
|
-
readonly id: string;
|
|
3
|
-
readonly title: string;
|
|
4
|
-
readonly order?: number;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface EditorToolContribution {
|
|
8
|
-
readonly id: string;
|
|
9
|
-
readonly title: string;
|
|
10
|
-
readonly cursor?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface EditorImporterContribution {
|
|
14
|
-
readonly id: string;
|
|
15
|
-
readonly label: string;
|
|
16
|
-
readonly extensions: readonly string[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface EditorScriptingNodeContribution {
|
|
20
|
-
readonly id: string;
|
|
21
|
-
readonly title: string;
|
|
22
|
-
readonly category: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface EditorPlugin {
|
|
26
|
-
readonly id: string;
|
|
27
|
-
readonly name: string;
|
|
28
|
-
readonly panels?: readonly EditorPanelContribution[];
|
|
29
|
-
readonly tools?: readonly EditorToolContribution[];
|
|
30
|
-
readonly importers?: readonly EditorImporterContribution[];
|
|
31
|
-
readonly scriptingNodes?: readonly EditorScriptingNodeContribution[];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface EditorPluginSnapshot {
|
|
35
|
-
readonly plugins: readonly EditorPlugin[];
|
|
36
|
-
readonly panels: readonly EditorPanelContribution[];
|
|
37
|
-
readonly tools: readonly EditorToolContribution[];
|
|
38
|
-
readonly importers: readonly EditorImporterContribution[];
|
|
39
|
-
readonly scriptingNodes: readonly EditorScriptingNodeContribution[];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export class EditorPluginHost {
|
|
43
|
-
private readonly plugins = new Map<string, EditorPlugin>();
|
|
44
|
-
|
|
45
|
-
register(plugin: EditorPlugin): void {
|
|
46
|
-
const id = normalizeId(plugin.id, "plugin");
|
|
47
|
-
if (this.plugins.has(id)) {
|
|
48
|
-
throw new Error(`Editor plugin already registered: ${id}`);
|
|
49
|
-
}
|
|
50
|
-
this.assertUnique(plugin.panels ?? [], "panel", id);
|
|
51
|
-
this.assertUnique(plugin.tools ?? [], "tool", id);
|
|
52
|
-
this.assertUnique(plugin.importers ?? [], "importer", id);
|
|
53
|
-
this.assertUnique(plugin.scriptingNodes ?? [], "scripting node", id);
|
|
54
|
-
this.plugins.set(id, { ...plugin, id });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
unregister(id: string): boolean {
|
|
58
|
-
return this.plugins.delete(normalizeId(id, "plugin"));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
get(id: string): EditorPlugin | undefined {
|
|
62
|
-
return this.plugins.get(normalizeId(id, "plugin"));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
list(): readonly EditorPlugin[] {
|
|
66
|
-
return [...this.plugins.values()];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
snapshot(): EditorPluginSnapshot {
|
|
70
|
-
const plugins = this.list();
|
|
71
|
-
return {
|
|
72
|
-
plugins,
|
|
73
|
-
panels: sortByOrder(plugins.flatMap((plugin) => plugin.panels ?? [])),
|
|
74
|
-
tools: sortByOrder(plugins.flatMap((plugin) => plugin.tools ?? [])),
|
|
75
|
-
importers: plugins.flatMap((plugin) => plugin.importers ?? []),
|
|
76
|
-
scriptingNodes: plugins.flatMap((plugin) => plugin.scriptingNodes ?? [])
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
clear(): void {
|
|
81
|
-
this.plugins.clear();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private assertUnique(contributions: readonly { readonly id: string }[], kind: string, pluginId: string): void {
|
|
85
|
-
const seen = new Set<string>();
|
|
86
|
-
for (const contribution of contributions) {
|
|
87
|
-
const id = normalizeId(contribution.id, kind);
|
|
88
|
-
if (seen.has(id)) {
|
|
89
|
-
throw new Error(`Editor plugin ${pluginId} declares duplicate ${kind}: ${id}`);
|
|
90
|
-
}
|
|
91
|
-
seen.add(id);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function normalizeId(id: string, kind: string): string {
|
|
97
|
-
const normalized = id.trim();
|
|
98
|
-
if (!/^[a-z0-9][a-z0-9.-]*$/i.test(normalized)) {
|
|
99
|
-
throw new Error(`Editor ${kind} id must be non-empty and use letters, numbers, dots, or dashes.`);
|
|
100
|
-
}
|
|
101
|
-
return normalized;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function sortByOrder<T extends { readonly order?: number; readonly id: string }>(items: readonly T[]): readonly T[] {
|
|
105
|
-
return [...items].sort((left, right) => (left.order ?? 0) - (right.order ?? 0) || left.id.localeCompare(right.id));
|
|
106
|
-
}
|
package/src/EditorRuntime.ts
DELETED
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
import type { Ray } from "@aura3d/math";
|
|
2
|
-
import { CommandHistory } from "./CommandHistory";
|
|
3
|
-
import type { Command, CommandContext } from "./Command";
|
|
4
|
-
import { DiagnosticsOverlayModel, type EditorDiagnosticsInput, type EditorDiagnosticsSnapshot } from "./DiagnosticsOverlayModel";
|
|
5
|
-
import { normalizeGizmoSettings, type GizmoDrag, type GizmoSettings } from "./Gizmo";
|
|
6
|
-
import { EditorStateModel, type EditorStateSnapshot, type EditorStateStorage, type EditorViewportSettings } from "./EditorStateModel";
|
|
7
|
-
import { HierarchyModel, type HierarchyLikeNode, type HierarchyNodeDescriptor } from "./HierarchyModel";
|
|
8
|
-
import { InspectorModel, type InspectorEditableValue, type InspectorProperty } from "./InspectorModel";
|
|
9
|
-
import { MaterialVariantWorkflow, type MaterialVariantState } from "./MaterialVariantWorkflow";
|
|
10
|
-
import type { PlayModeBridge } from "./PlayModeBridge";
|
|
11
|
-
import { PickingService, type EditorPickHit, type EditorPickTarget, type EditorPickingEvidenceSnapshot } from "./PickingService";
|
|
12
|
-
import { PrefabRegistry, type EditorPrefabNodeBase } from "./PrefabRegistry";
|
|
13
|
-
import { RotateGizmo } from "./RotateGizmo";
|
|
14
|
-
import { ScaleGizmo } from "./ScaleGizmo";
|
|
15
|
-
import { Selection, type SelectionId } from "./Selection";
|
|
16
|
-
import { TranslateGizmo } from "./TranslateGizmo";
|
|
17
|
-
import type { TransformTarget } from "./commands/TransformCommand";
|
|
18
|
-
|
|
19
|
-
export type EditorMode = "edit" | "play" | "paused";
|
|
20
|
-
|
|
21
|
-
export interface EditorRuntimeSnapshot {
|
|
22
|
-
readonly mode: EditorMode;
|
|
23
|
-
readonly activeTool: string;
|
|
24
|
-
readonly selection: readonly (string | number)[];
|
|
25
|
-
readonly canUndo: boolean;
|
|
26
|
-
readonly canRedo: boolean;
|
|
27
|
-
readonly undoDepth: number;
|
|
28
|
-
readonly redoDepth: number;
|
|
29
|
-
readonly materialVariants: readonly MaterialVariantState[];
|
|
30
|
-
readonly prefabCount: number;
|
|
31
|
-
readonly picking: EditorPickingEvidenceSnapshot;
|
|
32
|
-
readonly diagnostics: EditorDiagnosticsSnapshot;
|
|
33
|
-
readonly gizmoSettings: GizmoSettings;
|
|
34
|
-
readonly editorState: EditorStateSnapshot;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface EditorRuntimeOptions {
|
|
38
|
-
readonly stateStorage?: EditorStateStorage;
|
|
39
|
-
readonly stateStorageKey?: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export class EditorRuntime {
|
|
43
|
-
readonly selection = new Selection();
|
|
44
|
-
readonly history = new CommandHistory();
|
|
45
|
-
readonly inspector = new InspectorModel();
|
|
46
|
-
readonly hierarchy = new HierarchyModel();
|
|
47
|
-
readonly materialVariants = new MaterialVariantWorkflow();
|
|
48
|
-
readonly diagnostics = new DiagnosticsOverlayModel();
|
|
49
|
-
readonly prefabs = new PrefabRegistry<EditorPrefabNodeBase>();
|
|
50
|
-
readonly state: EditorStateModel;
|
|
51
|
-
|
|
52
|
-
private readonly picking = new PickingService();
|
|
53
|
-
private modeRef: EditorMode = "edit";
|
|
54
|
-
private activeToolRef = "select";
|
|
55
|
-
private gizmoSettingsRef: GizmoSettings;
|
|
56
|
-
private disposed = false;
|
|
57
|
-
private activePlayModeBridge: PlayModeBridge<unknown> | null = null;
|
|
58
|
-
|
|
59
|
-
constructor(options: EditorRuntimeOptions = {}) {
|
|
60
|
-
this.state = new EditorStateModel({ storage: options.stateStorage, storageKey: options.stateStorageKey });
|
|
61
|
-
this.activeToolRef = this.state.activeTool;
|
|
62
|
-
this.gizmoSettingsRef = this.state.gizmoSettings();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
get mode(): EditorMode {
|
|
66
|
-
return this.modeRef;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
get activeTool(): string {
|
|
70
|
-
return this.activeToolRef;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
setTool(tool: string): void {
|
|
74
|
-
this.assertEditable();
|
|
75
|
-
const normalized = tool.trim();
|
|
76
|
-
if (normalized.length === 0) {
|
|
77
|
-
throw new Error("EditorRuntime tool name cannot be empty.");
|
|
78
|
-
}
|
|
79
|
-
this.state.setActiveTool(normalized);
|
|
80
|
-
this.activeToolRef = normalized;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
configureGizmos(settings: Partial<GizmoSettings>): GizmoSettings {
|
|
84
|
-
this.assertEditable();
|
|
85
|
-
this.gizmoSettingsRef = normalizeGizmoSettings({ ...this.gizmoSettingsRef, ...settings });
|
|
86
|
-
this.state.configureFromGizmoSettings(this.gizmoSettingsRef);
|
|
87
|
-
return this.gizmoSettingsRef;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
gizmoSettings(): GizmoSettings {
|
|
91
|
-
this.assertAlive();
|
|
92
|
-
return this.gizmoSettingsRef;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
configureViewportState(settings: Partial<EditorViewportSettings>): EditorStateSnapshot {
|
|
96
|
-
this.assertEditable();
|
|
97
|
-
this.state.configureViewport(settings);
|
|
98
|
-
return this.state.snapshot();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
editorStateSnapshot(): EditorStateSnapshot {
|
|
102
|
-
this.assertAlive();
|
|
103
|
-
return this.state.snapshot();
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
setMode(mode: EditorMode): void {
|
|
107
|
-
this.assertAlive();
|
|
108
|
-
if (this.activePlayModeBridge && mode === "edit") {
|
|
109
|
-
this.exitPlayMode();
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
this.modeRef = mode;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
pruneSelection(alive: (id: SelectionId) => boolean): void {
|
|
116
|
-
this.assertEditable();
|
|
117
|
-
this.selection.prune(alive);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
currentSelection(): readonly SelectionId[] {
|
|
121
|
-
this.assertAlive();
|
|
122
|
-
return this.selection.current();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
select(ids: readonly SelectionId[]): void {
|
|
126
|
-
this.assertEditable();
|
|
127
|
-
this.selection.set(ids);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
clearSelection(): void {
|
|
131
|
-
this.assertEditable();
|
|
132
|
-
this.selection.clear();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async executeCommand(command: Command, context?: CommandContext): Promise<void> {
|
|
136
|
-
this.assertEditable();
|
|
137
|
-
await this.history.execute(command, context);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
async executeTransaction(commands: readonly Command[], context?: CommandContext): Promise<void> {
|
|
141
|
-
this.assertEditable();
|
|
142
|
-
await this.history.executeTransaction(commands, context);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
async undo(context?: CommandContext): Promise<void> {
|
|
146
|
-
this.assertEditable();
|
|
147
|
-
await this.history.undo(context);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async redo(context?: CommandContext): Promise<void> {
|
|
151
|
-
this.assertEditable();
|
|
152
|
-
await this.history.redo(context);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
clearHistory(): void {
|
|
156
|
-
this.assertEditable();
|
|
157
|
-
this.history.clear();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
inspect(target: object): readonly InspectorProperty[] {
|
|
161
|
-
this.assertAlive();
|
|
162
|
-
return this.inspector.describe(target);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
async editInspectedProperty<T extends object>(
|
|
166
|
-
target: T,
|
|
167
|
-
path: readonly string[],
|
|
168
|
-
value: InspectorEditableValue,
|
|
169
|
-
context?: CommandContext
|
|
170
|
-
): Promise<void> {
|
|
171
|
-
this.assertEditable();
|
|
172
|
-
await this.history.execute(this.inspector.createSetPropertyCommand(target, path, value), context);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
describeHierarchy(root: HierarchyLikeNode): HierarchyNodeDescriptor {
|
|
176
|
-
this.assertAlive();
|
|
177
|
-
return this.hierarchy.describe(root, new Set(this.selection.current()));
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
flattenHierarchy(root: HierarchyLikeNode): readonly HierarchyNodeDescriptor[] {
|
|
181
|
-
this.assertAlive();
|
|
182
|
-
return this.hierarchy.flatten(root, new Set(this.selection.current()));
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
setPickTargets(targets: readonly EditorPickTarget[]): void {
|
|
186
|
-
this.assertEditable();
|
|
187
|
-
this.picking.setTargets(targets);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
configurePickingBuffer(width: number, height: number): EditorPickingEvidenceSnapshot {
|
|
191
|
-
this.assertEditable();
|
|
192
|
-
this.picking.resizePickingBuffer(width, height);
|
|
193
|
-
return this.picking.snapshot();
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
pick(ray: Ray): EditorPickHit | undefined {
|
|
197
|
-
this.assertAlive();
|
|
198
|
-
return this.picking.pick(ray);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
pickingSnapshot(): EditorPickingEvidenceSnapshot {
|
|
202
|
-
this.assertAlive();
|
|
203
|
-
return this.picking.snapshot();
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
async translateTarget(target: TransformTarget | undefined, input: GizmoDrag): Promise<void> {
|
|
207
|
-
this.assertEditable();
|
|
208
|
-
if (!target) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
const gizmo = new TranslateGizmo(this.history, this.gizmoSettingsRef);
|
|
212
|
-
try {
|
|
213
|
-
gizmo.setTarget(target);
|
|
214
|
-
await gizmo.drag(input);
|
|
215
|
-
} finally {
|
|
216
|
-
gizmo.dispose();
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
async rotateTarget(target: TransformTarget | undefined, input: GizmoDrag): Promise<void> {
|
|
221
|
-
this.assertEditable();
|
|
222
|
-
if (!target) {
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
const gizmo = new RotateGizmo(this.history, this.gizmoSettingsRef);
|
|
226
|
-
try {
|
|
227
|
-
gizmo.setTarget(target);
|
|
228
|
-
await gizmo.drag(input);
|
|
229
|
-
} finally {
|
|
230
|
-
gizmo.dispose();
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
async scaleTarget(target: TransformTarget | undefined, input: GizmoDrag): Promise<void> {
|
|
235
|
-
this.assertEditable();
|
|
236
|
-
if (!target) {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
const gizmo = new ScaleGizmo(this.history, this.gizmoSettingsRef);
|
|
240
|
-
try {
|
|
241
|
-
gizmo.setTarget(target);
|
|
242
|
-
await gizmo.drag(input);
|
|
243
|
-
} finally {
|
|
244
|
-
gizmo.dispose();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
updateDiagnostics(input: EditorDiagnosticsInput): EditorDiagnosticsSnapshot {
|
|
249
|
-
this.assertAlive();
|
|
250
|
-
return this.diagnostics.update(input);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
diagnosticsSnapshot(): EditorDiagnosticsSnapshot {
|
|
254
|
-
this.assertAlive();
|
|
255
|
-
return this.diagnostics.snapshot();
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
registerMaterialVariants(assetId: string, variants: readonly string[], selected: string | null = null): MaterialVariantState {
|
|
259
|
-
this.assertEditable();
|
|
260
|
-
return this.materialVariants.register(assetId, variants, selected);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
setMaterialVariant(assetId: string, variant: string | null): MaterialVariantState {
|
|
264
|
-
this.assertEditable();
|
|
265
|
-
return this.materialVariants.select(assetId, variant);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
materialVariantState(assetId: string): MaterialVariantState {
|
|
269
|
-
this.assertAlive();
|
|
270
|
-
return this.materialVariants.state(assetId);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
enterPlayMode(bridge: PlayModeBridge<unknown>): void {
|
|
274
|
-
this.assertAlive();
|
|
275
|
-
if (this.modeRef !== "edit" || this.activePlayModeBridge) {
|
|
276
|
-
throw new Error("EditorRuntime can only enter play mode from edit mode.");
|
|
277
|
-
}
|
|
278
|
-
bridge.enter();
|
|
279
|
-
this.activePlayModeBridge = bridge;
|
|
280
|
-
this.modeRef = "play";
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
pausePlayMode(): void {
|
|
284
|
-
this.assertAlive();
|
|
285
|
-
if (this.modeRef !== "play") {
|
|
286
|
-
throw new Error("EditorRuntime can only pause while play mode is active.");
|
|
287
|
-
}
|
|
288
|
-
this.modeRef = "paused";
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
resumePlayMode(): void {
|
|
292
|
-
this.assertAlive();
|
|
293
|
-
if (this.modeRef !== "paused") {
|
|
294
|
-
throw new Error("EditorRuntime can only resume from paused play mode.");
|
|
295
|
-
}
|
|
296
|
-
this.modeRef = "play";
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
exitPlayMode({ restore = true } = {}): void {
|
|
300
|
-
this.assertAlive();
|
|
301
|
-
this.activePlayModeBridge?.exit({ restore });
|
|
302
|
-
this.activePlayModeBridge = null;
|
|
303
|
-
this.modeRef = "edit";
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
snapshot(): EditorRuntimeSnapshot {
|
|
307
|
-
this.assertAlive();
|
|
308
|
-
return {
|
|
309
|
-
mode: this.modeRef,
|
|
310
|
-
activeTool: this.activeToolRef,
|
|
311
|
-
selection: this.selection.current(),
|
|
312
|
-
canUndo: this.history.canUndo,
|
|
313
|
-
canRedo: this.history.canRedo,
|
|
314
|
-
undoDepth: this.history.undoDepth,
|
|
315
|
-
redoDepth: this.history.redoDepth,
|
|
316
|
-
materialVariants: this.materialVariants.snapshot(),
|
|
317
|
-
prefabCount: this.prefabs.list().length,
|
|
318
|
-
picking: this.picking.snapshot(),
|
|
319
|
-
diagnostics: this.diagnostics.snapshot(),
|
|
320
|
-
gizmoSettings: this.gizmoSettingsRef,
|
|
321
|
-
editorState: this.state.snapshot()
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
dispose(): void {
|
|
326
|
-
this.activePlayModeBridge?.exit({ restore: true });
|
|
327
|
-
this.activePlayModeBridge = null;
|
|
328
|
-
this.selection.clear();
|
|
329
|
-
this.history.clear();
|
|
330
|
-
this.materialVariants.clear();
|
|
331
|
-
this.diagnostics.clear();
|
|
332
|
-
this.prefabs.clear();
|
|
333
|
-
this.activeToolRef = "select";
|
|
334
|
-
this.disposed = true;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
private assertAlive(): void {
|
|
338
|
-
if (this.disposed) {
|
|
339
|
-
throw new Error("EditorRuntime has been disposed");
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
private assertEditable(): void {
|
|
344
|
-
this.assertAlive();
|
|
345
|
-
if (this.modeRef !== "edit") {
|
|
346
|
-
throw new Error("EditorRuntime edit commands can only run in edit mode.");
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|