- optimize IVibrator and Vibrator by delete unused this.patterns and add const offsetTime in vibrate.

- added in all models readonly token.
- rebuild and deploy
This commit is contained in:
Eugene Serb 2022-08-09 18:20:26 +03:00
parent 81ab823b6a
commit dd856936cc
11 changed files with 20 additions and 24 deletions

View File

@ -15,4 +15,4 @@
webvisor: true
});</script><style>[v-cloak] {
display: none;
}</style><script defer="defer" src="/js/chunk-vendors.248cd14b.js"></script><script defer="defer" src="/js/app.9e6bfa01.js"></script><link href="/css/app.b1ea1061.css" rel="stylesheet"></head><body><header class="header"><div class="header-wrapper container"><div class="logo-wrapper"><span class="logo-wrapper__logo" translate="no">Wavelovers</span></div><nav class="menu-wrapper"><ul class="navigation"><li class="navigation__item"><a href="/" target="_self" class="navigation__link">Home</a></li><li class="navigation__item"><a href="/faq.html" target="_self" class="navigation__link">FAQ</a></li><li class="navigation__item"><a href="/about.html" target="_self" class="navigation__link">About</a></li><li class="navigation__item"><a href="/donate.html" target="_self" class="navigation__link">Donate</a></li></ul></nav></div></header><main class="page container"><h1 class="visually-hidden">Wavelovers</h1><div id="app" v-cloak></div></main><footer class="footer"><div class="footer-wrapper container"><div class="annotation"><span class="annotation__text">© 2022 Wavelovers. Content licensed under </span><a href="https://wavelovers.ru/LICENSE.md" target="_blank">GNU General Public License v3.0</a><br><span class="annotation__text">This site is open source. </span><a href="https://github.com/eugene-serb/wavelovers/" target="_blank">Improve this page.</a></div><div class="annotation created-by"><span class="annotation__text">Created by</span><a href="https://eugene-serb.github.io/" target="_blank" translate="no">Eugene Serb</a></div></div></footer><noscript>You need to enable JavaScript to run this app.</noscript><noscript><div><img src="https://mc.yandex.ru/watch/89252711" style="position:absolute; left:-9999px;" alt=""/></div></noscript></body></html>
}</style><script defer="defer" src="/js/chunk-vendors.248cd14b.js"></script><script defer="defer" src="/js/app.26b99067.js"></script><link href="/css/app.b1ea1061.css" rel="stylesheet"></head><body><header class="header"><div class="header-wrapper container"><div class="logo-wrapper"><span class="logo-wrapper__logo" translate="no">Wavelovers</span></div><nav class="menu-wrapper"><ul class="navigation"><li class="navigation__item"><a href="/" target="_self" class="navigation__link">Home</a></li><li class="navigation__item"><a href="/faq.html" target="_self" class="navigation__link">FAQ</a></li><li class="navigation__item"><a href="/about.html" target="_self" class="navigation__link">About</a></li><li class="navigation__item"><a href="/donate.html" target="_self" class="navigation__link">Donate</a></li></ul></nav></div></header><main class="page container"><h1 class="visually-hidden">Wavelovers</h1><div id="app" v-cloak></div></main><footer class="footer"><div class="footer-wrapper container"><div class="annotation"><span class="annotation__text">© 2022 Wavelovers. Content licensed under </span><a href="https://wavelovers.ru/LICENSE.md" target="_blank">GNU General Public License v3.0</a><br><span class="annotation__text">This site is open source. </span><a href="https://github.com/eugene-serb/wavelovers/" target="_blank">Improve this page.</a></div><div class="annotation created-by"><span class="annotation__text">Created by</span><a href="https://eugene-serb.github.io/" target="_blank" translate="no">Eugene Serb</a></div></div></footer><noscript>You need to enable JavaScript to run this app.</noscript><noscript><div><img src="https://mc.yandex.ru/watch/89252711" style="position:absolute; left:-9999px;" alt=""/></div></noscript></body></html>

2
docs/js/app.26b99067.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,13 +2,13 @@ import IVibrationActuator from '@/models/IVibrationActuator';
import IGamepadButton from '@/models/IGamepadButton';
interface IGamepad {
id: string;
index: number;
timestamp: number;
connected: boolean;
mapping: string;
axes: number[];
buttons: IGamepadButton[];
readonly id: string;
readonly index: number;
readonly timestamp: number;
readonly connected: boolean;
readonly mapping: string;
readonly axes: number[];
readonly buttons: IGamepadButton[];
vibrationActuator: IVibrationActuator;
}

View File

@ -1,7 +1,7 @@
interface IGamepadButton {
pressed: boolean;
touched: boolean;
value: number;
readonly pressed: boolean;
readonly touched: boolean;
readonly value: number;
}
export default IGamepadButton;

View File

@ -1,7 +1,7 @@
import IGamepad from '@/models/IGamepad';
interface IGamepadEvent {
gamepad: IGamepad;
readonly gamepad: IGamepad;
}
export default IGamepadEvent;

View File

@ -1,7 +1,7 @@
import TPatternUnit from '@/models/TPatternUnit';
interface IVibrationActuator {
type: string;
readonly type: string;
reset(): void;
playEffect(mode: string, pattern: TPatternUnit): void;
}

View File

@ -6,7 +6,6 @@ interface IVibrator {
readonly canVibrate: boolean;
isVibrating: boolean;
unit: IGamepad;
pattern: TPatternUnit[];
interval: number;
update(): void;
reset(): void;

View File

@ -7,7 +7,6 @@ class Vibrator implements IVibrator {
readonly canVibrate: boolean;
isVibrating: boolean;
unit: IGamepad;
pattern: TPatternUnit[];
interval: number;
constructor(unit: IGamepad) {
@ -15,8 +14,6 @@ class Vibrator implements IVibrator {
this.id = Date.now();
this.canVibrate = (this.unit.vibrationActuator) ? true : false;
this.isVibrating = false;
this.pattern = [];
this.update = this.update.bind(this);
this.interval = setInterval(this.update, 1);
}
@ -33,12 +30,12 @@ class Vibrator implements IVibrator {
async vibrate(pattern: TPatternUnit[]) {
this.isVibrating = true;
this.pattern = pattern;
const offsetTime = 10;
while (this.isVibrating === true) {
for (let i = 0; i < this.pattern.length; i++) {
for (let i = 0; i < pattern.length; i++) {
if (this.isVibrating === true) {
this.unit.vibrationActuator.playEffect('dual-rumble', this.pattern[i]);
await this.sleep(this.pattern[i].startDelay + this.pattern[i].duration - 10);
this.unit.vibrationActuator.playEffect('dual-rumble', pattern[i]);
await this.sleep(pattern[i].startDelay + pattern[i].duration - offsetTime);
} else {
return;
}