动态合批
This commit is contained in:
2
source/bin/framework.d.ts
vendored
2
source/bin/framework.d.ts
vendored
@@ -364,6 +364,7 @@ declare module es {
|
||||
_renderers: Renderer[];
|
||||
readonly _postProcessors: PostProcessor[];
|
||||
_didSceneBegin: any;
|
||||
dynamicBatch: boolean;
|
||||
constructor();
|
||||
static createWithDefaultRenderer(): Scene;
|
||||
initialize(): void;
|
||||
@@ -376,6 +377,7 @@ declare module es {
|
||||
updateResolutionScaler(): void;
|
||||
update(): void;
|
||||
render(): void;
|
||||
dynamicInBatch(): void;
|
||||
postRender(): void;
|
||||
requestScreenshot(callback: Function): void;
|
||||
addSceneComponent<T extends SceneComponent>(component: T): T;
|
||||
|
||||
@@ -1637,6 +1637,7 @@ var es;
|
||||
_this._sceneComponents = [];
|
||||
_this._renderers = [];
|
||||
_this._postProcessors = [];
|
||||
_this.dynamicBatch = false;
|
||||
_this.entities = new es.EntityList(_this);
|
||||
_this.renderableComponents = new es.RenderableComponentList();
|
||||
_this.content = new es.ContentManager();
|
||||
@@ -1736,6 +1737,30 @@ var es;
|
||||
this._renderers[i].render(this);
|
||||
}
|
||||
};
|
||||
Scene.prototype.dynamicInBatch = function () {
|
||||
this.removeChildren();
|
||||
var batching = false;
|
||||
var displayContainer;
|
||||
for (var _i = 0, _a = this.renderableComponents.buffer; _i < _a.length; _i++) {
|
||||
var component = _a[_i];
|
||||
if (component instanceof es.SpriteAnimator) {
|
||||
this.addChild(component.displayObject);
|
||||
this.addChild(component.debugDisplayObject);
|
||||
batching = false;
|
||||
displayContainer = null;
|
||||
}
|
||||
else if (component instanceof es.RenderableComponent) {
|
||||
if (!batching) {
|
||||
batching = true;
|
||||
displayContainer = new egret.DisplayObjectContainer();
|
||||
displayContainer.cacheAsBitmap = true;
|
||||
this.addChild(displayContainer);
|
||||
}
|
||||
displayContainer.addChild(component.displayObject);
|
||||
displayContainer.addChild(component.debugDisplayObject);
|
||||
}
|
||||
}
|
||||
};
|
||||
Scene.prototype.postRender = function () {
|
||||
if (this.enablePostProcessing) {
|
||||
for (var i = 0; i < this._postProcessors.length; i++) {
|
||||
@@ -4514,13 +4539,16 @@ var es;
|
||||
for (var i = 0; i < this._components.length; i++) {
|
||||
var component = this._components[i];
|
||||
if (component instanceof es.RenderableComponent) {
|
||||
this._entity.scene.addChild(component.displayObject);
|
||||
if (!this._entity.scene.dynamicBatch)
|
||||
this._entity.scene.addChild(component.displayObject);
|
||||
this._entity.scene.renderableComponents.add(component);
|
||||
}
|
||||
this._entity.scene.addChild(component.debugDisplayObject);
|
||||
if (!this._entity.scene.dynamicBatch)
|
||||
this._entity.scene.addChild(component.debugDisplayObject);
|
||||
this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component));
|
||||
this._entity.scene.entityProcessors.onComponentAdded(this._entity);
|
||||
}
|
||||
this._entity.scene.dynamicInBatch();
|
||||
};
|
||||
ComponentList.prototype.updateLists = function () {
|
||||
if (this._componentsToRemove.length > 0) {
|
||||
@@ -4534,15 +4562,18 @@ var es;
|
||||
for (var i = 0, count = this._componentsToAdd.length; i < count; i++) {
|
||||
var component = this._componentsToAdd[i];
|
||||
if (component instanceof es.RenderableComponent) {
|
||||
this._entity.scene.addChild(component.displayObject);
|
||||
if (!this._entity.scene.dynamicBatch)
|
||||
this._entity.scene.addChild(component.displayObject);
|
||||
this._entity.scene.renderableComponents.add(component);
|
||||
}
|
||||
this._entity.scene.addChild(component.debugDisplayObject);
|
||||
if (!this._entity.scene.dynamicBatch)
|
||||
this._entity.scene.addChild(component.debugDisplayObject);
|
||||
this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component));
|
||||
this._entity.scene.entityProcessors.onComponentAdded(this._entity);
|
||||
this._components.push(component);
|
||||
this._tempBufferList.push(component);
|
||||
}
|
||||
this._entity.scene.dynamicInBatch();
|
||||
this._componentsToAdd.length = 0;
|
||||
this._isComponentListUnsorted = true;
|
||||
for (var i = 0; i < this._tempBufferList.length; i++) {
|
||||
|
||||
2
source/bin/framework.min.js
vendored
2
source/bin/framework.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user