Skip to content

Commit

Permalink
add workaround for no-unknown-property errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielburnworth committed Jun 28, 2024
1 parent 748cbf0 commit 8f12359
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
"no-null",
"import",
"promise",
"@react-three",
],
extends: [
"eslint:recommended",
Expand All @@ -29,6 +30,7 @@ module.exports = {
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:@react-three/recommended",
],
settings: {
react: {
Expand Down
24 changes: 13 additions & 11 deletions frontend/settings/pin_bindings/model.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/no-unknown-property */
/* eslint-disable no-null/no-null */
import React, { useRef } from "react";
import * as THREE from "three";
Expand All @@ -15,6 +14,9 @@ import { debounce, some } from "lodash";
import { t } from "../../i18next_wrapper";
import { isExpress } from "../../settings/firmware/firmware_hardware_support";
import { ButtonPin } from "./list_and_label_support";
import {
AmbientLight, DirectionalLight, Group, Mesh, PointLight,
} from "../../three_d_garden/components";

const ASSETS = "/3D/";
const LIB_DIR = `${ASSETS}lib/`;
Expand Down Expand Up @@ -265,27 +267,27 @@ export const Model = (props: BoxTopBaseProps) => {
setZForAllInGroup(e, Z);
document.body.style.cursor = "default";
};
return <group dispose={null}
return <Group dispose={null}
rotation={[0, 0, Math.PI / 2]}>
<PerspectiveCamera makeDefault name="camera" fov={30} near={0.1} far={1000}
position={[-150, 0, 300]}
rotation={[0, -Math.PI / 6, -Math.PI / 2]} />
<pointLight intensity={2} position={[0, 0, 200]} rotation={[0, 0, 0]}
<PointLight intensity={2} position={[0, 0, 200]} rotation={[0, 0, 0]}
distance={0} decay={0} />
<directionalLight intensity={0.1}
<DirectionalLight intensity={0.1}
position={[-100, 0, 100]} rotation={[0, 0, 0]} />
<ambientLight intensity={0.5} />
<mesh name={"electronicsBox"}
<AmbientLight intensity={0.5} />
<Mesh name={"electronicsBox"}
geometry={box.nodes.Electronics_Box.geometry}
material={box.materials[Material.box]}
scale={SCALE}
material-color={0xffffff}
material-emissive={0x999999} />
<mesh name={"electronicsBoxGasket"}
<Mesh name={"electronicsBoxGasket"}
geometry={box.nodes.Electronics_Box_Gasket.geometry}
material={box.materials[Material.gasket]}
scale={SCALE} />
<mesh name={"electronicsBoxLid"}
<Mesh name={"electronicsBoxLid"}
geometry={box.nodes.Electronics_Box_Lid.geometry}
material={box.materials[Material.lid]}
scale={SCALE} />
Expand All @@ -305,7 +307,7 @@ export const Model = (props: BoxTopBaseProps) => {
};
return <group key={btnPosition} name={"button-group"}
onPointerUp={leave}>
<mesh name={"button-housing"}
<Mesh name={"button-housing"}
geometry={btn.nodes["Push_Button_-_Red"].geometry}
material={btn.materials[Material.button]}
position={[-30, btnPosition, Z]}
Expand Down Expand Up @@ -363,7 +365,7 @@ export const Model = (props: BoxTopBaseProps) => {
.map(ledIndicator => {
const { position, color, ref } = ledIndicator;
return <group key={position}>
<mesh name={"led-housing"}
<Mesh name={"led-housing"}
geometry={led.nodes.LED.geometry}
material={led.materials[Material.led]}
position={[-50, position, Z]}
Expand All @@ -381,7 +383,7 @@ export const Model = (props: BoxTopBaseProps) => {
</Html>
</group>;
})}
</group>;
</Group>;
};

export const ElectronicsBoxModel = (props: BoxTopBaseProps) => {
Expand Down
26 changes: 26 additions & 0 deletions frontend/three_d_garden/components.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
import {
AmbientLightProps,
DirectionalLightProps,
GroupProps,
MeshProps,
PointLightProps,
} from "@react-three/fiber";

// Workaround to avoid disabling no-unknown-property rule
// eslint is marking props for THREE components starting with lowercase as unknown

export const AmbientLight = (props: AmbientLightProps) =>
<ambientLight {...props} />;

export const DirectionalLight = (props: DirectionalLightProps) =>
<directionalLight {...props} />;

export const Group = (props: GroupProps) =>
<group {...props} />;

export const Mesh = (props: MeshProps) =>
<mesh {...props} />;

export const PointLight = (props: PointLightProps) =>
<pointLight {...props} />;
6 changes: 3 additions & 3 deletions frontend/three_d_garden/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/no-unknown-property */
import { Circle, PerspectiveCamera, OrbitControls, Box } from "@react-three/drei";
import { Canvas } from "@react-three/fiber";
import React from "react";
import { AmbientLight, DirectionalLight } from "./components";

export interface ThreeDGardenProps {
}
Expand Down Expand Up @@ -29,8 +29,8 @@ export const ThreeDGardenModel = (props: ThreeDGardenModelProps) => {
<OrbitControls maxPolarAngle={Math.PI / 2} dampingFactor={0.2}
target={[0, 0, 0]}
minDistance={500} maxDistance={12000} />
<ambientLight intensity={1} />
<directionalLight intensity={0.5} position={[0, 0, 1000]} />
<AmbientLight intensity={1} />
<DirectionalLight intensity={0.5} position={[0, 0, 1000]} />
<Circle name={"ground"}
receiveShadow={true}
args={[30000, 16]}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"xterm": "5.3.0"
},
"devDependencies": {
"@react-three/eslint-plugin": "0.1.1",
"@types/enzyme": "3.10.12",
"@types/jest": "29.5.12",
"@types/readable-stream": "4.0.14",
Expand Down

0 comments on commit 8f12359

Please sign in to comment.