Skip to content

Commit

Permalink
fix(composer): Fixes 2nd camera viewing click bug (#291)
Browse files Browse the repository at this point in the history
* fix(composer): Fixes 2nd camera viewing click to look at object rather than view.

* Update the package.json test branch numbers due to auto-ratchet

Co-authored-by: Emily Dodds <mumanity@gmail.com>
  • Loading branch information
jwills-jdubs and mumanity authored Oct 24, 2022
1 parent d9e523a commit 7899333
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/scene-composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -127,9 +128,12 @@ const SceneHierarchyDataProvider: FC<SceneHierarchyDataProviderProps> = ({ 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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,7 +78,10 @@ const SceneHierarchyPanel: React.FC = (_) => {
<ClickableDiv
onClick={(event) => {
if (isViewing()) {
setCameraTarget(item.nodeRef, 'transition');
const node = getSceneNodeByRef(item.nodeRef);
if (!findComponentByType(node, KnownComponentType.Camera)) {
setCameraTarget(item.nodeRef, 'transition');
}
}

if (selectedSceneNodeRef === item.nodeRef) {
Expand Down

0 comments on commit 7899333

Please sign in to comment.