Skip to content

Commit 2591c71

Browse files
handle negative z coordinates in 3D
1 parent 5e01872 commit 2591c71

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

frontend/farm_designer/__tests__/three_d_garden_map_test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ describe("<ThreeDGardenMap />", () => {
2828
mapPoints: [],
2929
weeds: [],
3030
botPosition: { x: 1, y: 2, z: 3 },
31+
negativeZ: false,
3132
});
3233

3334
it("converts props", () => {
@@ -77,4 +78,17 @@ describe("<ThreeDGardenMap />", () => {
7778
weeds: [],
7879
}, {});
7980
});
81+
82+
it("converts props: negative z", () => {
83+
const p = fakeProps();
84+
p.botPosition = { x: undefined, y: undefined, z: -100 };
85+
p.negativeZ = true;
86+
render(<ThreeDGardenMap {...p} />);
87+
expect(ThreeDGarden).toHaveBeenCalledWith({
88+
config: expect.objectContaining({ x: 0, y: 0, z: 100 }),
89+
addPlantProps: expect.any(Object),
90+
mapPoints: [],
91+
weeds: [],
92+
}, {});
93+
});
8094
});

frontend/farm_designer/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ export class RawFarmDesigner
212212
plants={this.props.plants}
213213
get3DConfigValue={get3DConfigValueFunction(this.props.farmwareEnvs)}
214214
sourceFbosConfig={this.props.sourceFbosConfig}
215+
negativeZ={!!this.props.botMcuParams.movement_home_up_z}
215216
gridOffset={gridOffset}
216217
mapTransformProps={this.mapTransformProps}
217218
botSize={this.props.botSize}

frontend/farm_designer/three_d_garden_map.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface ThreeDGardenMapProps {
1919
gridOffset: AxisNumberProperty;
2020
get3DConfigValue(key: string): number;
2121
sourceFbosConfig: SourceFbosConfig;
22+
negativeZ: boolean;
2223
designer: DesignerState;
2324
plants: TaggedPlant[];
2425
dispatch: Function;
@@ -39,9 +40,11 @@ export const ThreeDGardenMap = (props: ThreeDGardenMapProps) => {
3940
config.zoomBeacons = false;
4041
config.trail = !!props.getWebAppConfigValue(BooleanSetting.display_trail);
4142

43+
const zDir = props.negativeZ ? -1 : 1;
44+
4245
config.x = props.botPosition.x || 0;
4346
config.y = props.botPosition.y || 0;
44-
config.z = props.botPosition.z || 0;
47+
config.z = zDir * (props.botPosition.z || 0);
4548

4649
const { designer } = props;
4750
config.distanceIndicator = designer.distanceIndicator;

0 commit comments

Comments
 (0)