mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
0d7c5c8f56
* move `cocos/core/scene-graph` to `cocos/scene-graph` * move some files in `cocos/core/components` to `cocos/scene-graph`: - component.ts - component-event-handler.ts - component-event-handler-schema.ts * move some files in `cocos/core/components` to `cocos/misc`: - missing-script.ts - model-renderer.ts - renderer.ts - camera-component.ts * move `cocos/core/components/system.ts` to ``cocos/core/system.ts``
65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
import { Node } from "../../../cocos/scene-graph";
|
|
import { addEmbeddedPlayerTag, AnimationClip } from "../../../cocos/animation/animation-clip";
|
|
import { EmbeddedPlayableState } from "../../../cocos/animation/embedded-player/embedded-player";
|
|
import { EmbeddedPlayer } from "../../../editor/exports/embedded-player";
|
|
|
|
export class EmbeddedPlayerHostMock {
|
|
constructor(root: Node, private _embeddedPlayer: EmbeddedPlayer, _hostDuration: number) {
|
|
const instantiatedPlayer = this._embeddedPlayer.playable?.instantiate(root) ?? null;
|
|
this._instantiatedPlayer = instantiatedPlayer;
|
|
}
|
|
|
|
get wellInstantiated() {
|
|
return !!this._instantiatedPlayer;
|
|
}
|
|
|
|
get randomAccessible() {
|
|
return this._instantiatedPlayer?.randomAccess ?? false;
|
|
}
|
|
|
|
public play(time: number) {
|
|
this._instantiatedPlayer?.play();
|
|
}
|
|
|
|
public stop() {
|
|
this._instantiatedPlayer?.stop();
|
|
}
|
|
|
|
public setSpeed(speed: number) {
|
|
this._instantiatedPlayer?.setSpeed(speed);
|
|
}
|
|
|
|
private _instantiatedPlayer: EmbeddedPlayableState | null;
|
|
}
|
|
|
|
export class AnimationClipHostEmbeddedPlayerMock {
|
|
constructor(_root: Node, embeddedPlayer: EmbeddedPlayer, hostDuration: number) {
|
|
const animationClip = new AnimationClip();
|
|
animationClip.duration = hostDuration;
|
|
animationClip[addEmbeddedPlayerTag](embeddedPlayer);
|
|
const evaluator = animationClip.createEmbeddedPlayerEvaluator(_root);
|
|
this._animationEvaluator = evaluator;
|
|
}
|
|
|
|
public play(time: number) {
|
|
this._animationEvaluator.notifyHostPlay(time);
|
|
}
|
|
|
|
public pause(time: number) {
|
|
this._animationEvaluator.notifyHostPause(time);
|
|
}
|
|
|
|
public stop() {
|
|
this._animationEvaluator.notifyHostStop();
|
|
}
|
|
|
|
public setSpeed(speed: number) {
|
|
this._animationEvaluator.notifyHostSpeedChanged(speed);
|
|
}
|
|
|
|
public evaluateAt(time: number, iterations: number) {
|
|
this._animationEvaluator.evaluate(time, iterations);
|
|
}
|
|
|
|
private _animationEvaluator: ReturnType<AnimationClip['createEmbeddedPlayerEvaluator']>;
|
|
} |