Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

Commit a2df55f

Browse files
authored
prevent scene from disappearing when double-clicking on a HierarchyTreeNode (#10932)
1 parent 1178168 commit a2df55f

File tree

1 file changed

+11
-4
lines changed
  • packages/ui/src/components/editor/panels/Hierarchy/container

1 file changed

+11
-4
lines changed

packages/ui/src/components/editor/panels/Hierarchy/container/index.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
2323
Ethereal Engine. All Rights Reserved.
2424
*/
2525

26-
import { getComponent, getMutableComponent, useOptionalComponent } from '@etherealengine/ecs/src/ComponentFunctions'
26+
import {
27+
getComponent,
28+
getMutableComponent,
29+
getOptionalComponent,
30+
useOptionalComponent
31+
} from '@etherealengine/ecs/src/ComponentFunctions'
2732
import { AllFileTypes } from '@etherealengine/engine/src/assets/constants/fileTypes'
2833
import { getMutableState, getState, none, useHookstate, useMutableState } from '@etherealengine/hyperflux'
2934
import { NameComponent } from '@etherealengine/spatial/src/common/NameComponent'
@@ -276,9 +281,11 @@ function HierarchyPanelContents(props: { sceneURL: string; rootEntity: Entity; i
276281
}
277282
setPrevClickedNode(entity)
278283
} else if (e.detail === 2) {
279-
const editorCameraState = getMutableComponent(Engine.instance.cameraEntity, CameraOrbitComponent)
280-
editorCameraState.focusedEntities.set([entity])
281-
editorCameraState.refocus.set(true)
284+
if (entity && getOptionalComponent(entity, CameraOrbitComponent)) {
285+
const editorCameraState = getMutableComponent(Engine.instance.cameraEntity, CameraOrbitComponent)
286+
editorCameraState.focusedEntities.set([entity])
287+
editorCameraState.refocus.set(true)
288+
}
282289
}
283290
},
284291
[prevClickedNode, entityHierarchy]

0 commit comments

Comments
 (0)