index.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>three.js</title>
  5. <meta charset="utf-8">
  6. <meta name="generator" content="Three.js Editor">
  7. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  8. <style>
  9. body {
  10. font-family: Helvetica, Arial, sans-serif;
  11. font-size: 12px;
  12. background-color: #000;
  13. margin: 0px;
  14. overflow: hidden;
  15. }
  16. #edit {
  17. position: absolute;
  18. bottom: 20px;
  19. right: 20px;
  20. padding: 8px;
  21. color: #555;
  22. background-color: #fff;
  23. opacity: 0.5;
  24. }
  25. #edit:hover {
  26. cursor: pointer;
  27. opacity: 1;
  28. }
  29. </style>
  30. </head>
  31. <body ontouchstart="">
  32. <script src="js/three.min.js"></script>
  33. <script src="js/app.js"></script>
  34. <!-- includes -->
  35. <script>
  36. var loader = new THREE.FileLoader();
  37. loader.load( 'app.json', function ( text ) {
  38. var json = JSON.parse( text );
  39. var player = new APP.Player();
  40. player.load( json );
  41. player.setSize( window.innerWidth, window.innerHeight );
  42. player.play();
  43. document.body.appendChild( player.dom );
  44. if ( json.project.editable === true ) {
  45. var button = document.createElement( 'div' );
  46. button.id = 'edit';
  47. button.textContent = 'EDIT';
  48. button.addEventListener( 'click', function ( event ) {
  49. var url = location.href.split( '/' ).slice( 0, - 1 ).join( '/' );
  50. window.open( 'http://threejs.org/editor/#file=' + url + '/app.json' );
  51. }, false );
  52. document.body.appendChild( button );
  53. }
  54. window.addEventListener( 'resize', function () {
  55. player.setSize( window.innerWidth, window.innerHeight );
  56. } );
  57. } );
  58. </script>
  59. </body>
  60. </html>