移除渲染模块,提供更纯净的ecs

This commit is contained in:
YHH
2022-03-05 10:23:49 +08:00
parent f3f5d0bbd1
commit ccc603b59f
43 changed files with 131 additions and 3826 deletions

View File

@@ -3,7 +3,6 @@ module es {
* 一系列静态方法来处理所有常见的tween类型结构以及它们的unclamped lerps.unclamped lerps对于超过0-1范围的bounce、elastic或其他tweens是必需的
*/
export class Lerps {
public static lerp(from: Color, to: Color, t: number);
public static lerp(from: number, to: number, t: number);
public static lerp(from: Rectangle, to: Rectangle, t: number);
public static lerp(from: Vector2, to: Vector2, t: number);
@@ -12,12 +11,6 @@ module es {
return from + (to - from) * t;
}
if (from instanceof Color && to instanceof Color) {
const t255 = t * 255;
return new Color(from.r + (to.r - from.r) * t255 / 255, from.g + (to.g - from.g) * t255 / 255,
from.b + (to.b - from.b) * t255 / 255, from.a + (to.a - from.a) * t255 / 255)
}
if (from instanceof Rectangle && to instanceof Rectangle) {
return new Rectangle(
(from.x + (to.x - from.x) * t),
@@ -41,7 +34,6 @@ module es {
public static ease(easeType: EaseType, from: Rectangle, to: Rectangle, t: number, duration: number);
public static ease(easeType: EaseType, from: Vector2, to: Vector2, t: number, duration: number);
public static ease(easeType: EaseType, from: number, to: number, t: number, duration: number);
public static ease(easeType: EaseType, from: Color, to: Color, t: number, duration: number);
public static ease(easeType: EaseType, from: any, to: any, t: number, duration: number) {
if (typeof(from) == 'number' && typeof(to) == "number") {
return this.lerp(from, to, EaseHelper.ease(easeType, t, duration));
@@ -54,10 +46,6 @@ module es {
if (from instanceof Rectangle && to instanceof Rectangle) {
return this.lerp(from, to, EaseHelper.ease(easeType, t, duration));
}
if (from instanceof Color && to instanceof Color) {
return this.lerp(from, to, EaseHelper.ease(easeType, t, duration));
}
}
public static easeAngle(easeType: EaseType, from: Vector2, to: Vector2, t: number, duration: number) {

View File

@@ -1,38 +0,0 @@
///<reference path="./Tweens.ts"/>
module es {
export class RenderableColorTween extends ColorTween implements ITweenTarget<Color> {
_renderable: RenderableComponent;
setTweenedValue(value: Color) {
this._renderable.color = value;
}
getTweenedValue(): Color {
return this._renderable.color;
}
public getTargetObject() {
return this._renderable;
}
public updateValue() {
this.setTweenedValue(Lerps.ease(this._easeType, this._fromValue, this._toValue, this._elapsedTime, this._duration));
}
public setTarget(renderable: RenderableComponent) {
this._renderable = renderable;
}
public recycleSelf() {
if (this._shouldRecycleTween) {
this._renderable = null;
this._target = null;
this._nextTween = null;
}
if (this._shouldRecycleTween && TweenManager.cacheColorTweens) {
Pool.free(ColorTween, this);
}
}
}
}

View File

@@ -88,30 +88,4 @@ module es {
Pool.free(RectangleTween, this);
}
}
export class ColorTween extends Tween<Color> {
public static create() : ColorTween {
return TweenManager.cacheColorTweens ? Pool.obtain(ColorTween) : new ColorTween();
}
constructor(target?: ITweenTarget<Color>, to?: Color, duration?: number) {
super();
this.initialize(target, to, duration);
}
public setIsRelative() {
this._isRelative = true;
this._toValue.r += this._fromValue.r;
this._toValue.g += this._fromValue.g;
this._toValue.b += this._fromValue.b;
this._toValue.a += this._fromValue.a;
return this;
}
protected updateValue() {
this._target.setTweenedValue(Lerps.ease(this._easeType, this._fromValue as any, this._toValue as any, this._elapsedTime, this._duration));
}
}
}