Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SDFGeometryGenerator addon. #26837

Merged
merged 22 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
71 changes: 71 additions & 0 deletions docs/examples/en/geometries/SDFGeometryGenerator.html
@@ -0,0 +1,71 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../../" />
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:BufferGeometry] &rarr;

<h1>[name]</h1>

<p class="desc">
[name] returns a THREE.BufferGeometry from a Signed Distance Function</br>
Uses <a href="https://www.npmjs.com/package/isosurface" target="_blank" > Mikola Lysenko's Isosurface</a>
</p>

<h2>Import</h2>

<p>
[name] is an add-on, and must be imported explicitly.
See [link:#manual/introduction/Installation Installation / Addons].
</p>

<code>
import { SDFGeometryGenerator } from 'three/addons/geometries/SDFGeometryGenerator.js';
</code>

<h2>Code Example</h2>

<code>
const generator = new SDFGeometryGenerator( renderer );
const sdf = 'float dist( vec3 p ){ return length(p) - 0.5; }' // glsl
const geometry = generator.generate( 64, sdf, 1 ); // ~> THREE.BufferGeometry
</code>

<h2>Examples</h2>

<p>[example:webgl_geometry_sdf geometry / sdf ]</p>

<h2>Constructor</h2>

<h3>[name]( [param:WebGLRenderer renderer] )</h3>

<p>
[page:WebGLRenderer renderer] -- The renderer used to render the scene. <br />
</p>

<h2>Methods</h2>

<h3>[method:undefined generate]( [param:Int resolution], [param:String distanceField], [param:Int bounds] )</h3>

<p>
<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.
</p>
<p>
<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.
</p>
<p>
<b>bounds</b> - Int [ optional ] Bounds in which signed distance field will be evaluated. Defaults to 1.
</p>


<h2>Source</h2>

<p>
[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/SDFGeometry.js examples/jsm/geometries/SDFGeometryGenerator.js]
</p>
</body>
</html>
3 changes: 2 additions & 1 deletion docs/list.json
Expand Up @@ -346,7 +346,8 @@
"ConvexGeometry": "examples/en/geometries/ConvexGeometry",
"DecalGeometry": "examples/en/geometries/DecalGeometry",
"ParametricGeometry": "examples/en/geometries/ParametricGeometry",
"TextGeometry": "examples/en/geometries/TextGeometry"
"TextGeometry": "examples/en/geometries/TextGeometry",
"SDFGeometryGenerator": "examples/en/geometries/SDFGeometryGenerator"
},

"Helpers": {
Expand Down
1 change: 1 addition & 0 deletions examples/files.json
Expand Up @@ -34,6 +34,7 @@
"webgl_geometry_extrude_splines",
"webgl_geometry_minecraft",
"webgl_geometry_nurbs",
"webgl_geometry_sdf",
"webgl_geometry_shapes",
"webgl_geometry_spline_editor",
"webgl_geometry_teapot",
Expand Down