1 |
- {"ast":null,"code":"import { ThinBlurPostProcess } from \"./thinBlurPostProcess.js\";\nimport { ThinCircleOfConfusionPostProcess } from \"./thinCircleOfConfusionPostProcess.js\";\nimport { ThinDepthOfFieldMergePostProcess } from \"./thinDepthOfFieldMergePostProcess.js\";\nimport { Vector2 } from \"../Maths/math.vector.js\";\n/**\n * Specifies the level of blur that should be applied when using the depth of field effect\n */\nexport var ThinDepthOfFieldEffectBlurLevel;\n(function (ThinDepthOfFieldEffectBlurLevel) {\n /**\n * Subtle blur\n */\n ThinDepthOfFieldEffectBlurLevel[ThinDepthOfFieldEffectBlurLevel[\"Low\"] = 0] = \"Low\";\n /**\n * Medium blur\n */\n ThinDepthOfFieldEffectBlurLevel[ThinDepthOfFieldEffectBlurLevel[\"Medium\"] = 1] = \"Medium\";\n /**\n * Large blur\n */\n ThinDepthOfFieldEffectBlurLevel[ThinDepthOfFieldEffectBlurLevel[\"High\"] = 2] = \"High\";\n})(ThinDepthOfFieldEffectBlurLevel || (ThinDepthOfFieldEffectBlurLevel = {}));\nexport class ThinDepthOfFieldEffect {\n /**\n * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)\n */\n set focalLength(value) {\n this._circleOfConfusion.focalLength = value;\n }\n get focalLength() {\n return this._circleOfConfusion.focalLength;\n }\n /**\n * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)\n */\n set fStop(value) {\n this._circleOfConfusion.fStop = value;\n }\n get fStop() {\n return this._circleOfConfusion.fStop;\n }\n /**\n * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)\n */\n set focusDistance(value) {\n this._circleOfConfusion.focusDistance = value;\n }\n get focusDistance() {\n return this._circleOfConfusion.focusDistance;\n }\n /**\n * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.\n */\n set lensSize(value) {\n this._circleOfConfusion.lensSize = value;\n }\n get lensSize() {\n return this._circleOfConfusion.lensSize;\n }\n /**\n * Creates a new instance of @see ThinDepthOfFieldEffect\n * @param name The name of the depth of field render effect\n * @param engine The engine which the render effect will be applied. (default: current engine)\n * @param blurLevel The quality of the effect. (default: DepthOfFieldEffectBlurLevel.Low)\n * @param depthNotNormalized If the (view) depth used in circle of confusion post-process is normalized (0.0 to 1.0 from near to far) or not (0 to camera max distance) (default: false)\n * @param blockCompilation If shaders should not be compiled when the effect is created (default: false)\n */\n constructor(name, engine, blurLevel = 0 /* ThinDepthOfFieldEffectBlurLevel.Low */, depthNotNormalized = false, blockCompilation = false) {\n /** @internal */\n this._depthOfFieldBlurX = [];\n /** @internal */\n this._depthOfFieldBlurY = [];\n this._circleOfConfusion = new ThinCircleOfConfusionPostProcess(name, engine, {\n depthNotNormalized,\n blockCompilation\n });\n this.blurLevel = blurLevel;\n let blurCount = 1;\n let kernelSize = 15;\n switch (blurLevel) {\n case 2 /* ThinDepthOfFieldEffectBlurLevel.High */:\n {\n blurCount = 3;\n kernelSize = 51;\n break;\n }\n case 1 /* ThinDepthOfFieldEffectBlurLevel.Medium */:\n {\n blurCount = 2;\n kernelSize = 31;\n break;\n }\n default:\n {\n kernelSize = 15;\n blurCount = 1;\n break;\n }\n }\n const adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);\n let ratio = 1.0;\n for (let i = 0; i < blurCount; i++) {\n this._depthOfFieldBlurY.push([new ThinBlurPostProcess(name, engine, new Vector2(0, 1), adjustedKernelSize, {\n blockCompilation\n }), ratio]);\n ratio = 0.75 / Math.pow(2, i);\n this._depthOfFieldBlurX.push([new ThinBlurPostProcess(name, engine, new Vector2(1, 0), adjustedKernelSize, {\n blockCompilation\n }), ratio]);\n }\n this._dofMerge = new ThinDepthOfFieldMergePostProcess(name, engine, {\n blockCompilation\n });\n }\n /**\n * Checks if the effect is ready to be used\n * @returns if the effect is ready\n */\n isReady() {\n let isReady = this._circleOfConfusion.isReady() && this._dofMerge.isReady();\n for (let i = 0; i < this._depthOfFieldBlurX.length; i++) {\n isReady = isReady && this._depthOfFieldBlurX[i][0].isReady() && this._depthOfFieldBlurY[i][0].isReady();\n }\n return isReady;\n }\n}","map":{"version":3,"names":["ThinBlurPostProcess","ThinCircleOfConfusionPostProcess","ThinDepthOfFieldMergePostProcess","Vector2","ThinDepthOfFieldEffectBlurLevel","ThinDepthOfFieldEffect","focalLength","value","_circleOfConfusion","fStop","focusDistance","lensSize","constructor","name","engine","blurLevel","depthNotNormalized","blockCompilation","_depthOfFieldBlurX","_depthOfFieldBlurY","blurCount","kernelSize","adjustedKernelSize","Math","pow","ratio","i","push","_dofMerge","isReady","length"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/PostProcesses/thinDepthOfFieldEffect.js"],"sourcesContent":["import { ThinBlurPostProcess } from \"./thinBlurPostProcess.js\";\nimport { ThinCircleOfConfusionPostProcess } from \"./thinCircleOfConfusionPostProcess.js\";\nimport { ThinDepthOfFieldMergePostProcess } from \"./thinDepthOfFieldMergePostProcess.js\";\nimport { Vector2 } from \"../Maths/math.vector.js\";\n/**\n * Specifies the level of blur that should be applied when using the depth of field effect\n */\nexport var ThinDepthOfFieldEffectBlurLevel;\n(function (ThinDepthOfFieldEffectBlurLevel) {\n /**\n * Subtle blur\n */\n ThinDepthOfFieldEffectBlurLevel[ThinDepthOfFieldEffectBlurLevel[\"Low\"] = 0] = \"Low\";\n /**\n * Medium blur\n */\n ThinDepthOfFieldEffectBlurLevel[ThinDepthOfFieldEffectBlurLevel[\"Medium\"] = 1] = \"Medium\";\n /**\n * Large blur\n */\n ThinDepthOfFieldEffectBlurLevel[ThinDepthOfFieldEffectBlurLevel[\"High\"] = 2] = \"High\";\n})(ThinDepthOfFieldEffectBlurLevel || (ThinDepthOfFieldEffectBlurLevel = {}));\nexport class ThinDepthOfFieldEffect {\n /**\n * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)\n */\n set focalLength(value) {\n this._circleOfConfusion.focalLength = value;\n }\n get focalLength() {\n return this._circleOfConfusion.focalLength;\n }\n /**\n * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)\n */\n set fStop(value) {\n this._circleOfConfusion.fStop = value;\n }\n get fStop() {\n return this._circleOfConfusion.fStop;\n }\n /**\n * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)\n */\n set focusDistance(value) {\n this._circleOfConfusion.focusDistance = value;\n }\n get focusDistance() {\n return this._circleOfConfusion.focusDistance;\n }\n /**\n * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.\n */\n set lensSize(value) {\n this._circleOfConfusion.lensSize = value;\n }\n get lensSize() {\n return this._circleOfConfusion.lensSize;\n }\n /**\n * Creates a new instance of @see ThinDepthOfFieldEffect\n * @param name The name of the depth of field render effect\n * @param engine The engine which the render effect will be applied. (default: current engine)\n * @param blurLevel The quality of the effect. (default: DepthOfFieldEffectBlurLevel.Low)\n * @param depthNotNormalized If the (view) depth used in circle of confusion post-process is normalized (0.0 to 1.0 from near to far) or not (0 to camera max distance) (default: false)\n * @param blockCompilation If shaders should not be compiled when the effect is created (default: false)\n */\n constructor(name, engine, blurLevel = 0 /* ThinDepthOfFieldEffectBlurLevel.Low */, depthNotNormalized = false, blockCompilation = false) {\n /** @internal */\n this._depthOfFieldBlurX = [];\n /** @internal */\n this._depthOfFieldBlurY = [];\n this._circleOfConfusion = new ThinCircleOfConfusionPostProcess(name, engine, { depthNotNormalized, blockCompilation });\n this.blurLevel = blurLevel;\n let blurCount = 1;\n let kernelSize = 15;\n switch (blurLevel) {\n case 2 /* ThinDepthOfFieldEffectBlurLevel.High */: {\n blurCount = 3;\n kernelSize = 51;\n break;\n }\n case 1 /* ThinDepthOfFieldEffectBlurLevel.Medium */: {\n blurCount = 2;\n kernelSize = 31;\n break;\n }\n default: {\n kernelSize = 15;\n blurCount = 1;\n break;\n }\n }\n const adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);\n let ratio = 1.0;\n for (let i = 0; i < blurCount; i++) {\n this._depthOfFieldBlurY.push([new ThinBlurPostProcess(name, engine, new Vector2(0, 1), adjustedKernelSize, { blockCompilation }), ratio]);\n ratio = 0.75 / Math.pow(2, i);\n this._depthOfFieldBlurX.push([new ThinBlurPostProcess(name, engine, new Vector2(1, 0), adjustedKernelSize, { blockCompilation }), ratio]);\n }\n this._dofMerge = new ThinDepthOfFieldMergePostProcess(name, engine, { blockCompilation });\n }\n /**\n * Checks if the effect is ready to be used\n * @returns if the effect is ready\n */\n isReady() {\n let isReady = this._circleOfConfusion.isReady() && this._dofMerge.isReady();\n for (let i = 0; i < this._depthOfFieldBlurX.length; i++) {\n isReady = isReady && this._depthOfFieldBlurX[i][0].isReady() && this._depthOfFieldBlurY[i][0].isReady();\n }\n return isReady;\n }\n}\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,gCAAgC,QAAQ,uCAAuC;AACxF,SAASC,gCAAgC,QAAQ,uCAAuC;AACxF,SAASC,OAAO,QAAQ,yBAAyB;AACjD;AACA;AACA;AACA,OAAO,IAAIC,+BAA+B;AAC1C,CAAC,UAAUA,+BAA+B,EAAE;EACxC;AACJ;AACA;EACIA,+BAA+B,CAACA,+BAA+B,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK;EACnF;AACJ;AACA;EACIA,+BAA+B,CAACA,+BAA+B,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ;EACzF;AACJ;AACA;EACIA,+BAA+B,CAACA,+BAA+B,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;AACzF,CAAC,EAAEA,+BAA+B,KAAKA,+BAA+B,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7E,OAAO,MAAMC,sBAAsB,CAAC;EAChC;AACJ;AACA;EACI,IAAIC,WAAWA,CAACC,KAAK,EAAE;IACnB,IAAI,CAACC,kBAAkB,CAAC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