index.html 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. <link type="text/css" rel="stylesheet" href="index.css">
  8. </head>
  9. <body>
  10. <script type="text/javascript">
  11. var _gaq = _gaq || [];
  12. _gaq.push(['_setAccount', 'UA-86951-15']);
  13. _gaq.push(['_trackPageview']);
  14. (function() {
  15. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  16. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  17. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  18. })();
  19. </script>
  20. <div id="panel" class="collapsed">
  21. <h1><a href="http://threejs.org">three.js</a> / docs</h1>
  22. <a id="expandButton" href="#">
  23. <span></span>
  24. <span></span>
  25. <span></span>
  26. </a>
  27. <div class="filterBlock" >
  28. <input type="text" id="filterInput" placeholder="Type to filter" autocorrect="off" autocapitalize="off" spellcheck="false">
  29. <a href="#" id="clearFilterButton">x</a>
  30. </div>
  31. <div id="content"></div>
  32. </div>
  33. <iframe name="viewer"></iframe>
  34. <script src="list.js"></script>
  35. <script>
  36. var panel = document.getElementById( 'panel' );
  37. var content = document.getElementById( 'content' );
  38. var clearFilterButton = document.getElementById( 'clearFilterButton' );
  39. var expandButton = document.getElementById( 'expandButton' );
  40. var filterInput = document.getElementById( 'filterInput' );
  41. var iframe = document.querySelector( 'iframe' );
  42. var pageProperties = {};
  43. var titles = {};
  44. var categoryElements = [];
  45. // Functionality for hamburger button (on small devices)
  46. expandButton.onclick = function ( event ) {
  47. event.preventDefault();
  48. panel.classList.toggle( 'collapsed' );
  49. };
  50. // Functionality for search/filter input field
  51. filterInput.oninput = function ( event ) {
  52. updateFilter();
  53. };
  54. // Functionality for filter clear button
  55. clearFilterButton.onclick = function ( event ) {
  56. event.preventDefault();
  57. filterInput.value = '';
  58. updateFilter();
  59. };
  60. // Activate content and title change on browser navigation
  61. window.onpopstate = createNewIframe;
  62. // Create the navigation panel and configure the iframe
  63. createNavigation();
  64. createNewIframe();
  65. // Navigation Panel
  66. function createLink( pageName, pageURL ) {
  67. var link = document.createElement( 'a' );
  68. link.href = pageURL + '.html';
  69. link.textContent = pageName;
  70. link.setAttribute( 'target', 'viewer' );
  71. link.addEventListener( 'click', function ( event ) {
  72. window.location.hash = pageURL;
  73. panel.classList.add( 'collapsed' );
  74. } );
  75. return link;
  76. }
  77. function createNavigation() {
  78. // Create the navigation panel using data from list.js
  79. var navigation = document.createElement( 'div' );
  80. content.appendChild( navigation );
  81. for ( var section in list ) {
  82. // Create sections
  83. var categories = list[ section ];
  84. var sectionHead = document.createElement( 'h2' );
  85. sectionHead.textContent = section;
  86. navigation.appendChild( sectionHead );
  87. for ( var category in categories ) {
  88. // Create categories
  89. var pages = categories[ category ];
  90. var categoryContainer = document.createElement( 'div' );
  91. navigation.appendChild( categoryContainer );
  92. var categoryHead = document.createElement( 'h3' );
  93. categoryHead.textContent = category;
  94. categoryContainer.appendChild( categoryHead );
  95. var categoryContent = document.createElement( 'ul' );
  96. categoryContainer.appendChild( categoryContent );
  97. for ( var pageName in pages ) {
  98. // Create page links
  99. var pageURL = pages[ pageName ];
  100. var listElement = document.createElement( 'li' );
  101. categoryContent.appendChild( listElement );
  102. var linkElement = createLink( pageName, pageURL )
  103. listElement.appendChild( linkElement );
  104. // Gather the main properties for the current subpage
  105. pageProperties[ pageName ] = {
  106. section: section,
  107. category: category,
  108. pageURL: pageURL,
  109. linkElement: linkElement
  110. };
  111. // Gather the document titles (used for easy access on browser navigation)
  112. titles[ pageURL ] = pageName;
  113. }
  114. // Gather the category elements for easy access on filtering
  115. categoryElements.push( categoryContent );
  116. }
  117. }
  118. }
  119. // Filtering
  120. function updateFilter() {
  121. // (uncomment the following line and the "Query strings" section, if you want query strings):
  122. // updateQueryString();
  123. var regExp = new RegExp( filterInput.value, 'gi' );
  124. for ( var pageName in pageProperties ) {
  125. var linkElement = pageProperties[ pageName ].linkElement;
  126. var categoryClassList = linkElement.parentElement.classList;
  127. var filterResults = pageName.match( regExp );
  128. if ( filterResults && filterResults.length > 0 ) {
  129. // Accentuate matching characters
  130. for ( var i = 0; i < filterResults.length; i++ ) {
  131. var result = filterResults[ i ];
  132. if ( result !== '' ) {
  133. pageName = pageName.replace( result, '<b>' + result + '</b>' );
  134. }
  135. }
  136. categoryClassList.remove( 'hidden' );
  137. linkElement.innerHTML = pageName;
  138. } else {
  139. // Hide all non-matching page names
  140. categoryClassList.add( 'hidden' );
  141. }
  142. }
  143. displayFilteredPanel();
  144. }
  145. function displayFilteredPanel() {
  146. // Show/hide categories depending on their content
  147. // First check if at least one page in this category is not hidden
  148. categoryElements.forEach( function ( category ) {
  149. var pages = category.children;
  150. var pagesLength = pages.length;
  151. var sectionClassList = category.parentElement.classList;
  152. var hideCategory = true;
  153. for ( var i = 0; i < pagesLength; i ++ ) {
  154. var pageClassList = pages[ i ].classList;
  155. if ( ! pageClassList.contains( 'hidden' ) ) {
  156. hideCategory = false;
  157. }
  158. }
  159. // If and only if all page names are hidden, hide the whole category
  160. if ( hideCategory ) {
  161. sectionClassList.add( 'hidden' );
  162. } else {
  163. sectionClassList.remove( 'hidden' );
  164. }
  165. } );
  166. }
  167. // Routing
  168. function setUrlFragment( pageName ) {
  169. // Handle navigation from the subpages (iframes):
  170. // First separate the memeber (if existing) from the page name,
  171. // then identify the subpage's URL and set it as URL fragment (re-adding the member)
  172. var splitPageName = decomposePageName( pageName, '.', '.' );
  173. var currentProperties = pageProperties[ splitPageName[ 0 ] ];
  174. if ( currentProperties ) {
  175. window.location.hash = currentProperties.pageURL + splitPageName[ 1 ];
  176. createNewIframe();
  177. }
  178. }
  179. function createNewIframe() {
  180. // Change the content displayed in the iframe
  181. // First separate the member part of the fragment (if existing)
  182. var hash = window.location.hash.substring( 1 );
  183. var splitHash = decomposePageName( hash, '.', '#' );
  184. // Creating a new Iframe instead of assigning a new src is
  185. // a cross-browser solution to allow normal browser navigation;
  186. // - only assigning a new src would result in two history states each time.
  187. // Note: iframe.contentWindow.location.replace(hash) should work, too,
  188. // but it doesn't work in Edge with links from the subpages!
  189. var oldIframe;
  190. var subtitle;
  191. oldIframe = iframe;
  192. iframe = oldIframe.cloneNode();
  193. if(hash) {
  194. iframe.src = splitHash[ 0 ] + '.html' + splitHash[ 1 ];
  195. subtitle = titles[ splitHash[ 0 ] ] + splitHash[ 1 ] + ' - ';
  196. } else {
  197. iframe.src = '';
  198. subtitle = '';
  199. }
  200. document.body.replaceChild( iframe, oldIframe );
  201. document.title = subtitle + 'three.js docs';
  202. }
  203. function decomposePageName( pageName, oldDelimiter, newDelimiter ) {
  204. // Helper function for separating the member (if existing) from the pageName
  205. // For example: 'Geometry.morphTarget' can be converted to
  206. // ['Geometry', '.morphTarget'] or ['Geometry', '#morphTarget']
  207. // Note: According RFC 3986 no '#' allowed inside of an URL fragment!
  208. var parts = [];
  209. var dotIndex = pageName.indexOf( oldDelimiter );
  210. if ( dotIndex !== -1 ) {
  211. parts = pageName.split( oldDelimiter );
  212. parts[ 1 ] = newDelimiter + parts[ 1 ];
  213. } else {
  214. parts[ 0 ] = pageName;
  215. parts[ 1 ] = '';
  216. }
  217. return parts;
  218. }
  219. //
  220. console.log([
  221. ' __ __',
  222. ' __/ __\\ / __\\__ ____ _____ _____',
  223. '/ __/ /\\/ / /___\\/ ____\\/ _____\\/ _____\\',
  224. '\\/_ __/ / _ / / __/ / __ / / __ /_ __ _____',
  225. '/ / / / / / / / / / / / ___/ / ___/\\ _\\/ __\\/ _____\\',
  226. '\\/__/ \\/__/\\/__/\\/__/ \\/_____/\\/_____/\\/__/ / / / ___/',
  227. ' / __/ / \\__ \\',
  228. ' \\/____/\\/_____/'
  229. ].join('\n'));
  230. </script>
  231. <script src="../build/three.min.js"></script> <!-- console sandbox -->
  232. </body>
  233. </html>