Skip to content

Commit 03a1956

Browse files
authored
Examples: Improved webgl_animation_keyframes. (#32685)
1 parent 5a7e8bc commit 03a1956

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

-37 KB
Loading

examples/webgl_animation_keyframes.html

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link type="text/css" rel="stylesheet" href="main.css">
88
<style>
99
body {
10-
background-color: #bfe3dd;
10+
background-color: #e2e0e0;
1111
color: #000;
1212
}
1313

@@ -43,7 +43,7 @@
4343
import Stats from 'three/addons/libs/stats.module.js';
4444

4545
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';
4747

4848
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
4949
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
@@ -59,22 +59,34 @@
5959
const renderer = new THREE.WebGLRenderer( { antialias: true } );
6060
renderer.setPixelRatio( window.devicePixelRatio );
6161
renderer.setSize( window.innerWidth, window.innerHeight );
62+
renderer.toneMapping = THREE.ACESFilmicToneMapping;
6263
container.appendChild( renderer.domElement );
6364

64-
const pmremGenerator = new THREE.PMREMGenerator( renderer );
65-
6665
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;
6982

7083
const camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 100 );
7184
camera.position.set( 5, 2, 8 );
7285

7386
const controls = new OrbitControls( camera, renderer.domElement );
74-
controls.target.set( 0, 0.5, 0 );
75-
controls.update();
76-
controls.enablePan = false;
7787
controls.enableDamping = true;
88+
controls.target.set( 0, 0.7, 0 );
89+
controls.update();
7890

7991
const dracoLoader = new DRACOLoader();
8092
dracoLoader.setDecoderPath( 'jsm/libs/draco/gltf/' );
@@ -99,7 +111,6 @@
99111

100112
} );
101113

102-
103114
window.onresize = function () {
104115

105116
camera.aspect = window.innerWidth / window.innerHeight;
@@ -109,7 +120,6 @@
109120

110121
};
111122

112-
113123
function animate() {
114124

115125
const delta = clock.getDelta();

0 commit comments

Comments
 (0)