index.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>three.js / examples</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. @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 20px 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. .action-button {
  77. padding: 8px;
  78. color: #fff;
  79. background-color: #555;
  80. opacity: 0.7;
  81. float: left;
  82. margin-left: 1px;
  83. position: fixed;
  84. bottom: 20px;
  85. right: 20px;
  86. }
  87. .action-button:hover {
  88. cursor: pointer;
  89. opacity: 1;
  90. }
  91. .filterBlock{
  92. margin: 20px;
  93. position: relative;
  94. }
  95. .filterBlock p {
  96. margin: 0;
  97. }
  98. #filterInput {
  99. width: 100%;
  100. padding: 5px;
  101. font-family: inherit;
  102. font-size: 15px;
  103. outline: none;
  104. border: 1px solid #dedede;
  105. }
  106. #filterInput:focus{
  107. border: 1px solid #2194CE;
  108. }
  109. #clearFilterButton {
  110. position: absolute;
  111. right: 6px;
  112. top: 50%;
  113. margin-top: -8px;
  114. width: 16px;
  115. height: 16px;
  116. font-size: 14px;
  117. color: grey;
  118. text-align: center;
  119. line-height: 0;
  120. padding-top: 7px;
  121. opacity: .5;
  122. }
  123. #clearFilterButton:hover {
  124. opacity: 1;
  125. }
  126. .filtered {
  127. display: none !important;
  128. }
  129. #panel li b {
  130. font-weight: bold;
  131. }
  132. /* mobile */
  133. #expandButton {
  134. display: none;
  135. position: absolute;
  136. right: 20px;
  137. top: 12px;
  138. width: 32px;
  139. height: 32px;
  140. }
  141. #expandButton span {
  142. height: 2px;
  143. background-color: #2194CE;
  144. width: 16px;
  145. position: absolute;
  146. left: 8px;
  147. top: 10px;
  148. }
  149. #expandButton span:nth-child(1) {
  150. top: 16px;
  151. }
  152. #expandButton span:nth-child(2) {
  153. top: 22px;
  154. }
  155. @media all and ( max-width: 640px ) {
  156. h1{
  157. margin-top: 20px;
  158. margin-bottom: 20px;
  159. }
  160. #panel{
  161. position: absolute;
  162. left: 0;
  163. top: 0;
  164. height: 480px;
  165. width: 100%;
  166. right: 0;
  167. z-index: 100;
  168. overflow: hidden;
  169. border-bottom: 1px solid #dedede;
  170. }
  171. #content{
  172. position: absolute;
  173. left: 0;
  174. top: 90px;
  175. right: 0;
  176. bottom: 0;
  177. font-size: 17px;
  178. line-height: 22px;
  179. overflow: auto;
  180. }
  181. #viewer{
  182. position: absolute;
  183. left: 0;
  184. top: 56px;
  185. width: 100%;
  186. height: calc(100% - 56px);
  187. }
  188. #expandButton{
  189. display: block;
  190. }
  191. #panel.collapsed{
  192. height: 56px;
  193. }
  194. }
  195. </style>
  196. </head>
  197. <body>
  198. <div id="panel" class="collapsed">
  199. <h1><a href="http://threejs.org">three.js</a> / examples</h1>
  200. <a id="expandButton" href="#">
  201. <span></span>
  202. <span></span>
  203. <span></span>
  204. </a>
  205. <div class="filterBlock" >
  206. <input type="text" id="filterInput" placeholder="Type to filter"/>
  207. <a href="#" id="clearFilterButton" >x</a>
  208. </div>
  209. <div id="content"></div>
  210. </div>
  211. <iframe id="viewer" name="viewer" allowfullscreen onmousewheel=""></iframe>
  212. <script src="files.js"></script>
  213. <script>
  214. var panel = document.getElementById( 'panel' );
  215. var content = document.getElementById( 'content' );
  216. var viewer = document.getElementById( 'viewer' );
  217. var filterInput = document.getElementById( 'filterInput' );
  218. var clearFilterButton = document.getElementById( 'clearFilterButton' );
  219. var expandButton = document.getElementById( 'expandButton' );
  220. expandButton.addEventListener( 'click', function ( event ) {
  221. panel.classList.toggle( 'collapsed' );
  222. event.preventDefault();
  223. } );
  224. // iOS8 workaround
  225. if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
  226. viewer.addEventListener( 'load', function ( event ) {
  227. viewer.contentWindow.innerWidth -= 10;
  228. viewer.contentWindow.innerHeight -= 2;
  229. } );
  230. }
  231. var container = document.createElement( 'div' );
  232. content.appendChild( container );
  233. var button = document.createElement( 'div' );
  234. button.className = 'action-button';
  235. button.id = 'button';
  236. button.textContent = 'View source';
  237. button.addEventListener( 'click', function ( event ) {
  238. window.open( 'https://github.com/mrdoob/three.js/blob/master/examples/' + selected + '.html' );
  239. }, false );
  240. button.style.display = 'none';
  241. document.body.appendChild( button );
  242. var links = {};
  243. var selected = null;
  244. for ( var key in files ) {
  245. var section = files[ key ];
  246. var header = document.createElement( 'h2' );
  247. header.textContent = key;
  248. header.setAttribute( 'data-category', key );
  249. container.appendChild( header );
  250. for ( var i = 0; i < section.length; i ++ ) {
  251. ( function ( file ) {
  252. var name = getName( file );
  253. var link = document.createElement( 'a' );
  254. link.className = 'link';
  255. link.textContent = name;
  256. link.href = file + '.html';
  257. link.setAttribute( 'target', 'viewer' );
  258. link.addEventListener( 'click', function ( event ) {
  259. if ( event.button === 0 ) {
  260. selectFile( file );
  261. }
  262. } );
  263. container.appendChild( link );
  264. links[ file ] = link;
  265. } )( section[ i ] );
  266. }
  267. }
  268. var load = function ( file ) {
  269. selectFile( file );
  270. viewer.src = file + '.html';
  271. };
  272. var selectFile = function( file ) {
  273. if ( selected !== null ) links[ selected ].className = 'link';
  274. links[ file ].className = 'link selected';
  275. window.location.hash = file;
  276. button.style.display = '';
  277. panel.classList.toggle( 'collapsed' );
  278. selected = file;
  279. }
  280. if ( window.location.hash !== '' ) {
  281. load( window.location.hash.substring( 1 ) );
  282. }
  283. // filter
  284. filterInput.addEventListener( 'input', function( e ) {
  285. updateFilter();
  286. } );
  287. clearFilterButton.addEventListener( 'click', function( e ) {
  288. filterInput.value = '';
  289. updateFilter();
  290. e.preventDefault();
  291. } );
  292. function updateFilter() {
  293. var exp = new RegExp( filterInput.value, 'gi' );
  294. for ( var key in files ) {
  295. var section = files[ key ];
  296. for ( var i = 0; i < section.length; i ++ ) {
  297. filterExample( section[ i ], exp );
  298. }
  299. }
  300. layoutList();
  301. }
  302. function filterExample( file, exp ){
  303. var link = links[ file ];
  304. var name = getName( file );
  305. var res = file.match( exp );
  306. var text;
  307. if ( res && res.length > 0 ) {
  308. link.classList.remove( 'filtered' );
  309. for( var i = 0; i < res.length; i++ ) {
  310. text = name.replace( res[ i ], '<b>' + res[ i ] + '</b>' );
  311. }
  312. link.innerHTML = text;
  313. } else {
  314. link.classList.add( 'filtered' );
  315. link.innerHTML = name;
  316. }
  317. }
  318. function getName( file ) {
  319. var name = file.split( '_' );
  320. name.shift();
  321. return name.join( ' / ' );
  322. }
  323. function layoutList() {
  324. for ( var key in files ) {
  325. var collapsed = true;
  326. var section = files[ key ];
  327. for ( var i = 0; i < section.length; i ++ ) {
  328. var file = section[ i ];
  329. if( !links[ file ].classList.contains( 'filtered' ) ){
  330. collapsed = false;
  331. break;
  332. }
  333. }
  334. var element = document.querySelector( 'h2[data-category="' + key + '"]' );
  335. if( collapsed ){
  336. element.classList.add( 'filtered' );
  337. } else {
  338. element.classList.remove( 'filtered' );
  339. }
  340. }
  341. }
  342. </script>
  343. </body>
  344. </html>