Skip to content

Commit

Permalink
fix: rename files + cleaner code
Browse files Browse the repository at this point in the history
  • Loading branch information
longtv2222 committed Dec 20, 2023
1 parent 73640bc commit c1b786b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions prototype/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Canvas } from '@react-three/fiber'
import { Environment, Loader, OrbitControls, Stats, useProgress } from "@react-three/drei"
import Lamborghini from "./components/Models/Lamborghini"
import Lamborghini from "./components/Models/Lamborghini Aventador J"
import Scene from "./components/Models/Autobianchi Stellina"
import Maserati from "./components/Models/Maserati_mc20"
import Maserati from "./components/Models/Maserati MC20"
import { Leva, levaStore, useControls, button } from 'leva'
import { Suspense, useEffect, useRef, useState } from 'react'
import { Model, ModelProps, models } from './components/Models/model'
Expand All @@ -14,7 +14,7 @@ interface Cars {
}

export default function App() {
const carNameComponentMap: Record<Model, Cars> = {
const cars: Record<Model, Cars> = {
"Lamborghini Aventador J": {
Model: Lamborghini,
interior: "#000000",
Expand All @@ -32,7 +32,7 @@ export default function App() {
},
};

const [carsState, setCarsState] = useState(() => carNameComponentMap);
const [carsState, setCarsState] = useState(() => cars);
const carsStateRef = useRef(carsState);

useEffect(() => {
Expand All @@ -42,8 +42,8 @@ export default function App() {
const resetCarColor = () => {
const model = levaStore.get("Select") as Model;
set({
Exterior: carNameComponentMap[model].exterior,
Interior: carNameComponentMap[model].interior,
Exterior: cars[model].exterior,
Interior: cars[model].interior,
});
};

Expand All @@ -68,7 +68,7 @@ export default function App() {
}
})
};

const [{ Rotation, Stats: stats }, set] = useControls(() => ({
Select: {
options: models,
Expand All @@ -92,15 +92,15 @@ export default function App() {
"Reset color": button(resetCarColor),
}));

const { progress } = useProgress()
const { progress } = useProgress();

return (
<>
<Canvas camera={{ position: [0, 0, 10] }} shadows={true} frameloop="demand">
<Suspense fallback={null}>
{models
.map(name => (
carNameComponentMap[name].Model({
cars[name].Model({
exterior: carsState[name].exterior,
interior: carsState[name].interior,
visible: levaStore.get("Select") === name,
Expand Down

0 comments on commit c1b786b

Please sign in to comment.