Add simulation decorator
This commit is contained in:
parent
bdf703c33a
commit
86023a2bb5
4 changed files with 53 additions and 0 deletions
|
|
@ -22,6 +22,7 @@
|
|||
- [Attributes](./api/advanced-scripting/attributes.md)
|
||||
- [Boolean Math](./api/advanced-scripting/boolean-math.md)
|
||||
- [Drivers](./api/advanced-scripting/drivers.md)
|
||||
- [Simulation](./api/advanced-scripting/simulation.md)
|
||||
|
||||
# Tutorials
|
||||
|
||||
|
|
|
|||
26
book/src/api/advanced-scripting/simulation.md
Normal file
26
book/src/api/advanced-scripting/simulation.md
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Simulation
|
||||
|
||||
> This API is subject to change as future builds of Blender with simulation nodes are released.
|
||||
|
||||
The `geometry-nodes-simulation` branch of Blender 3.5 includes support for "simulation nodes".
|
||||
|
||||
Using a *Simulation Input* and *Simulation Output* node, you can create effects that change over time.
|
||||
|
||||
As a convenience, the `@simulation` decorator is provided to make simulation node blocks easier to create.
|
||||
|
||||
```python
|
||||
@simulation
|
||||
def move_over_time(
|
||||
geometry: Geometry, # the first input must be `Geometry`
|
||||
speed: Float,
|
||||
dt: SimulationInput.DeltaTime, # Automatically passes the delta time on any argument annotated with `SimulationInput.DeltaTime`.
|
||||
elapsed: SimulationInput.ElapsedTime, # Automatically passes the elapsed time
|
||||
) -> Geometry:
|
||||
return geometry.set_position(
|
||||
offset=combine_xyz(x=speed)
|
||||
)
|
||||
```
|
||||
|
||||
Every frame the argument `geometry` will be set to the geometry from the previous frame. This allows the offset to accumulate over time.
|
||||
|
||||
The `SimulationInput.DeltaTime`/`SimulationInput.ElapsedTime` types mark arguments that should be given the outputs from the *Simulation Input* node.
|
||||
Reference in a new issue