diff --git a/.eslintrc.js b/.eslintrc.js index 7bb601619..88969caf5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -16,6 +16,7 @@ module.exports = { "no-null", "import", "promise", + "@react-three", ], extends: [ "eslint:recommended", @@ -29,6 +30,7 @@ module.exports = { "plugin:import/errors", "plugin:import/warnings", "plugin:import/typescript", + "plugin:@react-three/recommended", ], settings: { react: { diff --git a/frontend/settings/pin_bindings/model.tsx b/frontend/settings/pin_bindings/model.tsx index be05f20b1..12969a1be 100644 --- a/frontend/settings/pin_bindings/model.tsx +++ b/frontend/settings/pin_bindings/model.tsx @@ -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"; @@ -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/`; @@ -265,27 +267,27 @@ export const Model = (props: BoxTopBaseProps) => { setZForAllInGroup(e, Z); document.body.style.cursor = "default"; }; - return - - - - + - - @@ -305,7 +307,7 @@ export const Model = (props: BoxTopBaseProps) => { }; return - { .map(ledIndicator => { const { position, color, ref } = ledIndicator; return - { ; })} - ; + ; }; export const ElectronicsBoxModel = (props: BoxTopBaseProps) => { diff --git a/frontend/three_d_garden/components.tsx b/frontend/three_d_garden/components.tsx new file mode 100644 index 000000000..18cc9e443 --- /dev/null +++ b/frontend/three_d_garden/components.tsx @@ -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) => + ; + +export const DirectionalLight = (props: DirectionalLightProps) => + ; + +export const Group = (props: GroupProps) => + ; + +export const Mesh = (props: MeshProps) => + ; + +export const PointLight = (props: PointLightProps) => + ; diff --git a/frontend/three_d_garden/index.tsx b/frontend/three_d_garden/index.tsx index a1f26de56..c05144943 100644 --- a/frontend/three_d_garden/index.tsx +++ b/frontend/three_d_garden/index.tsx @@ -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 { } @@ -29,8 +29,8 @@ export const ThreeDGardenModel = (props: ThreeDGardenModelProps) => { - - + +