2
0

index.html 8.8 KB

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