index.html 10.0 KB

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