Sandbox
drcmda
/
Building-dynamic-envmaps
A
App.js - nodebox - CodeSandbox
    • 1

    Explorer

      Drag a view here to display.

      Sandbox Info

        nodebox

        public
        src
        App.js
        Effects.js
        index.js
        Lamborghini.js
        styles.css
        .prettierrc
        package.json
        thumbnail.png

        Dependencies

          @react-three/drei
          9.74.6
          @react-three/fiber
          8.13.0
          @react-three/postprocessing
          2.6.0
          @types/three
          0.152.1
          lamina
          1.1.23
          leva
          0.9.34
          react
          18.2.0
          react-dom
          18.2.0
          three
          0.143.0

          Outline

          Show All Commands
          Ctrl+Shift+P
          Go to File
          Ctrl+P
          Find in Files
          Ctrl+Shift+F
          Toggle Full Screen
          F11
          Show Settings
          Ctrl+,
          App.js
          src
          App.js
          1
          2
          3
          4
          5
          6
          7
          8
          9
          10
          11
          12
          13
          14
          15
          16
          17
          18
          19
          20
          21
          22
          23
          24
          25
          26
          27
          28
          29
          30
          31
          32
          33
          34
          35
          36
          37
          38
          39
          40
          41
          42
          43
          44
          import { Canvas } from '@react-three/fiber'
          import { Environment, Lightformer, ContactShadows, OrbitControls } from '@react-three/drei'
          import { Effects } from './Effects'
          import { Lamborghini } from './Lamborghini'
          export default function App() {
            return (
              <Canvas gl={{ logarithmicDepthBuffer: true, antialias: false }} dpr={[1, 1.5]} camera={{ position: [0, 0, 15], fov: 25 }}>
                <color attach="background" args={['#15151a']} />
                <Lamborghini rotation={[0, Math.PI / 1.5, 0]} scale={0.015} />
                <hemisphereLight intensity={0.5} />
                <ContactShadows resolution={1024} frames={1} position={[0, -1.16, 0]} scale={15} blur={0.5} opacity={1} far={20} />
                <mesh scale={4} position={[3, -1.161, -1.5]} rotation={[-Math.PI / 2, 0, Math.PI / 2.5]}>
                  <ringGeometry args={[0.9, 1, 4, 1]} />
                  <meshStandardMaterial color="white" roughness={0.75} />
                </mesh>
                <mesh scale={4} position={[-3, -1.161, -1]} rotation={[-Math.PI / 2, 0, Math.PI / 2.5]}>
                  <ringGeometry args={[0.9, 1, 3, 1]} />
                  <meshStandardMaterial color="white" roughness={0.75} />
                </mesh>
                {/* We're building a cube-mapped environment declaratively.
                    Anything you put in here will be filmed (once) by a cubemap-camera
                    and applied to the scenes environment, and optionally background. */}
                <Environment resolution={512}>
                  {/* Ceiling */}
                  <Lightformer intensity={2} rotation-x={Math.PI / 2} position={[0, 4, -9]} scale={[10, 1, 1]} />
                  <Lightformer intensity={2} rotation-x={Math.PI / 2} position={[0, 4, -6]} scale={[10, 1, 1]} />
                  <Lightformer intensity={2} rotation-x={Math.PI / 2} position={[0, 4, -3]} scale={[10, 1, 1]} />
                  <Lightformer intensity={2} rotation-x={Math.PI / 2} position={[0, 4, 0]} scale={[10, 1, 1]} />
                  <Lightformer intensity={2} rotation-x={Math.PI / 2} position={[0, 4, 3]} scale={[10, 1, 1]} />
                  <Lightformer intensity={2} rotation-x={Math.PI / 2} position={[0, 4, 6]} scale={[10, 1, 1]} />
                  <Lightformer intensity={2} rotation-x={Math.PI / 2} position={[0, 4, 9]} scale={[10, 1, 1]} />
                  {/* Sides */}
                  <Lightformer intensity={2} rotation-y={Math.PI / 2} position={[-50, 2, 0]} scale={[100, 2, 1]} />
                  <Lightformer intensity={2} rotation-y={-Math.PI / 2} position={[50, 2, 0]} scale={[100, 2, 1]} />
                  {/* Key */}
                  <Lightformer form="ring" color="red" intensity={10} scale={2} position={[10, 5, 10]} onUpdate={(self) => self.lookAt(0, 0, 0)} />
                </Environment>
                <Effects />
                <OrbitControls enablePan={false} enableZoom={false} minPolarAngle={Math.PI / 2.2} maxPolarAngle={Math.PI / 2.2} />
              </Canvas>
            )
          }
          Press desired key combination and then press ENTER.
          Show All Commands
          Ctrl+Shift+P
          Go to File
          Ctrl+P
          Find in Files
          Ctrl+Shift+F
          Toggle Full Screen
          F11
          Show Settings
          Ctrl+,
          Preview

              Drag a view here to display.

                  Drag a view here to display.
                  CodeSandbox - Sandbox (Web)
                  0 0
                  1
                  Prettier
                  Layout: US
                  JavaScript JSX
                  LF
                  UTF-8
                  Spaces: 2
                  Ln 1, Col 1
                  Open preview

                  🍪 Yes, we use cookies

                  This website utilizes cookies to enable essential site functionality and analytics. You may change your settings at any time or accept the default settings. You may close this banner to continue with only essential cookies.
                  Read more about this in our privacy and cookie statement.