PDBLoader.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:Loader] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">A loader for loading a <em>.pdb</em> resource.<br>
  13. The <a href="http://en.wikipedia.org/wiki/Protein_Data_Bank_(file_format)">Protein Data Bank</a> file format is a textual file describing the three-dimensional structures of molecules.
  14. </p>
  15. <h2>代码示例</h2>
  16. <code>
  17. // instantiate a loader
  18. const loader = new PDBLoader();
  19. // load a PDB resource
  20. loader.load(
  21. // resource URL
  22. 'models/pdb/caffeine.pdb',
  23. // called when the resource is loaded
  24. function ( pdb ) {
  25. const geometryAtoms = pdb.geometryAtoms;
  26. const geometryBonds = pdb.geometryBonds;
  27. const json = pdb.json;
  28. console.log( 'This molecule has ' + json.atoms.length + ' atoms' );
  29. },
  30. // called when loading is in progresses
  31. function ( xhr ) {
  32. console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
  33. },
  34. // called when loading has errors
  35. function ( error ) {
  36. console.log( 'An error happened' );
  37. }
  38. );
  39. </code>
  40. <h2>例子</h2>
  41. <p>
  42. [example:webgl_loader_pdb]
  43. </p>
  44. <h2>Constructor</h2>
  45. <h3>[name]( [param:LoadingManager manager] )</h3>
  46. <p>
  47. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  48. </p>
  49. <p>
  50. Creates a new [name].
  51. </p>
  52. <h2>Properties</h2>
  53. <p>See the base [page:Loader] class for common properties.</p>
  54. <h2>Methods</h2>
  55. <p>See the base [page:Loader] class for common methods.</p>
  56. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  57. <p>
  58. [page:String url] — A string containing the path/URL of the <em>.pdb</em> file.<br />
  59. [page:Function onLoad] — (optional) A function to be called after loading is successfully completed. The function receives the object having the following properties. [page:BufferGeometry geometryAtoms], [page:BufferGeometry geometryBonds] and the [page:Object JSON] structure.<br />
  60. [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, which contains [page:Integer total] and [page:Integer loaded] bytes.<br />
  61. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br />
  62. </p>
  63. <p>
  64. Begin loading from url and call onLoad with the parsed response content.
  65. </p>
  66. <h3>[method:Object parse]( [param:String text] )</h3>
  67. <p>
  68. [page:String text] — The textual <em>pdb</em> structure to parse.
  69. </p>
  70. <p>
  71. Parse a <em>pdb</em> text and return a <em>JSON</em> structure.<br />
  72. </p>
  73. <h2>Source</h2>
  74. <p>
  75. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PDBLoader.js examples/jsm/loaders/PDBLoader.js]
  76. </p>
  77. </body>
  78. </html>