feat: if device orientation interaction is turned off, disable dynamic minSpeed

This commit is contained in:
Usu171
2025-12-14 23:10:01 +08:00
parent 455c54b3cf
commit db3ce82eb2
2 changed files with 14 additions and 6 deletions

View File

@@ -128,6 +128,10 @@ export class DeviceOrientationInteraction {
return { x: this.ax, y: this.ay };
}
public getEnabled(): boolean {
return this.config.enable;
}
/**
* Apply Force (Gravity)
*/

View File

@@ -154,12 +154,16 @@ export class MarbleSystem {
} else {
subSteps = 4;
}
const maxMagnitude = 7.0;
const exponent = 3;
const t = Math.min(magnitude / maxMagnitude, 1.0);
const factor = 1 - (2 * t) ** exponent;
const minSpeed = MARBLE_CONFIG.physics.minSpeed * Math.max(0, factor);
this.physics.updateConfig({ minSpeed: minSpeed });
if (this.deviceOrientationInteraction.getEnabled()) {
const maxMagnitude = 7.0;
const exponent = 3;
const t = Math.min(magnitude / maxMagnitude, 1.0);
const factor = 1 - (2 * t) ** exponent;
const minSpeed = MARBLE_CONFIG.physics.minSpeed * Math.max(0, factor);
this.physics.updateConfig({ minSpeed: minSpeed });
} else {
this.physics.updateConfig({ minSpeed: MARBLE_CONFIG.physics.minSpeed });
}
}
this.currentSubSteps = subSteps;