index.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. function extractQuery() {
  200. var p = window.location.search.indexOf( '?q=' );
  201. if( p !== -1 ) {
  202. return window.location.search.substr( 3 );
  203. }
  204. return ''
  205. }
  206. var panel = document.getElementById( 'panel' );
  207. var viewer = document.getElementById( 'viewer' );
  208. var expandButton = document.getElementById( 'expandButton' );
  209. expandButton.addEventListener( 'click', function ( event ) {
  210. panel.classList.toggle( 'collapsed' );
  211. event.preventDefault();
  212. } );
  213. var filterInput = document.getElementById( 'filterInput' );
  214. var clearFilterButton = document.getElementById( 'clearFilterButton' );
  215. var DELIMITER = '/';
  216. var MEMBER_DELIMITER = '.';
  217. var nameCategoryMap = {};
  218. var sections = [];
  219. var content = document.getElementById( 'content' );
  220. for ( var section in list ) {
  221. var h2 = document.createElement( 'h2' );
  222. h2.textContent = section;
  223. content.appendChild( h2 );
  224. for ( var category in list[ section ] ) {
  225. var div = document.createElement( 'div' );
  226. var h3 = document.createElement( 'h3' );
  227. h3.textContent = category;
  228. div.appendChild( h3 );
  229. var ul = document.createElement( 'ul' );
  230. div.appendChild( ul );
  231. for ( var i = 0; i < list[ section ][ category ].length; i ++ ) {
  232. var page = list[ section ][ category ][ i ];
  233. var li = document.createElement( 'li' );
  234. var a = document.createElement( 'a' );
  235. a.setAttribute( 'href', '#' );
  236. ( function( s, c, p ) {
  237. a.addEventListener( 'click', function( e ) {
  238. goTo( s, c, p );
  239. e.preventDefault();
  240. } )
  241. } )( section, category, page[ 0 ] );
  242. a.textContent = page[ 0 ];
  243. li.appendChild( a );
  244. ul.appendChild( li );
  245. nameCategoryMap[page[0]] = {
  246. section: section,
  247. category: category,
  248. name: page[0],
  249. element: a
  250. };
  251. }
  252. content.appendChild( div );
  253. sections.push( ul );
  254. }
  255. }
  256. panel.appendChild( content );
  257. function layoutList() {
  258. sections.forEach( function( el ) {
  259. var collapsed = true;
  260. Array.prototype.slice.apply( el.children ).forEach( function( item ) {
  261. if( !item.classList.contains( 'filtered' ) ) {
  262. collapsed = false;
  263. }
  264. } );
  265. if( collapsed ) {
  266. el.parentElement.classList.add( 'filtered' );
  267. } else {
  268. el.parentElement.classList.remove( 'filtered' );
  269. }
  270. } );
  271. }
  272. filterInput.addEventListener( 'input', function( e ) {
  273. updateFilter();
  274. } );
  275. clearFilterButton.addEventListener( 'click', function( e ) {
  276. filterInput.value = '';
  277. updateFilter();
  278. e.preventDefault();
  279. } );
  280. function updateFilter() {
  281. var v = filterInput.value;
  282. if( v !== '' ) {
  283. window.history.replaceState( {} , '', '?q=' + v + window.location.hash );
  284. } else {
  285. window.history.replaceState( {} , '', window.location.pathname + window.location.hash );
  286. }
  287. var exp = new RegExp( filterInput.value, 'gi' );
  288. for( var j in nameCategoryMap ) {
  289. var res = nameCategoryMap[ j ].name.match( exp );
  290. if( res && res.length > 0 ) {
  291. nameCategoryMap[ j ].element.parentElement.classList.remove( 'filtered' );
  292. var str = nameCategoryMap[ j ].name;
  293. for( var i = 0; i < res.length; i++ ) {
  294. str = str.replace( res[ i ], '<b>' + res[ i ] + '</b>' );
  295. }
  296. nameCategoryMap[ j ].element.innerHTML = str;
  297. } else {
  298. nameCategoryMap[ j ].element.parentElement.classList.add( 'filtered' );
  299. nameCategoryMap[ j ].element.textContent = nameCategoryMap[ j ].name;
  300. }
  301. }
  302. layoutList();
  303. }
  304. function encodeUrl( path ) {
  305. return path.replace(/\ \/\ /g, '.').replace(/\ /g, '_');
  306. }
  307. function decodeUrl( path ) {
  308. return path.replace(/_/g, ' ').replace(/\./g, ' / ');
  309. }
  310. // Page loading
  311. function goTo( section, category, name, member ) {
  312. var parts, location;
  313. // Fully resolve links that only provide a name
  314. if(arguments.length == 1) {
  315. // Resolve links of the form 'Class.member'
  316. if(section.indexOf(MEMBER_DELIMITER) !== -1) {
  317. parts = section.split(MEMBER_DELIMITER);
  318. section = parts[0];
  319. member = parts[1];
  320. }
  321. location = nameCategoryMap[section];
  322. if (!location) return;
  323. section = location.section;
  324. category = location.category;
  325. name = location.name;
  326. }
  327. var title = 'three.js - documentation - ' + section + ' - ' + name;
  328. var url = encodeUrl(section) + DELIMITER + encodeUrl( category ) + DELIMITER + encodeUrl(name) + (!!member ? MEMBER_DELIMITER + encodeUrl(member) : '');
  329. window.location.hash = url;
  330. window.document.title = title;
  331. viewer.src = pages[ section ][ category ][ name ] + '.html' + (!!member ? '#'+member : '');
  332. panel.classList.add( 'collapsed' );
  333. }
  334. function goToHash() {
  335. var hash = window.location.hash.substring( 1 ).split(DELIMITER);
  336. var member = hash[2].split(MEMBER_DELIMITER);
  337. goTo( decodeUrl(hash[0]), decodeUrl(hash[1]), decodeUrl(member[0]), decodeUrl(member.length > 1 ? member[1] : '') );
  338. }
  339. window.addEventListener( 'hashchange', goToHash, false );
  340. if ( window.location.hash.length > 0 ) goToHash();
  341. console.log([
  342. ' __ __',
  343. ' __/ __\\ / __\\__ ____ _____ _____',
  344. '/ __/ /\\/ / /___\\/ ____\\/ _____\\/ _____\\',
  345. '\\/_ __/ / _ / / __/ / __ / / __ /_ __ _____',
  346. '/ / / / / / / / / / / / ___/ / ___/\\ _\\/ __\\/ _____\\',
  347. '\\/__/ \\/__/\\/__/\\/__/ \\/_____/\\/_____/\\/__/ / / / ___/',
  348. ' / __/ / \\__ \\',
  349. ' \\/____/\\/_____/'
  350. ].join('\n'));
  351. filterInput.value = extractQuery();
  352. updateFilter( )
  353. </script>
  354. <script src="../build/three.min.js"></script> <!-- console sandbox -->
  355. </body>
  356. </html>