Skip to content

Commit 80fc3ad

Browse files
committed
fix: run preFrame when addSprite at ac-canvas.ts
1 parent 4c83ca7 commit 80fc3ad

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

packages/av-canvas/src/av-canvas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ export class AVCanvas {
340340
this.#sprMapAudioNode.set(vs, audioNode);
341341
}
342342
await this.#spriteManager.addSprite(vs);
343+
vs.preFrame(0);
343344
};
344345
/**
345346
* 删除 {@link VisibleSprite}

packages/av-canvas/src/sprites/sprite-manager.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ export class SpriteManager {
2929

3030
async addSprite(vs: VisibleSprite): Promise<void> {
3131
await vs.ready;
32-
vs.preFrame(0);
3332
this.#sprites.push(vs);
3433
this.#sprites = this.#sprites.sort((a, b) => a.zIndex - b.zIndex);
3534
vs.on('propsChange', (props) => {
3635
if (props.zIndex == null) return;
37-
vs.preFrame(0);
3836
this.#sprites = this.#sprites.sort((a, b) => a.zIndex - b.zIndex);
3937
});
4038

packages/av-cliper/src/sprite/visible-sprite.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ export class VisibleSprite extends BaseSprite {
7171
* 提前准备指定 time 的帧
7272
*/
7373
preFrame(time: number) {
74+
if (this.#lastTime === time) return;
7475
this.#update(time);
76+
this.#lastTime = time;
7577
}
7678

7779
#lastTime = -1;

0 commit comments

Comments
 (0)