Add cilp model;
This commit is contained in:
parent
d53acf0146
commit
c923efcd99
88
source/Model/Clip.ts
Normal file
88
source/Model/Clip.ts
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
import { IAnyObject, Model } from "@Model/Model";
|
||||||
|
import { Group } from "@Model/Group";
|
||||||
|
import { Range } from "@Model/Range";
|
||||||
|
|
||||||
|
interface IDrawCommand {
|
||||||
|
type: "points" | "cube";
|
||||||
|
id: string;
|
||||||
|
data?: Float32Array;
|
||||||
|
position?: number[];
|
||||||
|
radius?: number[];
|
||||||
|
parameter?: IAnyObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IFrame {
|
||||||
|
commands: IDrawCommand[];
|
||||||
|
duration: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 剪辑片段
|
||||||
|
*/
|
||||||
|
class Clip {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户自定义名称
|
||||||
|
*/
|
||||||
|
public name: string = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型
|
||||||
|
*/
|
||||||
|
public model: Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全部帧
|
||||||
|
*/
|
||||||
|
public frames: IFrame[] = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 录制一帧
|
||||||
|
*/
|
||||||
|
public record(t: number): IFrame {
|
||||||
|
const commands: IDrawCommand[] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < this.model.objectPool.length; i++) {
|
||||||
|
|
||||||
|
let object = this.model.objectPool[i];
|
||||||
|
object.renderParameter.color = object.color;
|
||||||
|
|
||||||
|
if (object.display && object instanceof Group) {
|
||||||
|
commands.push({
|
||||||
|
type: "points",
|
||||||
|
id: object.id,
|
||||||
|
data: object.exportPositionData(),
|
||||||
|
parameter: object.renderParameter
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (object.display && object instanceof Range) {
|
||||||
|
commands.push({
|
||||||
|
type: "cube",
|
||||||
|
id: object.id,
|
||||||
|
position: object.position,
|
||||||
|
radius: object.radius,
|
||||||
|
parameter: object.renderParameter
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const frame: IFrame = {
|
||||||
|
commands: commands,
|
||||||
|
duration: t
|
||||||
|
};
|
||||||
|
|
||||||
|
this.frames.push(frame);
|
||||||
|
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public constructor(model: Model) {
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Clip };
|
@ -5,6 +5,7 @@ import { IParamValue } from "@Model/Parameter";
|
|||||||
import { CtrlObject } from "@Model/CtrlObject";
|
import { CtrlObject } from "@Model/CtrlObject";
|
||||||
import { Emitter } from "@Model/Emitter";
|
import { Emitter } from "@Model/Emitter";
|
||||||
import { AbstractRenderer } from "@Model/Renderer";
|
import { AbstractRenderer } from "@Model/Renderer";
|
||||||
|
import { Clip } from "@Model/Clip";
|
||||||
import { Behavior, IAnyBehavior, IAnyBehaviorRecorder } from "@Model/Behavior";
|
import { Behavior, IAnyBehavior, IAnyBehaviorRecorder } from "@Model/Behavior";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -330,6 +331,8 @@ class Model extends Emitter<ModelEvent> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public clipPool: Clip[] = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渲染器
|
* 渲染器
|
||||||
*/
|
*/
|
||||||
@ -347,7 +350,7 @@ class Model extends Emitter<ModelEvent> {
|
|||||||
/**
|
/**
|
||||||
* 更新渲染数据
|
* 更新渲染数据
|
||||||
*/
|
*/
|
||||||
public update(t: number) {
|
public update(t: number, skipDraw: boolean = false) {
|
||||||
|
|
||||||
// 第一轮更新
|
// 第一轮更新
|
||||||
for (let i = 0; i < this.objectPool.length; i++) {
|
for (let i = 0; i < this.objectPool.length; i++) {
|
||||||
@ -373,7 +376,9 @@ class Model extends Emitter<ModelEvent> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.draw();
|
if (!skipDraw) {
|
||||||
|
this.draw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public draw() {
|
public draw() {
|
||||||
|
Loading…
Reference in New Issue
Block a user