rendering stats

This commit is contained in:
azykov@mail.ru
2026-06-21 19:10:18 +03:00
parent a60e01e4d1
commit 0b7cdd9f05
10 changed files with 96 additions and 28 deletions
+20 -1
View File
@@ -3,13 +3,19 @@ import type { ObjectInstance, ObjectType } from "../types";
import { MobxReconcilerMap } from '../utils/reconciler';
import { ObjectGeometryViewItem, ObjectTypeGeometryViewItem, ControlledCameraViewItem, ViewItem } from './viewLayers';
import type { WorldState } from "./worldState";
import { ObjectSelectionViewItem } from "./viewLayers/objectSelection";
import type { WorldEditorState } from "./worldEditorState";
export class ViewState {
public objectTypeGeometries: MobxReconcilerMap<ObjectType, ObjectTypeGeometryViewItem>;
public objectGeometries: MobxReconcilerMap<ObjectInstance, ObjectGeometryViewItem>;
public camera?: ControlledCameraViewItem;
constructor(world: WorldState) {
private readonly editor: WorldEditorState;
constructor(world: WorldState, editor: WorldEditorState) {
this.editor = editor;
makeAutoObservable(
this,
);
@@ -38,11 +44,24 @@ export class ViewState {
this.objectGeometries.dispose();
}
public get selectedObject(): ObjectSelectionViewItem | undefined {
const sel = this.editor.selection;
if (sel?.type !== 'object')
return;
const geom = this.objectGeometries.get(sel.id);
if (!geom)
return;
return new ObjectSelectionViewItem(geom, sel.editMode);
}
public get items(): ViewItem[] {
return [
...this.objectTypeGeometries,
...this.objectGeometries,
...[this.camera ? [this.camera] : []],
...[this.selectedObject ? [this.selectedObject] : []],
];
}
}