修复无graphics报错问题

This commit is contained in:
yhh
2021-05-28 17:00:33 +08:00
parent 79d684caae
commit 44e2ca07e5
5 changed files with 28 additions and 2 deletions

View File

@@ -948,6 +948,8 @@ var es;
this.components.update(); this.components.update();
}; };
Entity.prototype.debugRender = function (batcher) { Entity.prototype.debugRender = function (batcher) {
if (!batcher)
return;
this.components.debugRender(batcher); this.components.debugRender(batcher);
}; };
/** /**
@@ -4196,6 +4198,8 @@ var es;
} }
}; };
ComponentList.prototype.debugRender = function (batcher) { ComponentList.prototype.debugRender = function (batcher) {
if (!batcher)
return;
for (var i = 0; i < this._components.length; i++) { for (var i = 0; i < this._components.length; i++) {
if (this._components[i].enabled) { if (this._components[i].enabled) {
this._components[i].debugRender(batcher); this._components[i].debugRender(batcher);
@@ -5527,15 +5531,23 @@ var es;
Renderer.prototype.onAddedToScene = function (scene) { }; Renderer.prototype.onAddedToScene = function (scene) { };
Renderer.prototype.unload = function () { }; Renderer.prototype.unload = function () { };
Renderer.prototype.beginRender = function (cam) { Renderer.prototype.beginRender = function (cam) {
if (!es.Graphics.instance)
return;
es.Graphics.instance.batcher.begin(cam); es.Graphics.instance.batcher.begin(cam);
}; };
Renderer.prototype.endRender = function () { Renderer.prototype.endRender = function () {
if (!es.Graphics.instance)
return;
es.Graphics.instance.batcher.end(); es.Graphics.instance.batcher.end();
}; };
Renderer.prototype.renderAfterStateCheck = function (renderable, cam) { Renderer.prototype.renderAfterStateCheck = function (renderable, cam) {
if (!es.Graphics.instance)
return;
renderable.render(es.Graphics.instance.batcher, cam); renderable.render(es.Graphics.instance.batcher, cam);
}; };
Renderer.prototype.debugRender = function (scene) { Renderer.prototype.debugRender = function (scene) {
if (!es.Graphics.instance)
return;
es.Physics.debugDraw(2); es.Physics.debugDraw(2);
for (var i = 0; i < scene.entities.count; i++) { for (var i = 0; i < scene.entities.count; i++) {
var entity = scene.entities.buffer[i]; var entity = scene.entities.buffer[i];

File diff suppressed because one or more lines are too long

View File

@@ -377,6 +377,7 @@ module es {
} }
public debugRender(batcher: IBatcher) { public debugRender(batcher: IBatcher) {
if (!batcher) return;
this.components.debugRender(batcher); this.components.debugRender(batcher);
} }

View File

@@ -327,6 +327,7 @@ module es {
} }
public debugRender(batcher: IBatcher) { public debugRender(batcher: IBatcher) {
if (!batcher) return;
for (let i = 0; i < this._components.length; i ++) { for (let i = 0; i < this._components.length; i ++) {
if (this._components[i].enabled) { if (this._components[i].enabled) {
this._components[i].debugRender(batcher); this._components[i].debugRender(batcher);

View File

@@ -14,22 +14,34 @@ module es {
public unload() { } public unload() { }
protected beginRender(cam: ICamera) { protected beginRender(cam: ICamera) {
if (!Graphics.instance)
return;
Graphics.instance.batcher.begin(cam); Graphics.instance.batcher.begin(cam);
} }
protected endRender() { protected endRender() {
if (!Graphics.instance)
return;
Graphics.instance.batcher.end(); Graphics.instance.batcher.end();
} }
public abstract render(scene: Scene): void; public abstract render(scene: Scene): void;
protected renderAfterStateCheck(renderable: IRenderable, cam: ICamera) { protected renderAfterStateCheck(renderable: IRenderable, cam: ICamera) {
if (!Graphics.instance)
return;
renderable.render(Graphics.instance.batcher, cam); renderable.render(Graphics.instance.batcher, cam);
} }
protected debugRender(scene: Scene) { protected debugRender(scene: Scene) {
es.Physics.debugDraw(2); if (!Graphics.instance)
return;
es.Physics.debugDraw(2);
for (let i = 0; i < scene.entities.count; i ++) { for (let i = 0; i < scene.entities.count; i ++) {
let entity = scene.entities.buffer[i]; let entity = scene.entities.buffer[i];
if (entity.enabled) { if (entity.enabled) {