1
0

PDBLoader.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <!DOCTYPE html>
  2. <html lang="en">
  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 `.pdb` resource.<br>
  13. The [link:http://en.wikipedia.org/wiki/Protein_Data_Bank_(file_format) Protein Data Bank] file format is a textual file describing the three-dimensional structures of molecules.
  14. </p>
  15. <h2>Import</h2>
  16. <p>
  17. [name] is an add-on, and must be imported explicitly.
  18. See [link:#manual/introduction/Installation Installation / Addons].
  19. </p>
  20. <code>
  21. import { PDBLoader } from 'three/addons/loaders/PDBLoader.js';
  22. </code>
  23. <h2>Code Example</h2>
  24. <code>
  25. // instantiate a loader
  26. const loader = new PDBLoader();
  27. // load a PDB resource
  28. loader.load(
  29. // resource URL
  30. 'models/pdb/caffeine.pdb',
  31. // called when the resource is loaded
  32. function ( pdb ) {
  33. const geometryAtoms = pdb.geometryAtoms;
  34. const geometryBonds = pdb.geometryBonds;
  35. const json = pdb.json;
  36. console.log( 'This molecule has ' + json.atoms.length + ' atoms' );
  37. },
  38. // called when loading is in progresses
  39. function ( xhr ) {
  40. console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
  41. },
  42. // called when loading has errors
  43. function ( error ) {
  44. console.log( 'An error happened' );
  45. }
  46. );
  47. </code>
  48. <h2>Examples</h2>
  49. <p>
  50. [example:webgl_loader_pdb]
  51. </p>
  52. <h2>Constructor</h2>
  53. <h3>[name]( [param:LoadingManager manager] )</h3>
  54. <p>
  55. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  56. </p>
  57. <p>
  58. Creates a new [name].
  59. </p>
  60. <h2>Properties</h2>
  61. <p>See the base [page:Loader] class for common properties.</p>
  62. <h2>Methods</h2>
  63. <p>See the base [page:Loader] class for common methods.</p>
  64. <h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  65. <p>
  66. [page:String url] — A string containing the path/URL of the `.pdb` file.<br />
  67. [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 />
  68. [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. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
  69. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br />
  70. </p>
  71. <p>
  72. Begin loading from url and call onLoad with the parsed response content.
  73. </p>
  74. <h3>[method:Object parse]( [param:String text] )</h3>
  75. <p>
  76. [page:String text] — The textual `pdb` structure to parse.
  77. </p>
  78. <p>
  79. Parse a `pdb` text and return a `JSON` structure.<br />
  80. </p>
  81. <h2>Source</h2>
  82. <p>
  83. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PDBLoader.js examples/jsm/loaders/PDBLoader.js]
  84. </p>
  85. </body>
  86. </html>