parent
8489fb0e32
commit
4d0c6617ee
@ -0,0 +1,26 @@
|
||||
import React from 'react'
|
||||
import {
|
||||
Bloom,
|
||||
DepthOfField,
|
||||
EffectComposer,
|
||||
Vignette,
|
||||
} from '@react-three/postprocessing'
|
||||
|
||||
// TODO Explore drei/three own's EffectComposer
|
||||
const Effects: React.FC = () => {
|
||||
return (
|
||||
<EffectComposer>
|
||||
<DepthOfField
|
||||
focusDistance={0}
|
||||
focalLength={0.15}
|
||||
bokehScale={2.5}
|
||||
width={window.innerWidth / 2}
|
||||
height={window.innerHeight / 2}
|
||||
/>
|
||||
<Vignette eskil={false} offset={0.1} darkness={0.8} />
|
||||
<Bloom luminanceThreshold={0.7} luminanceSmoothing={0.5} height={300} opacity={3} />
|
||||
</EffectComposer>
|
||||
)
|
||||
}
|
||||
|
||||
export default Effects
|
@ -0,0 +1,23 @@
|
||||
import React from 'react'
|
||||
import { Sky } from '@react-three/drei'
|
||||
|
||||
// TODO add props to change lighting according to real world time
|
||||
const Lighting: React.FC = () => {
|
||||
return (
|
||||
<>
|
||||
<ambientLight color={0xd3840e} />
|
||||
<pointLight position={[0, 20, -30]} color={0xd3840e} />
|
||||
<Sky
|
||||
distance={5500}
|
||||
azimuth={0.25}
|
||||
mieDirectionalG={0.83}
|
||||
mieCoefficient={0.008}
|
||||
inclination={0.5}
|
||||
turbidity={8}
|
||||
rayleigh={2.9}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default Lighting
|
@ -0,0 +1,38 @@
|
||||
import React, { Suspense } from 'react'
|
||||
import { Physics } from '@react-three/cannon'
|
||||
import { PointerLockControls } from '@react-three/drei'
|
||||
|
||||
import World from './models/World'
|
||||
import WorldCollisions from './models/WorldCollisions'
|
||||
import Player from './Player'
|
||||
import Lighting from './Lighting'
|
||||
import Effects from './Effects'
|
||||
|
||||
const Scene: React.FC = () => {
|
||||
return (
|
||||
<>
|
||||
<Lighting />
|
||||
|
||||
<Suspense fallback={null}>
|
||||
<World />
|
||||
<Physics
|
||||
gravity={[0, 0, 0]}
|
||||
iterations={2}
|
||||
size={10}
|
||||
defaultContactMaterial={{
|
||||
friction: 0,
|
||||
restitution: 0,
|
||||
}}
|
||||
>
|
||||
<WorldCollisions />
|
||||
<Player />
|
||||
</Physics>
|
||||
<Effects />
|
||||
</Suspense>
|
||||
|
||||
<PointerLockControls />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default Scene
|
Loading…
Reference in new issue