Class: ModuleBuilder
index.ModuleBuilder
Represents a builder for particle modules. Returns an evaluatable module function, that can be consumed by emitters.
remarks
Not all properties can be driven. TypeScript will validate this at compile time,
but no internal validation is performed due to performance reasons. Also, note
that the driving factor is "lifetime" by default.
example
new ModuleBuilder() .drive("size") .by((t) => t * 2) .through("lifetime") .build();
#
Constructors#
constructor• new ModuleBuilder()
#
Methods#
buildâ–¸ build(): ModuleFunction
Consumes the builder and returns an evaluatable module function.
remarks
Note that you need to specify the driving key and value, otherwise an error
will be thrown.
#
Returns#
Defined in#
byâ–¸ by<TDriver
>(driver
): ModuleBuilder
Specifies the value to drive the module behaviour by. This can be a constant, a spline or an evaluable function. Note that in the last case, the driving factor is passed as a parameter.
#
Type parametersName | Type |
---|---|
TDriver | extends DrivableType |
#
ParametersName | Type |
---|---|
driver | ModuleDriverValue <TDriver > |
#
ReturnsThe chained builder instance.
#
Defined in#
driveâ–¸ drive<TKey
>(key
): ModuleBuilder
Specifies the key in the particle that should be driven.
remarks
Note that not all of a particle's properties are drivable through modules. If you
need full control of a particle inside of a module, you can use a module function directly.
#
Type parametersName | Type |
---|---|
TKey | extends "size" | "rotation" | "color" | "opacity" |
#
ParametersName | Type |
---|---|
key | TKey |
#
ReturnsThe chained builder instance.
#
Defined in#
relativeâ–¸ relative(isRelative?
): ModuleBuilder
Specifies that the module function is supposed to act relative to the properties initial value.
remarks
Note that this is only possible if an "initial*" property exists on the
particle object. The operation applied to the initial and new value
is dependant on their type:
Vector
: Both vectors are added.number
: Both numbers are multiplied.
For more advanced relative customizations, consider using the particle object in the driver value function instead, like:
.by((t, p) => p.initialSize + t * 2);
#
ParametersName | Type | Default value |
---|---|---|
isRelative | boolean | true |
#
Returns#
Defined in#
throughâ–¸ through(factor
): ModuleBuilder
Specifies the factor to drive the evaluated value by. Supports "lifetime" and "size".
#
ParametersName | Type |
---|---|
factor | DrivableFactor |
#
ReturnsThe chained builder instance.