2
0

index.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>three.js / examples</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <style>
  8. @font-face {
  9. font-family: 'inconsolata';
  10. src: url('files/inconsolata.woff') format('woff');
  11. font-weight: normal;
  12. font-style: normal;
  13. }
  14. * {
  15. box-sizing: border-box;
  16. }
  17. html {
  18. height: 100%;
  19. }
  20. body {
  21. background-color: #ffffff;
  22. margin: 0px;
  23. height: 100%;
  24. color: #555;
  25. font-family: 'inconsolata';
  26. font-size: 15px;
  27. line-height: 18px;
  28. overflow: hidden;
  29. }
  30. h1 {
  31. margin-top: 30px;
  32. margin-bottom: 40px;
  33. margin-left: 20px;
  34. font-size: 25px;
  35. font-weight: normal;
  36. }
  37. h2 {
  38. font-size: 20px;
  39. font-weight: normal;
  40. }
  41. a {
  42. color: #2194CE;
  43. text-decoration: none;
  44. }
  45. #panel {
  46. position: fixed;
  47. left: 0px;
  48. width: 310px;
  49. height: 100%;
  50. overflow: auto;
  51. background: #fafafa;
  52. }
  53. #panel #content {
  54. padding: 0px 20px;
  55. }
  56. #panel #content .link {
  57. color: #2194CE;
  58. text-decoration: none;
  59. cursor: pointer;
  60. display: block;
  61. }
  62. #panel #content .selected {
  63. color: #ff0000;
  64. }
  65. #panel #content .link:hover {
  66. text-decoration: underline;
  67. }
  68. #viewer {
  69. position: absolute;
  70. border: 0px;
  71. left: 310px;
  72. width: calc(100% - 310px);
  73. height: 100%;
  74. overflow: auto;
  75. }
  76. #button {
  77. position: fixed;
  78. bottom: 20px;
  79. right: 20px;
  80. padding: 8px;
  81. color: #fff;
  82. background-color: #555;
  83. opacity: 0.7;
  84. }
  85. #button:hover {
  86. cursor: pointer;
  87. opacity: 1;
  88. }
  89. /* mobile */
  90. #expandButton {
  91. display: none;
  92. position: absolute;
  93. right: 20px;
  94. top: 12px;
  95. width: 32px;
  96. height: 32px;
  97. }
  98. #expandButton span {
  99. height: 2px;
  100. background-color: #2194CE;
  101. width: 16px;
  102. position: absolute;
  103. left: 8px;
  104. top: 10px;
  105. }
  106. #expandButton span:nth-child(1) {
  107. top: 16px;
  108. }
  109. #expandButton span:nth-child(2) {
  110. top: 22px;
  111. }
  112. @media all and ( max-width: 640px ) {
  113. h1{
  114. margin-top: 20px;
  115. margin-bottom: 20px;
  116. }
  117. #panel{
  118. position: absolute;
  119. left: 0;
  120. top: 0;
  121. height: 480px;
  122. width: 100%;
  123. right: 0;
  124. z-index: 100;
  125. overflow: hidden;
  126. border-bottom: 1px solid #dedede;
  127. }
  128. #content{
  129. position: absolute;
  130. left: 0;
  131. top: 60px;
  132. right: 0;
  133. bottom: 0;
  134. font-size: 17px;
  135. line-height: 22px;
  136. overflow: auto;
  137. }
  138. #viewer{
  139. position: absolute;
  140. left: 0;
  141. top: 56px;
  142. width: 100%;
  143. height: calc(100% - 56px);
  144. }
  145. #expandButton{
  146. display: block;
  147. }
  148. #panel.collapsed{
  149. height: 56px;
  150. }
  151. }
  152. </style>
  153. </head>
  154. <body>
  155. <div id="panel" class="collapsed">
  156. <h1><a href="http://threejs.org">three.js</a> / examples</h1>
  157. <a id="expandButton" href="#">
  158. <span></span>
  159. <span></span>
  160. <span></span>
  161. </a>
  162. <div id="content"></div>
  163. </div>
  164. <iframe id="viewer" allowfullscreen onmousewheel=""></iframe>
  165. <script src="files.js"></script>
  166. <script>
  167. var panel = document.getElementById( 'panel' );
  168. var content = document.getElementById( 'content' );
  169. var viewer = document.getElementById( 'viewer' );
  170. var expandButton = document.getElementById( 'expandButton' );
  171. expandButton.addEventListener( 'click', function ( event ) {
  172. panel.classList.toggle( 'collapsed' );
  173. event.preventDefault();
  174. } );
  175. // iOS8 workaround
  176. if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
  177. viewer.addEventListener( 'load', function ( event ) {
  178. viewer.contentWindow.innerWidth -= 10;
  179. viewer.contentWindow.innerHeight -= 2;
  180. } );
  181. }
  182. var container = document.createElement( 'div' );
  183. content.appendChild( container );
  184. var button = document.createElement( 'div' );
  185. button.id = 'button';
  186. button.textContent = 'View source';
  187. button.addEventListener( 'click', function ( event ) {
  188. var array = location.href.split( '/' );
  189. array.pop();
  190. window.open( 'view-source:' + array.join( '/' ) + '/' + selected + '.html' );
  191. }, false );
  192. button.style.display = 'none';
  193. document.body.appendChild( button );
  194. var links = {};
  195. var selected = null;
  196. for ( var key in files ) {
  197. var section = files[ key ];
  198. var div = document.createElement( 'h2' );
  199. div.textContent = key;
  200. container.appendChild( div );
  201. for ( var i = 0; i < section.length; i ++ ) {
  202. ( function ( file ) {
  203. var name = file.split( '_' );
  204. name.shift();
  205. name = name.join( ' / ' );
  206. var link = document.createElement( 'a' );
  207. link.className = 'link';
  208. link.textContent = name;
  209. link.href = "#" + file;
  210. link.addEventListener( 'click', function ( event ) {
  211. if ( event.button === 0 ) {
  212. event.preventDefault();
  213. panel.classList.toggle( 'collapsed' );
  214. load( file );
  215. }
  216. } );
  217. container.appendChild( link );
  218. links[ file ] = link;
  219. } )( section[ i ] );
  220. }
  221. }
  222. var load = function ( file ) {
  223. if ( selected !== null ) links[ selected ].className = 'link';
  224. links[ file ].className = 'link selected';
  225. window.location.hash = file;
  226. viewer.src = file + '.html';
  227. viewer.focus();
  228. button.style.display = '';
  229. selected = file;
  230. };
  231. if ( window.location.hash !== '' ) {
  232. load( window.location.hash.substring( 1 ) );
  233. }
  234. </script>
  235. </body>
  236. </html>