|
@@ -33221,10 +33221,6 @@ var Constants = /** @class */ (function () {
|
|
|
* Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
|
|
|
*/
|
|
|
Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
|
|
|
- /**
|
|
|
- * Gets or sets base Assets URL
|
|
|
- */
|
|
|
- Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
|
|
|
/** Default culling strategy : this is an exclusion test and it's the more accurate.
|
|
|
* Test order :
|
|
|
* Is the bounding sphere outside the frustum ?
|
|
@@ -61619,7 +61615,7 @@ var LightBlock = /** @class */ (function (_super) {
|
|
|
_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindLights(scene, mesh, effect, true, nodeMaterial.maxSimultaneousLights, false);
|
|
|
}
|
|
|
else {
|
|
|
- _materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindLight(this.light, this._lightId, scene, mesh, effect, true, false);
|
|
|
+ _materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindLight(this.light, this._lightId, scene, effect, true, false);
|
|
|
}
|
|
|
};
|
|
|
LightBlock.prototype._injectVertexCode = function (state) {
|
|
@@ -89044,22 +89040,6 @@ var MaterialHelper = /** @class */ (function () {
|
|
|
attribs.push("world3");
|
|
|
};
|
|
|
/**
|
|
|
- * Binds the light shadow information to the effect for the given mesh.
|
|
|
- * @param light The light containing the generator
|
|
|
- * @param scene The scene the lights belongs to
|
|
|
- * @param mesh The mesh we are binding the information to render
|
|
|
- * @param lightIndex The light index in the effect used to render the mesh
|
|
|
- * @param effect The effect we are binding the data to
|
|
|
- */
|
|
|
- MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
|
|
|
- if (light.shadowEnabled && mesh.receiveShadows) {
|
|
|
- var shadowGenerator = light.getShadowGenerator();
|
|
|
- if (shadowGenerator) {
|
|
|
- shadowGenerator.bindShadowLight(lightIndex, effect);
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- /**
|
|
|
* Binds the light information to the effect.
|
|
|
* @param light The light containing the generator
|
|
|
* @param effect The effect we are binding the data to
|
|
@@ -89073,32 +89053,43 @@ var MaterialHelper = /** @class */ (function () {
|
|
|
* @param light Light to bind
|
|
|
* @param lightIndex Light index
|
|
|
* @param scene The scene where the light belongs to
|
|
|
- * @param mesh The mesh we are binding the information to render
|
|
|
* @param effect The effect we are binding the data to
|
|
|
* @param useSpecular Defines if specular is supported
|
|
|
* @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
|
|
|
* @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
|
|
|
*/
|
|
|
- MaterialHelper.BindLight = function (light, lightIndex, scene, mesh, effect, useSpecular, usePhysicalLightFalloff, rebuildInParallel) {
|
|
|
+ MaterialHelper.BindLight = function (light, lightIndex, scene, effect, useSpecular, usePhysicalLightFalloff, rebuildInParallel) {
|
|
|
if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
|
|
|
if (rebuildInParallel === void 0) { rebuildInParallel = false; }
|
|
|
var iAsString = lightIndex.toString();
|
|
|
- var scaledIntensity = light.getScaledIntensity();
|
|
|
- if (!rebuildInParallel) {
|
|
|
- light._uniformBuffer.bindToEffect(effect, "Light" + iAsString);
|
|
|
+ var needUpdate = false;
|
|
|
+ if (rebuildInParallel && light._uniformBuffer._alreadyBound) {
|
|
|
+ return;
|
|
|
}
|
|
|
- MaterialHelper.BindLightProperties(light, effect, lightIndex);
|
|
|
- light.diffuse.scaleToRef(scaledIntensity, _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["TmpColors"].Color3[0]);
|
|
|
- light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["TmpColors"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
|
|
|
- if (useSpecular) {
|
|
|
- light.specular.scaleToRef(scaledIntensity, _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["TmpColors"].Color3[1]);
|
|
|
- light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["TmpColors"].Color3[1], iAsString);
|
|
|
+ light._uniformBuffer.bindToEffect(effect, "Light" + iAsString);
|
|
|
+ if (light._renderId !== scene.getRenderId() || !light._uniformBuffer.useUbo) {
|
|
|
+ light._renderId = scene.getRenderId();
|
|
|
+ var scaledIntensity = light.getScaledIntensity();
|
|
|
+ MaterialHelper.BindLightProperties(light, effect, lightIndex);
|
|
|
+ light.diffuse.scaleToRef(scaledIntensity, _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["TmpColors"].Color3[0]);
|
|
|
+ light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["TmpColors"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
|
|
|
+ if (useSpecular) {
|
|
|
+ light.specular.scaleToRef(scaledIntensity, _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["TmpColors"].Color3[1]);
|
|
|
+ light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["TmpColors"].Color3[1], iAsString);
|
|
|
+ }
|
|
|
+ needUpdate = true;
|
|
|
}
|
|
|
// Shadows
|
|
|
- if (scene.shadowsEnabled) {
|
|
|
- this.BindLightShadow(light, mesh, iAsString, effect);
|
|
|
+ if (scene.shadowsEnabled && light.shadowEnabled) {
|
|
|
+ var shadowGenerator = light.getShadowGenerator();
|
|
|
+ if (shadowGenerator) {
|
|
|
+ shadowGenerator.bindShadowLight(iAsString, effect);
|
|
|
+ needUpdate = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (needUpdate) {
|
|
|
+ light._uniformBuffer.update();
|
|
|
}
|
|
|
- light._uniformBuffer.update();
|
|
|
};
|
|
|
/**
|
|
|
* Binds the lights information from the scene to the effect for the given mesh.
|
|
@@ -89117,7 +89108,7 @@ var MaterialHelper = /** @class */ (function () {
|
|
|
var len = Math.min(mesh.lightSources.length, maxSimultaneousLights);
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
var light = mesh.lightSources[i];
|
|
|
- this.BindLight(light, i, scene, mesh, effect, typeof defines === "boolean" ? defines : defines["SPECULARTERM"], usePhysicalLightFalloff, rebuildInParallel);
|
|
|
+ this.BindLight(light, i, scene, effect, typeof defines === "boolean" ? defines : defines["SPECULARTERM"], usePhysicalLightFalloff, rebuildInParallel);
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
@@ -91532,7 +91523,9 @@ var StandardMaterial = /** @class */ (function (_super) {
|
|
|
_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
|
|
|
}
|
|
|
// Log. depth
|
|
|
- _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
|
|
|
+ if (this.useLogarithmicDepth) {
|
|
|
+ _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
|
|
|
+ }
|
|
|
// image processing
|
|
|
if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
|
|
|
this._imageProcessingConfiguration.bind(this._activeEffect);
|
|
@@ -92128,6 +92121,8 @@ var UniformBuffer = /** @class */ (function () {
|
|
|
* @param dynamic Define if the buffer is updatable
|
|
|
*/
|
|
|
function UniformBuffer(engine, data, dynamic) {
|
|
|
+ /** @hidden */
|
|
|
+ this._alreadyBound = false;
|
|
|
// Matrix cache
|
|
|
this._valueCache = {};
|
|
|
this._engine = engine;
|
|
@@ -92571,6 +92566,7 @@ var UniformBuffer = /** @class */ (function () {
|
|
|
if (this._noUBO || !this._buffer) {
|
|
|
return;
|
|
|
}
|
|
|
+ this._alreadyBound = true;
|
|
|
effect.bindUniformBuffer(this._buffer, name);
|
|
|
};
|
|
|
/**
|
|
@@ -110499,6 +110495,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
/* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
|
|
|
/* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
|
|
|
/* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
|
|
|
+/* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -110507,7 +110505,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
|
|
|
|
|
|
_Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._instancedMeshFactory = function (name, mesh) {
|
|
|
- return new InstancedMesh(name, mesh);
|
|
|
+ var instance = new InstancedMesh(name, mesh);
|
|
|
+ if (mesh.instancedBuffers) {
|
|
|
+ instance.instancedBuffers = {};
|
|
|
+ for (var key in mesh.instancedBuffers) {
|
|
|
+ instance.instancedBuffers[key] = mesh.instancedBuffers[key];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return instance;
|
|
|
};
|
|
|
/**
|
|
|
* Creates an instance based on a source mesh.
|
|
@@ -110894,6 +110899,102 @@ var InstancedMesh = /** @class */ (function (_super) {
|
|
|
return InstancedMesh;
|
|
|
}(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]));
|
|
|
|
|
|
+_Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].prototype.registerInstancedBuffer = function (kind, stride) {
|
|
|
+ // Remove existing one
|
|
|
+ this.removeVerticesData(kind);
|
|
|
+ // Creates the instancedBuffer field if not present
|
|
|
+ if (!this.instancedBuffers) {
|
|
|
+ this.instancedBuffers = {};
|
|
|
+ for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
|
|
|
+ var instance = _a[_i];
|
|
|
+ instance.instancedBuffers = {};
|
|
|
+ }
|
|
|
+ this._userInstancedBuffersStorage = {
|
|
|
+ data: {},
|
|
|
+ vertexBuffers: {},
|
|
|
+ strides: {},
|
|
|
+ sizes: {}
|
|
|
+ };
|
|
|
+ }
|
|
|
+ // Creates an empty property for this kind
|
|
|
+ this.instancedBuffers[kind] = null;
|
|
|
+ this._userInstancedBuffersStorage.strides[kind] = stride;
|
|
|
+ this._userInstancedBuffersStorage.sizes[kind] = stride * 32; // Initial size
|
|
|
+ this._userInstancedBuffersStorage.data[kind] = new Float32Array(this._userInstancedBuffersStorage.sizes[kind]);
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers[kind] = new _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"](this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true);
|
|
|
+ this.setVerticesBuffer(this._userInstancedBuffersStorage.vertexBuffers[kind]);
|
|
|
+ for (var _b = 0, _c = this.instances; _b < _c.length; _b++) {
|
|
|
+ var instance = _c[_b];
|
|
|
+ instance.instancedBuffers[kind] = null;
|
|
|
+ }
|
|
|
+};
|
|
|
+_Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].prototype._processInstancedBuffers = function (visibleInstances, renderSelf) {
|
|
|
+ var instanceCount = visibleInstances.length;
|
|
|
+ for (var kind in this.instancedBuffers) {
|
|
|
+ var size = this._userInstancedBuffersStorage.sizes[kind];
|
|
|
+ var stride = this._userInstancedBuffersStorage.strides[kind];
|
|
|
+ // Resize if required
|
|
|
+ var expectedSize = (instanceCount + 1) * stride;
|
|
|
+ while (size < expectedSize) {
|
|
|
+ size *= 2;
|
|
|
+ }
|
|
|
+ if (this._userInstancedBuffersStorage.data[kind].length != size) {
|
|
|
+ this._userInstancedBuffersStorage.data[kind] = new Float32Array(size);
|
|
|
+ this._userInstancedBuffersStorage.sizes[kind] = size;
|
|
|
+ if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers[kind].dispose();
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers[kind] = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var data = this._userInstancedBuffersStorage.data[kind];
|
|
|
+ // Update data buffer
|
|
|
+ var offset = 0;
|
|
|
+ if (renderSelf) {
|
|
|
+ offset += stride;
|
|
|
+ var value = this.instancedBuffers[kind];
|
|
|
+ if (value.toArray) {
|
|
|
+ value.toArray(data, offset);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ value.copyToArray(data, offset);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (var instanceIndex = 0; instanceIndex < instanceCount; instanceIndex++) {
|
|
|
+ var instance = visibleInstances[instanceIndex];
|
|
|
+ var value = instance.instancedBuffers[kind];
|
|
|
+ if (value.toArray) {
|
|
|
+ value.toArray(data, offset);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ value.copyToArray(data, offset);
|
|
|
+ }
|
|
|
+ offset += stride;
|
|
|
+ }
|
|
|
+ // Update vertex buffer
|
|
|
+ if (!this._userInstancedBuffersStorage.vertexBuffers[kind]) {
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers[kind] = new _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"](this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true);
|
|
|
+ this.setVerticesBuffer(this._userInstancedBuffersStorage.vertexBuffers[kind]);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers[kind].updateDirectly(data, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+_Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].prototype._disposeInstanceSpecificData = function () {
|
|
|
+ if (this._instanceDataStorage.instancesBuffer) {
|
|
|
+ this._instanceDataStorage.instancesBuffer.dispose();
|
|
|
+ this._instanceDataStorage.instancesBuffer = null;
|
|
|
+ }
|
|
|
+ while (this.instances.length) {
|
|
|
+ this.instances[0].dispose();
|
|
|
+ }
|
|
|
+ for (var kind in this.instancedBuffers) {
|
|
|
+ if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers[kind].dispose();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.instancedBuffers = {};
|
|
|
+};
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
@@ -112162,6 +112263,28 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
return this;
|
|
|
};
|
|
|
/**
|
|
|
+ * Delete a vertex buffer associated with this mesh
|
|
|
+ * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
|
|
|
+ * - VertexBuffer.PositionKind
|
|
|
+ * - VertexBuffer.UVKind
|
|
|
+ * - VertexBuffer.UV2Kind
|
|
|
+ * - VertexBuffer.UV3Kind
|
|
|
+ * - VertexBuffer.UV4Kind
|
|
|
+ * - VertexBuffer.UV5Kind
|
|
|
+ * - VertexBuffer.UV6Kind
|
|
|
+ * - VertexBuffer.ColorKind
|
|
|
+ * - VertexBuffer.MatricesIndicesKind
|
|
|
+ * - VertexBuffer.MatricesIndicesExtraKind
|
|
|
+ * - VertexBuffer.MatricesWeightsKind
|
|
|
+ * - VertexBuffer.MatricesWeightsExtraKind
|
|
|
+ */
|
|
|
+ Mesh.prototype.removeVerticesData = function (kind) {
|
|
|
+ if (!this._geometry) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this._geometry.removeVerticesData(kind);
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Flags an associated vertex buffer as updatable
|
|
|
* @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
|
|
|
* - VertexBuffer.PositionKind
|
|
@@ -112453,8 +112576,9 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
}
|
|
|
var offset = 0;
|
|
|
var instancesCount = 0;
|
|
|
+ var renderSelf = batch.renderSelf[subMesh._id];
|
|
|
var world = this._effectiveMesh.getWorldMatrix();
|
|
|
- if (batch.renderSelf[subMesh._id]) {
|
|
|
+ if (renderSelf) {
|
|
|
world.copyToArray(instanceStorage.instancesData, offset);
|
|
|
offset += 16;
|
|
|
instancesCount++;
|
|
@@ -112481,12 +112605,17 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
else {
|
|
|
instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
|
|
|
}
|
|
|
+ this._processInstancedBuffers(visibleInstances, renderSelf);
|
|
|
this._bind(subMesh, effect, fillMode);
|
|
|
this._draw(subMesh, fillMode, instancesCount);
|
|
|
engine.unbindInstanceAttributes();
|
|
|
return this;
|
|
|
};
|
|
|
/** @hidden */
|
|
|
+ Mesh.prototype._processInstancedBuffers = function (visibleInstances, renderSelf) {
|
|
|
+ // Do nothing
|
|
|
+ };
|
|
|
+ /** @hidden */
|
|
|
Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
|
|
|
var scene = this.getScene();
|
|
|
var engine = scene.getEngine();
|
|
@@ -113061,15 +113190,13 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
}
|
|
|
internalDataInfo._source = null;
|
|
|
// Instances
|
|
|
- if (this._instanceDataStorage.instancesBuffer) {
|
|
|
- this._instanceDataStorage.instancesBuffer.dispose();
|
|
|
- this._instanceDataStorage.instancesBuffer = null;
|
|
|
- }
|
|
|
- while (this.instances.length) {
|
|
|
- this.instances[0].dispose();
|
|
|
- }
|
|
|
+ this._disposeInstanceSpecificData();
|
|
|
_super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
|
|
|
};
|
|
|
+ /** @hidden */
|
|
|
+ Mesh.prototype._disposeInstanceSpecificData = function () {
|
|
|
+ // Do nothing
|
|
|
+ };
|
|
|
/**
|
|
|
* Modifies the mesh geometry according to a displacement map.
|
|
|
* A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
|
|
@@ -136595,8 +136722,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
/* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
|
|
|
/* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
|
|
|
/* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
|
|
|
-/* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -136692,7 +136817,7 @@ var ParticleHelper = /** @class */ (function () {
|
|
|
/**
|
|
|
* Gets or sets base Assets URL
|
|
|
*/
|
|
|
- ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
|
|
|
+ ParticleHelper.BaseAssetsUrl = _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].BaseAssetsUrl;
|
|
|
return ParticleHelper;
|
|
|
}());
|
|
|
|
|
@@ -139071,8 +139196,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
/* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
|
|
|
/* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
|
|
|
/* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
|
|
|
-/* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -139184,7 +139307,7 @@ var ParticleSystemSet = /** @class */ (function () {
|
|
|
ParticleSystemSet.Parse = function (data, scene, gpu) {
|
|
|
if (gpu === void 0) { gpu = false; }
|
|
|
var result = new ParticleSystemSet();
|
|
|
- var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
|
|
|
+ var rootUrl = this.BaseAssetsUrl + "/textures/";
|
|
|
scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
|
|
|
for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
|
|
|
var system = _a[_i];
|
|
@@ -139204,6 +139327,10 @@ var ParticleSystemSet = /** @class */ (function () {
|
|
|
}
|
|
|
return result;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Gets or sets base Assets URL
|
|
|
+ */
|
|
|
+ ParticleSystemSet.BaseAssetsUrl = "https://assets.babylonjs.com/particles";
|
|
|
return ParticleSystemSet;
|
|
|
}());
|
|
|
|
|
@@ -139614,11 +139741,11 @@ var PointsCloudSystem = /** @class */ (function () {
|
|
|
if (s > 1) {
|
|
|
s = 1;
|
|
|
}
|
|
|
- if (h < 0) {
|
|
|
- h = 0;
|
|
|
+ if (v < 0) {
|
|
|
+ v = 0;
|
|
|
}
|
|
|
- if (h > 1) {
|
|
|
- h = 1;
|
|
|
+ if (v > 1) {
|
|
|
+ v = 1;
|
|
|
}
|
|
|
_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].HSVtoRGBToRef(h, s, v, colPoint3);
|
|
|
colPoint.set(colPoint3.r, colPoint3.g, colPoint3.b, 1);
|
|
@@ -139777,6 +139904,9 @@ var PointsCloudSystem = /** @class */ (function () {
|
|
|
if (cp.color) {
|
|
|
this._colors.push(cp.color.r, cp.color.g, cp.color.b, cp.color.a);
|
|
|
}
|
|
|
+ if (cp.uv) {
|
|
|
+ this._uvs.push(cp.uv.x, cp.uv.y);
|
|
|
+ }
|
|
|
idx++;
|
|
|
}
|
|
|
this.nbParticles += nb;
|
|
@@ -140431,7 +140561,7 @@ var ModelShape = /** @class */ (function () {
|
|
|
* SPS internal tool, don't use it manually.
|
|
|
* @hidden
|
|
|
*/
|
|
|
- function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
|
|
|
+ function ModelShape(id, shape, indices, normals, colors, shapeUV, posFunction, vtxFunction) {
|
|
|
/**
|
|
|
* length of the shape in the model indices array (internal use)
|
|
|
* @hidden
|
|
@@ -140439,8 +140569,11 @@ var ModelShape = /** @class */ (function () {
|
|
|
this._indicesLength = 0;
|
|
|
this.shapeID = id;
|
|
|
this._shape = shape;
|
|
|
- this._indicesLength = indicesLength;
|
|
|
+ this._indices = indices;
|
|
|
+ this._indicesLength = indices.length;
|
|
|
this._shapeUV = shapeUV;
|
|
|
+ this._shapeColors = colors;
|
|
|
+ this._normals = normals;
|
|
|
this._positionFunction = posFunction;
|
|
|
this._vertexFunction = vtxFunction;
|
|
|
}
|
|
@@ -140588,6 +140721,7 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
this._mustUnrotateFixedNormals = false;
|
|
|
this._particlesIntersect = false;
|
|
|
this._needs32Bits = false;
|
|
|
+ this._isNotBuilt = true;
|
|
|
this.name = name;
|
|
|
this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
|
|
|
this._camera = scene.activeCamera;
|
|
@@ -140616,7 +140750,10 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
* @returns the created mesh
|
|
|
*/
|
|
|
SolidParticleSystem.prototype.buildMesh = function () {
|
|
|
- if (this.nbParticles === 0) {
|
|
|
+ if (!this._isNotBuilt && this.mesh) {
|
|
|
+ return this.mesh;
|
|
|
+ }
|
|
|
+ if (this.nbParticles === 0 && !this.mesh) {
|
|
|
var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_5__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
|
|
|
this.addShape(triangle, 1);
|
|
|
triangle.dispose();
|
|
@@ -140662,6 +140799,7 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
this.particles.length = 0;
|
|
|
}
|
|
|
}
|
|
|
+ this._isNotBuilt = false;
|
|
|
return this.mesh;
|
|
|
};
|
|
|
/**
|
|
@@ -140695,6 +140833,7 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
size = (size > totalFacets) ? totalFacets : size;
|
|
|
}
|
|
|
var facetPos = []; // submesh positions
|
|
|
+ var facetNor = [];
|
|
|
var facetInd = []; // submesh indices
|
|
|
var facetUV = []; // submesh UV
|
|
|
var facetCol = []; // submesh colors
|
|
@@ -140707,6 +140846,7 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
}
|
|
|
// reset temp arrays
|
|
|
facetPos.length = 0;
|
|
|
+ facetNor.length = 0;
|
|
|
facetInd.length = 0;
|
|
|
facetUV.length = 0;
|
|
|
facetCol.length = 0;
|
|
@@ -140715,12 +140855,16 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
for (var j = f * 3; j < (f + size) * 3; j++) {
|
|
|
facetInd.push(fi);
|
|
|
var i = meshInd[j];
|
|
|
- facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
|
|
|
+ var i3 = i * 3;
|
|
|
+ facetPos.push(meshPos[i3], meshPos[i3 + 1], meshPos[i3 + 2]);
|
|
|
+ facetNor.push(meshNor[i3], meshNor[i3 + 1], meshNor[i3 + 2]);
|
|
|
if (meshUV) {
|
|
|
- facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
|
|
|
+ var i2 = i * 2;
|
|
|
+ facetUV.push(meshUV[i2], meshUV[i2 + 1]);
|
|
|
}
|
|
|
if (meshCol) {
|
|
|
- facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
|
|
|
+ var i4 = i * 4;
|
|
|
+ facetCol.push(meshCol[i4], meshCol[i4 + 1], meshCol[i4 + 2], meshCol[i4 + 3]);
|
|
|
}
|
|
|
fi++;
|
|
|
}
|
|
@@ -140728,6 +140872,9 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
var idx = this.nbParticles;
|
|
|
var shape = this._posToShape(facetPos);
|
|
|
var shapeUV = this._uvsToShapeUV(facetUV);
|
|
|
+ var shapeInd = Array.from(facetInd);
|
|
|
+ var shapeCol = Array.from(facetCol);
|
|
|
+ var shapeNor = Array.from(facetNor);
|
|
|
// compute the barycenter of the shape
|
|
|
barycenter.copyFromFloats(0, 0, 0);
|
|
|
var v;
|
|
@@ -140748,11 +140895,11 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
if (this._particlesIntersect) {
|
|
|
bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_8__["BoundingInfo"](minimum, maximum);
|
|
|
}
|
|
|
- var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_7__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
|
|
|
+ var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_7__["ModelShape"](this._shapeCounter, shape, shapeInd, shapeNor, shapeCol, shapeUV, null, null);
|
|
|
// add the particle in the SPS
|
|
|
var currentPos = this._positions.length;
|
|
|
var currentInd = this._indices.length;
|
|
|
- this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
|
|
|
+ this._meshBuilder(this._index, shape, this._positions, shapeInd, this._indices, facetUV, this._uvs, shapeCol, this._colors, shapeNor, this._normals, idx, 0, null);
|
|
|
this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
|
|
|
// initialize the particle position
|
|
|
this.particles[this.nbParticles].position.addInPlace(barycenter);
|
|
@@ -140762,6 +140909,7 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
this._shapeCounter++;
|
|
|
f += size;
|
|
|
}
|
|
|
+ this._isNotBuilt = true; // buildMesh() is now expected for setParticles() to work
|
|
|
return this;
|
|
|
};
|
|
|
// unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
|
|
@@ -140932,6 +141080,9 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
|
|
|
var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
|
|
|
var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
|
|
|
+ var indices = Array.from(meshInd);
|
|
|
+ var shapeNormals = Array.from(meshNor);
|
|
|
+ var shapeColors = (meshCol) ? Array.from(meshCol) : [];
|
|
|
var bbInfo;
|
|
|
if (this._particlesIntersect) {
|
|
|
bbInfo = mesh.getBoundingInfo();
|
|
@@ -140940,7 +141091,7 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
var shapeUV = this._uvsToShapeUV(meshUV);
|
|
|
var posfunc = options ? options.positionFunction : null;
|
|
|
var vtxfunc = options ? options.vertexFunction : null;
|
|
|
- var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_7__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
|
|
|
+ var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_7__["ModelShape"](this._shapeCounter, shape, indices, shapeNormals, shapeColors, shapeUV, posfunc, vtxfunc);
|
|
|
// particles
|
|
|
var sp;
|
|
|
var currentCopy;
|
|
@@ -140967,10 +141118,12 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
}
|
|
|
this.nbParticles += nb;
|
|
|
this._shapeCounter++;
|
|
|
+ this._isNotBuilt = true; // buildMesh() is now expected for setParticles() to work
|
|
|
return this._shapeCounter - 1;
|
|
|
};
|
|
|
// rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
|
|
|
- SolidParticleSystem.prototype._rebuildParticle = function (particle) {
|
|
|
+ SolidParticleSystem.prototype._rebuildParticle = function (particle, reset) {
|
|
|
+ if (reset === void 0) { reset = false; }
|
|
|
this._resetCopy();
|
|
|
var copy = this._copy;
|
|
|
if (particle._model._positionFunction) { // recall to stored custom positionFunction
|
|
@@ -140999,30 +141152,82 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
|
|
|
tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
|
|
|
}
|
|
|
- particle.position.setAll(0.0);
|
|
|
- particle.rotation.setAll(0.0);
|
|
|
- particle.rotationQuaternion = null;
|
|
|
- particle.scaling.setAll(1.0);
|
|
|
- particle.uvs.setAll(0.0);
|
|
|
- particle.pivot.setAll(0.0);
|
|
|
- particle.translateFromPivot = false;
|
|
|
- particle.parentId = null;
|
|
|
+ if (reset) {
|
|
|
+ particle.position.setAll(0.0);
|
|
|
+ particle.rotation.setAll(0.0);
|
|
|
+ particle.rotationQuaternion = null;
|
|
|
+ particle.scaling.setAll(1.0);
|
|
|
+ particle.uvs.setAll(0.0);
|
|
|
+ particle.pivot.setAll(0.0);
|
|
|
+ particle.translateFromPivot = false;
|
|
|
+ particle.parentId = null;
|
|
|
+ }
|
|
|
};
|
|
|
/**
|
|
|
* Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
|
|
|
+ * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
|
|
|
* @returns the SPS.
|
|
|
*/
|
|
|
- SolidParticleSystem.prototype.rebuildMesh = function () {
|
|
|
+ SolidParticleSystem.prototype.rebuildMesh = function (reset) {
|
|
|
+ if (reset === void 0) { reset = false; }
|
|
|
for (var p = 0; p < this.particles.length; p++) {
|
|
|
- this._rebuildParticle(this.particles[p]);
|
|
|
+ this._rebuildParticle(this.particles[p], reset);
|
|
|
}
|
|
|
this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, this._positions32, false, false);
|
|
|
return this;
|
|
|
};
|
|
|
+ /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
|
|
|
+ * Returns an array with the removed particles.
|
|
|
+ * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
|
|
|
+ * The SPS can't be empty so at least one particle needs to remain in place.
|
|
|
+ * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
|
|
|
+ * @param start index of the first particle to remove
|
|
|
+ * @param end index of the last particle to remove (included)
|
|
|
+ * @returns an array populated with the removed particles
|
|
|
+ */
|
|
|
+ SolidParticleSystem.prototype.removeParticles = function (start, end) {
|
|
|
+ var nb = end - start + 1;
|
|
|
+ if (!this._expandable || nb <= 0 || nb >= this.nbParticles) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ var particles = this.particles;
|
|
|
+ var currentNb = this.nbParticles;
|
|
|
+ if (end < currentNb - 1) { // update the particle indexes in the positions array in case they're remaining particles after the last removed
|
|
|
+ var startPositionIndex = particles[start]._pos;
|
|
|
+ var firstRemaining = end + 1;
|
|
|
+ var shift = particles[firstRemaining]._pos - startPositionIndex;
|
|
|
+ for (var i = firstRemaining; i < currentNb; i++) {
|
|
|
+ particles[i]._pos -= shift;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var removed = particles.splice(start, nb);
|
|
|
+ this._positions.length = 0;
|
|
|
+ this._indices.length = 0;
|
|
|
+ this._colors.length = 0;
|
|
|
+ this._uvs.length = 0;
|
|
|
+ this._normals.length = 0;
|
|
|
+ this._index = 0;
|
|
|
+ var particlesLength = particles.length;
|
|
|
+ for (var p = 0; p < particlesLength; p++) {
|
|
|
+ var particle = particles[p];
|
|
|
+ var model = particle._model;
|
|
|
+ var shape = model._shape;
|
|
|
+ var modelIndices = model._indices;
|
|
|
+ var modelNormals = model._normals;
|
|
|
+ var modelColors = model._shapeColors;
|
|
|
+ var modelUVs = model._shapeUV;
|
|
|
+ this._meshBuilder(this._index, shape, this._positions, modelIndices, this._indices, modelUVs, this._uvs, modelColors, this._colors, modelNormals, this._normals, particle.idx, particle.idxInShape, null);
|
|
|
+ this._index += shape.length;
|
|
|
+ }
|
|
|
+ this.nbParticles -= nb;
|
|
|
+ this._isNotBuilt = true; // buildMesh() is now expected for setParticles() to work
|
|
|
+ return removed;
|
|
|
+ };
|
|
|
/**
|
|
|
* Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
|
|
|
* This method calls `updateParticle()` for each particle of the SPS.
|
|
|
* For an animated SPS, it is usually called within the render loop.
|
|
|
+ * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
|
|
|
* @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
|
|
|
* @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
|
|
|
* @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
|
|
@@ -141032,7 +141237,7 @@ var SolidParticleSystem = /** @class */ (function () {
|
|
|
if (start === void 0) { start = 0; }
|
|
|
if (end === void 0) { end = this.nbParticles - 1; }
|
|
|
if (update === void 0) { update = true; }
|
|
|
- if (!this._updatable) {
|
|
|
+ if (!this._updatable || this._isNotBuilt) {
|
|
|
return this;
|
|
|
}
|
|
|
// custom beforeUpdate
|
|
@@ -168227,17 +168432,20 @@ var Scene = /** @class */ (function (_super) {
|
|
|
* @returns the current scene
|
|
|
*/
|
|
|
Scene.prototype.freezeActiveMeshes = function () {
|
|
|
- if (!this.activeCamera) {
|
|
|
- return this;
|
|
|
- }
|
|
|
- if (!this._frustumPlanes) {
|
|
|
- this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
|
|
|
- }
|
|
|
- this._evaluateActiveMeshes();
|
|
|
- this._activeMeshesFrozen = true;
|
|
|
- for (var index = 0; index < this._activeMeshes.length; index++) {
|
|
|
- this._activeMeshes.data[index]._freeze();
|
|
|
- }
|
|
|
+ var _this = this;
|
|
|
+ this.executeWhenReady(function () {
|
|
|
+ if (!_this.activeCamera) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!_this._frustumPlanes) {
|
|
|
+ _this.setTransformMatrix(_this.activeCamera.getViewMatrix(), _this.activeCamera.getProjectionMatrix());
|
|
|
+ }
|
|
|
+ _this._evaluateActiveMeshes();
|
|
|
+ _this._activeMeshesFrozen = true;
|
|
|
+ for (var index = 0; index < _this._activeMeshes.length; index++) {
|
|
|
+ _this._activeMeshes.data[index]._freeze();
|
|
|
+ }
|
|
|
+ });
|
|
|
return this;
|
|
|
};
|
|
|
/**
|