pixi-wheels

SpinController

pixi-wheels


pixi-wheels / index / SpinController

Class: SpinController

Defined in: spin/SpinController.ts:64

The spin state machine of one ring.

spin() -> starting -> cruising -> [setResult] -> stopping -> [settling] -> idle
                                                    ^ anticipation legs live here

Rotation is integrated from a signed angular speed while starting and cruising, then driven by planned legs (see StopPlanner) once a result is in. Everything is a function of the ticker’s deltaMS, so a fake ticker reproduces a spin frame for frame.

Constructors#

Constructor#

new SpinController(_host: SpinHost): SpinController;

Defined in: spin/SpinController.ts:94

Parameters#

ParameterType
_hostSpinHost

Returns#

SpinController

Accessors#

currentLegIndex#

Get Signature#

get currentLegIndex(): number;

Defined in: spin/SpinController.ts:129

Returns

number


direction#

Get Signature#

get direction(): SpinDirection;

Defined in: spin/SpinController.ts:103

The direction of the current or last spin.

Returns

SpinDirection


isIdling#

Get Signature#

get isIdling(): boolean;

Defined in: spin/SpinController.ts:120

Returns

boolean


isSpinning#

Get Signature#

get isSpinning(): boolean;

Defined in: spin/SpinController.ts:112

Returns

boolean


legs#

Get Signature#

get legs(): readonly StopLeg[];

Defined in: spin/SpinController.ts:125

The planned legs, for the debug snapshot. Empty until the stop is planned.

Returns

readonly StopLeg[]


speed#

Get Signature#

get speed(): number;

Defined in: spin/SpinController.ts:108

Signed angular speed, deg/s, as of the last frame.

Returns

number


state#

Get Signature#

get state(): SpinState;

Defined in: spin/SpinController.ts:98

Returns

SpinState


target#

Get Signature#

get target(): ResolvedTarget | null;

Defined in: spin/SpinController.ts:116

Returns

ResolvedTarget | null

Methods#

abandon()#

abandon(): void;

Defined in: spin/SpinController.ts:560

Drop the pending promise without resolving. Called from destroy().

Returns#

void


requestSkip()#

requestSkip(): void;

Defined in: spin/SpinController.ts:280

skip() now if the result is in, otherwise the moment it arrives.

Returns#

void


setResult()#

setResult(target: WheelTarget, landing?: LandingOptions): ResolvedTarget;

Defined in: spin/SpinController.ts:175

Decide where this spin lands. Allowed once per spin, while the ring is starting or cruising.

Parameters#

ParameterType
targetWheelTarget
landingLandingOptions

Returns#

ResolvedTarget


skip()#

skip(): boolean;

Defined in: spin/SpinController.ts:217

Land now-ish: a short fast-forward to the landing angle. Returns false when nothing happened (skipping disabled, too early, no spin, or already settling). Throws before setResult(): use requestSkip() to queue a press made during the server round-trip.

Returns#

boolean


slamStop()#

slamStop(): void;

Defined in: spin/SpinController.ts:293

Snap to the final position and complete synchronously. Ignores skip protection and settle animation. This is what tests use.

Returns#

void


spin()#

spin(options?: SpinOptions): Promise<WheelSpinResult>;

Defined in: spin/SpinController.ts:135

Parameters#

ParameterType
optionsSpinOptions

Returns#

Promise<WheelSpinResult>


startIdle()#

startIdle(config: IdleConfig): void;

Defined in: spin/SpinController.ts:316

Parameters#

ParameterType
configIdleConfig

Returns#

void


stopIdle()#

stopIdle(): void;

Defined in: spin/SpinController.ts:332

Returns#

void


update()#

update(dtMs: number): void;

Defined in: spin/SpinController.ts:349

Advance by dtMs milliseconds.

Parameters#

ParameterType
dtMsnumber

Returns#

void