@@ -141,7 +141,7 @@ module BABYLON {
proxy._swapAndDie(this);
this.isReady = true;
- return;
+ return;
case InternalTexture.DATASOURCE_CUBE:
proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, () => {
@@ -73,14 +73,30 @@ module BABYLON {
generateDepthTexture: generateDepthTexture,
types: types,
textureCount: count
- };
-
- this._internalTextures = scene.getEngine().createMultipleRenderTarget(size, this._multiRenderTargetOptions);
+ };
+
+ this._createInternalTextures();
+ this._createTextures();
+ }
+ public _rebuild(): void {
+ this.releaseInternalTextures();
this._createInternalTextures();
+ for (var i = 0; i < this._internalTextures.length; i++) {
+ var texture = this._textures[i];
+ texture._texture = this._internalTextures[i];
+ // Keeps references to frame buffer and stencil/depth buffer
+ this._texture = this._internalTextures[0];
}
private _createInternalTextures(): void {
+ this._internalTextures = this.getScene().getEngine().createMultipleRenderTarget(this._size , this._multiRenderTargetOptions);
+ private _createTextures(): void {
this._textures = [];
for (var i = 0; i < this._internalTextures.length; i++) {
var texture = new BABYLON.Texture(null, this.getScene());
@@ -34,6 +34,10 @@
+ public rebuild(): void {
public dispose(): void {
var index = this._scene.particleSystems.indexOf(this);
if (index > -1) {
@@ -21,6 +21,8 @@
dispose(): void;
clone(name: string, newEmitter: any): IParticleSystem;
serialize(): any;
+ rebuild(): void
export class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
@@ -127,19 +129,7 @@
scene.particleSystems.push(this);
- var indices = [];
- var index = 0;
- for (var count = 0; count < capacity; count++) {
- indices.push(index);
- indices.push(index + 1);
- indices.push(index + 2);
- indices.push(index + 3);
- index += 4;
- }
- this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
+ this._createIndexBuffer();
// 11 floats per particle (x, y, z, r, g, b, a, angle, size, offsetX, offsetY) + 1 filler
this._vertexData = new Float32Array(capacity * 11 * 4);
@@ -199,6 +189,22 @@
+ private _createIndexBuffer() {
+ var indices = [];
+ var index = 0;
+ for (var count = 0; count < this._capacity ; count++) {
+ indices.push(index);
+ indices.push(index + 1);
+ indices.push(index + 2);
+ indices.push(index + 3);
+ index += 4;
+ this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
public recycleParticle(particle: Particle): void {
var lastParticle = this.particles.pop();
@@ -396,6 +402,12 @@
this._vertexBuffer.update(this._vertexData);
+ this._vertexBuffer._rebuild();
public render(): number {
var effect = this._getEffect();
@@ -250,6 +250,12 @@
};
+ public _rebuild() {
+ this._firstUpdate = true;
+ super._rebuild();
private _generateHemisphere(): number[] {
var numSamples = this.samples;
@@ -189,6 +189,11 @@
private _createSSAOPostProcess(ratio: number): void {
var numSamples = 16;
var sampleSphere = [
@@ -46,6 +46,10 @@ module BABYLON {
// private
public _enableEffect(renderEffectName: string, cameras: Camera);
public _enableEffect(renderEffectName: string, cameras: Camera[]);
public _enableEffect(renderEffectName: string, cameras: any): void {
@@ -84,12 +84,32 @@ module BABYLON {
public update(): void {
for (var renderPipelineName in this._renderPipelines) {
- var pipeline = this._renderPipelines[renderPipelineName];
- if (!pipeline.isSupported) {
+ if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
+ var pipeline = this._renderPipelines[renderPipelineName];
+ if (!pipeline.isSupported) {
+ pipeline.dispose();
+ delete this._renderPipelines[renderPipelineName];
+ } else {
+ pipeline._update();
+ for (var renderPipelineName in this._renderPipelines) {
+ pipeline._rebuild();
+ public dispose(): void {
pipeline.dispose();
- delete this._renderPipelines[renderPipelineName];
- } else {
- pipeline._update();
@@ -29,9 +29,19 @@
var engine = this._scene.getEngine();
var boxdata = VertexData.CreateBox({ size: 1.0 });
this._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(engine, boxdata.positions, VertexBuffer.PositionKind, false);
+ private _createIndexBuffer(): void {
+ var engine = this._scene.getEngine();
this._indexBuffer = engine.createIndexBuffer([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 7, 1, 6, 2, 5, 3, 4]);
+ this._vertexBuffers[VertexBuffer.PositionKind]._rebuild();
public reset(): void {
this.renderList.reset();
@@ -3650,6 +3650,12 @@
public updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: string = null, level = 0): void {
+ texture._bufferViewArray = data;
+ texture.format = format;
+ texture.type = type;
+ texture.invertY = invertY;
+ texture._compression = compression;
var gl = this._gl;
var textureType = this._getWebGLTextureType(type);
var internalFormat = this._getInternalFormat(format);
@@ -3474,6 +3474,10 @@
// Post-processes
this.postProcessManager.dispose();
+ if (this._postProcessRenderPipelineManager) {
+ this._postProcessRenderPipelineManager.dispose();
// Physics
if (this._physicsEngine) {
this.disablePhysicsEngine();
@@ -3857,6 +3861,18 @@
for (var highlightLayer of this.highlightLayers) {
highlightLayer._rebuild();
+ if (this._boundingBoxRenderer) {
+ this._boundingBoxRenderer._rebuild();
+ for (var system of this.particleSystems) {
+ system.rebuild();
+ this._postProcessRenderPipelineManager._rebuild();
public _rebuildTextures(): void {
@@ -217,7 +217,7 @@
},
{
"title": "Default rendering pipeline",
- "renderCount": 10,
+ "renderCount": 20,
"playgroundId": "#5XB8YT#2",
"referenceImage": "DefaultRenderingPipeline.png"
@@ -189,7 +189,7 @@ runTest(index) {
var code = JSON.parse(snippet.jsonPayload).code.toString();
code = code.replace(/\/textures\//g, pgRoot + "/textures/");
code = code.replace(/"textures\//g, "\"" + pgRoot + "/textures/");
- code = code.replace(/\/scenes\//g, "\"" + pgRoot + "/scenes/");
+ code = code.replace(/\/scenes\//g, pgRoot + "/scenes/");
code = code.replace(/"scenes\//g, "\"" + pgRoot + "/scenes/");
currentScene = eval(code + "\r\ncreateScene(engine)");