SCNFieldForceEvaluator
The signature for a block that SceneKit calls to determine the effect of a custom field on an object.
Declaration
typealias SCNFieldForceEvaluator = (SCNVector3, SCNVector3, Float, Float, TimeInterval) -> SCNVector3Discussion
You use this type of block to create a custom physics field with the customField(evaluationBlock:) method. SceneKit calls your block once for each object in the field’s area of effect, on each step of the physics simulation.
The block takes the following parameters:
- position
The position of the object affected by the field, in the local coordinate space of the node containing the field.
- velocity
The velocity of the object affected by the field, relative to the local coordinate space of the node containing the field.
- mass
The mass of the object affected by the field. (See the mass property for physics bodies and the particleMass property for particle systems.)
- charge
The electrical charge of the object affected by the field. (See the charge property for physics bodies and the particleCharge property for particle systems.)
- time
The elapsed time, in seconds, since the last simulation step.
Your block uses these parameters to compute and return an SCNVector3 force vector, which SceneKit then applies to the object affected by the field.