移除Graphics相关

This commit is contained in:
yhh
2020-11-30 18:23:03 +08:00
parent 0137309d3a
commit 0d8878abef
10 changed files with 20 additions and 1042 deletions

View File

@@ -1,33 +0,0 @@
module es {
/**
* 当该接口应用到组件时,它将注册组件以场景渲染器显示
* 该接口请谨慎实现
*/
export interface IRenderable {
/**
* 对象的AABB用于相机剔除
*/
bounds: Rectangle;
/**
* 这个组件是否应该被渲染
*/
enabled: boolean;
/**
* 较低的渲染层在前面,较高的在后面
*/
renderLayer: number;
/**
* 可渲染的可见性。状态的改变会调用onBecameVisible/onBecameInvisible方法
*/
isVisible: boolean;
}
/**
* 用于排序IRenderables的比较器
*/
export class RenderableComparer {
public compare(self: IRenderable, other: IRenderable) {
return other.renderLayer - self.renderLayer;
}
}
}

View File

@@ -1,49 +0,0 @@
module es {
/**
* 渲染器被添加到场景中并处理所有对RenderableComponent的实际调用
*/
export abstract class Renderer {
/**
* 指定场景调用渲染器的顺序
*/
public readonly renderOrder: number = 0;
/**
* 这个渲染器的标志,决定它是否应该调试渲染。
* render方法接收一个bool (debugRenderEnabled),让渲染器知道全局调试渲染是否打开/关闭。
* 渲染器然后使用本地bool来决定它是否应该调试渲染。
*/
public shouldDebugRender: boolean = true;
protected constructor(renderOrder: number) {
this.renderOrder = renderOrder;
}
/**
* 当渲染器被添加到场景时调用
* @param scene
*/
public onAddedToScene(scene: Scene) {
}
/**
* 当场景结束或渲染器从场景中移除时调用。使用这个进行清理。
*/
public unload() {
}
public abstract render(scene: Scene);
/**
* 当默认场景渲染目标被调整大小和当场景已经开始添加渲染器时调用
* @param newWidth
* @param newHeight
*/
public onSceneBackBufferSizeChanged(newWidth: number, newHeight: number) {
}
public compareTo(other: Renderer): number {
return this.renderOrder - other.renderOrder;
}
}
}

View File

@@ -1,68 +0,0 @@
module es {
/**
* SceneTransition用于从一个场景过渡到另一个场景或在一个有效果的场景中过渡
*/
export abstract class SceneTransition {
/** 是否加载新场景的标志 */
public loadsNewScene: boolean;
/**
* 将此用于两个部分的转换。例如淡出会先淡出到黑色然后当isNewSceneLoaded为true它会淡出。
* 对于场景过渡isNewSceneLoaded应该在中点设置为true这就标识一个新的场景被加载了。
*/
public isNewSceneLoaded: boolean;
/** 在loadNextScene执行时调用。这在进行场景间过渡时很有用这样你就知道什么时候可以更多地使用相机或者重置任何实体 */
public onScreenObscured: Function;
/** 当转换完成执行时调用,以便可以调用其他工作,比如启动另一个转换。 */
public onTransitionCompleted: Function;
/** 返回新加载场景的函数 */
protected sceneLoadAction: Function;
constructor(sceneLoadAction: Function) {
this.sceneLoadAction = sceneLoadAction;
this.loadsNewScene = sceneLoadAction != null;
}
private _hasPreviousSceneRender: boolean;
public get hasPreviousSceneRender() {
if (!this._hasPreviousSceneRender) {
this._hasPreviousSceneRender = true;
return false;
}
return true;
}
public preRender() {
}
public render() {
}
public async onBeginTransition() {
await this.loadNextScene();
this.transitionComplete();
}
protected transitionComplete() {
Core._instance._sceneTransition = null;
if (this.onTransitionCompleted) {
this.onTransitionCompleted();
}
}
protected async loadNextScene() {
if (this.onScreenObscured)
this.onScreenObscured();
if (!this.loadsNewScene) {
this.isNewSceneLoaded = true;
}
Core.scene = await this.sceneLoadAction();
this.isNewSceneLoaded = true;
}
}
}

View File

@@ -1,55 +0,0 @@
module es {
export class Viewport {
private _x: number;
private _y: number;
private _minDepth: number;
private _maxDepth: number;
constructor(x: number, y: number, width: number, height: number) {
this._x = x;
this._y = y;
this._width = width;
this._height = height;
this._minDepth = 0;
this._maxDepth = 1;
}
private _width: number;
public get width() {
return this._width;
}
public set width(value: number) {
this._width = value;
}
private _height: number;
public get height() {
return this._height;
}
public set height(value: number) {
this._height = value;
}
public get aspectRatio() {
if ((this._height != 0) && (this._width != 0))
return (this._width / this._height);
return 0;
}
public get bounds() {
return new Rectangle(this._x, this._y, this._width, this._height);
}
public set bounds(value: Rectangle) {
this._x = value.x;
this._y = value.y;
this._width = value.width;
this._height = value.height;
}
}
}