index.html 9.4 KB

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