index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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">
  29. <a href="#" id="clearFilterButton">x</a>
  30. </div>
  31. </div>
  32. <iframe></iframe>
  33. <script src="list.js"></script>
  34. <script>
  35. var panel = document.getElementById( 'panel' );
  36. var clearFilterButton = document.getElementById( 'clearFilterButton' );
  37. var expandButton = document.getElementById( 'expandButton' );
  38. var filterInput = document.getElementById( 'filterInput' );
  39. var iframe = document.querySelector( 'iframe' );
  40. var pageProperties = {};
  41. var titles = {};
  42. var categoryElements = [];
  43. // ----------------------------------------------------------------------------
  44. // Initialization
  45. // ----------------------------------------------------------------------------
  46. // Functionality for hamburger button (on small devices)
  47. expandButton.onclick = function ( event ) {
  48. event.preventDefault();
  49. panel.classList.toggle( 'collapsed' );
  50. };
  51. // Functionality for search/filter input field
  52. filterInput.oninput = function ( event ) {
  53. updateFilter();
  54. };
  55. // Functionality for filter clear button
  56. clearFilterButton.onclick = function ( event ) {
  57. event.preventDefault();
  58. filterInput.value = '';
  59. updateFilter();
  60. };
  61. // Activate content and title change on browser navigation
  62. window.onpopstate = createNewIframe;
  63. // Create the navigation panel and configure the iframe
  64. createNavigation();
  65. createNewIframe();
  66. // ----------------------------------------------------------------------------
  67. // Navigation Panel
  68. // ----------------------------------------------------------------------------
  69. function createNavigation () {
  70. // Create the navigation panel using data from list.js
  71. var navigation = createAndAppendDOMElement( { type: 'div', parent: panel } );
  72. for ( var section in list ) {
  73. // Create sections
  74. var categories = list[ section ];
  75. var sectionHead = createAndAppendDOMElement( { type: 'h2', parent: navigation, content: section } )
  76. for ( var category in categories ) {
  77. // Create categories
  78. var pages = categories[ category ];
  79. var categoryContainer = createAndAppendDOMElement( { type: 'div', parent: navigation } );
  80. var categoryHead = createAndAppendDOMElement( { type: 'h3', parent: categoryContainer, content: category } );
  81. var categoryContent = createAndAppendDOMElement( { type: 'ul', parent: categoryContainer } );
  82. for ( var pageName in pages ) {
  83. // Create page links
  84. var pageURL = pages[ pageName ];
  85. var listElement = createAndAppendDOMElement( { type: 'li', parent: categoryContent } );
  86. var linkElement = createAndAppendDOMElement( { type: 'a', parent: listElement, content: pageName } );
  87. // The href attribute is only used for the option to create a new tab by right click
  88. linkElement.setAttribute( 'href', '#' + pageURL );
  89. addClickHandlers( linkElement, pageURL );
  90. // Gather the main properties for the current subpage
  91. pageProperties[ pageName ] = {
  92. section: section,
  93. category: category,
  94. pageURL: pageURL,
  95. linkElement: linkElement
  96. };
  97. // Gather the document titles (used for easy access on browser navigation)
  98. titles[ pageURL ] = pageName;
  99. }
  100. // Gather the category elements for easy access on filtering
  101. categoryElements.push( categoryContent );
  102. }
  103. }
  104. };
  105. function createAndAppendDOMElement( properties ) {
  106. // Helper function for creating and appending new DOM elements
  107. var newElement = document.createElement( properties.type );
  108. properties.parent.appendChild( newElement );
  109. if ( properties.content ) {
  110. newElement.textContent = properties.content;
  111. }
  112. return newElement;
  113. }
  114. function addClickHandlers ( linkElement, pageURL ) {
  115. // Helper function for adding ClickHandlers to the page links
  116. linkElement.onclick = function ( event ) {
  117. event.preventDefault();
  118. window.location.hash = pageURL;
  119. createNewIframe();
  120. panel.classList.add( 'collapsed' );
  121. };
  122. };
  123. // ----------------------------------------------------------------------------
  124. // Query Strings (optional)
  125. // ----------------------------------------------------------------------------
  126. // (uncomment the following lines and the first line in updateFilter(), if you want query strings):
  127. // filterInput.value = extractFromQueryString();
  128. // updateFilter();
  129. //
  130. //
  131. // function extractFromQueryString() {
  132. //
  133. // var queryString = window.location.search;
  134. //
  135. // if ( queryString.indexOf( '?q=' ) === -1 ) return '';
  136. //
  137. // return queryString.substr( 3 );
  138. //
  139. // }
  140. //
  141. // function updateQueryString() {
  142. //
  143. // var searchString = filterInput.value;
  144. // var query = '';
  145. //
  146. // if (searchString !== '') {
  147. //
  148. // query = '?q=' + searchString;
  149. //
  150. // }
  151. //
  152. // window.history.replaceState( {} , '', window.location.pathname + query + window.location.hash );
  153. //
  154. // }
  155. // ----------------------------------------------------------------------------
  156. // Filtering
  157. // ----------------------------------------------------------------------------
  158. function updateFilter() {
  159. // (uncomment the following line and the "Query strings" section, if you want query strings):
  160. // updateQueryString();
  161. var regExp = new RegExp( filterInput.value, 'gi' );
  162. for ( var pageName in pageProperties ) {
  163. var linkElement = pageProperties[ pageName ].linkElement;
  164. var categoryClassList = linkElement.parentElement.classList;
  165. var filterResults = pageName.match( regExp );
  166. if ( filterResults && filterResults.length > 0 ) {
  167. // Accentuate matching characters
  168. for ( var i = 0; i < filterResults.length; i++ ) {
  169. var result = filterResults[ i ];
  170. if ( result !== '' ) {
  171. pageName = pageName.replace( result, '<b>' + result + '</b>' );
  172. }
  173. }
  174. categoryClassList.remove( 'hidden' );
  175. linkElement.innerHTML = pageName;
  176. } else {
  177. // Hide all non-matching page names
  178. categoryClassList.add( 'hidden' );
  179. }
  180. }
  181. displayFilteredPanel();
  182. }
  183. function displayFilteredPanel() {
  184. // Show/hide categories depending on their content
  185. // First check if at least one page in this category is not hidden
  186. categoryElements.forEach( function ( category ) {
  187. var pages = category.children;
  188. var pagesLength = pages.length;
  189. var sectionClassList = category.parentElement.classList;
  190. var hideCategory = true;
  191. for ( var i = 0; i < pagesLength; i ++ ) {
  192. var pageClassList = pages[ i ].classList;
  193. if ( ! pageClassList.contains( 'hidden' ) ) {
  194. hideCategory = false;
  195. }
  196. }
  197. // If and only if all page names are hidden, hide the whole category
  198. if ( hideCategory ) {
  199. sectionClassList.add( 'hidden' );
  200. } else {
  201. sectionClassList.remove( 'hidden' );
  202. }
  203. } );
  204. }
  205. // ----------------------------------------------------------------------------
  206. // Routing
  207. // ----------------------------------------------------------------------------
  208. function setUrlFragment( pageName ) {
  209. // Handle navigation from the subpages (iframes):
  210. // First separate the memeber (if existing) from the page name,
  211. // then identify the subpage's URL and set it as URL fragment (re-adding the member)
  212. var splitPageName = decomposePageName( pageName, '.', '.' );
  213. var currentProperties = pageProperties[ splitPageName[ 0 ] ];
  214. if ( currentProperties ) {
  215. window.location.hash = currentProperties.pageURL + splitPageName[ 1 ];
  216. createNewIframe();
  217. }
  218. }
  219. function createNewIframe() {
  220. // Change the content displayed in the iframe
  221. // First separate the member part of the fragment (if existing)
  222. var hash = window.location.hash.substring( 1 );
  223. var splitHash = decomposePageName( hash, '.', '#' );
  224. // Creating a new Iframe instead of assigning a new src is
  225. // a cross-browser solution to allow normal browser navigation;
  226. // - only assigning a new src would result in two history states each time.
  227. // Note: iframe.contentWindow.location.replace(hash) should work, too,
  228. // but it doesn't work in Edge with links from the subpages!
  229. var oldIframe;
  230. var subtitle;
  231. oldIframe = iframe;
  232. iframe = oldIframe.cloneNode();
  233. if(hash) {
  234. iframe.src = splitHash[ 0 ] + '.html' + splitHash[ 1 ];
  235. subtitle = ' - ' + titles[ splitHash[ 0 ] ] + splitHash[ 1 ];
  236. } else {
  237. iframe.src = '';
  238. subtitle = '';
  239. }
  240. document.body.replaceChild( iframe, oldIframe );
  241. document.title = 'three.js docs' + subtitle;
  242. }
  243. function decomposePageName ( pageName, oldDelimiter, newDelimiter ) {
  244. // Helper function for separating the member (if existing) from the pageName
  245. // For example: 'Geometry.morphTarget' can be converted to
  246. // ['Geometry', '.morphTarget'] or ['Geometry', '#morphTarget']
  247. // Note: According RFC 3986 no '#' allowed inside of an URL fragment!
  248. var parts = [];
  249. var dotIndex = pageName.indexOf( oldDelimiter );
  250. if ( dotIndex !== -1 ) {
  251. parts = pageName.split( oldDelimiter );
  252. parts[ 1 ] = newDelimiter + parts[ 1 ];
  253. } else {
  254. parts[ 0 ] = pageName;
  255. parts[ 1 ] = '';
  256. }
  257. return parts;
  258. }
  259. // ----------------------------------------------------------------------------
  260. // ASCII Art ;-)
  261. // ----------------------------------------------------------------------------
  262. console.log([
  263. ' __ __',
  264. ' __/ __\\ / __\\__ ____ _____ _____',
  265. '/ __/ /\\/ / /___\\/ ____\\/ _____\\/ _____\\',
  266. '\\/_ __/ / _ / / __/ / __ / / __ /_ __ _____',
  267. '/ / / / / / / / / / / / ___/ / ___/\\ _\\/ __\\/ _____\\',
  268. '\\/__/ \\/__/\\/__/\\/__/ \\/_____/\\/_____/\\/__/ / / / ___/',
  269. ' / __/ / \\__ \\',
  270. ' \\/____/\\/_____/'
  271. ].join('\n'));
  272. </script>
  273. <script src="../build/three.min.js"></script> <!-- console sandbox -->
  274. </body>
  275. </html>