Skip to content

SphereBucket

Overview

SphereBucket is a model of a bucket that can be used to store spherical objects. It manages the addition and removal of the spheres, stacks them as they are added, and manages the stack as spheres are removed.

This expects the spheres to have certain properties, please inspect the code to understand the 'contract' between the bucket and the spheres.

@author John Blanco

Class SphereBucket

import { SphereBucket } from 'scenerystack/phetcommon';

Constructor

new SphereBucket( providedOptions? : SphereBucketOptions )

Instance Methods

addParticleFirstOpen( particle : Particle, animate : boolean )

add a particle to the first open position in the stacking order

addParticleNearestOpen( particle : Particle, animate : boolean )

add a particle to the nearest open position in the particle stack

removeParticle( particle : ParticleWithBucketRemovalListener<Particle>, skipLayout )

remove a particle from the bucket, updating listeners as necessary

containsParticle( particle : Particle ) : boolean

extractClosestParticle( position : Vector2 ) : Particle | null

extract the particle that is closest to the provided position from the bucket

getParticleList() : Particle[]

get the list of particles currently contained within this bucket

reset()

Instance Properties

sphereBucketTandem : Tandem

(readonly)

Static Properties

SphereBucketIO : IOType

Source Code

See the source for SphereBucket.ts in the phetcommon repository.