mirror of
https://github.com/motajs/template.git
synced 2026-11-27 00:14:34 +08:00
refactor: 音频系统
This commit is contained in:
1 parent
191ba8d1db
commit
ee54148558
29 files changed
+2170
-1273
No files matched your search
@@ -6,7 +6,8 @@ import {
|
||||
IExcitationVariator,
|
||||
ExcitationCurve,
|
||||
VariatorCurveMode,
|
||||
IExcitationDivider
|
||||
IExcitationDivider,
|
||||
IIntervalExcitation
|
||||
} from './types';
|
||||
import { excited } from './utils';
|
||||
|
||||
@@ -108,6 +109,30 @@ export class RafExcitation extends ExcitationBase<number> {
|
||||
}
|
||||
}
|
||||
|
||||
export class IntervalExcitation
|
||||
extends ExcitationBase<number>
|
||||
implements IIntervalExcitation
|
||||
{
|
||||
private now: number = 0;
|
||||
private readonly id: number;
|
||||
|
||||
constructor(readonly interval: number) {
|
||||
super();
|
||||
this.id = window.setInterval(() => {
|
||||
this.excite(this.now);
|
||||
this.now += interval;
|
||||
}, interval);
|
||||
}
|
||||
|
||||
payload(): number {
|
||||
return this.now;
|
||||
}
|
||||
|
||||
override destroy(): void {
|
||||
window.clearInterval(this.id);
|
||||
}
|
||||
}
|
||||
|
||||
interface CurveQueue {
|
||||
/** 速率曲线 */
|
||||
curve: ExcitationCurve;
|
||||
|
||||
@@ -158,6 +158,11 @@ export interface IExcitationDivider<T> extends IExcitation<T> {
|
||||
setDivider(divider: number): void;
|
||||
}
|
||||
|
||||
export interface IIntervalExcitation extends IExcitation<number> {
|
||||
/** 两次触发之间的时间间隔 */
|
||||
readonly interval: number;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 动画类
|
||||
|
||||
Reference in new issue
Block a user