easter-egg-quest 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -142,7 +142,7 @@ function resolveConfig(raw = {}) {
|
|
|
142
142
|
stageDurations: {
|
|
143
143
|
stillnessMs: clampDuration((_i = raw.stageDurations) == null ? void 0 : _i.stillnessMs, 2e4),
|
|
144
144
|
motionMs: clampDuration((_j = raw.stageDurations) == null ? void 0 : _j.motionMs, 2e4),
|
|
145
|
-
rhythmCycles: clampInt((_k = raw.stageDurations) == null ? void 0 : _k.rhythmCycles,
|
|
145
|
+
rhythmCycles: clampInt((_k = raw.stageDurations) == null ? void 0 : _k.rhythmCycles, 3, 1, 50)
|
|
146
146
|
},
|
|
147
147
|
renderer: raw.renderer ?? "auto",
|
|
148
148
|
scoring: {
|
|
@@ -4791,6 +4791,7 @@ class RhythmStage {
|
|
|
4791
4791
|
this._lastPhaseCount = 0;
|
|
4792
4792
|
this._bestAccuracy = 0;
|
|
4793
4793
|
this._lastGuideTime = 0;
|
|
4794
|
+
this._lastGoodCycleAt = 0;
|
|
4794
4795
|
this.IDEAL_MOVE_MIN = 900;
|
|
4795
4796
|
this.IDEAL_MOVE_MAX = 4200;
|
|
4796
4797
|
this.IDEAL_PAUSE_MIN = 600;
|
|
@@ -4839,6 +4840,7 @@ class RhythmStage {
|
|
|
4839
4840
|
this._totalCycles++;
|
|
4840
4841
|
if (isGood) {
|
|
4841
4842
|
this._goodCycles++;
|
|
4843
|
+
this._lastGoodCycleAt = Date.now();
|
|
4842
4844
|
} else {
|
|
4843
4845
|
this._goodCycles = Math.max(0, this._goodCycles - 0.5);
|
|
4844
4846
|
this._showReaction();
|
|
@@ -4851,6 +4853,9 @@ class RhythmStage {
|
|
|
4851
4853
|
const accuracy = this._totalCycles > 0 ? this._goodCycles / this._totalCycles : 0;
|
|
4852
4854
|
if (accuracy > this._bestAccuracy) this._bestAccuracy = accuracy;
|
|
4853
4855
|
const progress = Math.min(1, this._goodCycles / requiredCycles);
|
|
4856
|
+
const targetPhase = this._getTargetPhase();
|
|
4857
|
+
const phaseMatch = this.input.snapshot.isMoving === (targetPhase === "move");
|
|
4858
|
+
const cycleSignal = this._lastGoodCycleAt > 0 ? Math.max(0, 1 - (Date.now() - this._lastGoodCycleAt) / 2200) : 0;
|
|
4854
4859
|
this.bus.emit("stage:progress", progress);
|
|
4855
4860
|
this.bus.emit("rhythm:breathe", {
|
|
4856
4861
|
accuracy,
|
|
@@ -4858,7 +4863,10 @@ class RhythmStage {
|
|
|
4858
4863
|
progress,
|
|
4859
4864
|
moveDuration: this.input.moveDuration,
|
|
4860
4865
|
stillDuration: this.input.stillDuration,
|
|
4861
|
-
liveConfidence: this._getLiveConfidence()
|
|
4866
|
+
liveConfidence: this._getLiveConfidence(),
|
|
4867
|
+
targetPhase,
|
|
4868
|
+
phaseMatch,
|
|
4869
|
+
cycleSignal
|
|
4862
4870
|
});
|
|
4863
4871
|
if (accuracy === 0 && Date.now() - this._lastGuideTime > 12e3) {
|
|
4864
4872
|
this._lastGuideTime = Date.now();
|
|
@@ -4897,6 +4905,12 @@ class RhythmStage {
|
|
|
4897
4905
|
}
|
|
4898
4906
|
return this._scoreDuration(this.input.stillDuration, this.IDEAL_PAUSE_MIN, this.IDEAL_PAUSE_MAX);
|
|
4899
4907
|
}
|
|
4908
|
+
_getTargetPhase() {
|
|
4909
|
+
if (this.input.snapshot.isMoving) {
|
|
4910
|
+
return this.input.moveDuration >= this.IDEAL_MOVE_MIN ? "still" : "move";
|
|
4911
|
+
}
|
|
4912
|
+
return this.input.stillDuration >= this.IDEAL_PAUSE_MIN ? "move" : "still";
|
|
4913
|
+
}
|
|
4900
4914
|
_scoreDuration(duration, idealMin, idealMax) {
|
|
4901
4915
|
if (duration <= 0) return 0;
|
|
4902
4916
|
if (duration >= idealMin && duration <= idealMax) return 1;
|
|
@@ -5029,24 +5043,25 @@ class PageBreather {
|
|
|
5029
5043
|
this._isUserMoving = false;
|
|
5030
5044
|
this._inSync = false;
|
|
5031
5045
|
this._accuracy = 0;
|
|
5032
|
-
this.
|
|
5046
|
+
this._targetPhase = "move";
|
|
5047
|
+
this._phaseMatch = false;
|
|
5048
|
+
this._signal = 0;
|
|
5033
5049
|
this._tick = () => {
|
|
5034
5050
|
if (!this._active || !this._overlay) return;
|
|
5035
5051
|
this._rafId = requestAnimationFrame(this._tick);
|
|
5036
5052
|
this._intensity += (this._targetIntensity - this._intensity) * 0.06;
|
|
5037
5053
|
const elapsed = Date.now() - this._startTime;
|
|
5038
|
-
const
|
|
5039
|
-
const
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
const
|
|
5043
|
-
const
|
|
5044
|
-
const opacity = this._intensity * (0.18 + baseOpacity + (1 - wave) * 0.12 + syncBonus);
|
|
5054
|
+
const wave = (Math.sin(elapsed * 4e-3) + 1) * 0.5;
|
|
5055
|
+
const shouldMove = this._targetPhase === "move";
|
|
5056
|
+
this._inSync = this._phaseMatch && this._signal > 0.15;
|
|
5057
|
+
const baseOpacity = shouldMove ? 0.12 + wave * 0.08 : 0.32 + wave * 0.18;
|
|
5058
|
+
const syncBonus = this._inSync ? 0.12 + this._signal * 0.18 : 0;
|
|
5059
|
+
const opacity = this._intensity * (baseOpacity + syncBonus);
|
|
5045
5060
|
this._overlay.style.opacity = String(Math.min(0.9, opacity));
|
|
5046
|
-
this._overlay.style.transform = `scale(${1 + wave * 0.
|
|
5061
|
+
this._overlay.style.transform = `scale(${1 + wave * (shouldMove ? 0.01 : 0.02)})`;
|
|
5047
5062
|
if (this._label) {
|
|
5048
5063
|
this._label.textContent = shouldMove ? "In" : "Out";
|
|
5049
|
-
this._label.style.opacity =
|
|
5064
|
+
this._label.style.opacity = this._phaseMatch ? "0.98" : "0.78";
|
|
5050
5065
|
this._label.style.boxShadow = this._inSync ? "0 0 28px rgba(212,165,80,0.4)" : "0 0 20px rgba(255,255,255,0.08)";
|
|
5051
5066
|
this._label.style.borderColor = this._inSync ? "rgba(212,165,80,0.55)" : "rgba(255,255,255,0.12)";
|
|
5052
5067
|
}
|
|
@@ -5096,12 +5111,15 @@ class PageBreather {
|
|
|
5096
5111
|
this._label = label;
|
|
5097
5112
|
this._tick();
|
|
5098
5113
|
}
|
|
5099
|
-
update(accuracy, isMoving) {
|
|
5114
|
+
update(accuracy, isMoving, targetPhase, phaseMatch, signal) {
|
|
5100
5115
|
if (!this._active) return;
|
|
5101
5116
|
this._isUserMoving = isMoving;
|
|
5102
5117
|
this._accuracy = accuracy;
|
|
5103
|
-
|
|
5104
|
-
this.
|
|
5118
|
+
this._targetPhase = targetPhase;
|
|
5119
|
+
this._phaseMatch = phaseMatch;
|
|
5120
|
+
this._signal = signal;
|
|
5121
|
+
const raw = Math.max(0, Math.min(1, Math.max(accuracy, signal) / 0.8));
|
|
5122
|
+
this._targetIntensity = 0.38 + raw * 0.62;
|
|
5105
5123
|
}
|
|
5106
5124
|
/** Whether the user is currently in sync with the breathing rhythm. */
|
|
5107
5125
|
isInSync() {
|
|
@@ -5120,6 +5138,9 @@ class PageBreather {
|
|
|
5120
5138
|
this._targetIntensity = 0;
|
|
5121
5139
|
this._inSync = false;
|
|
5122
5140
|
this._accuracy = 0;
|
|
5141
|
+
this._targetPhase = "move";
|
|
5142
|
+
this._phaseMatch = false;
|
|
5143
|
+
this._signal = 0;
|
|
5123
5144
|
}
|
|
5124
5145
|
destroy() {
|
|
5125
5146
|
this.stop();
|
|
@@ -5220,10 +5241,15 @@ class GameController {
|
|
|
5220
5241
|
this.bus.on("rhythm:breathe", (data) => {
|
|
5221
5242
|
var _a3, _b3;
|
|
5222
5243
|
(_a3 = this.eggRenderer) == null ? void 0 : _a3.setBreathIntensity(data.accuracy);
|
|
5223
|
-
(_b3 = this.pageBreather) == null ? void 0 : _b3.update(
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5244
|
+
(_b3 = this.pageBreather) == null ? void 0 : _b3.update(
|
|
5245
|
+
data.accuracy,
|
|
5246
|
+
data.isMoving,
|
|
5247
|
+
data.targetPhase,
|
|
5248
|
+
data.phaseMatch,
|
|
5249
|
+
Math.max(data.liveConfidence * 0.55, data.cycleSignal)
|
|
5250
|
+
);
|
|
5251
|
+
if (data.cycleSignal > 0.12 && this.threeRenderer) {
|
|
5252
|
+
this.threeRenderer.showProgressParticles(0.35 + Math.max(data.progress, data.cycleSignal) * 0.65, "rhythm");
|
|
5227
5253
|
} else if (this.threeRenderer) {
|
|
5228
5254
|
this.threeRenderer.fadeOutAmbientParticles();
|
|
5229
5255
|
}
|