mirror of
https://github.com/101island/lolisland.us.git
synced 2026-03-01 03:49:42 +08:00
feat: if device orientation interaction is turned off, disable dynamic minSpeed
This commit is contained in:
@@ -128,6 +128,10 @@ export class DeviceOrientationInteraction {
|
||||
return { x: this.ax, y: this.ay };
|
||||
}
|
||||
|
||||
public getEnabled(): boolean {
|
||||
return this.config.enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply Force (Gravity)
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user