index.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>three.js / documentation</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. color: #454545;
  39. font-size: 18px;
  40. font-weight: normal;
  41. margin-top: 20px;
  42. margin-left: 20px;
  43. }
  44. h3 {
  45. color: #666;
  46. font-size: 16px;
  47. font-weight: normal;
  48. margin-top: 20px;
  49. margin-left: 20px;
  50. }
  51. a {
  52. color: #2194CE;
  53. text-decoration: none;
  54. }
  55. #panel {
  56. position: fixed;
  57. left: 0px;
  58. width: 260px;
  59. height: 100%;
  60. overflow: auto;
  61. background: #fafafa;
  62. }
  63. #panel ul {
  64. list-style-type: none;
  65. padding: 0px;
  66. margin-left: 20px;
  67. }
  68. #viewer {
  69. position: absolute;
  70. border: 0px;
  71. left: 260px;
  72. width: calc(100% - 260px);
  73. height: 100%;
  74. overflow: auto;
  75. }
  76. .filterBlock{
  77. margin: 20px;
  78. position: relative;
  79. }
  80. .filterBlock p {
  81. margin: 0;
  82. }
  83. #filterInput {
  84. width: 100%;
  85. padding: 5px;
  86. font-family: inherit;
  87. font-size: 15px;
  88. outline: none;
  89. border: 1px solid #dedede;
  90. }
  91. #filterInput:focus{
  92. border: 1px solid #2194CE;
  93. }
  94. #clearFilterButton {
  95. position: absolute;
  96. right: 6px;
  97. top: 50%;
  98. margin-top: -8px;
  99. width: 16px;
  100. height: 16px;
  101. font-size: 14px;
  102. color: grey;
  103. text-align: center;
  104. line-height: 0;
  105. padding-top: 7px;
  106. opacity: .5;
  107. }
  108. #clearFilterButton:hover {
  109. opacity: 1;
  110. }
  111. .filtered {
  112. display: none;
  113. }
  114. #panel li b {
  115. font-weight: bold;
  116. }
  117. /* mobile */
  118. #expandButton {
  119. display: none;
  120. position: absolute;
  121. right: 20px;
  122. top: 12px;
  123. width: 32px;
  124. height: 32px;
  125. }
  126. #expandButton span {
  127. height: 2px;
  128. background-color: #2194CE;
  129. width: 16px;
  130. position: absolute;
  131. left: 8px;
  132. top: 10px;
  133. }
  134. #expandButton span:nth-child(1) {
  135. top: 16px;
  136. }
  137. #expandButton span:nth-child(2) {
  138. top: 22px;
  139. }
  140. @media all and ( max-width: 640px ) {
  141. h1{
  142. margin-top: 20px;
  143. margin-bottom: 20px;
  144. }
  145. #panel{
  146. position: absolute;
  147. left: 0;
  148. top: 0;
  149. height: 480px;
  150. width: 100%;
  151. right: 0;
  152. z-index: 100;
  153. overflow: hidden;
  154. border-bottom: 1px solid #dedede;
  155. }
  156. #content{
  157. position: absolute;
  158. left: 0;
  159. top: 90px;
  160. right: 0;
  161. bottom: 0;
  162. font-size: 17px;
  163. line-height: 22px;
  164. overflow: auto;
  165. }
  166. #viewer{
  167. position: absolute;
  168. left: 0;
  169. top: 56px;
  170. width: 100%;
  171. height: calc(100% - 56px);
  172. }
  173. #expandButton{
  174. display: block;
  175. }
  176. #panel.collapsed{
  177. height: 56px;
  178. }
  179. }
  180. </style>
  181. </head>
  182. <body>
  183. <div id="panel" class="collapsed">
  184. <h1><a href="http://threejs.org">three.js</a> / docs</h1>
  185. <a id="expandButton" href="#">
  186. <span></span>
  187. <span></span>
  188. <span></span>
  189. </a>
  190. <div class="filterBlock" >
  191. <input type="text" id="filterInput" placeholder="Type to filter"/>
  192. <a href="#" id="clearFilterButton" >x</a>
  193. </div>
  194. <div id="content"></div>
  195. </div>
  196. <iframe id="viewer"></iframe>
  197. <script src="list.js"></script>
  198. <script>
  199. var panel = document.getElementById( 'panel' );
  200. var viewer = document.getElementById( 'viewer' );
  201. var expandButton = document.getElementById( 'expandButton' );
  202. expandButton.addEventListener( 'click', function ( event ) {
  203. panel.classList.toggle( 'collapsed' );
  204. event.preventDefault();
  205. } );
  206. var filterInput = document.getElementById( 'filterInput' );
  207. var clearFilterButton = document.getElementById( 'clearFilterButton' );
  208. var DELIMITER = '/';
  209. var MEMBER_DELIMITER = '.';
  210. var nameCategoryMap = {};
  211. var sections = [];
  212. var content = document.getElementById( 'content' );
  213. for ( var section in list ) {
  214. var h2 = document.createElement( 'h2' );
  215. h2.textContent = section;
  216. content.appendChild( h2 );
  217. for ( var category in list[ section ] ) {
  218. var div = document.createElement( 'div' );
  219. var h3 = document.createElement( 'h3' );
  220. h3.textContent = category;
  221. div.appendChild( h3 );
  222. var ul = document.createElement( 'ul' );
  223. div.appendChild( ul );
  224. for ( var i = 0; i < list[ section ][ category ].length; i ++ ) {
  225. var page = list[ section ][ category ][ i ];
  226. var li = document.createElement( 'li' );
  227. var a = document.createElement( 'a' );
  228. a.setAttribute( 'href', '#' );
  229. ( function( s, c, p ) {
  230. a.addEventListener( 'click', function( e ) {
  231. goTo( s, c, p );
  232. e.preventDefault();
  233. } )
  234. } )( section, category, page[ 0 ] )
  235. a.textContent = page[ 0 ];
  236. li.appendChild( a );
  237. ul.appendChild( li );
  238. nameCategoryMap[page[0]] = {
  239. section: section,
  240. category: category,
  241. name: page[0],
  242. element: a
  243. };
  244. }
  245. content.appendChild( div );
  246. sections.push( ul );
  247. }
  248. }
  249. panel.appendChild( content )
  250. function layoutList() {
  251. sections.forEach( function( el ) {
  252. var collapsed = true;
  253. Array.prototype.slice.apply( el.children ).forEach( function( item ) {
  254. if( !item.classList.contains( 'filtered' ) ) {
  255. collapsed = false;
  256. return;
  257. }
  258. } );
  259. if( collapsed ) {
  260. el.parentElement.classList.add( 'filtered' );
  261. } else {
  262. el.parentElement.classList.remove( 'filtered' );
  263. }
  264. } );
  265. }
  266. filterInput.addEventListener( 'input', function( e ) {
  267. updateFilter();
  268. } );
  269. clearFilterButton.addEventListener( 'click', function( e ) {
  270. filterInput.value = '';
  271. updateFilter();
  272. e.preventDefault();
  273. } );
  274. function updateFilter() {
  275. var exp = new RegExp( filterInput.value, 'gi' );
  276. for( var j in nameCategoryMap ) {
  277. var res = nameCategoryMap[ j ].name.match( exp );
  278. if( res && res.length > 0 ) {
  279. nameCategoryMap[ j ].element.parentElement.classList.remove( 'filtered' );
  280. var str = nameCategoryMap[ j ].name;
  281. for( var i = 0; i < res.length; i++ ) {
  282. str = str.replace( res[ i ], '<b>' + res[ i ] + '</b>' );
  283. }
  284. nameCategoryMap[ j ].element.innerHTML = str;
  285. } else {
  286. nameCategoryMap[ j ].element.parentElement.classList.add( 'filtered' );
  287. nameCategoryMap[ j ].element.textContent = nameCategoryMap[ j ].name;
  288. }
  289. }
  290. layoutList();
  291. }
  292. function encodeUrl( path ) {
  293. return path.replace(/\ \/\ /g, '.').replace(/\ /g, '_');
  294. }
  295. function decodeUrl( path ) {
  296. return path.replace(/_/g, ' ').replace(/\./g, ' / ');
  297. }
  298. // Page loading
  299. function goTo( section, category, name, member ) {
  300. var parts, location;
  301. // Fully resolve links that only provide a name
  302. if(arguments.length == 1) {
  303. // Resolve links of the form 'Class.member'
  304. if(section.indexOf(MEMBER_DELIMITER) !== -1) {
  305. parts = section.split(MEMBER_DELIMITER)
  306. section = parts[0];
  307. member = parts[1];
  308. }
  309. location = nameCategoryMap[section];
  310. if (!location) return;
  311. section = location.section;
  312. category = location.category;
  313. name = location.name;
  314. }
  315. var title = 'three.js - documentation - ' + section + ' - ' + name;
  316. var url = encodeUrl(section) + DELIMITER + encodeUrl( category ) + DELIMITER + encodeUrl(name) + (!!member ? MEMBER_DELIMITER + encodeUrl(member) : '');
  317. window.location.hash = url;
  318. window.document.title = title;
  319. viewer.src = pages[ section ][ category ][ name ] + '.html' + (!!member ? '#'+member : '');
  320. panel.classList.add( 'collapsed' );
  321. }
  322. function goToHash() {
  323. var hash = window.location.hash.substring( 1 ).split(DELIMITER);
  324. var member = hash[2].split(MEMBER_DELIMITER)
  325. goTo( decodeUrl(hash[0]), decodeUrl(hash[1]), decodeUrl(member[0]), decodeUrl(member.length > 1 ? member[1] : '') );
  326. }
  327. window.addEventListener( 'hashchange', goToHash, false );
  328. if ( window.location.hash.length > 0 ) goToHash();
  329. console.log([
  330. ' __ __',
  331. ' __/ __\\ / __\\__ ____ _____ _____',
  332. '/ __/ /\\/ / /___\\/ ____\\/ _____\\/ _____\\',
  333. '\\/_ __/ / _ / / __/ / __ / / __ /_ __ _____',
  334. '/ / / / / / / / / / / / ___/ / ___/\\ _\\/ __\\/ _____\\',
  335. '\\/__/ \\/__/\\/__/\\/__/ \\/_____/\\/_____/\\/__/ / / / ___/',
  336. ' / __/ / \\__ \\',
  337. ' \\/____/\\/_____/'
  338. ].join('\n'));
  339. </script>
  340. </body>
  341. </html>