babylon.quarks - v1.0.0
    Preparing search index...

    Class ApplyCollision

    Bounces particles off surfaces, as Unity's Collision module.

    With planes (Unity's Planes mode) the particles collide with those planes, which the effect carries in its emitter's local space and which follow the emitter as it moves. A particle collides when its next step would take it, as a sphere of radiusScale times half its size, behind a plane while it moves toward it, so it never passes through.

    Without planes (Unity's World mode) every step each particle's position is handed to a PhysicsResolver: the behavior's own when it was given one, otherwise whatever is registered with setPhysicsResolver at that moment, so a resolver registered after the effect loaded still takes effect. A particle inside a collider and moving into it collides. Without any resolver the behavior does nothing, so a collision-bearing effect loads and plays anywhere. The resolver belongs to the host and is not saved.

    A hit turns the velocity into the surface back out of it, keeping bounce of that part; the velocity along the surface is kept. Then dampen of the whole speed is lost, and the particle ages by lifetimeLoss of its lifetime. Applies in every render mode.

    Implements

    Index
    • Parameters

      • resolver: PhysicsResolver | undefined

        The resolver this behavior asks, or undefined to ask the one registered with setPhysicsResolver when a particle is tested.

      • bounce: number

        How much of its speed into the surface a particle keeps, turned back out, after a hit: 1 bounces back at full speed, 0 stops it there and lets it slide along.

      • Optionaloptions: ApplyCollisionOptions

      Returns ApplyCollision

    _frame: EmitterFrame

    The emitter's transform this frame, refreshed by frameUpdate.

    _simPlanes: Vector3[]

    The planes in the simulation space, as point and unit normal in turn; refreshed by frameUpdate.

    bounce: number

    How much of its speed into the surface a particle keeps, turned back out, after a hit: 1 bounces back at full speed, 0 stops it there and lets it slide along.

    dampen: number

    The share of speed lost on each hit, 0 to 1.

    lifetimeLoss: number

    The share of its lifetime a particle loses on each hit, 0 to 1.

    planes: CollisionPlane[]

    Planes the effect carries, in the emitter's local space; none collides with the resolver.

    Learned in initialize, so undefined until this behavior sees a particle.

    radiusScale: number

    The particle's collision radius as a share of half its size, against planes.

    resolver: PhysicsResolver | undefined

    The resolver this behavior asks, or undefined to ask the one registered with setPhysicsResolver when a particle is tested.

    type: string

    The name the behavior is registered under in BehaviorTypes.

    • A copy with the same settings that shares nothing mutable with this one.

      Returns Behavior

    • Called once per step before this behavior updates the particles, with the step's length in seconds.

      Parameters

      • delta: number

      Returns void

    • Called once per particle when it is emitted; see the interface's description for when.

      Parameters

      Returns void

    • Called when the system restarts (not when a looping system starts its next loop): forget state accumulated across steps, so the replay starts as the first play did.

      Returns void

    • The behavior's settings as plain data, with its type; see the interface's description.

      Returns ApplyCollisionJSON

    • Called once per live particle per step, with the step's length in seconds.

      Parameters

      Returns void