index.html 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. <script>
  34. var loader = new THREE.XHRLoader();
  35. loader.load( 'app.json', function ( text ) {
  36. var json = JSON.parse( text );
  37. var player = new APP.Player();
  38. player.load( json );
  39. player.setSize( window.innerWidth, window.innerHeight );
  40. player.play();
  41. document.body.appendChild( player.dom );
  42. if ( json.project.editable === true ) {
  43. var button = document.createElement( 'div' );
  44. button.id = 'edit';
  45. button.textContent = 'EDIT';
  46. button.addEventListener( 'click', function ( event ) {
  47. var url = location.href.split( '/' ).slice( 0, - 1 ).join( '/' );
  48. window.open( 'http://threejs.org/editor/#file=https://crossorigin.me/' + url + '/app.json' );
  49. }, false );
  50. document.body.appendChild( button );
  51. }
  52. window.addEventListener( 'resize', function () {
  53. player.setSize( window.innerWidth, window.innerHeight );
  54. } );
  55. } );
  56. </script>
  57. </body>
  58. </html>