index.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>three.js - documentation</title>
  6. <style>
  7. body {
  8. margin: 0;
  9. padding: 0;
  10. color: #555;
  11. font-family: Arial, sans-serif;
  12. overflow: hidden;
  13. }
  14. h1 {
  15. color: #999;
  16. font-size: 18px;
  17. margin-top: 30px;
  18. }
  19. #panel {
  20. position: fixed;
  21. width: 160px;
  22. padding-left: 20px;
  23. font-size: 15px;
  24. overflow: auto;
  25. }
  26. #panel ul {
  27. list-style-type: none;
  28. padding: 0px;
  29. margin: 0px;
  30. }
  31. #viewer {
  32. overflow: auto;
  33. }
  34. #viewer h1 {
  35. color: #444;
  36. font-size: 25px;
  37. }
  38. #viewer h2 {
  39. color: #999;
  40. font-size: 18px;
  41. margin-top: 40px;
  42. }
  43. #viewer h3 {
  44. font-size: 15px;
  45. margin-top: 30px;
  46. }
  47. #viewer div {
  48. padding-left: 30px;
  49. }
  50. #viewer code {
  51. display: block;
  52. margin: 0px;
  53. width: 90%;
  54. padding: 20px;
  55. white-space: pre;
  56. background-color: #f9f9f9;
  57. overflow: auto;
  58. }
  59. </style>
  60. </head>
  61. <body>
  62. <div id="panel"></div>
  63. <div id="viewer"></div>
  64. <script>
  65. var panel = document.getElementById( 'panel' );
  66. var viewer = document.getElementById( 'viewer' );
  67. var pages = {
  68. "Arrya": "Array",
  69. "Number": "Number",
  70. "Camera": "cameras/Camera"
  71. };
  72. var list = {
  73. "Core": [
  74. { name: "Clock", path: "core/Clock" },
  75. { name: "Color", path: "core/Color" },
  76. { name: "Edge", path: "core/Edge" },
  77. { name: "Face3", path: "core/Face3" },
  78. { name: "Face4", path: "core/Face4" },
  79. { name: "Frustum", path: "core/Frustum" },
  80. { name: "Geometry", path: "core/Geometry" },
  81. { name: "Math", path: "core/Math" },
  82. { name: "Matrix3", path: "core/Matrix3" },
  83. { name: "Matrix4", path: "core/Matrix4" },
  84. { name: "Object3D", path: "core/Object3D" },
  85. { name: "Projector", path: "core/Projector" },
  86. { name: "Quaternion", path: "core/Quaternion" },
  87. { name: "Ray", path: "core/Ray" },
  88. { name: "Rectangle", path: "core/Rectangle" },
  89. { name: "Spline", path: "core/Spline" },
  90. { name: "UV", path: "core/UV" },
  91. { name: "Vector2", path: "core/Vector2" },
  92. { name: "Vector3", path: "core/Vector3" },
  93. { name: "Vector4", path: "core/Vector4" },
  94. { name: "Vertex", path: "core/Vertex" }
  95. ],
  96. "Cameras": [
  97. { name: "PerspectiveCamera", path: "cameras/PerspectiveCamera" },
  98. { name: "OrtographicCamera", path: "cameras/OrtographicCamera" }
  99. ],
  100. "Lights": [
  101. { name: "AmbientLight", path: "lights/AmbientLight" },
  102. { name: "DirectionalLight", path: "lights/DirectionalLight" },
  103. { name: "PointLight", path: "lights/PointLight" },
  104. { name: "SpotLight", path: "lights/SpotLight" },
  105. ]
  106. };
  107. var html = '';
  108. for ( var category in list ) {
  109. html += '<h1>' + category + '</h1>';
  110. for ( var i = 0; i < list[ category ].length; i ++ ) {
  111. var page = list[ category ][ i ];
  112. pages[ page.name ] = page.path;
  113. html += '<li><a href="javascript:goTo(\'' + page.path + '\')">' + page.name + '</a></li>';
  114. }
  115. }
  116. panel.innerHTML += '<ul>' + html + '</ul>';
  117. // Page loading
  118. function goTo( path ) {
  119. viewer.innerHTML = '';
  120. window.location.hash = path
  121. var xhr = new XMLHttpRequest();
  122. xhr.open( 'GET', 'api/' + path + '.html', true );
  123. xhr.onreadystatechange = function () {
  124. if ( xhr.readyState == 4 && ( xhr.status == 200 || xhr.status == 0 ) ) {
  125. var text = xhr.responseText;
  126. text = text.replace(/\[path\]/gi, path);
  127. text = text.replace(/\[page:(\w+)\]/gi, function ( str, p1 ) {
  128. return "<a href=\"javascript:goTo('" + pages[ p1 ] + "')\">" + p1 + "</a>";
  129. } );
  130. viewer.innerHTML = text + '<br>';
  131. }
  132. };
  133. xhr.send( null );
  134. }
  135. goTo( window.location.hash.substring(1) );
  136. // Layout
  137. var margin = 200;
  138. function updateLayout() {
  139. panel.style.height = window.innerHeight + 'px';
  140. viewer.style.marginLeft = margin + 'px';
  141. viewer.style.width = ( window.innerWidth - margin ) + 'px';
  142. viewer.style.height = window.innerHeight + 'px';
  143. }
  144. window.addEventListener( 'resize', updateLayout, false );
  145. updateLayout();
  146. </script>
  147. </body>
  148. </html>