未验证 提交 a02e5b1e 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #19867 from Mugen87/dev46

Examples: Clean up.
...@@ -184,6 +184,7 @@ THREE.Ocean = function ( renderer, camera, scene, options ) { ...@@ -184,6 +184,7 @@ THREE.Ocean = function ( renderer, camera, scene, options ) {
this.materialOcean.uniforms.u_skyColor = { value: this.skyColor }; this.materialOcean.uniforms.u_skyColor = { value: this.skyColor };
this.materialOcean.uniforms.u_sunDirection = { value: new THREE.Vector3( this.sunDirectionX, this.sunDirectionY, this.sunDirectionZ ) }; this.materialOcean.uniforms.u_sunDirection = { value: new THREE.Vector3( this.sunDirectionX, this.sunDirectionY, this.sunDirectionZ ) };
this.materialOcean.uniforms.u_exposure = { value: this.exposure }; this.materialOcean.uniforms.u_exposure = { value: this.exposure };
this.materialOcean.uniforms.u_size = { value: this.size };
// Disable blending to prevent default premultiplied alpha values // Disable blending to prevent default premultiplied alpha values
this.materialOceanHorizontal.blending = 0; this.materialOceanHorizontal.blending = 0;
......
...@@ -204,6 +204,7 @@ var Ocean = function ( renderer, camera, scene, options ) { ...@@ -204,6 +204,7 @@ var Ocean = function ( renderer, camera, scene, options ) {
this.materialOcean.uniforms.u_skyColor = { value: this.skyColor }; this.materialOcean.uniforms.u_skyColor = { value: this.skyColor };
this.materialOcean.uniforms.u_sunDirection = { value: new Vector3( this.sunDirectionX, this.sunDirectionY, this.sunDirectionZ ) }; this.materialOcean.uniforms.u_sunDirection = { value: new Vector3( this.sunDirectionX, this.sunDirectionY, this.sunDirectionZ ) };
this.materialOcean.uniforms.u_exposure = { value: this.exposure }; this.materialOcean.uniforms.u_exposure = { value: this.exposure };
this.materialOcean.uniforms.u_size = { value: this.size };
// Disable blending to prevent default premultiplied alpha values // Disable blending to prevent default premultiplied alpha values
this.materialOceanHorizontal.blending = 0; this.materialOceanHorizontal.blending = 0;
......
...@@ -247,7 +247,7 @@ ...@@ -247,7 +247,7 @@
var dolly, camera, scene, renderer; var dolly, camera, scene, renderer;
var geometry, material, mesh; var geometry, material, mesh;
var stats; var stats, clock;
var canvas = document.querySelector( '#canvas' ); var canvas = document.querySelector( '#canvas' );
...@@ -278,6 +278,8 @@ ...@@ -278,6 +278,8 @@
dolly = new THREE.Group(); dolly = new THREE.Group();
scene.add( dolly ); scene.add( dolly );
clock = new THREE.Clock();
camera = new THREE.PerspectiveCamera( 60, canvas.width / canvas.height, 1, 2000 ); camera = new THREE.PerspectiveCamera( 60, canvas.width / canvas.height, 1, 2000 );
camera.position.z = 4; camera.position.z = 4;
dolly.add( camera ); dolly.add( camera );
...@@ -330,11 +332,13 @@ ...@@ -330,11 +332,13 @@
} }
function render( time ) { function render() {
stats.begin(); stats.begin();
dolly.position.z = - time / 1000; var elapsedTime = clock.getElapsedTime();
dolly.position.z = - elapsedTime;
renderer.render( scene, camera ); renderer.render( scene, camera );
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
var container, stats; var container, stats;
var camera, scene, renderer; var camera, scene, renderer, clock;
init(); init();
animate(); animate();
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.1, 10 ); camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.1, 10 );
camera.position.set( 0, 0, 1 ); camera.position.set( 0, 0, 1 );
clock = new THREE.Clock();
scene = new THREE.Scene(); scene = new THREE.Scene();
var colorArray = [ new THREE.Color( 0xff0080 ), new THREE.Color( 0xffffff ), new THREE.Color( 0x8000ff ) ]; var colorArray = [ new THREE.Color( 0xff0080 ), new THREE.Color( 0xffffff ), new THREE.Color( 0x8000ff ) ];
...@@ -66,10 +68,6 @@ ...@@ -66,10 +68,6 @@
window.addEventListener( 'resize', onWindowResize, false ); window.addEventListener( 'resize', onWindowResize, false );
//
if ( typeof TESTING !== 'undefined' ) { for ( var i = 0; i < 1000; i ++ ) { render( 1000 - i ); } };
} }
function onWindowResize() { function onWindowResize() {
...@@ -83,18 +81,20 @@ ...@@ -83,18 +81,20 @@
// //
function animate( now ) { function animate() {
requestAnimationFrame( animate ); requestAnimationFrame( animate );
render( now ); render();
stats.update(); stats.update();
} }
function render( now ) { function render() {
var elapsedTime = clock.getElapsedTime();
scene.rotation.y = now / 2000; scene.rotation.y = elapsedTime * 0.5;
renderer.render( scene, camera ); renderer.render( scene, camera );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册