|
7 | 7 | <link type="text/css" rel="stylesheet" href="main.css"> |
8 | 8 | <style> |
9 | 9 | body { |
10 | | - background-color: #bfe3dd; |
| 10 | + background-color: #e2e0e0; |
11 | 11 | color: #000; |
12 | 12 | } |
13 | 13 |
|
|
43 | 43 | import Stats from 'three/addons/libs/stats.module.js'; |
44 | 44 |
|
45 | 45 | import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; |
46 | | - import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js'; |
| 46 | + import { Sky } from 'three/addons/objects/Sky.js'; |
47 | 47 |
|
48 | 48 | import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js'; |
49 | 49 | import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js'; |
|
59 | 59 | const renderer = new THREE.WebGLRenderer( { antialias: true } ); |
60 | 60 | renderer.setPixelRatio( window.devicePixelRatio ); |
61 | 61 | renderer.setSize( window.innerWidth, window.innerHeight ); |
| 62 | + renderer.toneMapping = THREE.ACESFilmicToneMapping; |
62 | 63 | container.appendChild( renderer.domElement ); |
63 | 64 |
|
64 | | - const pmremGenerator = new THREE.PMREMGenerator( renderer ); |
65 | | - |
66 | 65 | const scene = new THREE.Scene(); |
67 | | - scene.background = new THREE.Color( 0xbfe3dd ); |
68 | | - scene.environment = pmremGenerator.fromScene( new RoomEnvironment(), 0.04 ).texture; |
| 66 | + |
| 67 | + // Sky |
| 68 | + |
| 69 | + const sky = new Sky(); |
| 70 | + |
| 71 | + const uniforms = sky.material.uniforms; |
| 72 | + uniforms[ 'turbidity' ].value = 0; |
| 73 | + uniforms[ 'rayleigh' ].value = 3; |
| 74 | + uniforms[ 'mieDirectionalG' ].value = 0.7; |
| 75 | + uniforms[ 'cloudElevation' ].value = 1; |
| 76 | + uniforms[ 'sunPosition' ].value.set( - 0.8, 0.19, 0.56 ); // elevation: 11, azimuth: -55 |
| 77 | + |
| 78 | + const pmremGenerator = new THREE.PMREMGenerator( renderer ); |
| 79 | + const environment = pmremGenerator.fromScene( sky ).texture; |
| 80 | + scene.background = environment; |
| 81 | + scene.environment = environment; |
69 | 82 |
|
70 | 83 | const camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 100 ); |
71 | 84 | camera.position.set( 5, 2, 8 ); |
72 | 85 |
|
73 | 86 | const controls = new OrbitControls( camera, renderer.domElement ); |
74 | | - controls.target.set( 0, 0.5, 0 ); |
75 | | - controls.update(); |
76 | | - controls.enablePan = false; |
77 | 87 | controls.enableDamping = true; |
| 88 | + controls.target.set( 0, 0.7, 0 ); |
| 89 | + controls.update(); |
78 | 90 |
|
79 | 91 | const dracoLoader = new DRACOLoader(); |
80 | 92 | dracoLoader.setDecoderPath( 'jsm/libs/draco/gltf/' ); |
|
99 | 111 |
|
100 | 112 | } ); |
101 | 113 |
|
102 | | - |
103 | 114 | window.onresize = function () { |
104 | 115 |
|
105 | 116 | camera.aspect = window.innerWidth / window.innerHeight; |
|
109 | 120 |
|
110 | 121 | }; |
111 | 122 |
|
112 | | - |
113 | 123 | function animate() { |
114 | 124 |
|
115 | 125 | const delta = clock.getDelta(); |
|
0 commit comments