webgl_postprocessing_crossfade.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>three.js webgl - scenes transition</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <style>
  8. body {
  9. font-family: Monospace;
  10. background-color: #f0f0f0;
  11. margin: 0px;
  12. overflow: hidden;
  13. }
  14. .info {
  15. position: absolute;
  16. background-color: black;
  17. opacity: 0.8;
  18. color: white;
  19. text-align: center;
  20. top: 0px;
  21. width: 100%;
  22. }
  23. a { color: #00ffff; }
  24. </style>
  25. </head>
  26. <body>
  27. <div class="info">
  28. <a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> webgl scene transitions - by <a href="https://twitter.com/fernandojsg">fernandojsg</a> - <a href="https://github.com/kile/three.js-demos">github</a>
  29. </div>
  30. <div id="container"></div>
  31. <script src="../build/three.js"></script>
  32. <script src="js/libs/stats.min.js"></script>
  33. <script src="js/libs/dat.gui.min.js"></script>
  34. <script src="js/crossfade/scenes.js"></script>
  35. <script src="js/crossfade/gui.js"></script>
  36. <script src="js/crossfade/transition.js"></script>
  37. <script src="js/utils/BufferGeometryUtils.js"></script>
  38. <script>
  39. var container, stats;
  40. var renderer;
  41. var transition;
  42. var clock = new THREE.Clock();
  43. init();
  44. animate();
  45. function init() {
  46. initGUI();
  47. container = document.getElementById( "container" );
  48. renderer = new THREE.WebGLRenderer( { antialias: true } );
  49. renderer.setPixelRatio( window.devicePixelRatio );
  50. renderer.setSize( window.innerWidth, window.innerHeight );
  51. container.appendChild( renderer.domElement );
  52. stats = new Stats();
  53. container.appendChild( stats.dom );
  54. var sceneA = new Scene( "cube", 5000, 1200, 120, new THREE.Vector3( 0, - 0.4, 0 ), 0xffffff );
  55. var sceneB = new Scene( "sphere", 500, 2000, 50, new THREE.Vector3( 0, 0.2, 0.1 ), 0x000000 );
  56. transition = new Transition( sceneA, sceneB );
  57. }
  58. function animate() {
  59. requestAnimationFrame( animate );
  60. render();
  61. stats.update();
  62. }
  63. function render() {
  64. transition.render( clock.getDelta() );
  65. }
  66. </script>
  67. </body>
  68. </html>