kopia lustrzana https://github.com/carson-katri/geometry-script
deploy: e7bae54662
rodzic
0ab36b1595
commit
8120875e03
|
@ -155,26 +155,26 @@
|
|||
<h2 id="enum-properties"><a class="header" href="#enum-properties">Enum Properties</a></h2>
|
||||
<p>Many nodes have enum properties. For example, the math node lets you choose which operation to perform. You can pass a string to specify the enum case to use. But a safer way to set these values is with the autogenerated enum types. The enums are namespaced to the name of the node in PascalCase:</p>
|
||||
<pre><code class="language-python"># Access it by Node.Enum Name.Case
|
||||
math(operation=Math.Operation.Add)
|
||||
math(operation=Math.Operation.Subtract)
|
||||
math(operation=Math.Operation.ADD)
|
||||
math(operation=Math.Operation.SUBTRACT)
|
||||
math(operation='MULTIPLY') # Or manually pass a string
|
||||
</code></pre>
|
||||
<p>Internally, this type is generated as:</p>
|
||||
<pre><code class="language-python">import enum
|
||||
class Math:
|
||||
class Operation(enum.Enum):
|
||||
Add = 'ADD'
|
||||
Subtract = 'SUBTRACT'
|
||||
Multiply = 'MULTIPLY'
|
||||
ADD = 'ADD'
|
||||
SUBTRACT = 'SUBTRACT'
|
||||
MULTIPLY = 'MULTIPLY'
|
||||
...
|
||||
...
|
||||
</code></pre>
|
||||
<p>The cases will appear in code completion if you setup an <a href="../../setup/external-editing.html">external editor</a>.</p>
|
||||
<h2 id="duplicate-names"><a class="header" href="#duplicate-names">Duplicate Names</a></h2>
|
||||
<p>Some nodes use the same input name multiple times. For example, the <em>Math</em> node has three inputs named <code>value</code>. To specify each value, pass a tuple for the input:</p>
|
||||
<pre><code class="language-python">math(operation=Math.Operation.Wrap, value=(0.5, 1, 0)) # Pass all 3
|
||||
math(operation=Math.Operation.Wrap, value=(0.5, 1)) # Only pass 2/3
|
||||
math(operation=Math.Operation.Wrap, value=0.5) # Only pass 1/3
|
||||
<pre><code class="language-python">math(operation=Math.Operation.WRAP, value=(0.5, 1, 0)) # Pass all 3
|
||||
math(operation=Math.Operation.WRAP, value=(0.5, 1)) # Only pass 2/3
|
||||
math(operation=Math.Operation.WRAP, value=0.5) # Only pass 1/3
|
||||
</code></pre>
|
||||
<p><img src="./math_wrap.png" alt="" /></p>
|
||||
<h2 id="examples"><a class="header" href="#examples">Examples</a></h2>
|
||||
|
@ -237,7 +237,7 @@ size.cube(...)
|
|||
<li>Return <code>{ geometry: Geometry, attribute: Int }</code></li>
|
||||
</ol>
|
||||
<p>The node can now be used as a function:</p>
|
||||
<pre><code class="language-python">result = capture_attribute(data_type=CaptureAttribute.DataType.Boolean, geometry=cube_geo) # Specify a property and an input
|
||||
<pre><code class="language-python">result = capture_attribute(data_type=CaptureAttribute.DataType.BOOLEAN, geometry=cube_geo) # Specify a property and an input
|
||||
result.geometry # Access the geometry
|
||||
result.attribute # Access the attribute
|
||||
</code></pre>
|
||||
|
|
40
print.html
40
print.html
|
@ -471,26 +471,26 @@ def cube_tree(size: Vector):
|
|||
<h2 id="enum-properties"><a class="header" href="#enum-properties">Enum Properties</a></h2>
|
||||
<p>Many nodes have enum properties. For example, the math node lets you choose which operation to perform. You can pass a string to specify the enum case to use. But a safer way to set these values is with the autogenerated enum types. The enums are namespaced to the name of the node in PascalCase:</p>
|
||||
<pre><code class="language-python"># Access it by Node.Enum Name.Case
|
||||
math(operation=Math.Operation.Add)
|
||||
math(operation=Math.Operation.Subtract)
|
||||
math(operation=Math.Operation.ADD)
|
||||
math(operation=Math.Operation.SUBTRACT)
|
||||
math(operation='MULTIPLY') # Or manually pass a string
|
||||
</code></pre>
|
||||
<p>Internally, this type is generated as:</p>
|
||||
<pre><code class="language-python">import enum
|
||||
class Math:
|
||||
class Operation(enum.Enum):
|
||||
Add = 'ADD'
|
||||
Subtract = 'SUBTRACT'
|
||||
Multiply = 'MULTIPLY'
|
||||
ADD = 'ADD'
|
||||
SUBTRACT = 'SUBTRACT'
|
||||
MULTIPLY = 'MULTIPLY'
|
||||
...
|
||||
...
|
||||
</code></pre>
|
||||
<p>The cases will appear in code completion if you setup an <a href="api/basics/../../setup/external-editing.html">external editor</a>.</p>
|
||||
<h2 id="duplicate-names"><a class="header" href="#duplicate-names">Duplicate Names</a></h2>
|
||||
<p>Some nodes use the same input name multiple times. For example, the <em>Math</em> node has three inputs named <code>value</code>. To specify each value, pass a tuple for the input:</p>
|
||||
<pre><code class="language-python">math(operation=Math.Operation.Wrap, value=(0.5, 1, 0)) # Pass all 3
|
||||
math(operation=Math.Operation.Wrap, value=(0.5, 1)) # Only pass 2/3
|
||||
math(operation=Math.Operation.Wrap, value=0.5) # Only pass 1/3
|
||||
<pre><code class="language-python">math(operation=Math.Operation.WRAP, value=(0.5, 1, 0)) # Pass all 3
|
||||
math(operation=Math.Operation.WRAP, value=(0.5, 1)) # Only pass 2/3
|
||||
math(operation=Math.Operation.WRAP, value=0.5) # Only pass 1/3
|
||||
</code></pre>
|
||||
<p><img src="api/basics/./math_wrap.png" alt="" /></p>
|
||||
<h2 id="examples"><a class="header" href="#examples">Examples</a></h2>
|
||||
|
@ -553,7 +553,7 @@ size.cube(...)
|
|||
<li>Return <code>{ geometry: Geometry, attribute: Int }</code></li>
|
||||
</ol>
|
||||
<p>The node can now be used as a function:</p>
|
||||
<pre><code class="language-python">result = capture_attribute(data_type=CaptureAttribute.DataType.Boolean, geometry=cube_geo) # Specify a property and an input
|
||||
<pre><code class="language-python">result = capture_attribute(data_type=CaptureAttribute.DataType.BOOLEAN, geometry=cube_geo) # Specify a property and an input
|
||||
result.geometry # Access the geometry
|
||||
result.attribute # Access the attribute
|
||||
</code></pre>
|
||||
|
@ -654,7 +654,7 @@ def voxelize(geometry: Geometry):
|
|||
interior_band_width=resolution,
|
||||
fill_volume=False
|
||||
).distribute_points_in_volume( # Uniform grid distribution
|
||||
mode='DENSITY_GRID',
|
||||
mode=DistributePointsInVolume.Mode.DENSITY_GRID,
|
||||
spacing=resolution
|
||||
)
|
||||
</code></pre>
|
||||
|
@ -666,7 +666,7 @@ def voxelize(geometry: Geometry):
|
|||
interior_band_width=resolution,
|
||||
fill_volume=False
|
||||
).distribute_points_in_volume(
|
||||
mode='DENSITY_GRID',
|
||||
mode=DistributePointsInVolume.Mode.DENSITY_GRID,
|
||||
spacing=resolution
|
||||
).instance_on_points( # Cube instancing
|
||||
instance=cube(size=resolution)
|
||||
|
@ -685,7 +685,7 @@ def voxelize(geometry: Geometry, resolution: Float = 0.2):
|
|||
interior_band_width=resolution,
|
||||
fill_volume=False
|
||||
).distribute_points_in_volume(
|
||||
mode='DENSITY_GRID',
|
||||
mode=DistributePointsInVolume.Mode.DENSITY_GRID,
|
||||
spacing=resolution
|
||||
).instance_on_points(
|
||||
instance=cube(size=resolution)
|
||||
|
@ -725,7 +725,7 @@ def city_builder(
|
|||
...
|
||||
return building_points.instance_on_points(
|
||||
instance=cube().transform(translation=(0, 0, 0.5)),
|
||||
scale=random_value(data_type='FLOAT_VECTOR', min=building_size_min, max=building_size_max, seed=seed),
|
||||
scale=random_value(data_type=RandomValue.DataType.FLOAT_VECTOR, min=building_size_min, max=building_size_max, seed=seed),
|
||||
)
|
||||
</code></pre>
|
||||
<h2 id="roads"><a class="header" href="#roads">Roads</a></h2>
|
||||
|
@ -742,10 +742,10 @@ def city_builder(
|
|||
<pre><code class="language-python">def city_builder(...):
|
||||
...
|
||||
building_points = ...
|
||||
road_points = geometry.curve_to_points(mode='EVALUATED').points
|
||||
road_points = geometry.curve_to_points(mode=CurveToPoints.Mode.EVALUATED).points
|
||||
building_points = building_points.delete_geometry(
|
||||
domain='POINT',
|
||||
selection=geometry_proximity(target_element='POINTS', target=road_points, source_position=position()).distance < road_width
|
||||
domain=DeleteGeometry.Domain.POINT,
|
||||
selection=geometry_proximity(target_element=GeometryProximity.TargetElement.POINTS, target=road_points, source_position=position()).distance < road_width
|
||||
)
|
||||
...
|
||||
</code></pre>
|
||||
|
@ -771,16 +771,16 @@ def city_builder(
|
|||
))
|
||||
# Building points
|
||||
building_points = grid(size_x=size_x, size_y=size_y).distribute_points_on_faces(density=density, seed=seed).points
|
||||
road_points = geometry.curve_to_points(mode='EVALUATED').points
|
||||
road_points = geometry.curve_to_points(mode=CurveToPoints.Mode.EVALUATED).points
|
||||
# Delete points within the curve
|
||||
building_points = building_points.delete_geometry(
|
||||
domain='POINT',
|
||||
selection=geometry_proximity(target_element='POINTS', target=road_points, source_position=position()).distance < road_width
|
||||
domain=DeleteGeometry.Domain.POINT,
|
||||
selection=geometry_proximity(target_element=GeometryProximity.TargetElement.POINTS, target=road_points, source_position=position()).distance < road_width
|
||||
)
|
||||
# Building instances
|
||||
yield building_points.instance_on_points(
|
||||
instance=cube().transform(translation=(0, 0, 0.5)),
|
||||
scale=random_value(data_type='FLOAT_VECTOR', min=building_size_min, max=building_size_max, seed=seed),
|
||||
scale=random_value(data_type=RandomValue.DataType.FLOAT_VECTOR, min=building_size_min, max=building_size_max, seed=seed),
|
||||
)
|
||||
</code></pre>
|
||||
<h2 id="generated-node-tree-2"><a class="header" href="#generated-node-tree-2">Generated Node Tree</a></h2>
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -167,7 +167,7 @@ def city_builder(
|
|||
...
|
||||
return building_points.instance_on_points(
|
||||
instance=cube().transform(translation=(0, 0, 0.5)),
|
||||
scale=random_value(data_type='FLOAT_VECTOR', min=building_size_min, max=building_size_max, seed=seed),
|
||||
scale=random_value(data_type=RandomValue.DataType.FLOAT_VECTOR, min=building_size_min, max=building_size_max, seed=seed),
|
||||
)
|
||||
</code></pre>
|
||||
<h2 id="roads"><a class="header" href="#roads">Roads</a></h2>
|
||||
|
@ -184,10 +184,10 @@ def city_builder(
|
|||
<pre><code class="language-python">def city_builder(...):
|
||||
...
|
||||
building_points = ...
|
||||
road_points = geometry.curve_to_points(mode='EVALUATED').points
|
||||
road_points = geometry.curve_to_points(mode=CurveToPoints.Mode.EVALUATED).points
|
||||
building_points = building_points.delete_geometry(
|
||||
domain='POINT',
|
||||
selection=geometry_proximity(target_element='POINTS', target=road_points, source_position=position()).distance < road_width
|
||||
domain=DeleteGeometry.Domain.POINT,
|
||||
selection=geometry_proximity(target_element=GeometryProximity.TargetElement.POINTS, target=road_points, source_position=position()).distance < road_width
|
||||
)
|
||||
...
|
||||
</code></pre>
|
||||
|
@ -213,16 +213,16 @@ def city_builder(
|
|||
))
|
||||
# Building points
|
||||
building_points = grid(size_x=size_x, size_y=size_y).distribute_points_on_faces(density=density, seed=seed).points
|
||||
road_points = geometry.curve_to_points(mode='EVALUATED').points
|
||||
road_points = geometry.curve_to_points(mode=CurveToPoints.Mode.EVALUATED).points
|
||||
# Delete points within the curve
|
||||
building_points = building_points.delete_geometry(
|
||||
domain='POINT',
|
||||
selection=geometry_proximity(target_element='POINTS', target=road_points, source_position=position()).distance < road_width
|
||||
domain=DeleteGeometry.Domain.POINT,
|
||||
selection=geometry_proximity(target_element=GeometryProximity.TargetElement.POINTS, target=road_points, source_position=position()).distance < road_width
|
||||
)
|
||||
# Building instances
|
||||
yield building_points.instance_on_points(
|
||||
instance=cube().transform(translation=(0, 0, 0.5)),
|
||||
scale=random_value(data_type='FLOAT_VECTOR', min=building_size_min, max=building_size_max, seed=seed),
|
||||
scale=random_value(data_type=RandomValue.DataType.FLOAT_VECTOR, min=building_size_min, max=building_size_max, seed=seed),
|
||||
)
|
||||
</code></pre>
|
||||
<h2 id="generated-node-tree"><a class="header" href="#generated-node-tree">Generated Node Tree</a></h2>
|
||||
|
|
|
@ -175,7 +175,7 @@ def voxelize(geometry: Geometry):
|
|||
interior_band_width=resolution,
|
||||
fill_volume=False
|
||||
).distribute_points_in_volume( # Uniform grid distribution
|
||||
mode='DENSITY_GRID',
|
||||
mode=DistributePointsInVolume.Mode.DENSITY_GRID,
|
||||
spacing=resolution
|
||||
)
|
||||
</code></pre>
|
||||
|
@ -187,7 +187,7 @@ def voxelize(geometry: Geometry):
|
|||
interior_band_width=resolution,
|
||||
fill_volume=False
|
||||
).distribute_points_in_volume(
|
||||
mode='DENSITY_GRID',
|
||||
mode=DistributePointsInVolume.Mode.DENSITY_GRID,
|
||||
spacing=resolution
|
||||
).instance_on_points( # Cube instancing
|
||||
instance=cube(size=resolution)
|
||||
|
@ -206,7 +206,7 @@ def voxelize(geometry: Geometry, resolution: Float = 0.2):
|
|||
interior_band_width=resolution,
|
||||
fill_volume=False
|
||||
).distribute_points_in_volume(
|
||||
mode='DENSITY_GRID',
|
||||
mode=DistributePointsInVolume.Mode.DENSITY_GRID,
|
||||
spacing=resolution
|
||||
).instance_on_points(
|
||||
instance=cube(size=resolution)
|
||||
|
|
Ładowanie…
Reference in New Issue