@combeenation/3d-viewer 5.2.0-alpha4 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/lib-cjs/api/classes/dottedPath.js +1 -1
  2. package/dist/lib-cjs/api/classes/dottedPath.js.map +1 -1
  3. package/dist/lib-cjs/api/classes/element.js +3 -2
  4. package/dist/lib-cjs/api/classes/element.js.map +1 -1
  5. package/dist/lib-cjs/api/classes/parameter.d.ts +6 -3
  6. package/dist/lib-cjs/api/classes/parameter.js +8 -5
  7. package/dist/lib-cjs/api/classes/parameter.js.map +1 -1
  8. package/dist/lib-cjs/api/classes/placementAnimation.js +2 -1
  9. package/dist/lib-cjs/api/classes/placementAnimation.js.map +1 -1
  10. package/dist/lib-cjs/api/classes/variant.d.ts +1 -1
  11. package/dist/lib-cjs/api/classes/variant.js +7 -7
  12. package/dist/lib-cjs/api/classes/variant.js.map +1 -1
  13. package/dist/lib-cjs/api/classes/variantInstance.d.ts +0 -1
  14. package/dist/lib-cjs/api/classes/variantInstance.js +27 -23
  15. package/dist/lib-cjs/api/classes/variantInstance.js.map +1 -1
  16. package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +2 -2
  17. package/dist/lib-cjs/api/classes/variantParameterizable.js +2 -2
  18. package/dist/lib-cjs/api/classes/viewer.d.ts +4 -2
  19. package/dist/lib-cjs/api/classes/viewer.js +6 -5
  20. package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
  21. package/dist/lib-cjs/api/classes/viewerLight.js +14 -9
  22. package/dist/lib-cjs/api/classes/viewerLight.js.map +1 -1
  23. package/dist/lib-cjs/api/internal/sceneSetup.js +5 -4
  24. package/dist/lib-cjs/api/internal/sceneSetup.js.map +1 -1
  25. package/dist/lib-cjs/api/manager/animationManager.js +3 -3
  26. package/dist/lib-cjs/api/manager/animationManager.js.map +1 -1
  27. package/dist/lib-cjs/api/manager/gltfExportManager.d.ts +2 -2
  28. package/dist/lib-cjs/api/manager/gltfExportManager.js +5 -4
  29. package/dist/lib-cjs/api/manager/gltfExportManager.js.map +1 -1
  30. package/dist/lib-cjs/api/util/babylonHelper.js +20 -26
  31. package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
  32. package/dist/lib-cjs/api/util/globalTypes.d.ts +11 -7
  33. package/dist/lib-cjs/api/util/resourceHelper.js +5 -3
  34. package/dist/lib-cjs/api/util/resourceHelper.js.map +1 -1
  35. package/dist/lib-cjs/api/util/sceneLoaderHelper.d.ts +2 -2
  36. package/dist/lib-cjs/api/util/sceneLoaderHelper.js +5 -7
  37. package/dist/lib-cjs/api/util/sceneLoaderHelper.js.map +1 -1
  38. package/dist/lib-cjs/api/util/stringHelper.d.ts +1 -1
  39. package/dist/lib-cjs/api/util/stringHelper.js +4 -2
  40. package/dist/lib-cjs/api/util/stringHelper.js.map +1 -1
  41. package/dist/lib-cjs/buildinfo.json +1 -1
  42. package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -0
  43. package/dist/lib-es6/api/classes/dottedPath.js +1 -1
  44. package/dist/lib-es6/api/classes/dottedPath.js.map +1 -1
  45. package/dist/lib-es6/api/classes/element.js +5 -4
  46. package/dist/lib-es6/api/classes/element.js.map +1 -1
  47. package/dist/lib-es6/api/classes/parameter.d.ts +6 -3
  48. package/dist/lib-es6/api/classes/parameter.js +8 -5
  49. package/dist/lib-es6/api/classes/parameter.js.map +1 -1
  50. package/dist/lib-es6/api/classes/placementAnimation.js +2 -1
  51. package/dist/lib-es6/api/classes/placementAnimation.js.map +1 -1
  52. package/dist/lib-es6/api/classes/variant.d.ts +1 -1
  53. package/dist/lib-es6/api/classes/variant.js +9 -9
  54. package/dist/lib-es6/api/classes/variant.js.map +1 -1
  55. package/dist/lib-es6/api/classes/variantInstance.d.ts +0 -1
  56. package/dist/lib-es6/api/classes/variantInstance.js +27 -23
  57. package/dist/lib-es6/api/classes/variantInstance.js.map +1 -1
  58. package/dist/lib-es6/api/classes/variantParameterizable.d.ts +2 -2
  59. package/dist/lib-es6/api/classes/variantParameterizable.js +2 -2
  60. package/dist/lib-es6/api/classes/viewer.d.ts +4 -2
  61. package/dist/lib-es6/api/classes/viewer.js +6 -5
  62. package/dist/lib-es6/api/classes/viewer.js.map +1 -1
  63. package/dist/lib-es6/api/classes/viewerLight.js +14 -9
  64. package/dist/lib-es6/api/classes/viewerLight.js.map +1 -1
  65. package/dist/lib-es6/api/internal/sceneSetup.js +5 -4
  66. package/dist/lib-es6/api/internal/sceneSetup.js.map +1 -1
  67. package/dist/lib-es6/api/manager/animationManager.js +3 -3
  68. package/dist/lib-es6/api/manager/animationManager.js.map +1 -1
  69. package/dist/lib-es6/api/manager/gltfExportManager.d.ts +2 -2
  70. package/dist/lib-es6/api/manager/gltfExportManager.js +5 -4
  71. package/dist/lib-es6/api/manager/gltfExportManager.js.map +1 -1
  72. package/dist/lib-es6/api/manager/sceneManager.js +1 -1
  73. package/dist/lib-es6/api/manager/sceneManager.js.map +1 -1
  74. package/dist/lib-es6/api/util/babylonHelper.js +20 -26
  75. package/dist/lib-es6/api/util/babylonHelper.js.map +1 -1
  76. package/dist/lib-es6/api/util/globalTypes.d.ts +11 -7
  77. package/dist/lib-es6/api/util/resourceHelper.js +5 -3
  78. package/dist/lib-es6/api/util/resourceHelper.js.map +1 -1
  79. package/dist/lib-es6/api/util/sceneLoaderHelper.d.ts +2 -2
  80. package/dist/lib-es6/api/util/sceneLoaderHelper.js +4 -6
  81. package/dist/lib-es6/api/util/sceneLoaderHelper.js.map +1 -1
  82. package/dist/lib-es6/api/util/stringHelper.d.ts +1 -1
  83. package/dist/lib-es6/api/util/stringHelper.js +4 -2
  84. package/dist/lib-es6/api/util/stringHelper.js.map +1 -1
  85. package/dist/lib-es6/buildinfo.json +1 -1
  86. package/dist/lib-es6/es6.tsconfig.tsbuildinfo +1 -0
  87. package/package.json +33 -30
  88. package/src/api/classes/dottedPath.ts +1 -1
  89. package/src/api/classes/element.ts +3 -2
  90. package/src/api/classes/parameter.ts +8 -5
  91. package/src/api/classes/placementAnimation.ts +2 -1
  92. package/src/api/classes/variant.ts +9 -9
  93. package/src/api/classes/variantInstance.ts +24 -24
  94. package/src/api/classes/variantParameterizable.ts +2 -2
  95. package/src/api/classes/viewer.ts +8 -7
  96. package/src/api/classes/viewerLight.ts +14 -9
  97. package/src/api/internal/debugViewer.ts +1 -1
  98. package/src/api/internal/sceneSetup.ts +6 -5
  99. package/src/api/manager/animationManager.ts +3 -3
  100. package/src/api/manager/gltfExportManager.ts +5 -4
  101. package/src/api/util/babylonHelper.ts +18 -36
  102. package/src/api/util/globalTypes.ts +11 -7
  103. package/src/api/util/resourceHelper.ts +5 -3
  104. package/src/api/util/sceneLoaderHelper.ts +3 -7
  105. package/src/api/util/stringHelper.ts +4 -4
  106. package/dist/lib-full/lens-rendering.js +0 -2
  107. package/dist/lib-full/lens-rendering.js.map +0 -1
  108. package/dist/lib-full/main.js +0 -3
  109. package/dist/lib-full/main.js.LICENSE.txt +0 -9
  110. package/dist/lib-full/main.js.map +0 -1
@@ -275,7 +275,7 @@ const changeEnvironment = function (scene: Scene, envDef: EnvironmentDefinition)
275
275
  // issue warning if both background texture and usedefault are set
276
276
  if (envDef.environmentUseDefault && envDef.environmentBackground) {
277
277
  console.warn(
278
- `!!! Warning !!! Spec parameter \'environment.usedefault\' is being overruled by \'environment.background\'.`
278
+ `!!! Warning !!! Spec parameter 'environment.usedefault' is being overruled by 'environment.background'.`
279
279
  );
280
280
  }
281
281
 
@@ -290,26 +290,17 @@ const changeEnvironment = function (scene: Scene, envDef: EnvironmentDefinition)
290
290
  : defaultSceneClearColor;
291
291
  const clearColorChanged = clearColorBefore !== scene.clearColor.toString();
292
292
 
293
- // Remove all URI params from given env URL as `CubeTexture.CreateFromPrefilteredData` does not work correctly with
294
- // URLs which contain URI params.
295
- // E.g. `https://some.url/.../studio.env?name=defaultEnv` throws an exception whilst `https://some.url/.../studio.env`
296
- // works as expected.
297
- //
298
- // See BJS forum for more details:
299
- // https://forum.babylonjs.com/t/cubetexture-createfromprefiltereddata-does-not-work-with-url-that-contains-uri-params/34097
300
- const newEnvUrl = envDef.environment?.split('?')[0];
301
-
302
293
  // 2) dispose existing & set new ENVIRONMENT (==texture)
303
294
  const curEnvTexture = scene.environmentTexture as Nullable<CubeTexture>;
304
- const envTextureChanged = newEnvUrl !== curEnvTexture?.url;
295
+ const envTextureChanged = envDef.environment !== curEnvTexture?.url;
305
296
 
306
- if (curEnvTexture && (!newEnvUrl || envTextureChanged)) {
297
+ if (curEnvTexture && (!envDef.environment || envTextureChanged)) {
307
298
  curEnvTexture.dispose();
308
299
  }
309
300
 
310
301
  const rotation = envDef.environmentRotation !== undefined ? Tools.ToRadians(envDef.environmentRotation) : 0;
311
- if (newEnvUrl && envTextureChanged) {
312
- const envTexture = CubeTexture.CreateFromPrefilteredData(newEnvUrl, scene);
302
+ if (envDef.environment && envTextureChanged) {
303
+ const envTexture = CubeTexture.CreateFromPrefilteredData(envDef.environment, scene);
313
304
  envTexture.rotationY = rotation;
314
305
  scene.environmentTexture = envTexture;
315
306
  } else if (curEnvTexture && curEnvTexture.rotationY !== rotation) {
@@ -367,19 +358,22 @@ const changeEnvironment = function (scene: Scene, envDef: EnvironmentDefinition)
367
358
  */
368
359
  const setMaterial = function (variant: Variant, node: TransformNode, materialName: string, deep: boolean = true) {
369
360
  if (node instanceof AbstractMesh) {
361
+ const materialExists = variant.viewer.scene.getMaterialById(materialName);
370
362
  const hasMissingMaterial = has(node.metadata, missingMaterialMetadataName);
371
- if (node.isEnabled()) {
372
- node.material = variant.getMaterial(materialName);
373
- if (hasMissingMaterial) {
374
- delete node.metadata[missingMaterialMetadataName];
375
- }
376
- } else {
363
+ const deferMaterialCreation = !materialExists && !node.isEnabled();
364
+
365
+ if (deferMaterialCreation) {
377
366
  injectNodeMetadata(node, { [missingMaterialMetadataName]: materialName }, false);
378
367
 
379
368
  // If it already had the missing material flag before, there already exists an observer...
380
369
  if (!hasMissingMaterial) {
381
370
  addMissingMaterialObserver(node);
382
371
  }
372
+ } else {
373
+ node.material = variant.getOrCreateMaterial(materialName);
374
+ if (hasMissingMaterial) {
375
+ delete node.metadata[missingMaterialMetadataName];
376
+ }
383
377
  }
384
378
  }
385
379
  if (deep) {
@@ -604,22 +598,10 @@ const getClientRectFromMesh = function (mesh: AbstractMesh, scene: Scene, canvas
604
598
  return projection;
605
599
  });
606
600
  // get the min and max for all the coordinates so we can calculate the largest possible screen size
607
- const maxX = Math.max.apply(
608
- Math,
609
- coordinates.map(o => o.x)
610
- );
611
- const minX = Math.min.apply(
612
- Math,
613
- coordinates.map(o => o.x)
614
- );
615
- const maxY = Math.max.apply(
616
- Math,
617
- coordinates.map(o => o.y)
618
- );
619
- const minY = Math.min.apply(
620
- Math,
621
- coordinates.map(o => o.y)
622
- );
601
+ const maxX = Math.max(...coordinates.map(o => o.x));
602
+ const minX = Math.min(...coordinates.map(o => o.x));
603
+ const maxY = Math.max(...coordinates.map(o => o.y));
604
+ const minY = Math.min(...coordinates.map(o => o.y));
623
605
  // return a ClientRect from this
624
606
  return {
625
607
  width: maxX - minX,
@@ -190,7 +190,9 @@ type SceneGlobals = {
190
190
  'aa'?: 'fxaa';
191
191
  'tone-mapping'?: boolean;
192
192
  /**
193
- * @bloom is widely known as glow. There you can define it’s size (Specifies the size of the bloom blur kernel, relative to the final output size) and threshold (The luminance threshold to find bright areas of the image to bloom).
193
+ * @bloom is widely known as glow. There you can define it’s size (Specifies the size of the bloom blur kernel,
194
+ * relative to the final output size) and threshold (The luminance threshold to find bright areas of the image to
195
+ * bloom).
194
196
  * Further Information under [BloomEffect](https://doc.babylonjs.com/typedoc/classes/babylon.bloomeffect).
195
197
  *
196
198
  * @dof short for "depth-of-field" defines the focus in the view. Parameters in settings are listed in [Depth of Field and Other Lens Effects link](https://doc.babylonjs.com/divingDeeper/postProcesses/dofLenseEffects).
@@ -228,8 +230,8 @@ type ScreenshotSettings = {
228
230
  *
229
231
  * **Info regarding JPEG:** \
230
232
  * Use mimeType `image/jpeg` (**not** `image/jpg`) when creating jpeg's. \
231
- * Also ensure that {@link Scene.clearColor | viewer.scene.clearColor} has an alpha value of `1` as jpeg's don't support
232
- * transparency. Otherwise background will always be black for jpeg's.
233
+ * Also ensure that {@link Scene.clearColor | viewer.scene.clearColor} has an alpha value of `1` as jpeg's don't
234
+ * support transparency. Otherwise background will always be black for jpeg's.
233
235
  */
234
236
  mimeType?: string;
235
237
  /** Default `1` */
@@ -318,8 +320,10 @@ type CameraDefinition = {
318
320
  * `arc` is a default camera position where the 3D-model is the center and the camera rotates around the 3D-model.
319
321
  * More Information about `arc` in [ArcRotateCamera](https://doc.babylonjs.com/typedoc/classes/babylon.arcrotatecamera).
320
322
  *
321
- * NOTE: While "baked" camera definitions from a GLB or babylon file can currently not be instatiated within the `Specification`, it's still possible to use them in the viewer.\
322
- * For the moment all camera definitions inside these files are automatically added to the scene and can be actived using the {@link Viewer.switchCamera} function.\
323
+ * NOTE: While "baked" camera definitions from a GLB or babylon file can currently not be instatiated within the
324
+ * `Specification`, it's still possible to use them in the viewer.\
325
+ * For the moment all camera definitions inside these files are automatically added to the scene and can be actived
326
+ * using the {@link Viewer.switchCamera} function.\
323
327
  * The `newCamera` input has to match the name of the camera node inside the GLB/babylon file.
324
328
  */
325
329
  type: 'arc';
@@ -389,8 +393,8 @@ type AnimationDefinitions = {
389
393
  *
390
394
  * The `GSAPTWeenVars` are extended by the `shortestWay` property.\
391
395
  * This property defines if the camera should move to the target position within the shortest possible distance.\
392
- * If `shortestWay` is `false`, the camera moves the whole difference between the current camera position and the target position
393
- * and that could be > 360, which can appear very unconvenient to the operator.\
396
+ * If `shortestWay` is `false`, the camera moves the whole difference between the current camera position and the target
397
+ * position and that could be > 360, which can appear very unconvenient to the operator.\
394
398
  * The default value of this flag is `true`.
395
399
  *
396
400
  * Example usage in {@link SceneJson | SceneJson.animations}:
@@ -12,7 +12,7 @@ const sleep = (ms: number) => new Promise(resolve => window.setTimeout(resolve,
12
12
  */
13
13
  const load = async function (path: string): Promise<Response> {
14
14
  emitter.emit(Event.LOADING_START, path);
15
- let data = await fetch(path);
15
+ const data = await fetch(path);
16
16
  emitter.emit(Event.LOADING_END, path);
17
17
  return data;
18
18
  };
@@ -59,8 +59,10 @@ const loadJavascript = (url: string): Promise<void> =>
59
59
  const debounce = function (func: Function, wait: number, immediate: boolean = false) {
60
60
  let timeout: any;
61
61
  return function () {
62
- // @ts-ignore
62
+ // @ts-ignore this function is not very "ESLint friendly", also see ESLint disable comment 2 lines below
63
+ // => take some time to refactor this function when there is time
63
64
  const context = this;
65
+ // eslint-disable-next-line prefer-rest-params
64
66
  const args = arguments;
65
67
  const later = function () {
66
68
  timeout = null;
@@ -127,7 +129,7 @@ const createImageFromSvg = async function (svgSrc: string): Promise<HTMLImageEle
127
129
  * {@link createImageFromSvg} for further details.
128
130
  */
129
131
  const createImageFromImgSrc = async function (imgSrc: string): Promise<HTMLImageElement> {
130
- let img = new Image();
132
+ const img = new Image();
131
133
 
132
134
  await new Promise(resolve => {
133
135
  img.onload = () => {
@@ -46,7 +46,7 @@ const getCustomCbnBabylonLoaderPlugin = function (previousLoaderPlugin: ISceneLo
46
46
  * @returns observer
47
47
  */
48
48
  const getMaterialPostLoadObserver = function (targetMeshOrInstance: AbstractMesh, concerningMesh: Mesh) {
49
- return (_eventData: any, _eventState: any) => {
49
+ return (eventData: any, eventState: any) => {
50
50
  const hasBeenEnabled = concerningMesh.isEnabled(true);
51
51
  const materialMissing = has(concerningMesh.metadata, missingMaterialMetadataName);
52
52
  if (!hasBeenEnabled || !materialMissing) return;
@@ -55,7 +55,7 @@ const getMaterialPostLoadObserver = function (targetMeshOrInstance: AbstractMesh
55
55
  // try to find material on the scene
56
56
  const existingMat = concerningMesh.getScene().getMaterialById(missingMatId);
57
57
  // assign either existing material or freshly created one
58
- concerningMesh.material = existingMat || getMaterialFromCbnAssets(missingMatId, concerningMesh.getScene());
58
+ concerningMesh.material = existingMat || createMaterialFromCbnAssets(missingMatId, concerningMesh.getScene());
59
59
  // since the material is there now, we do not need the related metadata tag anymore
60
60
  delete concerningMesh.metadata[missingMaterialMetadataName];
61
61
  };
@@ -75,10 +75,6 @@ const addMissingMaterialMetadata = function (dataParsed: any, container: AssetCo
75
75
  const materialOnImportedMesh = currMeshImported.material?.id;
76
76
  const materialOnOriginalMesh = currMeshOriginal.materialId;
77
77
  if (!materialOnOriginalMesh || materialOnImportedMesh === materialOnOriginalMesh) continue;
78
- // TODO: Just for easier debugging. Remove before publishment...
79
- console.info(
80
- `Adding "${missingMaterialMetadataName}" info on mesh "${currMeshOriginal.name}" with material "${currMeshOriginal.materialId}"`
81
- );
82
78
  // if we're here, the imported mesh has different material than original one
83
79
  window.Cbn?.Assets.assertMaterialExists(materialOnOriginalMesh);
84
80
  injectNodeMetadata(currMeshImported, { [missingMaterialMetadataName]: materialOnOriginalMesh }, false);
@@ -131,7 +127,7 @@ const addMissingMaterialObserver = function (node: BjsNode) {
131
127
  * @param scene BabylonJs scene
132
128
  * @returns PBRMaterial | null
133
129
  */
134
- export const getMaterialFromCbnAssets = function (materialId: string, scene: Scene): Material | null {
130
+ export const createMaterialFromCbnAssets = function (materialId: string, scene: Scene): Material | null {
135
131
  const materialDefinition = window.Cbn?.Assets.getMaterial(materialId);
136
132
  // The generic `Material.Parse` actually returns a more specific material like `BABYLON.StandardMaterial`,
137
133
  // `BABYLON.PBRMaterial` or stuff like `BABYLON.PBRMetallicRoughnessMaterial` etc. based on the given `customType`
@@ -2,10 +2,10 @@
2
2
  * Creates a random uuidv4.
3
3
  */
4
4
  const uuidv4 = function () {
5
- // @ts-ignore
6
- return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
7
- (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
8
- );
5
+ return ([1e7].toString() + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => {
6
+ const cNum = parseInt(c);
7
+ return (cNum ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (cNum / 4)))).toString(16);
8
+ });
9
9
  };
10
10
 
11
11
  /**
@@ -1,2 +0,0 @@
1
- "use strict";(self.webpackChunkcombeenation=self.webpackChunkcombeenation||[]).push([[288],{3862:(e,t,r)=>{r.r(t),r.d(t,{LensRenderingPipeline:()=>g});var i=r(5187),h=r(554),n=r(7334),o=r(1817),l=r(547),s=(r(6425),r(63),r(1206));const a="uniform sampler2D textureSampler; \nuniform float gain;\nuniform float threshold;\nuniform float screen_width;\nuniform float screen_height;\nvarying vec2 vUV;\nvec4 highlightColor(vec4 color) {\nvec4 highlight=color;\nfloat luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));\nfloat lum_threshold;\nif (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }\nelse { lum_threshold=0.5+0.44*threshold; }\nluminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);\nhighlight*=luminance*gain;\nhighlight.a=1.0;\nreturn highlight;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 original=texture2D(textureSampler,vUV);\nif (gain==-1.0) {\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\nreturn;\n}\nfloat w=2.0/screen_width;\nfloat h=2.0/screen_height;\nfloat weight=1.0;\nvec4 blurred=vec4(0.0,0.0,0.0,0.0);\n#ifdef PENTAGON\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));\n#else\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));\n#endif\nblurred/=39.0;\ngl_FragColor=blurred;\n}";s.v.ShadersStore.lensHighlightsPixelShader=a;const c="uniform sampler2D textureSampler;\nuniform sampler2D highlightsSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D grainSampler;\nuniform float grain_amount;\nuniform bool blur_noise;\nuniform float screen_width;\nuniform float screen_height;\nuniform float distortion;\nuniform bool dof_enabled;\nuniform float screen_distance; \nuniform float aperture;\nuniform float darken;\nuniform float edge_blur;\nuniform bool highlights;\nuniform float near;\nuniform float far;\nvarying vec2 vUV;\n#define PI 3.14159265\n#define TWOPI 6.28318530\n#define inverse_focal_length 0.1 \nvec2 centered_screen_pos;\nvec2 distorted_coords;\nfloat radius2;\nfloat radius;\nvec2 rand(vec2 co)\n{\nfloat noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));\nfloat noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));\nreturn clamp(vec2(noise1,noise2),0.0,1.0);\n}\nvec2 getDistortedCoords(vec2 coords) {\nif (distortion==0.0) { return coords; }\nvec2 direction=1.0*normalize(centered_screen_pos);\nvec2 dist_coords=vec2(0.5,0.5);\ndist_coords.x=0.5+direction.x*radius2*1.0;\ndist_coords.y=0.5+direction.y*radius2*1.0;\nfloat dist_amount=clamp(distortion*0.23,0.0,1.0);\ndist_coords=mix(coords,dist_coords,dist_amount);\nreturn dist_coords;\n}\nfloat sampleScreen(inout vec4 color,in vec2 offset,in float weight) {\nvec2 coords=distorted_coords;\nfloat angle=rand(coords*100.0).x*TWOPI;\ncoords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));\ncolor+=texture2D(textureSampler,coords)*weight;\nreturn weight;\n}\nfloat getBlurLevel(float size) {\nreturn min(3.0,ceil(size/1.0));\n}\nvec4 getBlurColor(float size) {\nvec4 col=texture2D(textureSampler,distorted_coords);\nfloat blur_level=getBlurLevel(size);\nfloat w=(size/screen_width);\nfloat h=(size/screen_height);\nfloat total_weight=1.0;\nvec2 sample_coords;\ntotal_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);\ntotal_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);\ntotal_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);\ntotal_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);\ntotal_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);\ntotal_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);\ntotal_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);\ntotal_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);\ntotal_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);\nif (blur_level>1.0) {\ntotal_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);\ntotal_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);\ntotal_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);\ntotal_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);\ntotal_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);\ntotal_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);\ntotal_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);\ntotal_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);\ntotal_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);\n}\nif (blur_level>2.0) {\ntotal_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);\ntotal_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);\ntotal_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);\ntotal_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);\ntotal_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);\ntotal_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);\ntotal_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);\ntotal_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);\ntotal_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);\n}\ncol/=total_weight; \nif (darken>0.0) {\ncol.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);\n}\nreturn col;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ncentered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);\nradius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;\nradius=sqrt(radius2);\ndistorted_coords=getDistortedCoords(vUV); \nvec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height); \nfloat depth=texture2D(depthSampler,distorted_coords).r; \nfloat distance=near+(far-near)*depth; \nvec4 color=texture2D(textureSampler,vUV); \nfloat coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));\nif (dof_enabled==false || coc<0.07) { coc=0.0; }\nfloat edge_blur_amount=0.0;\nif (edge_blur>0.0) {\nedge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;\n}\nfloat blur_amount=max(edge_blur_amount,coc);\nif (blur_amount==0.0) {\ngl_FragColor=texture2D(textureSampler,distorted_coords);\n}\nelse {\ngl_FragColor=getBlurColor(blur_amount*1.7);\nif (highlights) {\ngl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;\n}\nif (blur_noise) {\nvec2 noise=rand(distorted_coords)*0.01*blur_amount;\nvec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);\ngl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;\n}\n}\nif (grain_amount>0.0) {\nvec4 grain_color=texture2D(grainSampler,texels_coords*0.003);\ngl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;\n}\n}\n";s.v.ShadersStore.depthOfFieldPixelShader=c;class g extends o.${constructor(e,t,r,i=1,h){super(r.getEngine(),e),this.LensChromaticAberrationEffect="LensChromaticAberrationEffect",this.HighlightsEnhancingEffect="HighlightsEnhancingEffect",this.LensDepthOfFieldEffect="LensDepthOfFieldEffect",this._pentagonBokehIsEnabled=!1,this._scene=r,this._depthTexture=r.enableDepthRenderer().getDepthMap(),t.grain_texture?this._grainTexture=t.grain_texture:this._createGrainTexture(),this._edgeBlur=t.edge_blur?t.edge_blur:0,this._grainAmount=t.grain_amount?t.grain_amount:0,this._chromaticAberration=t.chromatic_aberration?t.chromatic_aberration:0,this._distortion=t.distortion?t.distortion:0,this._highlightsGain=void 0!==t.dof_gain?t.dof_gain:-1,this._highlightsThreshold=t.dof_threshold?t.dof_threshold:1,this._dofDistance=void 0!==t.dof_focus_distance?t.dof_focus_distance:-1,this._dofAperture=t.dof_aperture?t.dof_aperture:1,this._dofDarken=t.dof_darken?t.dof_darken:0,this._dofPentagon=void 0===t.dof_pentagon||t.dof_pentagon,this._blurNoise=void 0===t.blur_noise||t.blur_noise,this._createChromaticAberrationPostProcess(i),this._createHighlightsPostProcess(i),this._createDepthOfFieldPostProcess(i/4),this.addEffect(new l.L(r.getEngine(),this.LensChromaticAberrationEffect,(()=>this._chromaticAberrationPostProcess),!0)),this.addEffect(new l.L(r.getEngine(),this.HighlightsEnhancingEffect,(()=>this._highlightsPostProcess),!0)),this.addEffect(new l.L(r.getEngine(),this.LensDepthOfFieldEffect,(()=>this._depthOfFieldPostProcess),!0)),-1===this._highlightsGain&&this._disableEffect(this.HighlightsEnhancingEffect,null),r.postProcessRenderPipelineManager.addPipeline(this),h&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,h)}getClassName(){return"LensRenderingPipeline"}get scene(){return this._scene}get edgeBlur(){return this._edgeBlur}set edgeBlur(e){this.setEdgeBlur(e)}get grainAmount(){return this._grainAmount}set grainAmount(e){this.setGrainAmount(e)}get chromaticAberration(){return this._chromaticAberration}set chromaticAberration(e){this.setChromaticAberration(e)}get dofAperture(){return this._dofAperture}set dofAperture(e){this.setAperture(e)}get edgeDistortion(){return this._distortion}set edgeDistortion(e){this.setEdgeDistortion(e)}get dofDistortion(){return this._dofDistance}set dofDistortion(e){this.setFocusDistance(e)}get darkenOutOfFocus(){return this._dofDarken}set darkenOutOfFocus(e){this.setDarkenOutOfFocus(e)}get blurNoise(){return this._blurNoise}set blurNoise(e){this._blurNoise=e}get pentagonBokeh(){return this._pentagonBokehIsEnabled}set pentagonBokeh(e){e?this.enablePentagonBokeh():this.disablePentagonBokeh()}get highlightsGain(){return this._highlightsGain}set highlightsGain(e){this.setHighlightsGain(e)}get highlightsThreshold(){return this._highlightsThreshold}set highlightsThreshold(e){this.setHighlightsThreshold(e)}setEdgeBlur(e){this._edgeBlur=e}disableEdgeBlur(){this._edgeBlur=0}setGrainAmount(e){this._grainAmount=e}disableGrain(){this._grainAmount=0}setChromaticAberration(e){this._chromaticAberration=e}disableChromaticAberration(){this._chromaticAberration=0}setEdgeDistortion(e){this._distortion=e}disableEdgeDistortion(){this._distortion=0}setFocusDistance(e){this._dofDistance=e}disableDepthOfField(){this._dofDistance=-1}setAperture(e){this._dofAperture=e}setDarkenOutOfFocus(e){this._dofDarken=e}enablePentagonBokeh(){this._highlightsPostProcess.updateEffect("#define PENTAGON\n"),this._pentagonBokehIsEnabled=!0}disablePentagonBokeh(){this._pentagonBokehIsEnabled=!1,this._highlightsPostProcess.updateEffect()}enableNoiseBlur(){this._blurNoise=!0}disableNoiseBlur(){this._blurNoise=!1}setHighlightsGain(e){this._highlightsGain=e}setHighlightsThreshold(e){-1===this._highlightsGain&&(this._highlightsGain=1),this._highlightsThreshold=e}disableHighlights(){this._highlightsGain=-1}dispose(e=!1){this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),this._chromaticAberrationPostProcess=null,this._highlightsPostProcess=null,this._depthOfFieldPostProcess=null,this._grainTexture.dispose(),e&&this._scene.disableDepthRenderer()}_createChromaticAberrationPostProcess(e){this._chromaticAberrationPostProcess=new n.D("LensChromaticAberration","chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],e,null,i.x.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._chromaticAberrationPostProcess.onApply=e=>{e.setFloat("chromatic_aberration",this._chromaticAberration),e.setFloat("screen_width",this._scene.getEngine().getRenderWidth()),e.setFloat("screen_height",this._scene.getEngine().getRenderHeight()),e.setFloat("radialIntensity",1),e.setFloat2("direction",17,17),e.setFloat2("centerPosition",.5,.5)}}_createHighlightsPostProcess(e){this._highlightsPostProcess=new n.D("LensHighlights","lensHighlights",["gain","threshold","screen_width","screen_height"],[],e,null,i.x.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,this._dofPentagon?"#define PENTAGON\n":""),this._highlightsPostProcess.externalTextureSamplerBinding=!0,this._highlightsPostProcess.onApply=e=>{e.setFloat("gain",this._highlightsGain),e.setFloat("threshold",this._highlightsThreshold),e.setTextureFromPostProcess("textureSampler",this._chromaticAberrationPostProcess),e.setFloat("screen_width",this._scene.getEngine().getRenderWidth()),e.setFloat("screen_height",this._scene.getEngine().getRenderHeight())}}_createDepthOfFieldPostProcess(e){this._depthOfFieldPostProcess=new n.D("LensDepthOfField","depthOfField",["grain_amount","blur_noise","screen_width","screen_height","distortion","dof_enabled","screen_distance","aperture","darken","edge_blur","highlights","near","far"],["depthSampler","grainSampler","highlightsSampler"],e,null,i.x.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._depthOfFieldPostProcess.externalTextureSamplerBinding=!0,this._depthOfFieldPostProcess.onApply=e=>{e.setTexture("depthSampler",this._depthTexture),e.setTexture("grainSampler",this._grainTexture),e.setTextureFromPostProcess("textureSampler",this._highlightsPostProcess),e.setTextureFromPostProcess("highlightsSampler",this._depthOfFieldPostProcess),e.setFloat("grain_amount",this._grainAmount),e.setBool("blur_noise",this._blurNoise),e.setFloat("screen_width",this._scene.getEngine().getRenderWidth()),e.setFloat("screen_height",this._scene.getEngine().getRenderHeight()),e.setFloat("distortion",this._distortion),e.setBool("dof_enabled",-1!==this._dofDistance),e.setFloat("screen_distance",1/(.1-1/this._dofDistance)),e.setFloat("aperture",this._dofAperture),e.setFloat("darken",this._dofDarken),e.setFloat("edge_blur",this._edgeBlur),e.setBool("highlights",-1!==this._highlightsGain),this._scene.activeCamera&&(e.setFloat("near",this._scene.activeCamera.minZ),e.setFloat("far",this._scene.activeCamera.maxZ))}}_createGrainTexture(){this._grainTexture=new h.c("LensNoiseTexture",512,this._scene,!1,i.x.BILINEAR_SAMPLINGMODE),this._grainTexture.wrapU=i.x.WRAP_ADDRESSMODE,this._grainTexture.wrapV=i.x.WRAP_ADDRESSMODE;const e=this._grainTexture.getContext();let t;for(let i=0;i<512;i++)for(let h=0;h<512;h++)t=Math.floor(255*(r=.42,n=.58,Math.random()*(n-r)+r)),e.fillStyle="rgb("+t+", "+t+", "+t+")",e.fillRect(i,h,1,1);var r,n;this._grainTexture.update(!1)}}var u=r(1057),d=r(2122),_=r(4559);u.x.prototype.enableDepthRenderer=function(e,t=!1,r=!1){if(!(e=e||this.activeCamera))throw"No camera available to enable depth renderer";if(this._depthRenderer||(this._depthRenderer={}),!this._depthRenderer[e.id]){const i=!!this.getEngine().getCaps().textureFloatRender;let h=0;h=!this.getEngine().getCaps().textureHalfFloatRender||r&&i?i?1:0:2,this._depthRenderer[e.id]=new d.g(this,h,e,t)}return this._depthRenderer[e.id]},u.x.prototype.disableDepthRenderer=function(e){(e=e||this.activeCamera)&&this._depthRenderer&&this._depthRenderer[e.id]&&this._depthRenderer[e.id].dispose()};class p{constructor(e){this.name=_.l.NAME_DEPTHRENDERER,this.scene=e}register(){this.scene._gatherRenderTargetsStage.registerStep(_.l.STEP_GATHERRENDERTARGETS_DEPTHRENDERER,this,this._gatherRenderTargets),this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_.l.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER,this,this._gatherActiveCameraRenderTargets)}rebuild(){}dispose(){for(const e in this.scene._depthRenderer)this.scene._depthRenderer[e].dispose()}_gatherRenderTargets(e){if(this.scene._depthRenderer)for(const t in this.scene._depthRenderer){const r=this.scene._depthRenderer[t];r.enabled&&!r.useOnlyInActiveCamera&&e.push(r.getDepthMap())}}_gatherActiveCameraRenderTargets(e){if(this.scene._depthRenderer)for(const t in this.scene._depthRenderer){const r=this.scene._depthRenderer[t];r.enabled&&r.useOnlyInActiveCamera&&this.scene.activeCamera.id===t&&e.push(r.getDepthMap())}}}d.g._SceneComponentInitialization=e=>{let t=e._getComponent(_.l.NAME_DEPTHRENDERER);t||(t=new p(e),e._addComponent(t))}}}]);
2
- //# sourceMappingURL=lens-rendering.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lens-rendering.js","mappings":"qOAEA,MACMA,EAAS,q1NCsFf,EAA0C,EAAE,aAAyC,0BAAI,EAEzF,MAMM,EAA+B,2kKAwIrC,EAA0C,EAAE,aAAuC,wBAAI,EAoBvF,MAAM,UAA8B,EAAyD,EA2BzF,YAAY,EAAM,EAAY,EAAO,EAAQ,EAAK,GAC9C,MAAM,EAAM,YAAa,GAezBC,KAAK,8BAAgC,gCAKrC,KAAK,0BAA4B,4BAKjC,KAAK,uBAAyB,yBAC9B,KAAK,yBAA0B,EAC/B,KAAK,OAAS,EAEdA,KAAK,cAAgB,EAAM,sBAAsB,cAC7C,EAAW,cACX,KAAK,cAAgB,EAAW,cAGhC,KAAK,sBAGT,KAAK,UAAY,EAAW,UAAY,EAAW,UAAY,EAC/D,KAAK,aAAe,EAAW,aAAe,EAAW,aAAe,EACxE,KAAK,qBAAuB,EAAW,qBAAuB,EAAW,qBAAuB,EAChG,KAAK,YAAc,EAAW,WAAa,EAAW,WAAa,EACnE,KAAK,qBAA0C,IAAxB,EAAW,SAAyB,EAAW,UAAY,EAClFA,KAAK,qBAAuB,EAAW,cAAgB,EAAW,cAAgB,EAClFA,KAAK,kBAAiD,IAAlC,EAAW,mBAAmC,EAAW,oBAAsB,EACnG,KAAK,aAAe,EAAW,aAAe,EAAW,aAAe,EACxE,KAAK,WAAa,EAAW,WAAa,EAAW,WAAa,EAClE,KAAK,kBAA2C,IAA5B,EAAW,cAA6B,EAAW,aACvE,KAAK,gBAAuC,IAA1B,EAAW,YAA2B,EAAW,WAEnEA,KAAK,sCAAsC,GAC3C,KAAK,6BAA6B,GAClC,KAAK,+BAA+B,EAAQ,GAE5C,KAAK,UAAU,IAAI,EAAqD,EAAE,EAAM,YAAa,KAAK,+BAA+B,IACtH,KAAK,kCACb,IACH,KAAK,UAAU,IAAI,EAAqD,EAAE,EAAM,YAAa,KAAK,2BAA2B,IAClH,KAAK,yBACb,IACH,KAAK,UAAU,IAAI,EAAqD,EAAE,EAAM,YAAa,KAAK,wBAAwB,IAC/G,KAAK,2BACb,KAC2B,IAA1B,KAAK,iBACL,KAAK,eAAe,KAAK,0BAA2B,MAGxD,EAAM,iCAAiC,YAAY,MAC/C,GACA,EAAM,iCAAiC,8BAA8B,EAAM,EAEnF,CAKA,eACI,MAAO,uBACX,CAKI,YACA,OAAO,KAAK,MAChB,CAII,eACA,OAAO,KAAK,SAChB,CACI,aAAS,GACT,KAAK,YAAY,EACrB,CAII,kBACA,OAAO,KAAK,YAChB,CACI,gBAAY,GACZ,KAAK,eAAe,EACxB,CAII,0BACA,OAAO,KAAK,oBAChB,CACI,wBAAoB,GACpBA,KAAK,uBAAuB,EAChC,CAII,kBACA,OAAO,KAAK,YAChB,CACI,gBAAY,GACZ,KAAK,YAAY,EACrB,CAII,qBACA,OAAO,KAAK,WAChB,CACI,mBAAe,GACf,KAAK,kBAAkB,EAC3B,CAII,oBACA,OAAO,KAAK,YAChB,CACI,kBAAc,GACd,KAAK,iBAAiB,EAC1B,CAII,uBACA,OAAO,KAAK,UAChB,CACI,qBAAiB,GACjB,KAAK,oBAAoB,EAC7B,CAII,gBACA,OAAO,KAAK,UAChB,CACI,cAAU,GACV,KAAK,WAAa,CACtB,CAII,oBACA,OAAO,KAAK,uBAChB,CACI,kBAAc,GACV,EACA,KAAK,sBAGL,KAAK,sBAEb,CAII,qBACA,OAAO,KAAK,eAChB,CACI,mBAAe,GACf,KAAK,kBAAkB,EAC3B,CAII,0B,2FC7c2D,YAAY,GAC/E,gBACI,CAIA,kBACIA,KAAK,UAAY,CACrB,CAKA,eAAe,GACX,KAAK,aAAe,CACxB,CAIA,eACI,KAAK,aAAe,CACxB,CAKA,uBAAuB,GACnB,KAAK,qBAAuB,CAChC,CAIA,6BACI,KAAK,qBAAuB,CAChC,CAKA,kBAAkB,GACd,KAAK,YAAc,CACvB,CAIA,wBACIA,KAAK,YAAc,CACvB,CAKA,iBAAiB,GACbA,KAAK,aAAe,CACxB,CAIA,sBACI,KAAK,cAAgB,CACzB,CAKA,YAAY,GACR,KAAK,aAAe,CACxB,CAKA,oBAAoB,GAChB,KAAK,WAAa,CACtB,CAIA,sBACI,KAAK,uBAAuB,aAAa,sBACzC,KAAK,yBAA0B,CACnC,CAIA,uBACI,KAAK,yBAA0B,EAC/B,KAAK,uBAAuB,cAChC,CAIA,kBACI,KAAK,YAAa,CACtB,CAIA,mBACI,KAAK,YAAa,C,CClGtB,kBAAkB,GACuG,KAAK,gBAAkB,CACjF,C","sources":["webpack://combeenation/./node_modules/@babylonjs/core/Shaders/lensHighlights.fragment.js","webpack://combeenation/./node_modules/@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js","webpack://combeenation/./node_modules/@babylonjs/core/Rendering/depthRendererSceneComponent.js","webpack://combeenation/./src/api/internal/lensRendering.ts"],"sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore.js\";\nconst name = \"lensHighlightsPixelShader\";\nconst shader = `uniform sampler2D textureSampler; \runiform float gain;\runiform float threshold;\runiform float screen_width;\runiform float screen_height;\rvarying vec2 vUV;\rvec4 highlightColor(vec4 color) {\rvec4 highlight=color;\rfloat luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));\rfloat lum_threshold;\rif (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }\relse { lum_threshold=0.5+0.44*threshold; }\rluminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);\rhighlight*=luminance*gain;\rhighlight.a=1.0;\rreturn highlight;\r}\r#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\r{\rvec4 original=texture2D(textureSampler,vUV);\rif (gain==-1.0) {\rgl_FragColor=vec4(0.0,0.0,0.0,1.0);\rreturn;\r}\rfloat w=2.0/screen_width;\rfloat h=2.0/screen_height;\rfloat weight=1.0;\rvec4 blurred=vec4(0.0,0.0,0.0,0.0);\r#ifdef PENTAGON\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));\r#else\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));\rblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));\r#endif\nblurred/=39.0;\rgl_FragColor=blurred;\r}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const lensHighlightsPixelShader = { name, shader };\n//# sourceMappingURL=lensHighlights.fragment.js.map","import { Texture } from \"../../../Materials/Textures/texture.js\";\nimport { DynamicTexture } from \"../../../Materials/Textures/dynamicTexture.js\";\nimport { PostProcess } from \"../../../PostProcesses/postProcess.js\";\nimport { PostProcessRenderPipeline } from \"../../../PostProcesses/RenderPipeline/postProcessRenderPipeline.js\";\nimport { PostProcessRenderEffect } from \"../../../PostProcesses/RenderPipeline/postProcessRenderEffect.js\";\nimport \"../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.js\";\nimport \"../../../Shaders/chromaticAberration.fragment.js\";\nimport \"../../../Shaders/lensHighlights.fragment.js\";\nimport \"../../../Shaders/depthOfField.fragment.js\";\n/**\n * BABYLON.JS Chromatic Aberration GLSL Shader\n * Author: Olivier Guyot\n * Separates very slightly R, G and B colors on the edges of the screen\n * Inspired by Francois Tarlier & Martins Upitis\n */\nexport class LensRenderingPipeline extends PostProcessRenderPipeline {\n /**\n * @constructor\n *\n * Effect parameters are as follow:\n * {\n * chromatic_aberration: number; // from 0 to x (1 for realism)\n * edge_blur: number; // from 0 to x (1 for realism)\n * distortion: number; // from 0 to x (1 for realism), note that this will effect the pointer position precision\n * grain_amount: number; // from 0 to 1\n * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise\n * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)\n * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)\n * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)\n * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like \"bokeh\" effect\n * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)\n * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)\n * blur_noise: boolean; // add a little bit of noise to the blur (default: true)\n * }\n * Note: if an effect parameter is unset, effect is disabled\n *\n * @param name The rendering pipeline name\n * @param parameters - An object containing all parameters (see above)\n * @param scene The scene linked to this pipeline\n * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)\n * @param cameras The array of cameras that the rendering pipeline will be attached to\n */\n constructor(name, parameters, scene, ratio = 1.0, cameras) {\n super(scene.getEngine(), name);\n // Lens effects can be of the following:\n // - chromatic aberration (slight shift of RGB colors)\n // - blur on the edge of the lens\n // - lens distortion\n // - depth-of-field blur & highlights enhancing\n // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)\n // - grain effect (noise or custom texture)\n // Two additional texture samplers are needed:\n // - depth map (for depth-of-field)\n // - grain texture\n /**\n * @ignore\n * The chromatic aberration PostProcess id in the pipeline\n */\n this.LensChromaticAberrationEffect = \"LensChromaticAberrationEffect\";\n /**\n * @ignore\n * The highlights enhancing PostProcess id in the pipeline\n */\n this.HighlightsEnhancingEffect = \"HighlightsEnhancingEffect\";\n /**\n * @ignore\n * The depth-of-field PostProcess id in the pipeline\n */\n this.LensDepthOfFieldEffect = \"LensDepthOfFieldEffect\";\n this._pentagonBokehIsEnabled = false;\n this._scene = scene;\n // Fetch texture samplers\n this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer \"on\"\n if (parameters.grain_texture) {\n this._grainTexture = parameters.grain_texture;\n }\n else {\n this._createGrainTexture();\n }\n // save parameters\n this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;\n this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;\n this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;\n this._distortion = parameters.distortion ? parameters.distortion : 0;\n this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;\n this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;\n this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;\n this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;\n this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;\n this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;\n this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;\n // Create effects\n this._createChromaticAberrationPostProcess(ratio);\n this._createHighlightsPostProcess(ratio);\n this._createDepthOfFieldPostProcess(ratio / 4);\n // Set up pipeline\n this.addEffect(new PostProcessRenderEffect(scene.getEngine(), this.LensChromaticAberrationEffect, () => {\n return this._chromaticAberrationPostProcess;\n }, true));\n this.addEffect(new PostProcessRenderEffect(scene.getEngine(), this.HighlightsEnhancingEffect, () => {\n return this._highlightsPostProcess;\n }, true));\n this.addEffect(new PostProcessRenderEffect(scene.getEngine(), this.LensDepthOfFieldEffect, () => {\n return this._depthOfFieldPostProcess;\n }, true));\n if (this._highlightsGain === -1) {\n this._disableEffect(this.HighlightsEnhancingEffect, null);\n }\n // Finish\n scene.postProcessRenderPipelineManager.addPipeline(this);\n if (cameras) {\n scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);\n }\n }\n /**\n * Get the class name\n * @returns \"LensRenderingPipeline\"\n */\n getClassName() {\n return \"LensRenderingPipeline\";\n }\n // Properties\n /**\n * Gets associated scene\n */\n get scene() {\n return this._scene;\n }\n /**\n * Gets or sets the edge blur\n */\n get edgeBlur() {\n return this._edgeBlur;\n }\n set edgeBlur(value) {\n this.setEdgeBlur(value);\n }\n /**\n * Gets or sets the grain amount\n */\n get grainAmount() {\n return this._grainAmount;\n }\n set grainAmount(value) {\n this.setGrainAmount(value);\n }\n /**\n * Gets or sets the chromatic aberration amount\n */\n get chromaticAberration() {\n return this._chromaticAberration;\n }\n set chromaticAberration(value) {\n this.setChromaticAberration(value);\n }\n /**\n * Gets or sets the depth of field aperture\n */\n get dofAperture() {\n return this._dofAperture;\n }\n set dofAperture(value) {\n this.setAperture(value);\n }\n /**\n * Gets or sets the edge distortion\n */\n get edgeDistortion() {\n return this._distortion;\n }\n set edgeDistortion(value) {\n this.setEdgeDistortion(value);\n }\n /**\n * Gets or sets the depth of field distortion\n */\n get dofDistortion() {\n return this._dofDistance;\n }\n set dofDistortion(value) {\n this.setFocusDistance(value);\n }\n /**\n * Gets or sets the darken out of focus amount\n */\n get darkenOutOfFocus() {\n return this._dofDarken;\n }\n set darkenOutOfFocus(value) {\n this.setDarkenOutOfFocus(value);\n }\n /**\n * Gets or sets a boolean indicating if blur noise is enabled\n */\n get blurNoise() {\n return this._blurNoise;\n }\n set blurNoise(value) {\n this._blurNoise = value;\n }\n /**\n * Gets or sets a boolean indicating if pentagon bokeh is enabled\n */\n get pentagonBokeh() {\n return this._pentagonBokehIsEnabled;\n }\n set pentagonBokeh(value) {\n if (value) {\n this.enablePentagonBokeh();\n }\n else {\n this.disablePentagonBokeh();\n }\n }\n /**\n * Gets or sets the highlight grain amount\n */\n get highlightsGain() {\n return this._highlightsGain;\n }\n set highlightsGain(value) {\n this.setHighlightsGain(value);\n }\n /**\n * Gets or sets the highlight threshold\n */\n get highlightsThreshold() {\n return this._highlightsThreshold;\n }\n set highlightsThreshold(value) {\n this.setHighlightsThreshold(value);\n }\n // public methods (self explanatory)\n /**\n * Sets the amount of blur at the edges\n * @param amount blur amount\n */\n setEdgeBlur(amount) {\n this._edgeBlur = amount;\n }\n /**\n * Sets edge blur to 0\n */\n disableEdgeBlur() {\n this._edgeBlur = 0;\n }\n /**\n * Sets the amount of grain\n * @param amount Amount of grain\n */\n setGrainAmount(amount) {\n this._grainAmount = amount;\n }\n /**\n * Set grain amount to 0\n */\n disableGrain() {\n this._grainAmount = 0;\n }\n /**\n * Sets the chromatic aberration amount\n * @param amount amount of chromatic aberration\n */\n setChromaticAberration(amount) {\n this._chromaticAberration = amount;\n }\n /**\n * Sets chromatic aberration amount to 0\n */\n disableChromaticAberration() {\n this._chromaticAberration = 0;\n }\n /**\n * Sets the EdgeDistortion amount\n * @param amount amount of EdgeDistortion\n */\n setEdgeDistortion(amount) {\n this._distortion = amount;\n }\n /**\n * Sets edge distortion to 0\n */\n disableEdgeDistortion() {\n this._distortion = 0;\n }\n /**\n * Sets the FocusDistance amount\n * @param amount amount of FocusDistance\n */\n setFocusDistance(amount) {\n this._dofDistance = amount;\n }\n /**\n * Disables depth of field\n */\n disableDepthOfField() {\n this._dofDistance = -1;\n }\n /**\n * Sets the Aperture amount\n * @param amount amount of Aperture\n */\n setAperture(amount) {\n this._dofAperture = amount;\n }\n /**\n * Sets the DarkenOutOfFocus amount\n * @param amount amount of DarkenOutOfFocus\n */\n setDarkenOutOfFocus(amount) {\n this._dofDarken = amount;\n }\n /**\n * Creates a pentagon bokeh effect\n */\n enablePentagonBokeh() {\n this._highlightsPostProcess.updateEffect(\"#define PENTAGON\\n\");\n this._pentagonBokehIsEnabled = true;\n }\n /**\n * Disables the pentagon bokeh effect\n */\n disablePentagonBokeh() {\n this._pentagonBokehIsEnabled = false;\n this._highlightsPostProcess.updateEffect();\n }\n /**\n * Enables noise blur\n */\n enableNoiseBlur() {\n this._blurNoise = true;\n }\n /**\n * Disables noise blur\n */\n disableNoiseBlur() {\n this._blurNoise = false;\n }\n /**\n * Sets the HighlightsGain amount\n * @param amount amount of HighlightsGain\n */\n setHighlightsGain(amount) {\n this._highlightsGain = amount;\n }\n /**\n * Sets the HighlightsThreshold amount\n * @param amount amount of HighlightsThreshold\n */\n setHighlightsThreshold(amount) {\n if (this._highlightsGain === -1) {\n this._highlightsGain = 1.0;\n }\n this._highlightsThreshold = amount;\n }\n /**\n * Disables highlights\n */\n disableHighlights() {\n this._highlightsGain = -1;\n }\n /**\n * Removes the internal pipeline assets and detaches the pipeline from the scene cameras\n * @param disableDepthRender If the scene's depth rendering should be disabled (default: false)\n */\n dispose(disableDepthRender = false) {\n this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);\n this._chromaticAberrationPostProcess = null;\n this._highlightsPostProcess = null;\n this._depthOfFieldPostProcess = null;\n this._grainTexture.dispose();\n if (disableDepthRender) {\n this._scene.disableDepthRenderer();\n }\n }\n // colors shifting and distortion\n _createChromaticAberrationPostProcess(ratio) {\n this._chromaticAberrationPostProcess = new PostProcess(\"LensChromaticAberration\", \"chromaticAberration\", [\"chromatic_aberration\", \"screen_width\", \"screen_height\", \"direction\", \"radialIntensity\", \"centerPosition\"], // uniforms\n [], // samplers\n ratio, null, Texture.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);\n this._chromaticAberrationPostProcess.onApply = (effect) => {\n effect.setFloat(\"chromatic_aberration\", this._chromaticAberration);\n effect.setFloat(\"screen_width\", this._scene.getEngine().getRenderWidth());\n effect.setFloat(\"screen_height\", this._scene.getEngine().getRenderHeight());\n effect.setFloat(\"radialIntensity\", 1);\n effect.setFloat2(\"direction\", 17, 17);\n effect.setFloat2(\"centerPosition\", 0.5, 0.5);\n };\n }\n // highlights enhancing\n _createHighlightsPostProcess(ratio) {\n this._highlightsPostProcess = new PostProcess(\"LensHighlights\", \"lensHighlights\", [\"gain\", \"threshold\", \"screen_width\", \"screen_height\"], // uniforms\n [], // samplers\n ratio, null, Texture.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? \"#define PENTAGON\\n\" : \"\");\n this._highlightsPostProcess.externalTextureSamplerBinding = true;\n this._highlightsPostProcess.onApply = (effect) => {\n effect.setFloat(\"gain\", this._highlightsGain);\n effect.setFloat(\"threshold\", this._highlightsThreshold);\n effect.setTextureFromPostProcess(\"textureSampler\", this._chromaticAberrationPostProcess);\n effect.setFloat(\"screen_width\", this._scene.getEngine().getRenderWidth());\n effect.setFloat(\"screen_height\", this._scene.getEngine().getRenderHeight());\n };\n }\n // colors shifting and distortion\n _createDepthOfFieldPostProcess(ratio) {\n this._depthOfFieldPostProcess = new PostProcess(\"LensDepthOfField\", \"depthOfField\", [\n \"grain_amount\",\n \"blur_noise\",\n \"screen_width\",\n \"screen_height\",\n \"distortion\",\n \"dof_enabled\",\n \"screen_distance\",\n \"aperture\",\n \"darken\",\n \"edge_blur\",\n \"highlights\",\n \"near\",\n \"far\",\n ], [\"depthSampler\", \"grainSampler\", \"highlightsSampler\"], ratio, null, Texture.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);\n this._depthOfFieldPostProcess.externalTextureSamplerBinding = true;\n this._depthOfFieldPostProcess.onApply = (effect) => {\n effect.setTexture(\"depthSampler\", this._depthTexture);\n effect.setTexture(\"grainSampler\", this._grainTexture);\n effect.setTextureFromPostProcess(\"textureSampler\", this._highlightsPostProcess);\n effect.setTextureFromPostProcess(\"highlightsSampler\", this._depthOfFieldPostProcess);\n effect.setFloat(\"grain_amount\", this._grainAmount);\n effect.setBool(\"blur_noise\", this._blurNoise);\n effect.setFloat(\"screen_width\", this._scene.getEngine().getRenderWidth());\n effect.setFloat(\"screen_height\", this._scene.getEngine().getRenderHeight());\n effect.setFloat(\"distortion\", this._distortion);\n effect.setBool(\"dof_enabled\", this._dofDistance !== -1);\n effect.setFloat(\"screen_distance\", 1.0 / (0.1 - 1.0 / this._dofDistance));\n effect.setFloat(\"aperture\", this._dofAperture);\n effect.setFloat(\"darken\", this._dofDarken);\n effect.setFloat(\"edge_blur\", this._edgeBlur);\n effect.setBool(\"highlights\", this._highlightsGain !== -1);\n if (this._scene.activeCamera) {\n effect.setFloat(\"near\", this._scene.activeCamera.minZ);\n effect.setFloat(\"far\", this._scene.activeCamera.maxZ);\n }\n };\n }\n // creates a black and white random noise texture, 512x512\n _createGrainTexture() {\n const size = 512;\n this._grainTexture = new DynamicTexture(\"LensNoiseTexture\", size, this._scene, false, Texture.BILINEAR_SAMPLINGMODE);\n this._grainTexture.wrapU = Texture.WRAP_ADDRESSMODE;\n this._grainTexture.wrapV = Texture.WRAP_ADDRESSMODE;\n const context = this._grainTexture.getContext();\n const rand = (min, max) => {\n return Math.random() * (max - min) + min;\n };\n let value;\n for (let x = 0; x < size; x++) {\n for (let y = 0; y < size; y++) {\n value = Math.floor(rand(0.42, 0.58) * 255);\n context.fillStyle = \"rgb(\" + value + \", \" + value + \", \" + value + \")\";\n context.fillRect(x, y, 1, 1);\n }\n }\n this._grainTexture.update(false);\n }\n}\n//# sourceMappingURL=lensRenderingPipeline.js.map","import { Scene } from \"../scene.js\";\nimport { DepthRenderer } from \"./depthRenderer.js\";\n\nimport { SceneComponentConstants } from \"../sceneComponent.js\";\nScene.prototype.enableDepthRenderer = function (camera, storeNonLinearDepth = false, force32bitsFloat = false) {\n camera = camera || this.activeCamera;\n if (!camera) {\n throw \"No camera available to enable depth renderer\";\n }\n if (!this._depthRenderer) {\n this._depthRenderer = {};\n }\n if (!this._depthRenderer[camera.id]) {\n const supportFullfloat = !!this.getEngine().getCaps().textureFloatRender;\n let textureType = 0;\n if (this.getEngine().getCaps().textureHalfFloatRender && (!force32bitsFloat || !supportFullfloat)) {\n textureType = 2;\n }\n else if (supportFullfloat) {\n textureType = 1;\n }\n else {\n textureType = 0;\n }\n this._depthRenderer[camera.id] = new DepthRenderer(this, textureType, camera, storeNonLinearDepth);\n }\n return this._depthRenderer[camera.id];\n};\nScene.prototype.disableDepthRenderer = function (camera) {\n camera = camera || this.activeCamera;\n if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {\n return;\n }\n this._depthRenderer[camera.id].dispose();\n};\n/**\n * Defines the Depth Renderer scene component responsible to manage a depth buffer useful\n * in several rendering techniques.\n */\nexport class DepthRendererSceneComponent {\n /**\n * Creates a new instance of the component for the given scene\n * @param scene Defines the scene to register the component in\n */\n constructor(scene) {\n /**\n * The component name helpful to identify the component in the list of scene components.\n */\n this.name = SceneComponentConstants.NAME_DEPTHRENDERER;\n this.scene = scene;\n }\n /**\n * Registers the component in a given scene\n */\n register() {\n this.scene._gatherRenderTargetsStage.registerStep(SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);\n this.scene._gatherActiveCameraRenderTargetsStage.registerStep(SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);\n }\n /**\n * Rebuilds the elements related to this component in case of\n * context lost for instance.\n */\n rebuild() {\n // Nothing to do for this component\n }\n /**\n * Disposes the component and the associated resources\n */\n dispose() {\n for (const key in this.scene._depthRenderer) {\n this.scene._depthRenderer[key].dispose();\n }\n }\n _gatherRenderTargets(renderTargets) {\n if (this.scene._depthRenderer) {\n for (const key in this.scene._depthRenderer) {\n const depthRenderer = this.scene._depthRenderer[key];\n if (depthRenderer.enabled && !depthRenderer.useOnlyInActiveCamera) {\n renderTargets.push(depthRenderer.getDepthMap());\n }\n }\n }\n }\n _gatherActiveCameraRenderTargets(renderTargets) {\n if (this.scene._depthRenderer) {\n for (const key in this.scene._depthRenderer) {\n const depthRenderer = this.scene._depthRenderer[key];\n if (depthRenderer.enabled && depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {\n renderTargets.push(depthRenderer.getDepthMap());\n }\n }\n }\n }\n}\nDepthRenderer._SceneComponentInitialization = (scene) => {\n // Register the G Buffer component to the scene.\n let component = scene._getComponent(SceneComponentConstants.NAME_DEPTHRENDERER);\n if (!component) {\n component = new DepthRendererSceneComponent(scene);\n scene._addComponent(component);\n }\n};\n//# sourceMappingURL=depthRendererSceneComponent.js.map","/**\r\n * Group the required LensRendering dependencies into a single file to allow a single \"import\"\r\n *\r\n * @internal\r\n */\r\nimport { LensRenderingPipeline } from '@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline';\r\nimport '@babylonjs/core/Rendering/depthRendererSceneComponent';\r\n\r\nexport { LensRenderingPipeline };\r\n"],"names":["shader","this"],"sourceRoot":""}