|
@@ -23,6 +23,7 @@
|
|
private _customOpaqueSortCompareFn: { [id:number]: (a: SubMesh, b: SubMesh) => number } = {};
|
|
private _customOpaqueSortCompareFn: { [id:number]: (a: SubMesh, b: SubMesh) => number } = {};
|
|
private _customAlphaTestSortCompareFn: { [id:number]: (a: SubMesh, b: SubMesh) => number } = {};
|
|
private _customAlphaTestSortCompareFn: { [id:number]: (a: SubMesh, b: SubMesh) => number } = {};
|
|
private _customTransparentSortCompareFn: { [id:number]: (a: SubMesh, b: SubMesh) => number } = {};
|
|
private _customTransparentSortCompareFn: { [id:number]: (a: SubMesh, b: SubMesh) => number } = {};
|
|
|
|
+ private _renderinGroupInfo: RenderingGroupInfo = null;
|
|
|
|
|
|
constructor(scene: Scene) {
|
|
constructor(scene: Scene) {
|
|
this._scene = scene;
|
|
this._scene = scene;
|
|
@@ -101,6 +102,18 @@
|
|
public render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void,
|
|
public render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void,
|
|
activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void {
|
|
activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void {
|
|
|
|
|
|
|
|
+ // Check if there's at least on observer on the onRenderingGroupObservable and initialize things to fire it
|
|
|
|
+ let observable = this._scene.onRenderingGroupObservable.hasObservers() ? this._scene.onRenderingGroupObservable : null;
|
|
|
|
+ let info: RenderingGroupInfo = null;
|
|
|
|
+ if (observable) {
|
|
|
|
+ if (!this._renderinGroupInfo) {
|
|
|
|
+ this._renderinGroupInfo = new RenderingGroupInfo();
|
|
|
|
+ }
|
|
|
|
+ info = this._renderinGroupInfo;
|
|
|
|
+ info.scene = this._scene;
|
|
|
|
+ info.camera = this._scene.activeCamera;
|
|
|
|
+ }
|
|
|
|
+
|
|
this._currentActiveMeshes = activeMeshes;
|
|
this._currentActiveMeshes = activeMeshes;
|
|
this._currentRenderParticles = renderParticles;
|
|
this._currentRenderParticles = renderParticles;
|
|
this._currentRenderSprites = renderSprites;
|
|
this._currentRenderSprites = renderSprites;
|
|
@@ -113,19 +126,48 @@
|
|
this._currentIndex = index;
|
|
this._currentIndex = index;
|
|
|
|
|
|
if (renderingGroup) {
|
|
if (renderingGroup) {
|
|
|
|
+ let renderingGroupMask = 0;
|
|
|
|
+
|
|
|
|
+ // Fire PRECLEAR stage
|
|
|
|
+ if (observable) {
|
|
|
|
+ renderingGroupMask = Math.pow(2, index);
|
|
|
|
+ info.renderStage = RenderingGroupInfo.STAGE_PRECLEAR;
|
|
|
|
+ info.renderingGroupId = index;
|
|
|
|
+ observable.notifyObservers(info, renderingGroupMask);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Clear depth/stencil if needed
|
|
if (this._autoClearDepthStencil[index]) {
|
|
if (this._autoClearDepthStencil[index]) {
|
|
this._clearDepthStencilBuffer();
|
|
this._clearDepthStencilBuffer();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Fire PREOPAQUE stage
|
|
|
|
+ if (observable) {
|
|
|
|
+ info.renderStage = RenderingGroupInfo.STAGE_PREOPAQUE;
|
|
|
|
+ observable.notifyObservers(info, renderingGroupMask);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!renderingGroup.onBeforeTransparentRendering) {
|
|
if (!renderingGroup.onBeforeTransparentRendering) {
|
|
renderingGroup.onBeforeTransparentRendering = this._renderSpritesAndParticles.bind(this);
|
|
renderingGroup.onBeforeTransparentRendering = this._renderSpritesAndParticles.bind(this);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Fire PRETRANSPARENT stage
|
|
|
|
+ if (observable) {
|
|
|
|
+ info.renderStage = RenderingGroupInfo.STAGE_PRETRANSPARENT;
|
|
|
|
+ observable.notifyObservers(info, renderingGroupMask);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!renderingGroup.render(customRenderFunction)) {
|
|
if (!renderingGroup.render(customRenderFunction)) {
|
|
this._renderingGroups.splice(index, 1);
|
|
this._renderingGroups.splice(index, 1);
|
|
needToStepBack = true;
|
|
needToStepBack = true;
|
|
this._renderSpritesAndParticles();
|
|
this._renderSpritesAndParticles();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // Fire POSTTRANSPARENT stage
|
|
|
|
+ if (observable) {
|
|
|
|
+ info.renderStage = RenderingGroupInfo.STAGE_POSTTRANSPARENT;
|
|
|
|
+ observable.notifyObservers(info, renderingGroupMask);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
this._renderSpritesAndParticles();
|
|
this._renderSpritesAndParticles();
|
|
}
|
|
}
|