取消wxgame依赖,去除debugRender与camera依赖
This commit is contained in:
@@ -78,12 +78,6 @@ module es {
|
||||
public onEntityTransformChanged(comp: transform.Component) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public debugRender(camera: Camera) {
|
||||
}
|
||||
|
||||
/**
|
||||
*当父实体或此组件启用时调用
|
||||
*/
|
||||
|
||||
@@ -74,9 +74,6 @@ module es {
|
||||
}
|
||||
}
|
||||
|
||||
public debugRender(camera: Camera) {
|
||||
}
|
||||
|
||||
public toString() {
|
||||
return `[BoxCollider: bounds: ${this.bounds}]`;
|
||||
}
|
||||
|
||||
@@ -36,10 +36,6 @@ module es {
|
||||
return this;
|
||||
}
|
||||
|
||||
public debugRender(camera: Camera) {
|
||||
|
||||
}
|
||||
|
||||
public toString() {
|
||||
return `[CircleCollider: bounds: ${this.bounds}, radius: ${(this.shape as Circle).radius}]`
|
||||
}
|
||||
|
||||
@@ -302,13 +302,6 @@ module es {
|
||||
this.components.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* 在默认渲染器中,如果Core.debugRenderEnabled为true,则调用。自定义渲染器可以选择是否调用它。
|
||||
*/
|
||||
public debugRender(camera: Camera){
|
||||
this.components.debugRender(camera);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将组件添加到组件列表中。返回组件。
|
||||
* @param component
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
module es {
|
||||
/** 场景 */
|
||||
export class Scene {
|
||||
/**
|
||||
* 默认场景摄像机
|
||||
*/
|
||||
public camera: Camera;
|
||||
/**
|
||||
* 这个场景中的实体列表
|
||||
*/
|
||||
@@ -31,15 +27,6 @@ module es {
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 辅助器,创建一个场景与DefaultRenderer附加并准备使用
|
||||
*/
|
||||
public static createWithDefaultRenderer() {
|
||||
let scene = new Scene();
|
||||
scene.addRenderer(new DefaultRenderer());
|
||||
return scene;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在场景子类中重写这个并在这里进行加载。在场景设置好之后,在调用begin之前,从构造器中调用。
|
||||
*/
|
||||
@@ -72,11 +59,6 @@ module es {
|
||||
}
|
||||
|
||||
public begin() {
|
||||
if (this._renderers.length == 0) {
|
||||
this.addRenderer(new DefaultRenderer());
|
||||
console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染");
|
||||
}
|
||||
|
||||
Physics.reset();
|
||||
this.updateResolutionScaler();
|
||||
|
||||
@@ -108,8 +90,6 @@ module es {
|
||||
}
|
||||
this._sceneComponents.length = 0;
|
||||
|
||||
this.camera = null;
|
||||
|
||||
if (this.entityProcessors)
|
||||
this.entityProcessors.end();
|
||||
|
||||
|
||||
@@ -250,12 +250,5 @@ module es {
|
||||
for (let i = 0; i < this._components.length; i++)
|
||||
this._components.buffer[i].onDisabled();
|
||||
}
|
||||
|
||||
public debugRender(camera: Camera){
|
||||
for (let i = 0; i < this._components.length; i ++){
|
||||
if (this._components.buffer[i].enabled)
|
||||
this._components.buffer[i].debugRender(camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
///<reference path="./Renderer.ts" />
|
||||
module es {
|
||||
export class DefaultRenderer extends Renderer {
|
||||
constructor() {
|
||||
super(0, null);
|
||||
}
|
||||
|
||||
public render(scene: Scene) {
|
||||
let cam = this.camera ? this.camera : scene.camera;
|
||||
this.beginRender(cam);
|
||||
|
||||
for (let i = 0; i < scene.renderableComponents.count; i++) {
|
||||
let renderable = scene.renderableComponents.buffer[i];
|
||||
if (renderable.enabled && renderable.isVisibleFromCamera(cam))
|
||||
this.renderAfterStateCheck(renderable, cam);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,25 +20,6 @@ module es {
|
||||
* 可渲染的可见性。状态的改变会调用onBecameVisible/onBecameInvisible方法
|
||||
*/
|
||||
isVisible: boolean;
|
||||
|
||||
/**
|
||||
* 如果renderableComponent的边界与camera.bounds相交 返回true
|
||||
* 用于处理isVisible标志的状态开关
|
||||
* 在渲染方法中使用这个方法来决定是否渲染
|
||||
* @param camera
|
||||
*/
|
||||
isVisibleFromCamera(camera: Camera);
|
||||
|
||||
/**
|
||||
* 由渲染器调用。可以使用摄像机进行剔除
|
||||
* @param camera
|
||||
*/
|
||||
render(camera: Camera);
|
||||
|
||||
/**
|
||||
* 只有在没有碰撞器时才呈现边界。总是在原点上渲染一个正方形。
|
||||
*/
|
||||
debugRender(camera: Camera);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,12 +3,6 @@ module es {
|
||||
* 渲染器被添加到场景中并处理所有对RenderableComponent的实际调用
|
||||
*/
|
||||
export abstract class Renderer {
|
||||
/**
|
||||
* 渲染器用于渲染的摄像机(实际上是用于剔除的变换矩阵和边界)
|
||||
* 不是必须的
|
||||
* Renderer子类可以选择调用beginRender时使用的摄像头
|
||||
*/
|
||||
public camera: Camera;
|
||||
/**
|
||||
* 指定场景调用渲染器的顺序
|
||||
*/
|
||||
@@ -20,8 +14,7 @@ module es {
|
||||
*/
|
||||
public shouldDebugRender: boolean = true;
|
||||
|
||||
protected constructor(renderOrder: number, camera: Camera = null) {
|
||||
this.camera = camera;
|
||||
protected constructor(renderOrder: number) {
|
||||
this.renderOrder = renderOrder;
|
||||
}
|
||||
|
||||
@@ -52,34 +45,5 @@ module es {
|
||||
public compareTo(other: Renderer): number {
|
||||
return this.renderOrder - other.renderOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cam
|
||||
*/
|
||||
protected beginRender(cam: Camera) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param renderable
|
||||
* @param cam
|
||||
*/
|
||||
protected renderAfterStateCheck(renderable: IRenderable, cam: Camera) {
|
||||
renderable.render(cam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认debugRender方法只循环遍历所有实体并调用entity.debugRender
|
||||
* @param scene
|
||||
* @param cam
|
||||
*/
|
||||
protected debugRender(scene: Scene, cam: Camera){
|
||||
for (let i = 0; i < scene.entities.count; i ++){
|
||||
let entity = scene.entities.buffer[i];
|
||||
if (entity.enabled)
|
||||
entity.debugRender(cam);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user