|
@@ -12889,6 +12889,19 @@ var BABYLON;
|
|
|
return null;
|
|
|
};
|
|
|
/**
|
|
|
+ * get a particle system by id
|
|
|
+ * @param id {number} the particle system id
|
|
|
+ * @return {BABYLON.ParticleSystem|null} the corresponding system or null if none found.
|
|
|
+ */
|
|
|
+ Scene.prototype.getParticleSystemByID = function (id) {
|
|
|
+ for (var index = 0; index < this.particleSystems.length; index++) {
|
|
|
+ if (this.particleSystems[index].id === id) {
|
|
|
+ return this.particleSystems[index];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ };
|
|
|
+ /**
|
|
|
* get a geometry using its ID
|
|
|
* @param {string} the geometry's id
|
|
|
* @return {BABYLON.Geometry|null} the geometry or null if none found.
|
|
@@ -21220,7 +21233,14 @@ var BABYLON;
|
|
|
};
|
|
|
ParticleSystem.prototype.serialize = function () {
|
|
|
var serializationObject = {};
|
|
|
- serializationObject.emitterId = this.emitter.id;
|
|
|
+ serializationObject.name = this.name;
|
|
|
+ if (this.emitter.position) {
|
|
|
+ serializationObject.emitterId = this.emitter.id;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ serializationObject.emitter = this.emitter.asArray();
|
|
|
+ ;
|
|
|
+ }
|
|
|
serializationObject.capacity = this.getCapacity();
|
|
|
if (this.particleTexture) {
|
|
|
serializationObject.textureName = this.particleTexture.name;
|
|
@@ -21229,6 +21249,8 @@ var BABYLON;
|
|
|
serializationObject.maxAngularSpeed = this.maxAngularSpeed;
|
|
|
serializationObject.minSize = this.minSize;
|
|
|
serializationObject.maxSize = this.maxSize;
|
|
|
+ serializationObject.minEmitPower = this.minEmitPower;
|
|
|
+ serializationObject.maxEmitPower = this.maxEmitPower;
|
|
|
serializationObject.minLifeTime = this.minLifeTime;
|
|
|
serializationObject.maxLifeTime = this.maxLifeTime;
|
|
|
serializationObject.emitRate = this.emitRate;
|
|
@@ -21247,19 +21269,26 @@ var BABYLON;
|
|
|
return serializationObject;
|
|
|
};
|
|
|
ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl) {
|
|
|
- var emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
|
|
|
- var particleSystem = new ParticleSystem("particles#" + emitter.name, parsedParticleSystem.capacity, scene);
|
|
|
+ var name = parsedParticleSystem.name;
|
|
|
+ var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene);
|
|
|
if (parsedParticleSystem.textureName) {
|
|
|
particleSystem.particleTexture = new BABYLON.Texture(rootUrl + parsedParticleSystem.textureName, scene);
|
|
|
particleSystem.particleTexture.name = parsedParticleSystem.textureName;
|
|
|
}
|
|
|
+ if (parsedParticleSystem.emitterId) {
|
|
|
+ particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ particleSystem.emitter = BABYLON.Vector3.FromArray(parsedParticleSystem.emitter);
|
|
|
+ }
|
|
|
particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
|
|
|
particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
|
|
|
particleSystem.minSize = parsedParticleSystem.minSize;
|
|
|
particleSystem.maxSize = parsedParticleSystem.maxSize;
|
|
|
particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
|
|
|
particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
|
|
|
- particleSystem.emitter = emitter;
|
|
|
+ particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
|
|
|
+ particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
|
|
|
particleSystem.emitRate = parsedParticleSystem.emitRate;
|
|
|
particleSystem.minEmitBox = BABYLON.Vector3.FromArray(parsedParticleSystem.minEmitBox);
|
|
|
particleSystem.maxEmitBox = BABYLON.Vector3.FromArray(parsedParticleSystem.maxEmitBox);
|
|
@@ -21270,7 +21299,7 @@ var BABYLON;
|
|
|
particleSystem.color2 = BABYLON.Color4.FromArray(parsedParticleSystem.color2);
|
|
|
particleSystem.colorDead = BABYLON.Color4.FromArray(parsedParticleSystem.colorDead);
|
|
|
particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
|
|
|
- particleSystem.targetStopDuration = parsedParticleSystem.targetStopFrame;
|
|
|
+ particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
|
|
|
particleSystem.textureMask = BABYLON.Color4.FromArray(parsedParticleSystem.textureMask);
|
|
|
particleSystem.blendMode = parsedParticleSystem.blendMode;
|
|
|
particleSystem.start();
|
|
@@ -22945,120 +22974,54 @@ var BABYLON;
|
|
|
}
|
|
|
};
|
|
|
VertexData.prototype.merge = function (other) {
|
|
|
- var index;
|
|
|
if (other.indices) {
|
|
|
if (!this.indices) {
|
|
|
this.indices = [];
|
|
|
}
|
|
|
var offset = this.positions ? this.positions.length / 3 : 0;
|
|
|
- for (index = 0; index < other.indices.length; index++) {
|
|
|
+ for (var index = 0; index < other.indices.length; index++) {
|
|
|
//TODO check type - if Int32Array!
|
|
|
this.indices.push(other.indices[index] + offset);
|
|
|
}
|
|
|
}
|
|
|
- if (other.positions) {
|
|
|
- if (!this.positions) {
|
|
|
- this.positions = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.positions.length; index++) {
|
|
|
- this.positions.push(other.positions[index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (other.normals) {
|
|
|
- if (!this.normals) {
|
|
|
- this.normals = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.normals.length; index++) {
|
|
|
- this.normals.push(other.normals[index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (other.uvs) {
|
|
|
- if (!this.uvs) {
|
|
|
- this.uvs = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.uvs.length; index++) {
|
|
|
- this.uvs.push(other.uvs[index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (other.uvs2) {
|
|
|
- if (!this.uvs2) {
|
|
|
- this.uvs2 = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.uvs2.length; index++) {
|
|
|
- this.uvs2.push(other.uvs2[index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (other.uvs3) {
|
|
|
- if (!this.uvs3) {
|
|
|
- this.uvs3 = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.uvs3.length; index++) {
|
|
|
- this.uvs3.push(other.uvs3[index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (other.uvs4) {
|
|
|
- if (!this.uvs4) {
|
|
|
- this.uvs4 = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.uvs4.length; index++) {
|
|
|
- this.uvs4.push(other.uvs4[index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (other.uvs5) {
|
|
|
- if (!this.uvs5) {
|
|
|
- this.uvs5 = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.uvs5.length; index++) {
|
|
|
- this.uvs5.push(other.uvs5[index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (other.uvs6) {
|
|
|
- if (!this.uvs6) {
|
|
|
- this.uvs6 = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.uvs6.length; index++) {
|
|
|
- this.uvs6.push(other.uvs6[index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (other.matricesIndices) {
|
|
|
- if (!this.matricesIndices) {
|
|
|
- this.matricesIndices = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.matricesIndices.length; index++) {
|
|
|
- this.matricesIndices.push(other.matricesIndices[index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (other.matricesWeights) {
|
|
|
- if (!this.matricesWeights) {
|
|
|
- this.matricesWeights = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.matricesWeights.length; index++) {
|
|
|
- this.matricesWeights.push(other.matricesWeights[index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (other.matricesIndicesExtra) {
|
|
|
- if (!this.matricesIndicesExtra) {
|
|
|
- this.matricesIndicesExtra = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.matricesIndicesExtra.length; index++) {
|
|
|
- this.matricesIndicesExtra.push(other.matricesIndicesExtra[index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (other.matricesWeightsExtra) {
|
|
|
- if (!this.matricesWeightsExtra) {
|
|
|
- this.matricesWeightsExtra = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.matricesWeightsExtra.length; index++) {
|
|
|
- this.matricesWeightsExtra.push(other.matricesWeightsExtra[index]);
|
|
|
- }
|
|
|
+ this.positions = this._mergeElement(this.positions, other.positions);
|
|
|
+ this.normals = this._mergeElement(this.normals, other.normals);
|
|
|
+ this.uvs = this._mergeElement(this.uvs, other.uvs);
|
|
|
+ this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
|
|
|
+ this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
|
|
|
+ this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
|
|
|
+ this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
|
|
|
+ this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
|
|
|
+ this.colors = this._mergeElement(this.colors, other.colors);
|
|
|
+ this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
|
|
|
+ this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
|
|
|
+ this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
|
|
|
+ this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
|
|
|
+ };
|
|
|
+ VertexData.prototype._mergeElement = function (source, other) {
|
|
|
+ if (!other)
|
|
|
+ return source;
|
|
|
+ if (!source)
|
|
|
+ return other;
|
|
|
+ var len = other.length + source.length;
|
|
|
+ var isSrcTypedArray = source instanceof Float32Array;
|
|
|
+ var isOthTypedArray = other instanceof Float32Array;
|
|
|
+ // use non-loop method when the source is Float32Array
|
|
|
+ if (isSrcTypedArray) {
|
|
|
+ var ret32 = new Float32Array(len);
|
|
|
+ ret32.set(source);
|
|
|
+ ret32.set(other, source.length);
|
|
|
+ return ret32;
|
|
|
+ }
|
|
|
+ else if (!isOthTypedArray) {
|
|
|
+ return source.concat(other);
|
|
|
}
|
|
|
- if (other.colors) {
|
|
|
- if (!this.colors) {
|
|
|
- this.colors = [];
|
|
|
- }
|
|
|
- for (index = 0; index < other.colors.length; index++) {
|
|
|
- this.colors.push(other.colors[index]);
|
|
|
+ else {
|
|
|
+ var ret = source.slice(0); // copy source to a separate array
|
|
|
+ for (var i = 0, len = other.length; i < len; i++) {
|
|
|
+ ret.push(other[i]);
|
|
|
}
|
|
|
+ return ret;
|
|
|
}
|
|
|
};
|
|
|
VertexData.prototype.serialize = function () {
|
|
@@ -23097,6 +23060,13 @@ var BABYLON;
|
|
|
if (this.matricesWeights) {
|
|
|
serializationObject.matricesWeights = this.matricesWeights;
|
|
|
}
|
|
|
+ if (this.matricesIndicesExtra) {
|
|
|
+ serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
|
|
|
+ serializationObject.matricesIndicesExtra._isExpanded = true;
|
|
|
+ }
|
|
|
+ if (this.matricesWeightsExtra) {
|
|
|
+ serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
|
|
|
+ }
|
|
|
serializationObject.indices = this.indices;
|
|
|
return serializationObject;
|
|
|
};
|
|
@@ -23255,7 +23225,7 @@ var BABYLON;
|
|
|
vTotalDistance[i] = dist;
|
|
|
}
|
|
|
}
|
|
|
- // uvs
|
|
|
+ // uvs
|
|
|
var u;
|
|
|
var v;
|
|
|
for (p = 0; p < pathArray.length; p++) {
|
|
@@ -23271,7 +23241,7 @@ var BABYLON;
|
|
|
var l1 = lg[p] - 1; // path1 length
|
|
|
var l2 = lg[p + 1] - 1; // path2 length
|
|
|
var min = (l1 < l2) ? l1 : l2; // current path stop index
|
|
|
- var shft = idx[1] - idx[0]; // shift
|
|
|
+ var shft = idx[1] - idx[0]; // shift
|
|
|
var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
|
|
|
while (pi <= min && p < path1nb) {
|
|
|
// draw two triangles between path1 (p1) and path2 (p2) : (p1.pi, p2.pi, p1.pi+1) and (p2.pi+1, p1.pi+1, p2.pi) clockwise
|
|
@@ -23469,7 +23439,7 @@ var BABYLON;
|
|
|
vertexData.uvs = uvs;
|
|
|
return vertexData;
|
|
|
};
|
|
|
- // Cylinder and cone
|
|
|
+ // Cylinder and cone
|
|
|
VertexData.CreateCylinder = function (options) {
|
|
|
var height = options.height || 2;
|
|
|
var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
|
|
@@ -24557,7 +24527,7 @@ var BABYLON;
|
|
|
}
|
|
|
break;
|
|
|
case BABYLON.Mesh.DOUBLESIDE:
|
|
|
- // positions
|
|
|
+ // positions
|
|
|
var lp = positions.length;
|
|
|
var l = lp / 3;
|
|
|
for (var p = 0; p < lp; p++) {
|