webgl_postprocessing_crossfade.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. .info a {
  24. color: #00ffff;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <div class="info">
  30. <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>
  31. </div>
  32. <div id="container"></div>
  33. <script src="../build/three.js"></script>
  34. <script src="js/libs/stats.min.js"></script>
  35. <script src="js/libs/dat.gui.min.js"></script>
  36. <script src="js/crossfade/scenes.js"></script>
  37. <script src="js/crossfade/gui.js"></script>
  38. <script src="js/crossfade/transition.js"></script>
  39. <script>
  40. var container, stats;
  41. var renderer;
  42. var transition;
  43. var clock = new THREE.Clock();
  44. init();
  45. animate();
  46. function init() {
  47. initGUI();
  48. container = document.getElementById( "container" );
  49. renderer = new THREE.WebGLRenderer( { antialias: true } );
  50. renderer.setPixelRatio( window.devicePixelRatio );
  51. renderer.setSize( window.innerWidth, window.innerHeight );
  52. container.appendChild( renderer.domElement );
  53. stats = new Stats();
  54. container.appendChild( stats.dom );
  55. var sceneA = new Scene( "cube", 5000, 1200, 120, new THREE.Vector3(0,-0.4,0), 0xffffff );
  56. var sceneB = new Scene( "sphere", 500, 2000, 50, new THREE.Vector3(0,0.2,0.1), 0x000000 );
  57. transition = new Transition(sceneA,sceneB);
  58. }
  59. function animate() {
  60. requestAnimationFrame( animate );
  61. render();
  62. stats.update();
  63. }
  64. function render() {
  65. transition.render( clock.getDelta() );
  66. }
  67. </script>
  68. </body>
  69. </html>