diff --git a/packages/scene-composer/package.json b/packages/scene-composer/package.json index be9383151..d3f1dacb7 100644 --- a/packages/scene-composer/package.json +++ b/packages/scene-composer/package.json @@ -154,10 +154,10 @@ "jest": { "coverageThreshold": { "global": { - "lines": 77.48, - "statements": 76.61, - "functions": 77.57, - "branches": 63.58, + "lines": 77.56, + "statements": 76.71, + "functions": 77.64, + "branches": 63.57, "branchesTrue": 100 } } diff --git a/packages/scene-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyDataProvider.tsx b/packages/scene-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyDataProvider.tsx index 6b5f87b5e..2c9c66375 100644 --- a/packages/scene-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyDataProvider.tsx +++ b/packages/scene-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyDataProvider.tsx @@ -3,9 +3,10 @@ import { DndProvider } from 'react-dnd'; import { HTML5Backend } from 'react-dnd-html5-backend'; import { useSceneComposerId } from '../../../common/sceneComposerIdContext'; -import { isEnvironmentNode } from '../../../utils/nodeUtils'; +import { findComponentByType, isEnvironmentNode } from '../../../utils/nodeUtils'; import { ISceneNodeInternal, useNodeErrorState, useStore } from '../../../store'; import useLifecycleLogging from '../../../logger/react-logger/hooks/useLifecycleLogging'; +import { KnownComponentType } from '../../../interfaces'; import ISceneHierarchyNode from './model/ISceneHierarchyNode'; @@ -127,9 +128,12 @@ const SceneHierarchyDataProvider: FC = ({ selec const activate = useCallback( (nodeRef: string) => { const setCameraTarget = useStore(sceneComposerId).getState().setCameraTarget; - setCameraTarget(nodeRef, 'transition'); + const node = getSceneNodeByRef(nodeRef); + if (!isViewing() || !findComponentByType(node, KnownComponentType.Camera)) { + setCameraTarget(nodeRef, 'transition'); + } }, - [sceneComposerId], + [sceneComposerId, isViewing], ); const search = useCallback((terms: string) => { diff --git a/packages/scene-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyPanel.C.tsx b/packages/scene-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyPanel.C.tsx index 3c08524f6..f4c50970d 100644 --- a/packages/scene-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyPanel.C.tsx +++ b/packages/scene-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyPanel.C.tsx @@ -7,6 +7,8 @@ import useLifecycleLogging from '../../../logger/react-logger/hooks/useLifecycle import { ISceneNodeInternal } from '../../../store'; import { useStore } from '../../../store/Store'; import { sceneComposerIdContext } from '../../../common/sceneComposerIdContext'; +import { findComponentByType } from '../../../utils/nodeUtils'; +import { KnownComponentType } from '../../../interfaces'; const ClickableDiv = styled.div` cursor: pointer; @@ -76,7 +78,10 @@ const SceneHierarchyPanel: React.FC = (_) => { { if (isViewing()) { - setCameraTarget(item.nodeRef, 'transition'); + const node = getSceneNodeByRef(item.nodeRef); + if (!findComponentByType(node, KnownComponentType.Camera)) { + setCameraTarget(item.nodeRef, 'transition'); + } } if (selectedSceneNodeRef === item.nodeRef) {