BABYLON.AssetContainer.prototype.clone = function(d, o=!0, s, c=!0) { const _ = new BABYLON.AssetContainer(this.scene); d || (d = ""); const b = tt=>d + "_CloneOf_" + tt , k = {} , j = {} , $ = [] , _e = []; s || (s = { doNotInstantiate: !0 }); const et = (tt,rt)=>{ if (k[tt.uniqueId] = rt.uniqueId, j[rt.uniqueId] = rt, b && (rt.name = b(tt.name)), rt instanceof Mesh) { const it = rt; if (_.meshes.push(rt), rt.geometry && _.geometries.push(rt.geometry), it.morphTargetManager) { const nt = tt.morphTargetManager; it.morphTargetManager = nt.clone(), _.morphTargetManagers.push(it.morphTargetManager); for (let at = 0; at < nt.numTargets; at++) { const ot = nt.getTarget(at) , st = it.morphTargetManager.getTarget(at); k[ot.uniqueId] = st.uniqueId, j[st.uniqueId] = st } } } else rt instanceof TransformNode && _.transformNodes.push(rt) } ; return this.transformNodes.forEach(tt=>{ if (!tt.parent) { const rt = tt.instantiateHierarchy(null, s, (it,nt)=>{ et(it, nt) } ); rt && _.rootNodes.push(rt) } } ), this.meshes.forEach(tt=>{ if (!tt.parent) { const rt = tt.instantiateHierarchy(null, s, (it,nt)=>{ if (et(it, nt), nt.material) { const at = nt; if (at.material) if (o) { const ot = it.material; if (_e.indexOf(ot) === -1) { let st = ot.clone(b ? b(ot.name) : "Clone of " + ot.name); if (_.materials.push(st), _e.push(ot), k[ot.uniqueId] = st.uniqueId, j[st.uniqueId] = st, ot.getClassName() === "MultiMaterial") { const lt = ot; for (const ut of lt.subMaterials) !ut || (st = ut.clone(b ? b(ut.name) : "Clone of " + ut.name), _e.push(ut), k[ut.uniqueId] = st.uniqueId, j[st.uniqueId] = st); lt.subMaterials = lt.subMaterials.map(ut=>ut && j[k[ut.uniqueId]]), _.multiMaterials.push(lt) } } at.getClassName() !== "InstancedMesh" && (at.material = j[k[ot.uniqueId]]) } else at.material.getClassName() === "MultiMaterial" ? (this.scene.multiMaterials.indexOf(at.material) === -1 && this.scene.addMultiMaterial(at.material), _.multiMaterials.indexOf(at.material) === -1 && _.multiMaterials.push(at.material)) : (this.scene.materials.indexOf(at.material) === -1 && this.scene.addMaterial(at.material), _.materials.indexOf(at.material) === -1 && _.materials.push(at.material)) } } ); rt && _.rootNodes.push(rt) } } ), this.skeletons.forEach(tt=>{ const rt = tt.clone(b ? b(tt.name) : "Clone of " + tt.name); tt.overrideMesh && (rt.overrideMesh = j[k[tt.overrideMesh.uniqueId]]); for (const it of this.meshes) if (it.skeleton === tt && !it.isAnInstance) { const nt = j[k[it.uniqueId]]; if (nt.isAnInstance || (nt.skeleton = rt, $.indexOf(rt) !== -1)) continue; $.push(rt); for (const at of rt.bones) at._linkedTransformNode && (at._linkedTransformNode = j[k[at._linkedTransformNode.uniqueId]]) } _.skeletons.push(rt) } ), this.animationGroups.forEach(tt=>{ const rt = tt.clone(tt.name, it=>j[k[it.uniqueId]] || it, c); _.animationGroups.push(rt) } ), this.textures.forEach(tt=>{ const rt = tt.clone(); rt && _.textures.push(rt) } ), this.cameras.forEach(tt=>{ _.cameras.push(tt.clone(b(tt.name))) } ), this.lights.forEach(tt=>{ const rt = tt.clone(b(tt.name)); rt && _.lights.push(rt) } ), _ } ; BABYLON.AssetContainer.prototype.GetName = function() { return this._name || (this._name = ""), this._name } ; BABYLON.AssetContainer.prototype.SetName = function(d) { this._name = d } ; BABYLON.AssetContainer.prototype.GetRootNode = function() { return this._rootNode || (this._rootNode = this.meshes[0]), this._rootNode } ; BABYLON.AssetContainer.prototype.CreateRootNodeByName = function(d) { const o = new Mesh("BABYLON.AssetContainerRootMesh_" + d,this.scene); return this.meshes.forEach(s=>{ s.parent || o.addChild(s) } ), this.meshes.unshift(o), o } ; BABYLON.AssetContainer.prototype.GetMeshesWithoutParent = function() { const d = new Array; return this.meshes.forEach(o=>{ o.parent || d.push(o) } ), d } ; BABYLON.AssetContainer.prototype.GetOwner = function() { return this._owner } ; BABYLON.AssetContainer.prototype.SetOwner = function(d) { this._owner || (this._owner = new XObject), this._owner = d } ; BABYLON.AssetContainer.prototype.toJSON = function() { const d = this.GetOwner() , o = d == null ? void 0 : d.outer; return o ? o.SaveAsset(this) : "" } ; BABYLON.AssetContainer.prototype.getClassName = function() { return "BABYLON.AssetContainer" } ; function CreateScreenshot(d, o, s, c, _="image/png", b=!1) { const {height: k, width: j} = _getScreenshotSize(d, o, s); if (console.info("[Engine]CreateScreenshot!"), !(k && j)) { console.error("[Engine]CreateScreenshot Invalid 'size' parameter !"); return } BABYLON.Tools._ScreenshotCanvas || (BABYLON.Tools._ScreenshotCanvas = document.createElement("canvas")), BABYLON.Tools._ScreenshotCanvas.width = j, BABYLON.Tools._ScreenshotCanvas.height = k; const $ = BABYLON.Tools._ScreenshotCanvas.getContext("2d") , _e = d.getRenderWidth() / d.getRenderHeight(); let et = j , tt = et / _e; tt > k && (tt = k, et = tt * _e); const rt = Math.max(0, j - et) / 2 , it = Math.max(0, k - tt) / 2; o.getScene().onAfterRenderObservable.addOnce(function() { const at = d.getRenderingCanvas(); $ && at ? $.drawImage(at, rt, it, et, tt) : console.error("[Engine]CreateScreenshot Invalid renderContext and renderingCanvas!"), b ? (BABYLON.Tools.EncodeScreenshotCanvasData(void 0, _), c && c("")) : BABYLON.Tools.EncodeScreenshotCanvasData(c, _) }) } function CreateScreenshotAsync(d, o, s, c="image/png") { return new Promise((_,b)=>{ CreateScreenshot(d, o, s, k=>{ typeof k != "undefined" ? _(k) : b(new Error("Data is undefined")) } , c) } ) } function CreateScreenshotUsingRenderTarget(d, o, s, c, _="image/png", b=1, k=!1, j, $=!1, _e=!1) { const {height: et, width: tt} = _getScreenshotSize(d, o, s) , rt = { width: tt, height: et }; if (!(et && tt)) { console.error("Invalid 'size' parameter !"); return } const it = o.getScene(); let nt = null; const at = it.activeCameras; it.activeCameras = null, it.activeCamera !== o && (nt = it.activeCamera, it.activeCamera = o), it.render(); const ot = new RenderTargetTexture("screenShot",rt,it,!1,!1,Constants.TEXTURETYPE_UNSIGNED_INT,!1,Texture.NEAREST_SAMPLINGMODE,void 0,_e,void 0,void 0,void 0,b); ot.renderList = null, ot.samples = b, ot.renderSprites = $, it.onAfterRenderTargetsRenderObservable.addOnce(function() { ot.readPixels(void 0, void 0, void 0, !1).then(lt=>{ BABYLON.Tools.DumpData(tt, et, lt, c, _, j, !0), ot.dispose() } ) }); const st = ()=>{ it.incrementRenderId(), it.resetCachedMaterial(), ot.render(!0), it.incrementRenderId(), it.resetCachedMaterial(), nt && (it.activeCamera = nt), it.activeCameras = at, o.getProjectionMatrix(!0), it.render() } ; if (k) { const lt = new FxaaPostProcess("antialiasing",1,it.activeCamera); ot.addPostProcess(lt), lt.getEffect().isReady() ? st() : lt.getEffect().onCompiled = ()=>{ st() } } else st() } function CreateScreenshotUsingRenderTargetAsync(d, o, s, c="image/png", _=1, b=!1, k, j=!1) { return new Promise(($,_e)=>{ CreateScreenshotUsingRenderTarget(d, o, s, et=>{ typeof et != "undefined" ? $(et) : _e(new Error("Data is undefined")) } , c, _, b, k, j) } ) } function _getScreenshotSize(d, o, s) { let c = 0 , _ = 0; if (typeof s == "object") { const b = s.precision ? Math.abs(s.precision) : 1; s.width && s.height ? (c = s.height * b, _ = s.width * b) : s.width && !s.height ? (_ = s.width * b, c = Math.round(_ / d.getAspectRatio(o))) : s.height && !s.width ? (c = s.height * b, _ = Math.round(c * d.getAspectRatio(o))) : (_ = Math.round(d.getRenderWidth() * b), c = Math.round(_ / d.getAspectRatio(o))) } else isNaN(s) || (c = s, _ = s); return _ && (_ = Math.floor(_)), c && (c = Math.floor(c)), { height: c | 0, width: _ | 0 } } const initSideEffects = ()=>{ BABYLON.Tools.CreateScreenshot = CreateScreenshot, BABYLON.Tools.CreateScreenshotAsync = CreateScreenshotAsync, BABYLON.Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget, BABYLON.Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync } ; BABYLON.ParticleSystem.prototype.isReady = function() { if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady()) return !1; if (this.blendMode !== BABYLON.ParticleSystem.BLENDMODE_MULTIPLYADD) { if (!this._getWrapper(this.blendMode).effect.isReady()) return !1 } else if (!this._getWrapper(BABYLON.ParticleSystem.BLENDMODE_MULTIPLY).effect.isReady() || !this._getWrapper(BABYLON.ParticleSystem.BLENDMODE_ADD).effect.isReady()) return !1; return !0 } ; function LinearBezierCurves(d, o, s) { return BABYLON.Vector3.Lerp(o, s, 1 - d) } function QuadraticBezierCurves(d, o, s, c) { const _ = LinearBezierCurves(d, o, s) , b = LinearBezierCurves(d, s, c); return LinearBezierCurves(d, _, b) } function CubicBezierCurves(d, o, s, c, _) { const b = QuadraticBezierCurves(d, o, s, c) , k = QuadraticBezierCurves(d, s, c, _); return LinearBezierCurves(d, b, k) } function CardinalMultiply(d, o, s, c, _, b) { const k = d[0] * o + d[1] * s + d[2] * c + d[3] * _ , j = d[4] * o + d[5] * s + d[6] * c + d[7] * _ , $ = d[8] * o + d[9] * s + d[10] * c + d[11] * _; return d[12] * o + d[13] * s + d[14] * c + d[15] * _ + b * ($ + b * (j + b * k)) } function CardinalCurves(d, o, s, c, _, b) { const k = new Array(16) , j = b; return k[0] = -j, k[1] = 2 - j, k[2] = j - 2, k[3] = j, k[4] = 2 * j, k[5] = j - 3, k[8] = -j, k[9] = 0, k[12] = 0, k[13] = 1, k[6] = 3 - 2 * j, k[7] = -j, k[10] = j, k[11] = 0, k[14] = 0, k[15] = 0, new BABYLON.Vector3(CardinalMultiply(k, o.x, s.x, c.x, _.x, d),CardinalMultiply(k, o.y, s.y, c.y, _.x, d),CardinalMultiply(k, o.z, s.z, c.z, _.x, d)) } function HermiteCurves(d, o, s, c, _) { const b = Math.pow(d, 3) , k = Math.pow(d, 2) , j = 2 * b - 3 * k + 1 , $ = -2 * b + 3 * k , _e = b - 2 * k + d , et = b - k , tt = o.multiplyByFloats(j, j, j) , rt = s.multiplyByFloats($, $, $) , it = c.multiplyByFloats(_e, _e, _e) , nt = _.multiplyByFloats(et, et, et); return tt.add(rt.add(it).add(nt)) }