diff --git a/src/components/ObjectView.tsx b/src/components/ObjectView.tsx index 238738e..4f00766 100644 --- a/src/components/ObjectView.tsx +++ b/src/components/ObjectView.tsx @@ -16,7 +16,8 @@ export const ObjectView = observer(function ({ object }: ObjectViewProps) { if (!objectType) return null; - const isSelected = state.worldEditor.selectedObjectId === object.id; + const isSelected = state.worldEditor.isEnabled && + state.worldEditor.selectedObjectId === object.id; const handleClick = (e: { stopPropagation: () => void }) => { if (!state.worldEditor.isEnabled) diff --git a/src/state/world.ts b/src/state/world.ts index 192b3dc..aa97282 100644 --- a/src/state/world.ts +++ b/src/state/world.ts @@ -5,6 +5,7 @@ import { CharacterState } from "./character"; import type { Pos3, V3 } from "../types/3d"; import { clone, randomId } from "../utils"; import type { VoxelType } from "../types/voxel"; +import { state } from "./root"; export class WorldState { public data: World = WorldFactory.create(); @@ -117,6 +118,8 @@ export class WorldState { scene: clone(this.data.intialScene), } } + + state.worldEditor.setSelectedObjectId(undefined); } public pause(): void {