@@ -7,22 +7,34 @@ import { Leva, useControls } from 'leva'
77import { Suspense } from 'react'
88
99export default function App ( ) {
10+ const carNameComponentMap = {
11+ "Lamborghini Aventador J" : Lamborghini ,
12+ "Maserati MC20" : Maserati ,
13+ "Autobianchi Stellina" : Scene
14+ } ;
15+
1016 const { Interior, Exterior, Rotation, Select, Stats : stats } = useControls ( {
11- Select : { options : [ 'Lamborghini Aventador J' , 'Autobianchi Stellina' , "Maserati MC20" ] } ,
12- Interior : '#aa5252 ' ,
17+ Select : { options : Object . keys ( carNameComponentMap ) } ,
18+ Interior : '#000000 ' ,
1319 Exterior : '#9a9898' ,
1420 Rotation : false ,
1521 Stats : true ,
1622 } ) ;
23+
1724 const { progress } = useProgress ( )
1825
1926 return (
2027 < >
2128 < Canvas camera = { { position : [ 0 , 0 , 10 ] } } shadows = { true } frameloop = "demand" >
2229 < Suspense fallback = { null } >
23- < Lamborghini interior = { Interior } exterior = { Exterior } visible = { Select === "Lamborghini Aventador J" } />
24- < Scene interior = { Interior } exterior = { Exterior } visible = { Select === "Autobianchi Stellina" } />
25- < Maserati interior = { Interior } exterior = { Exterior } visible = { Select === "Maserati MC20" } />
30+ { Object . entries ( carNameComponentMap )
31+ . map ( ( [ name , CarModel ] ) => (
32+ CarModel ( {
33+ exterior : Exterior ,
34+ interior : Interior ,
35+ visible : Select === name ,
36+ } )
37+ ) ) }
2638 </ Suspense >
2739 < Environment
2840 background
0 commit comments