Skip to content

Commit

Permalink
修复无graphics报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
esengine committed May 28, 2021
1 parent 79d684c commit 44e2ca0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
12 changes: 12 additions & 0 deletions source/bin/framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,8 @@ var es;
this.components.update();
};
Entity.prototype.debugRender = function (batcher) {
if (!batcher)
return;
this.components.debugRender(batcher);
};
/**
Expand Down Expand Up @@ -4196,6 +4198,8 @@ var es;
}
};
ComponentList.prototype.debugRender = function (batcher) {
if (!batcher)
return;
for (var i = 0; i < this._components.length; i++) {
if (this._components[i].enabled) {
this._components[i].debugRender(batcher);
Expand Down Expand Up @@ -5527,15 +5531,23 @@ var es;
Renderer.prototype.onAddedToScene = function (scene) { };
Renderer.prototype.unload = function () { };
Renderer.prototype.beginRender = function (cam) {
if (!es.Graphics.instance)
return;
es.Graphics.instance.batcher.begin(cam);
};
Renderer.prototype.endRender = function () {
if (!es.Graphics.instance)
return;
es.Graphics.instance.batcher.end();
};
Renderer.prototype.renderAfterStateCheck = function (renderable, cam) {
if (!es.Graphics.instance)
return;
renderable.render(es.Graphics.instance.batcher, cam);
};
Renderer.prototype.debugRender = function (scene) {
if (!es.Graphics.instance)
return;
es.Physics.debugDraw(2);
for (var i = 0; i < scene.entities.count; i++) {
var entity = scene.entities.buffer[i];
Expand Down
2 changes: 1 addition & 1 deletion source/bin/framework.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions source/src/ECS/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ module es {
}

public debugRender(batcher: IBatcher) {
if (!batcher) return;
this.components.debugRender(batcher);
}

Expand Down
1 change: 1 addition & 0 deletions source/src/ECS/Utils/ComponentList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ module es {
}

public debugRender(batcher: IBatcher) {
if (!batcher) return;
for (let i = 0; i < this._components.length; i ++) {
if (this._components[i].enabled) {
this._components[i].debugRender(batcher);
Expand Down
14 changes: 13 additions & 1 deletion source/src/Graphics/Renderers/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,34 @@ module es {
public unload() { }

protected beginRender(cam: ICamera) {
if (!Graphics.instance)
return;

Graphics.instance.batcher.begin(cam);
}

protected endRender() {
if (!Graphics.instance)
return;

Graphics.instance.batcher.end();
}

public abstract render(scene: Scene): void;

protected renderAfterStateCheck(renderable: IRenderable, cam: ICamera) {
if (!Graphics.instance)
return;

renderable.render(Graphics.instance.batcher, cam);
}

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 ++) {
let entity = scene.entities.buffer[i];
if (entity.enabled) {
Expand Down

0 comments on commit 44e2ca0

Please sign in to comment.