|
@@ -23377,26 +23377,150 @@ var BABYLON;
|
|
|
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * Set of assets to keep when moving a scene into an asset container.
|
|
|
+ */
|
|
|
+ var KeepAssets = /** @class */ (function () {
|
|
|
+ function KeepAssets() {
|
|
|
+ /**
|
|
|
+ * Cameras to keep.
|
|
|
+ */
|
|
|
+ this.cameras = new Array();
|
|
|
+ /**
|
|
|
+ * Lights to keep.
|
|
|
+ */
|
|
|
+ this.lights = new Array();
|
|
|
+ /**
|
|
|
+ * Meshes to keep.
|
|
|
+ */
|
|
|
+ this.meshes = new Array();
|
|
|
+ /**
|
|
|
+ * Skeletons to keep.
|
|
|
+ */
|
|
|
+ this.skeletons = new Array();
|
|
|
+ /**
|
|
|
+ * ParticleSystems to keep.
|
|
|
+ */
|
|
|
+ this.particleSystems = new Array();
|
|
|
+ /**
|
|
|
+ * Animations to keep.
|
|
|
+ */
|
|
|
+ this.animations = new Array();
|
|
|
+ /**
|
|
|
+ * MultiMaterials to keep.
|
|
|
+ */
|
|
|
+ this.multiMaterials = new Array();
|
|
|
+ /**
|
|
|
+ * Materials to keep.
|
|
|
+ */
|
|
|
+ this.materials = new Array();
|
|
|
+ /**
|
|
|
+ * MorphTargetManagers to keep.
|
|
|
+ */
|
|
|
+ this.morphTargetManagers = new Array();
|
|
|
+ /**
|
|
|
+ * Geometries to keep.
|
|
|
+ */
|
|
|
+ this.geometries = new Array();
|
|
|
+ /**
|
|
|
+ * TransformNodes to keep.
|
|
|
+ */
|
|
|
+ this.transformNodes = new Array();
|
|
|
+ /**
|
|
|
+ * LensFlareSystems to keep.
|
|
|
+ */
|
|
|
+ this.lensFlareSystems = new Array();
|
|
|
+ /**
|
|
|
+ * ShadowGenerators to keep.
|
|
|
+ */
|
|
|
+ this.shadowGenerators = new Array();
|
|
|
+ /**
|
|
|
+ * ActionManagers to keep.
|
|
|
+ */
|
|
|
+ this.actionManagers = new Array();
|
|
|
+ /**
|
|
|
+ * Sounds to keep.
|
|
|
+ */
|
|
|
+ this.sounds = new Array();
|
|
|
+ }
|
|
|
+ return KeepAssets;
|
|
|
+ }());
|
|
|
+ BABYLON.KeepAssets = KeepAssets;
|
|
|
+ /**
|
|
|
+ * Container with a set of assets that can be added or removed from a scene.
|
|
|
+ */
|
|
|
var AssetContainer = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Instantiates an AssetContainer.
|
|
|
+ * @param scene The scene the AssetContainer belongs to.
|
|
|
+ */
|
|
|
function AssetContainer(scene) {
|
|
|
// Objects
|
|
|
+ /**
|
|
|
+ * Cameras populated in the container.
|
|
|
+ */
|
|
|
this.cameras = new Array();
|
|
|
+ /**
|
|
|
+ * Lights populated in the container.
|
|
|
+ */
|
|
|
this.lights = new Array();
|
|
|
+ /**
|
|
|
+ * Meshes populated in the container.
|
|
|
+ */
|
|
|
this.meshes = new Array();
|
|
|
+ /**
|
|
|
+ * Skeletons populated in the container.
|
|
|
+ */
|
|
|
this.skeletons = new Array();
|
|
|
+ /**
|
|
|
+ * ParticleSystems populated in the container.
|
|
|
+ */
|
|
|
this.particleSystems = new Array();
|
|
|
+ /**
|
|
|
+ * Animations populated in the container.
|
|
|
+ */
|
|
|
this.animations = new Array();
|
|
|
+ /**
|
|
|
+ * MultiMaterials populated in the container.
|
|
|
+ */
|
|
|
this.multiMaterials = new Array();
|
|
|
+ /**
|
|
|
+ * Materials populated in the container.
|
|
|
+ */
|
|
|
this.materials = new Array();
|
|
|
+ /**
|
|
|
+ * MorphTargetManagers populated in the container.
|
|
|
+ */
|
|
|
this.morphTargetManagers = new Array();
|
|
|
+ /**
|
|
|
+ * Geometries populated in the container.
|
|
|
+ */
|
|
|
this.geometries = new Array();
|
|
|
+ /**
|
|
|
+ * TransformNodes populated in the container.
|
|
|
+ */
|
|
|
this.transformNodes = new Array();
|
|
|
+ /**
|
|
|
+ * LensFlareSystems populated in the container.
|
|
|
+ */
|
|
|
this.lensFlareSystems = new Array();
|
|
|
+ /**
|
|
|
+ * ShadowGenerators populated in the container.
|
|
|
+ */
|
|
|
this.shadowGenerators = new Array();
|
|
|
+ /**
|
|
|
+ * ActionManagers populated in the container.
|
|
|
+ */
|
|
|
this.actionManagers = new Array();
|
|
|
+ /**
|
|
|
+ * Sounds populated in the container.
|
|
|
+ */
|
|
|
this.sounds = new Array();
|
|
|
this.scene = scene;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Adds all the assets from the container to the scene.
|
|
|
+ */
|
|
|
AssetContainer.prototype.addAllToScene = function () {
|
|
|
var _this = this;
|
|
|
this.cameras.forEach(function (o) {
|
|
@@ -23444,6 +23568,9 @@ var BABYLON;
|
|
|
_this.scene.mainSoundTrack.AddSound(o);
|
|
|
});
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Removes all the assets in the container from the scene
|
|
|
+ */
|
|
|
AssetContainer.prototype.removeAllFromScene = function () {
|
|
|
var _this = this;
|
|
|
this.cameras.forEach(function (o) {
|
|
@@ -23491,6 +23618,46 @@ var BABYLON;
|
|
|
_this.scene.mainSoundTrack.RemoveSound(o);
|
|
|
});
|
|
|
};
|
|
|
+ AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
|
|
|
+ for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
|
|
|
+ var asset = sourceAssets_1[_i];
|
|
|
+ var move = true;
|
|
|
+ for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
|
|
|
+ var keepAsset = keepAssets_1[_a];
|
|
|
+ if (asset === keepAsset) {
|
|
|
+ move = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (move) {
|
|
|
+ targetAssets.push(asset);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Removes all the assets contained in the scene and adds them to the container.
|
|
|
+ * @param keepAssets Set of assets to keep in the scene. (default: empty)
|
|
|
+ */
|
|
|
+ AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
|
|
|
+ if (keepAssets === undefined) {
|
|
|
+ keepAssets = new KeepAssets();
|
|
|
+ }
|
|
|
+ this._moveAssets(this.scene.cameras, this.cameras, keepAssets.cameras);
|
|
|
+ this._moveAssets(this.scene.meshes, this.meshes, keepAssets.meshes);
|
|
|
+ this._moveAssets(this.scene.getGeometries(), this.geometries, keepAssets.geometries);
|
|
|
+ this._moveAssets(this.scene.materials, this.materials, keepAssets.materials);
|
|
|
+ Array.prototype.push.apply(this.actionManagers, this.scene._actionManagers);
|
|
|
+ Array.prototype.push.apply(this.animations, this.scene.animations);
|
|
|
+ Array.prototype.push.apply(this.lensFlareSystems, this.scene.lensFlareSystems);
|
|
|
+ Array.prototype.push.apply(this.lights, this.scene.lights);
|
|
|
+ Array.prototype.push.apply(this.morphTargetManagers, this.scene.morphTargetManagers);
|
|
|
+ Array.prototype.push.apply(this.multiMaterials, this.scene.multiMaterials);
|
|
|
+ Array.prototype.push.apply(this.skeletons, this.scene.skeletons);
|
|
|
+ Array.prototype.push.apply(this.particleSystems, this.scene.particleSystems);
|
|
|
+ Array.prototype.push.apply(this.sounds, this.scene.mainSoundTrack.soundCollection);
|
|
|
+ Array.prototype.push.apply(this.transformNodes, this.scene.transformNodes);
|
|
|
+ this.removeAllFromScene();
|
|
|
+ };
|
|
|
return AssetContainer;
|
|
|
}());
|
|
|
BABYLON.AssetContainer = AssetContainer;
|
|
@@ -25274,6 +25441,13 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ /**
|
|
|
+ * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
|
|
|
+ * @returns an array of {BABYLON.MeshLODLevel}
|
|
|
+ */
|
|
|
+ Mesh.prototype.getLODLevels = function () {
|
|
|
+ return this._LODLevels;
|
|
|
+ };
|
|
|
Mesh.prototype._sortLODLevels = function () {
|
|
|
this._LODLevels.sort(function (a, b) {
|
|
|
if (a.distance < b.distance) {
|