rendering stats
This commit is contained in:
@@ -15,15 +15,13 @@ export type RenderInfo = {
|
||||
|
||||
export class RootState {
|
||||
public readonly world = new WorldState();
|
||||
public readonly worldEditor: WorldEditorState;
|
||||
public readonly worldEditor = new WorldEditorState(this.world);
|
||||
public game: GameState | undefined;
|
||||
public renderInfo: RenderInfo | undefined;
|
||||
public readonly menu = new MenuState();
|
||||
public readonly view = new ViewState(this.world);
|
||||
public readonly view = new ViewState(this.world, this.worldEditor);
|
||||
|
||||
constructor() {
|
||||
this.worldEditor = new WorldEditorState(this.world);
|
||||
|
||||
makeAutoObservable(
|
||||
this,
|
||||
{
|
||||
|
||||
@@ -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] : []],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user