|
@@ -75,21 +75,37 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
});
|
|
|
/**
|
|
|
* Removes the defines that shoould be removed when falling back.
|
|
|
- * @param currentDefines The current define statements for the shader.
|
|
|
+ * @param currentDefines defines the current define statements for the shader.
|
|
|
+ * @param effect defines the current effect we try to compile
|
|
|
* @returns The resulting defines with defines of the current rank removed.
|
|
|
*/
|
|
|
- EffectFallbacks.prototype.reduce = function (currentDefines) {
|
|
|
+ EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
|
|
|
// First we try to switch to CPU skinning
|
|
|
- if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0) {
|
|
|
+ if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
|
|
|
this._mesh.computeBonesUsingShaders = false;
|
|
|
currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
|
|
|
- BABYLON.Tools.Log("Falling back to CPU skinning for " + this._mesh.name);
|
|
|
var scene = this._mesh.getScene();
|
|
|
for (var index = 0; index < scene.meshes.length; index++) {
|
|
|
var otherMesh = scene.meshes[index];
|
|
|
- if (otherMesh.material === this._mesh.material && otherMesh.computeBonesUsingShaders && otherMesh.numBoneInfluencers > 0) {
|
|
|
+ if (!otherMesh.material) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (otherMesh.material.getEffect() === effect) {
|
|
|
otherMesh.computeBonesUsingShaders = false;
|
|
|
}
|
|
|
+ else {
|
|
|
+ for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
|
|
|
+ var subMesh = _a[_i];
|
|
|
+ var subMeshEffect = subMesh.effect;
|
|
|
+ if (subMeshEffect === effect) {
|
|
|
+ otherMesh.computeBonesUsingShaders = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -665,7 +681,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
}
|
|
|
if (fallbacks && fallbacks.isMoreFallbacks) {
|
|
|
BABYLON.Tools.Error("Trying next fallback.");
|
|
|
- this.defines = fallbacks.reduce(this.defines);
|
|
|
+ this.defines = fallbacks.reduce(this.defines, this);
|
|
|
this._prepareEffect();
|
|
|
}
|
|
|
else {
|
|
@@ -50533,6 +50549,13 @@ var BABYLON;
|
|
|
this._stopped = true;
|
|
|
};
|
|
|
/**
|
|
|
+ * Remove all active particles
|
|
|
+ */
|
|
|
+ ParticleSystem.prototype.reset = function () {
|
|
|
+ this._stockParticles = [];
|
|
|
+ this._particles = [];
|
|
|
+ };
|
|
|
+ /**
|
|
|
* @ignore (for internal use only)
|
|
|
*/
|
|
|
ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
|
|
@@ -51409,7 +51432,7 @@ var BABYLON;
|
|
|
|
|
|
|
|
|
|
|
|
-//# sourceMappingURL=babylon.IParticleEmitterType.js.map
|
|
|
+//# sourceMappingURL=babylon.iParticleEmitterType.js.map
|
|
|
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
@@ -51707,6 +51730,15 @@ var BABYLON;
|
|
|
* Last computed particle rotation matrix
|
|
|
*/
|
|
|
this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
|
|
|
+ /**
|
|
|
+ * Parent particle Id, if any.
|
|
|
+ * Default null.
|
|
|
+ */
|
|
|
+ this.parentId = null;
|
|
|
+ /**
|
|
|
+ * Internal global position in the SPS.
|
|
|
+ */
|
|
|
+ this._globalPosition = BABYLON.Vector3.Zero();
|
|
|
this.idx = particleIndex;
|
|
|
this._pos = positionIndex;
|
|
|
this._ind = indiceIndex;
|
|
@@ -51935,6 +51967,8 @@ var BABYLON;
|
|
|
};
|
|
|
this._needs32Bits = false;
|
|
|
this._pivotBackTranslation = BABYLON.Vector3.Zero();
|
|
|
+ this._scaledPivot = BABYLON.Vector3.Zero();
|
|
|
+ this._particleHasParent = false;
|
|
|
this.name = name;
|
|
|
this._scene = scene || BABYLON.Engine.LastCreatedScene;
|
|
|
this._camera = scene.activeCamera;
|
|
@@ -52169,11 +52203,14 @@ var BABYLON;
|
|
|
this._quaternionRotationYPR();
|
|
|
}
|
|
|
this._quaternionToRotationMatrix();
|
|
|
+ this._scaledPivot.x = this._copy.pivot.x * this._copy.scaling.x;
|
|
|
+ this._scaledPivot.y = this._copy.pivot.y * this._copy.scaling.y;
|
|
|
+ this._scaledPivot.z = this._copy.pivot.z * this._copy.scaling.z;
|
|
|
if (this._copy.translateFromPivot) {
|
|
|
this._pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
|
|
|
}
|
|
|
else {
|
|
|
- this._pivotBackTranslation.copyFrom(this._copy.pivot);
|
|
|
+ this._pivotBackTranslation.copyFrom(this._scaledPivot);
|
|
|
}
|
|
|
for (i = 0; i < shape.length; i++) {
|
|
|
this._vertex.x = shape[i].x;
|
|
@@ -52185,9 +52222,9 @@ var BABYLON;
|
|
|
this._vertex.x *= this._copy.scaling.x;
|
|
|
this._vertex.y *= this._copy.scaling.y;
|
|
|
this._vertex.z *= this._copy.scaling.z;
|
|
|
- this._vertex.x -= this._copy.pivot.x;
|
|
|
- this._vertex.y -= this._copy.pivot.y;
|
|
|
- this._vertex.z -= this._copy.pivot.z;
|
|
|
+ this._vertex.x -= this._scaledPivot.x;
|
|
|
+ this._vertex.y -= this._scaledPivot.y;
|
|
|
+ this._vertex.z -= this._scaledPivot.z;
|
|
|
BABYLON.Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
|
|
|
this._rotated.addInPlace(this._pivotBackTranslation);
|
|
|
positions.push(this._copy.position.x + this._rotated.x, this._copy.position.y + this._rotated.y, this._copy.position.z + this._rotated.z);
|
|
@@ -52331,11 +52368,14 @@ var BABYLON;
|
|
|
this._quaternionRotationYPR();
|
|
|
}
|
|
|
this._quaternionToRotationMatrix();
|
|
|
+ this._scaledPivot.x = this._particle.pivot.x * this._particle.scaling.x;
|
|
|
+ this._scaledPivot.y = this._particle.pivot.y * this._particle.scaling.y;
|
|
|
+ this._scaledPivot.z = this._particle.pivot.z * this._particle.scaling.z;
|
|
|
if (this._copy.translateFromPivot) {
|
|
|
this._pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
|
|
|
}
|
|
|
else {
|
|
|
- this._pivotBackTranslation.copyFrom(this._copy.pivot);
|
|
|
+ this._pivotBackTranslation.copyFrom(this._scaledPivot);
|
|
|
}
|
|
|
this._shape = particle._model._shape;
|
|
|
for (var pt = 0; pt < this._shape.length; pt++) {
|
|
@@ -52348,9 +52388,9 @@ var BABYLON;
|
|
|
this._vertex.x *= this._copy.scaling.x;
|
|
|
this._vertex.y *= this._copy.scaling.y;
|
|
|
this._vertex.z *= this._copy.scaling.z;
|
|
|
- this._vertex.x -= this._copy.pivot.x;
|
|
|
- this._vertex.y -= this._copy.pivot.y;
|
|
|
- this._vertex.z -= this._copy.pivot.z;
|
|
|
+ this._vertex.x -= this._scaledPivot.x;
|
|
|
+ this._vertex.y -= this._scaledPivot.y;
|
|
|
+ this._vertex.z -= this._scaledPivot.z;
|
|
|
BABYLON.Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
|
|
|
this._rotated.addInPlace(this._pivotBackTranslation);
|
|
|
this._positions32[particle._pos + pt * 3] = this._copy.position.x + this._rotated.x;
|
|
@@ -52367,6 +52407,15 @@ var BABYLON;
|
|
|
particle.scaling.x = 1.0;
|
|
|
particle.scaling.y = 1.0;
|
|
|
particle.scaling.z = 1.0;
|
|
|
+ particle.uvs.x = 0.0;
|
|
|
+ particle.uvs.y = 0.0;
|
|
|
+ particle.uvs.z = 1.0;
|
|
|
+ particle.uvs.w = 1.0;
|
|
|
+ particle.pivot.x = 0.0;
|
|
|
+ particle.pivot.y = 0.0;
|
|
|
+ particle.pivot.z = 0.0;
|
|
|
+ particle.translateFromPivot = false;
|
|
|
+ particle.parentId = null;
|
|
|
};
|
|
|
/**
|
|
|
* Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
|
|
@@ -52481,6 +52530,10 @@ var BABYLON;
|
|
|
}
|
|
|
if (this._particle.isVisible) {
|
|
|
this._particle._stillInvisible = false; // un-mark permanent invisibility
|
|
|
+ this._particleHasParent = (this._particle.parentId !== null);
|
|
|
+ this._scaledPivot.x = this._particle.pivot.x * this._particle.scaling.x;
|
|
|
+ this._scaledPivot.y = this._particle.pivot.y * this._particle.scaling.y;
|
|
|
+ this._scaledPivot.z = this._particle.pivot.z * this._particle.scaling.z;
|
|
|
// particle rotation matrix
|
|
|
if (this.billboard) {
|
|
|
this._particle.rotation.x = 0.0;
|
|
@@ -52497,15 +52550,42 @@ var BABYLON;
|
|
|
this._quaternionRotationYPR();
|
|
|
}
|
|
|
this._quaternionToRotationMatrix();
|
|
|
- this._particle._rotationMatrix[0] = this._rotMatrix.m[0];
|
|
|
- this._particle._rotationMatrix[1] = this._rotMatrix.m[1];
|
|
|
- this._particle._rotationMatrix[2] = this._rotMatrix.m[2];
|
|
|
- this._particle._rotationMatrix[3] = this._rotMatrix.m[4];
|
|
|
- this._particle._rotationMatrix[4] = this._rotMatrix.m[5];
|
|
|
- this._particle._rotationMatrix[5] = this._rotMatrix.m[6];
|
|
|
- this._particle._rotationMatrix[6] = this._rotMatrix.m[8];
|
|
|
- this._particle._rotationMatrix[7] = this._rotMatrix.m[9];
|
|
|
- this._particle._rotationMatrix[8] = this._rotMatrix.m[10];
|
|
|
+ }
|
|
|
+ if (this._particleHasParent) {
|
|
|
+ this._parent = this.particles[this._particle.parentId];
|
|
|
+ this._rotated.x = this._particle.position.x * this._parent._rotationMatrix[0] + this._particle.position.y * this._parent._rotationMatrix[3] + this._particle.position.z * this._parent._rotationMatrix[6];
|
|
|
+ this._rotated.y = this._particle.position.x * this._parent._rotationMatrix[1] + this._particle.position.y * this._parent._rotationMatrix[4] + this._particle.position.z * this._parent._rotationMatrix[7];
|
|
|
+ this._rotated.z = this._particle.position.x * this._parent._rotationMatrix[2] + this._particle.position.y * this._parent._rotationMatrix[5] + this._particle.position.z * this._parent._rotationMatrix[8];
|
|
|
+ this._particle._globalPosition.x = this._parent._globalPosition.x + this._rotated.x;
|
|
|
+ this._particle._globalPosition.y = this._parent._globalPosition.y + this._rotated.y;
|
|
|
+ this._particle._globalPosition.z = this._parent._globalPosition.z + this._rotated.z;
|
|
|
+ if (this._computeParticleRotation || this.billboard) {
|
|
|
+ this._particle._rotationMatrix[0] = this._rotMatrix.m[0] * this._parent._rotationMatrix[0] + this._rotMatrix.m[1] * this._parent._rotationMatrix[3] + this._rotMatrix.m[2] * this._parent._rotationMatrix[6];
|
|
|
+ this._particle._rotationMatrix[1] = this._rotMatrix.m[0] * this._parent._rotationMatrix[1] + this._rotMatrix.m[1] * this._parent._rotationMatrix[4] + this._rotMatrix.m[2] * this._parent._rotationMatrix[7];
|
|
|
+ this._particle._rotationMatrix[2] = this._rotMatrix.m[0] * this._parent._rotationMatrix[2] + this._rotMatrix.m[1] * this._parent._rotationMatrix[5] + this._rotMatrix.m[2] * this._parent._rotationMatrix[8];
|
|
|
+ this._particle._rotationMatrix[3] = this._rotMatrix.m[4] * this._parent._rotationMatrix[0] + this._rotMatrix.m[5] * this._parent._rotationMatrix[3] + this._rotMatrix.m[6] * this._parent._rotationMatrix[6];
|
|
|
+ this._particle._rotationMatrix[4] = this._rotMatrix.m[4] * this._parent._rotationMatrix[1] + this._rotMatrix.m[5] * this._parent._rotationMatrix[4] + this._rotMatrix.m[6] * this._parent._rotationMatrix[7];
|
|
|
+ this._particle._rotationMatrix[5] = this._rotMatrix.m[4] * this._parent._rotationMatrix[2] + this._rotMatrix.m[5] * this._parent._rotationMatrix[5] + this._rotMatrix.m[6] * this._parent._rotationMatrix[8];
|
|
|
+ this._particle._rotationMatrix[6] = this._rotMatrix.m[8] * this._parent._rotationMatrix[0] + this._rotMatrix.m[9] * this._parent._rotationMatrix[3] + this._rotMatrix.m[10] * this._parent._rotationMatrix[6];
|
|
|
+ this._particle._rotationMatrix[7] = this._rotMatrix.m[8] * this._parent._rotationMatrix[1] + this._rotMatrix.m[9] * this._parent._rotationMatrix[4] + this._rotMatrix.m[10] * this._parent._rotationMatrix[7];
|
|
|
+ this._particle._rotationMatrix[8] = this._rotMatrix.m[8] * this._parent._rotationMatrix[2] + this._rotMatrix.m[9] * this._parent._rotationMatrix[5] + this._rotMatrix.m[10] * this._parent._rotationMatrix[8];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this._particle._globalPosition.x = this._particle.position.x;
|
|
|
+ this._particle._globalPosition.y = this._particle.position.y;
|
|
|
+ this._particle._globalPosition.z = this._particle.position.z;
|
|
|
+ if (this._computeParticleRotation || this.billboard) {
|
|
|
+ this._particle._rotationMatrix[0] = this._rotMatrix.m[0];
|
|
|
+ this._particle._rotationMatrix[1] = this._rotMatrix.m[1];
|
|
|
+ this._particle._rotationMatrix[2] = this._rotMatrix.m[2];
|
|
|
+ this._particle._rotationMatrix[3] = this._rotMatrix.m[4];
|
|
|
+ this._particle._rotationMatrix[4] = this._rotMatrix.m[5];
|
|
|
+ this._particle._rotationMatrix[5] = this._rotMatrix.m[6];
|
|
|
+ this._particle._rotationMatrix[6] = this._rotMatrix.m[8];
|
|
|
+ this._particle._rotationMatrix[7] = this._rotMatrix.m[9];
|
|
|
+ this._particle._rotationMatrix[8] = this._rotMatrix.m[10];
|
|
|
+ }
|
|
|
}
|
|
|
if (this._particle.translateFromPivot) {
|
|
|
this._pivotBackTranslation.x = 0.0;
|
|
@@ -52513,9 +52593,9 @@ var BABYLON;
|
|
|
this._pivotBackTranslation.z = 0.0;
|
|
|
}
|
|
|
else {
|
|
|
- this._pivotBackTranslation.x = this._particle.pivot.x;
|
|
|
- this._pivotBackTranslation.y = this._particle.pivot.y;
|
|
|
- this._pivotBackTranslation.z = this._particle.pivot.z;
|
|
|
+ this._pivotBackTranslation.x = this._scaledPivot.x;
|
|
|
+ this._pivotBackTranslation.y = this._scaledPivot.y;
|
|
|
+ this._pivotBackTranslation.z = this._scaledPivot.z;
|
|
|
}
|
|
|
// particle vertex loop
|
|
|
for (pt = 0; pt < this._shape.length; pt++) {
|
|
@@ -52532,18 +52612,18 @@ var BABYLON;
|
|
|
this._vertex.x *= this._particle.scaling.x;
|
|
|
this._vertex.y *= this._particle.scaling.y;
|
|
|
this._vertex.z *= this._particle.scaling.z;
|
|
|
- this._vertex.x -= this._particle.pivot.x;
|
|
|
- this._vertex.y -= this._particle.pivot.y;
|
|
|
- this._vertex.z -= this._particle.pivot.z;
|
|
|
+ this._vertex.x -= this._scaledPivot.x;
|
|
|
+ this._vertex.y -= this._scaledPivot.y;
|
|
|
+ this._vertex.z -= this._scaledPivot.z;
|
|
|
this._rotated.x = this._vertex.x * this._particle._rotationMatrix[0] + this._vertex.y * this._particle._rotationMatrix[3] + this._vertex.z * this._particle._rotationMatrix[6];
|
|
|
this._rotated.y = this._vertex.x * this._particle._rotationMatrix[1] + this._vertex.y * this._particle._rotationMatrix[4] + this._vertex.z * this._particle._rotationMatrix[7];
|
|
|
this._rotated.z = this._vertex.x * this._particle._rotationMatrix[2] + this._vertex.y * this._particle._rotationMatrix[5] + this._vertex.z * this._particle._rotationMatrix[8];
|
|
|
this._rotated.x += this._pivotBackTranslation.x;
|
|
|
this._rotated.y += this._pivotBackTranslation.y;
|
|
|
this._rotated.z += this._pivotBackTranslation.z;
|
|
|
- this._positions32[idx] = this._particle.position.x + this._cam_axisX.x * this._rotated.x + this._cam_axisY.x * this._rotated.y + this._cam_axisZ.x * this._rotated.z;
|
|
|
- this._positions32[idx + 1] = this._particle.position.y + this._cam_axisX.y * this._rotated.x + this._cam_axisY.y * this._rotated.y + this._cam_axisZ.y * this._rotated.z;
|
|
|
- this._positions32[idx + 2] = this._particle.position.z + this._cam_axisX.z * this._rotated.x + this._cam_axisY.z * this._rotated.y + this._cam_axisZ.z * this._rotated.z;
|
|
|
+ this._positions32[idx] = this._particle._globalPosition.x + this._cam_axisX.x * this._rotated.x + this._cam_axisY.x * this._rotated.y + this._cam_axisZ.x * this._rotated.z;
|
|
|
+ this._positions32[idx + 1] = this._particle._globalPosition.y + this._cam_axisX.y * this._rotated.x + this._cam_axisY.y * this._rotated.y + this._cam_axisZ.y * this._rotated.z;
|
|
|
+ this._positions32[idx + 2] = this._particle._globalPosition.z + this._cam_axisX.z * this._rotated.x + this._cam_axisY.z * this._rotated.y + this._cam_axisZ.z * this._rotated.z;
|
|
|
if (this._computeBoundingBox) {
|
|
|
if (this._positions32[idx] < this._minimum.x) {
|
|
|
this._minimum.x = this._positions32[idx];
|
|
@@ -52639,9 +52719,9 @@ var BABYLON;
|
|
|
this._maxBbox.x = this._particle._modelBoundingInfo.maximum.x * this._particle.scaling.x;
|
|
|
this._maxBbox.y = this._particle._modelBoundingInfo.maximum.y * this._particle.scaling.y;
|
|
|
this._maxBbox.z = this._particle._modelBoundingInfo.maximum.z * this._particle.scaling.z;
|
|
|
- bSphere.center.x = this._particle.position.x + (this._minBbox.x + this._maxBbox.x) * 0.5;
|
|
|
- bSphere.center.y = this._particle.position.y + (this._minBbox.y + this._maxBbox.y) * 0.5;
|
|
|
- bSphere.center.z = this._particle.position.z + (this._minBbox.z + this._maxBbox.z) * 0.5;
|
|
|
+ bSphere.center.x = this._particle._globalPosition.x + (this._minBbox.x + this._maxBbox.x) * 0.5;
|
|
|
+ bSphere.center.y = this._particle._globalPosition.y + (this._minBbox.y + this._maxBbox.y) * 0.5;
|
|
|
+ bSphere.center.z = this._particle._globalPosition.z + (this._minBbox.z + this._maxBbox.z) * 0.5;
|
|
|
bSphere.radius = this._bSphereRadiusFactor * 0.5 * Math.sqrt((this._maxBbox.x - this._minBbox.x) * (this._maxBbox.x - this._minBbox.x) + (this._maxBbox.y - this._minBbox.y) * (this._maxBbox.y - this._minBbox.y) + (this._maxBbox.z - this._minBbox.z) * (this._maxBbox.z - this._minBbox.z));
|
|
|
bSphere._update(this.mesh._worldMatrix);
|
|
|
}
|
|
@@ -83634,6 +83714,8 @@ var BABYLON;
|
|
|
mainTextureFixedSize: _this._options.mainTextureFixedSize,
|
|
|
mainTextureRatio: _this._options.mainTextureRatio
|
|
|
});
|
|
|
+ // Do not render as long as no meshes have been added
|
|
|
+ _this._shouldRender = false;
|
|
|
return _this;
|
|
|
}
|
|
|
Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
|
|
@@ -83786,6 +83868,7 @@ var BABYLON;
|
|
|
var previousStencilOperationPass = engine.getStencilOperationPass();
|
|
|
var previousStencilOperationFail = engine.getStencilOperationFail();
|
|
|
var previousStencilOperationDepthFail = engine.getStencilOperationDepthFail();
|
|
|
+ var previousStencilReference = engine.getStencilFunctionReference();
|
|
|
// Stencil operations
|
|
|
engine.setStencilOperationPass(BABYLON.Engine.REPLACE);
|
|
|
engine.setStencilOperationFail(BABYLON.Engine.KEEP);
|
|
@@ -83812,6 +83895,7 @@ var BABYLON;
|
|
|
engine.setStencilOperationPass(previousStencilOperationPass);
|
|
|
engine.setStencilOperationFail(previousStencilOperationFail);
|
|
|
engine.setStencilOperationDepthFail(previousStencilOperationDepthFail);
|
|
|
+ engine.setStencilFunctionReference(previousStencilReference);
|
|
|
};
|
|
|
/**
|
|
|
* Returns true if the layer contains information to display, otherwise false.
|