Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(CameraView): Minimum FOV check introduced #284

Merged
merged 1 commit into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 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.47,
"statements": 76.6,
"lines": 77.48,
"statements": 76.61,
"functions": 77.57,
"branches": 63.58,
"branches": 63.62,
"branchesTrue": 100
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ describe('CameraComponentEditor', () => {
expect(innerHTML.includes(`${expectedCamera.getFocalLength().toFixed(2)}mm`)).toEqual(true);
});

it('should not update if FOV is below the minimum value', () => {
useStore('default').setState(baseState);

const { container } = render(<CameraComponentEditor node={mockNode} component={cameraComponent} />);

const polarisWrapper = wrapper(container);
const input = polarisWrapper.find('[data-testid="camera-fov-field"]')?.findInput();

expect(input).not.toBeUndefined();
input!.focus();
input!.setInputValue('1');
input!.blur();
expect(updateComponentInternalFn).not.toBeCalled();
});

it('should update camera node when updating far', () => {
useStore('default').setState(baseState);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const CameraComponentEditor: React.FC<ICameraComponentEditorProps> = ({
const updateSceneNodeInternal = useStore(sceneComposerId)((state) => state.updateSceneNodeInternal);
const getObject3DBySceneNodeRef = useStore(sceneComposerId)((state) => state.getObject3DBySceneNodeRef);

const [fovError, setFovError] = useState<boolean>(false);

const cameraComponent = component as ICameraComponentInternal;

const focalLengthIntlMessages = {
Expand Down Expand Up @@ -306,7 +308,17 @@ const CameraComponentEditor: React.FC<ICameraComponentEditorProps> = ({
{intl.formatMessage({ defaultMessage: 'FOV', description: 'Form field label' })}
</div>
</TextContent>
<FormField data-testid={'camera-fov-field'}>
<FormField
data-testid={'camera-fov-field'}
errorText={
fovError
? intl.formatMessage({
defaultMessage: 'FOV cannot be less than 10',
description: 'Form field errorText',
})
: undefined
}
>
<NumericInput
value={cameraSettings.fov!}
toStr={(val) => val.toFixed(2)}
Expand All @@ -317,6 +329,9 @@ const CameraComponentEditor: React.FC<ICameraComponentEditorProps> = ({
fov: value,
});

setFovError(value < 10);
if (value < 10) return;

updateSettings(updatedSettings);
}
}, [])}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@
"note": "75mm lens",
"text": "75mm"
},
"NXP1Hm": {
"note": "Form field errorText",
"text": "FOV cannot be less than 10"
},
"Nj6Ob1": {
"note": "Select Color type option",
"text": "Define arrow color"
Expand Down