SDFGeometryGenerator.html 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. <h1>[name]</h1>
  11. <p class="desc">
  12. [name] generates instances of [page:BufferGeometry] from a Signed Distance Function</br>
  13. Uses <a href="https://www.npmjs.com/package/isosurface" target="_blank" > Mikola Lysenko's Isosurface</a>
  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 { SDFGeometryGenerator } from 'three/addons/geometries/SDFGeometryGenerator.js';
  22. </code>
  23. <h2>Code Example</h2>
  24. <code>
  25. const generator = new SDFGeometryGenerator( renderer );
  26. const sdf = 'float dist( vec3 p ){ return length(p) - 0.5; }' // glsl
  27. const geometry = generator.generate( 64, sdf, 1 ); // ~> THREE.BufferGeometry
  28. </code>
  29. <h2>Examples</h2>
  30. <p>[example:webgl_geometry_sdf geometry / sdf ]</p>
  31. <h2>Constructor</h2>
  32. <h3>[name]( [param:WebGLRenderer renderer] )</h3>
  33. <p>
  34. [page:WebGLRenderer renderer] -- The renderer used to render the scene. <br />
  35. </p>
  36. <h2>Methods</h2>
  37. <h3>[method:BufferGeometry generate]( [param:Int resolution], [param:String distanceField], [param:Int bounds] )</h3>
  38. <p>
  39. <b>resolution</b> - Int [ mandatory ] Amount of 'voxels' used for triangulation. Must be power of 2. <br/>Gets heavy after 256, most machines won't be able to process over 512. Defaults to 64.
  40. </p>
  41. <p>
  42. <b>distanceField</b> - String [ mandatory ] String with glsl distance function. Name of function must be 'dist', with a vec3 argument. ( see code above ). Defaults to a sphere distance.
  43. </p>
  44. <p>
  45. <b>bounds</b> - Int [ optional ] Bounds in which signed distance field will be evaluated. Defaults to 1.
  46. </p>
  47. <h2>Source</h2>
  48. <p>
  49. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/SDFGeometry.js examples/jsm/geometries/SDFGeometryGenerator.js]
  50. </p>
  51. </body>
  52. </html>