|
@@ -296,6 +296,9 @@ var BABYLON;
|
|
* @returns if the effect is compiled and prepared.
|
|
* @returns if the effect is compiled and prepared.
|
|
*/
|
|
*/
|
|
Effect.prototype.isReady = function () {
|
|
Effect.prototype.isReady = function () {
|
|
|
|
+ if (!this._isReady && this._program && this._program.isParallelCompiled) {
|
|
|
|
+ return this._engine._isProgramCompiled(this._program);
|
|
|
|
+ }
|
|
return this._isReady;
|
|
return this._isReady;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
@@ -647,50 +650,53 @@ var BABYLON;
|
|
* @hidden
|
|
* @hidden
|
|
*/
|
|
*/
|
|
Effect.prototype._prepareEffect = function () {
|
|
Effect.prototype._prepareEffect = function () {
|
|
|
|
+ var _this = this;
|
|
var attributesNames = this._attributesNames;
|
|
var attributesNames = this._attributesNames;
|
|
var defines = this.defines;
|
|
var defines = this.defines;
|
|
var fallbacks = this._fallbacks;
|
|
var fallbacks = this._fallbacks;
|
|
this._valueCache = {};
|
|
this._valueCache = {};
|
|
var previousProgram = this._program;
|
|
var previousProgram = this._program;
|
|
try {
|
|
try {
|
|
- var engine = this._engine;
|
|
|
|
|
|
+ var engine_1 = this._engine;
|
|
if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
|
|
if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
|
|
- this._program = engine.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
|
|
|
|
|
|
+ this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- this._program = engine.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
|
|
|
|
|
|
+ this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
|
|
}
|
|
}
|
|
this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
|
|
this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
|
|
- if (engine.supportsUniformBuffers) {
|
|
|
|
- for (var name in this._uniformBuffersNames) {
|
|
|
|
- this.bindUniformBlock(name, this._uniformBuffersNames[name]);
|
|
|
|
|
|
+ engine_1._executeWhenProgramIsCompiled(this._program, function () {
|
|
|
|
+ if (engine_1.supportsUniformBuffers) {
|
|
|
|
+ for (var name in _this._uniformBuffersNames) {
|
|
|
|
+ _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- this._uniforms = engine.getUniforms(this._program, this._uniformsNames);
|
|
|
|
- this._attributes = engine.getAttributes(this._program, attributesNames);
|
|
|
|
- var index;
|
|
|
|
- for (index = 0; index < this._samplers.length; index++) {
|
|
|
|
- var sampler = this.getUniform(this._samplers[index]);
|
|
|
|
- if (sampler == null) {
|
|
|
|
- this._samplers.splice(index, 1);
|
|
|
|
- index--;
|
|
|
|
|
|
+ _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
|
|
|
|
+ _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
|
|
|
|
+ var index;
|
|
|
|
+ for (index = 0; index < _this._samplers.length; index++) {
|
|
|
|
+ var sampler = _this.getUniform(_this._samplers[index]);
|
|
|
|
+ if (sampler == null) {
|
|
|
|
+ _this._samplers.splice(index, 1);
|
|
|
|
+ index--;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- engine.bindSamplers(this);
|
|
|
|
- this._compilationError = "";
|
|
|
|
- this._isReady = true;
|
|
|
|
- if (this.onCompiled) {
|
|
|
|
- this.onCompiled(this);
|
|
|
|
- }
|
|
|
|
- this.onCompileObservable.notifyObservers(this);
|
|
|
|
- this.onCompileObservable.clear();
|
|
|
|
- // Unbind mesh reference in fallbacks
|
|
|
|
- if (this._fallbacks) {
|
|
|
|
- this._fallbacks.unBindMesh();
|
|
|
|
- }
|
|
|
|
- if (previousProgram) {
|
|
|
|
- this.getEngine()._deleteProgram(previousProgram);
|
|
|
|
- }
|
|
|
|
|
|
+ engine_1.bindSamplers(_this);
|
|
|
|
+ _this._compilationError = "";
|
|
|
|
+ _this._isReady = true;
|
|
|
|
+ if (_this.onCompiled) {
|
|
|
|
+ _this.onCompiled(_this);
|
|
|
|
+ }
|
|
|
|
+ _this.onCompileObservable.notifyObservers(_this);
|
|
|
|
+ _this.onCompileObservable.clear();
|
|
|
|
+ // Unbind mesh reference in fallbacks
|
|
|
|
+ if (_this._fallbacks) {
|
|
|
|
+ _this._fallbacks.unBindMesh();
|
|
|
|
+ }
|
|
|
|
+ if (previousProgram) {
|
|
|
|
+ _this.getEngine()._deleteProgram(previousProgram);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
catch (e) {
|
|
catch (e) {
|
|
this._compilationError = e.message;
|
|
this._compilationError = e.message;
|
|
@@ -2976,7 +2982,7 @@ var BABYLON;
|
|
* @returns a new Quaternion object, computed from the Vector3 coordinates
|
|
* @returns a new Quaternion object, computed from the Vector3 coordinates
|
|
*/
|
|
*/
|
|
Vector3.prototype.toQuaternion = function () {
|
|
Vector3.prototype.toQuaternion = function () {
|
|
- return BABYLON.Quaternion.RotationYawPitchRoll(this.x, this.y, this.z);
|
|
|
|
|
|
+ return BABYLON.Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Adds the given vector to the current Vector3
|
|
* Adds the given vector to the current Vector3
|
|
@@ -12684,7 +12690,7 @@ var BABYLON;
|
|
* Returns the current version of the framework
|
|
* Returns the current version of the framework
|
|
*/
|
|
*/
|
|
get: function () {
|
|
get: function () {
|
|
- return "3.3.0";
|
|
|
|
|
|
+ return "4.0.0-alpha.0";
|
|
},
|
|
},
|
|
enumerable: true,
|
|
enumerable: true,
|
|
configurable: true
|
|
configurable: true
|
|
@@ -12933,6 +12939,12 @@ var BABYLON;
|
|
this._caps.drawBuffersExtension = false;
|
|
this._caps.drawBuffersExtension = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // Shader compiler threads
|
|
|
|
+ this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
|
|
|
|
+ if (this._caps.parallelShaderCompile) {
|
|
|
|
+ var threads = this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);
|
|
|
|
+ this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(threads);
|
|
|
|
+ }
|
|
// Depth Texture
|
|
// Depth Texture
|
|
if (this._webGLVersion > 1) {
|
|
if (this._webGLVersion > 1) {
|
|
this._caps.depthTextureExtension = true;
|
|
this._caps.depthTextureExtension = true;
|
|
@@ -14667,6 +14679,21 @@ var BABYLON;
|
|
if (this.webGLVersion > 1 && transformFeedbackVaryings) {
|
|
if (this.webGLVersion > 1 && transformFeedbackVaryings) {
|
|
this.bindTransformFeedback(null);
|
|
this.bindTransformFeedback(null);
|
|
}
|
|
}
|
|
|
|
+ shaderProgram.context = context;
|
|
|
|
+ shaderProgram.vertexShader = vertexShader;
|
|
|
|
+ shaderProgram.fragmentShader = fragmentShader;
|
|
|
|
+ if (!this._caps.parallelShaderCompile) {
|
|
|
|
+ this._finalizeProgram(shaderProgram);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ shaderProgram.isParallelCompiled = true;
|
|
|
|
+ }
|
|
|
|
+ return shaderProgram;
|
|
|
|
+ };
|
|
|
|
+ Engine.prototype._finalizeProgram = function (shaderProgram) {
|
|
|
|
+ var context = shaderProgram.context;
|
|
|
|
+ var vertexShader = shaderProgram.vertexShader;
|
|
|
|
+ var fragmentShader = shaderProgram.fragmentShader;
|
|
var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
|
|
var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
|
|
if (!linked) {
|
|
if (!linked) {
|
|
var error = context.getProgramInfoLog(shaderProgram);
|
|
var error = context.getProgramInfoLog(shaderProgram);
|
|
@@ -14686,7 +14713,32 @@ var BABYLON;
|
|
}
|
|
}
|
|
context.deleteShader(vertexShader);
|
|
context.deleteShader(vertexShader);
|
|
context.deleteShader(fragmentShader);
|
|
context.deleteShader(fragmentShader);
|
|
- return shaderProgram;
|
|
|
|
|
|
+ shaderProgram.context = undefined;
|
|
|
|
+ shaderProgram.vertexShader = undefined;
|
|
|
|
+ shaderProgram.fragmentShader = undefined;
|
|
|
|
+ if (shaderProgram.onCompiled) {
|
|
|
|
+ shaderProgram.onCompiled();
|
|
|
|
+ shaderProgram.onCompiled = undefined;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ /** @hidden */
|
|
|
|
+ Engine.prototype._isProgramCompiled = function (shaderProgram) {
|
|
|
|
+ if (!shaderProgram.isParallelCompiled) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
|
|
|
|
+ this._finalizeProgram(shaderProgram);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ };
|
|
|
|
+ /** @hidden */
|
|
|
|
+ Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
|
|
|
|
+ if (!shaderProgram.isParallelCompiled) {
|
|
|
|
+ action();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ shaderProgram.onCompiled = action;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
|
|
* Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
|
|
@@ -25283,7 +25335,7 @@ var BABYLON;
|
|
* Creates a new Scene
|
|
* Creates a new Scene
|
|
* @param engine defines the engine to use to render this scene
|
|
* @param engine defines the engine to use to render this scene
|
|
*/
|
|
*/
|
|
- function Scene(engine) {
|
|
|
|
|
|
+ function Scene(engine, options) {
|
|
var _this = _super.call(this) || this;
|
|
var _this = _super.call(this) || this;
|
|
// Members
|
|
// Members
|
|
/**
|
|
/**
|
|
@@ -25797,6 +25849,10 @@ var BABYLON;
|
|
* Defines the actions happening when a pointer up event happens.
|
|
* Defines the actions happening when a pointer up event happens.
|
|
*/
|
|
*/
|
|
_this._pointerUpStage = BABYLON.Stage.Create();
|
|
_this._pointerUpStage = BABYLON.Stage.Create();
|
|
|
|
+ /**
|
|
|
|
+ * an optional map from Geometry Id to Geometry index in the 'geometries' array
|
|
|
|
+ */
|
|
|
|
+ _this.geometriesById = null;
|
|
_this._defaultMeshCandidates = {
|
|
_this._defaultMeshCandidates = {
|
|
data: [],
|
|
data: [],
|
|
length: 0
|
|
length: 0
|
|
@@ -25835,6 +25891,9 @@ var BABYLON;
|
|
_this._imageProcessingConfiguration = new BABYLON.ImageProcessingConfiguration();
|
|
_this._imageProcessingConfiguration = new BABYLON.ImageProcessingConfiguration();
|
|
}
|
|
}
|
|
_this.setDefaultCandidateProviders();
|
|
_this.setDefaultCandidateProviders();
|
|
|
|
+ if (options && options.useGeometryIdsMap === true) {
|
|
|
|
+ _this.geometriesById = {};
|
|
|
|
+ }
|
|
return _this;
|
|
return _this;
|
|
}
|
|
}
|
|
Object.defineProperty(Scene.prototype, "environmentTexture", {
|
|
Object.defineProperty(Scene.prototype, "environmentTexture", {
|
|
@@ -28090,6 +28149,9 @@ var BABYLON;
|
|
* @param newGeometry The geometry to add
|
|
* @param newGeometry The geometry to add
|
|
*/
|
|
*/
|
|
Scene.prototype.addGeometry = function (newGeometry) {
|
|
Scene.prototype.addGeometry = function (newGeometry) {
|
|
|
|
+ if (this.geometriesById) {
|
|
|
|
+ this.geometriesById[newGeometry.id] = this.geometries.length;
|
|
|
|
+ }
|
|
this.geometries.push(newGeometry);
|
|
this.geometries.push(newGeometry);
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
@@ -28320,9 +28382,17 @@ var BABYLON;
|
|
* @return the geometry or null if none found.
|
|
* @return the geometry or null if none found.
|
|
*/
|
|
*/
|
|
Scene.prototype.getGeometryByID = function (id) {
|
|
Scene.prototype.getGeometryByID = function (id) {
|
|
- for (var index = 0; index < this.geometries.length; index++) {
|
|
|
|
- if (this.geometries[index].id === id) {
|
|
|
|
- return this.geometries[index];
|
|
|
|
|
|
+ if (this.geometriesById) {
|
|
|
|
+ var index_1 = this.geometriesById[id];
|
|
|
|
+ if (index_1 !== undefined) {
|
|
|
|
+ return this.geometries[index_1];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ for (var index = 0; index < this.geometries.length; index++) {
|
|
|
|
+ if (this.geometries[index].id === id) {
|
|
|
|
+ return this.geometries[index];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
@@ -28337,7 +28407,7 @@ var BABYLON;
|
|
if (!force && this.getGeometryByID(geometry.id)) {
|
|
if (!force && this.getGeometryByID(geometry.id)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- this.geometries.push(geometry);
|
|
|
|
|
|
+ this.addGeometry(geometry);
|
|
//notify the collision coordinator
|
|
//notify the collision coordinator
|
|
if (this.collisionCoordinator) {
|
|
if (this.collisionCoordinator) {
|
|
this.collisionCoordinator.onGeometryAdded(geometry);
|
|
this.collisionCoordinator.onGeometryAdded(geometry);
|
|
@@ -28351,17 +28421,34 @@ var BABYLON;
|
|
* @return a boolean defining if the geometry was removed or not
|
|
* @return a boolean defining if the geometry was removed or not
|
|
*/
|
|
*/
|
|
Scene.prototype.removeGeometry = function (geometry) {
|
|
Scene.prototype.removeGeometry = function (geometry) {
|
|
- var index = this.geometries.indexOf(geometry);
|
|
|
|
- if (index > -1) {
|
|
|
|
- this.geometries.splice(index, 1);
|
|
|
|
- //notify the collision coordinator
|
|
|
|
- if (this.collisionCoordinator) {
|
|
|
|
- this.collisionCoordinator.onGeometryDeleted(geometry);
|
|
|
|
|
|
+ var index;
|
|
|
|
+ if (this.geometriesById) {
|
|
|
|
+ index = this.geometriesById[geometry.id];
|
|
|
|
+ if (index === undefined) {
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
- this.onGeometryRemovedObservable.notifyObservers(geometry);
|
|
|
|
- return true;
|
|
|
|
}
|
|
}
|
|
- return false;
|
|
|
|
|
|
+ else {
|
|
|
|
+ index = this.geometries.indexOf(geometry);
|
|
|
|
+ if (index < 0) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (index !== this.geometries.length - 1) {
|
|
|
|
+ var lastGeometry = this.geometries[this.geometries.length - 1];
|
|
|
|
+ this.geometries[index] = lastGeometry;
|
|
|
|
+ if (this.geometriesById) {
|
|
|
|
+ this.geometriesById[lastGeometry.id] = index;
|
|
|
|
+ this.geometriesById[geometry.id] = undefined;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.geometries.pop();
|
|
|
|
+ //notify the collision coordinator
|
|
|
|
+ if (this.collisionCoordinator) {
|
|
|
|
+ this.collisionCoordinator.onGeometryDeleted(geometry);
|
|
|
|
+ }
|
|
|
|
+ this.onGeometryRemovedObservable.notifyObservers(geometry);
|
|
|
|
+ return true;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Gets the list of geometries attached to the scene
|
|
* Gets the list of geometries attached to the scene
|
|
@@ -114330,7 +114417,8 @@ var BABYLON;
|
|
NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
|
|
NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
|
|
return {
|
|
return {
|
|
transformFeedback: null,
|
|
transformFeedback: null,
|
|
- __SPECTOR_rebuildProgram: null
|
|
|
|
|
|
+ __SPECTOR_rebuildProgram: null,
|
|
|
|
+ isParallelCompiled: false
|
|
};
|
|
};
|
|
};
|
|
};
|
|
NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
|
|
NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
|