index.html 1.6 KB

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