@babylonjs/core 7.44.0 → 7.45.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 (203) hide show
  1. package/Debug/debugLayer.d.ts +4 -0
  2. package/Debug/debugLayer.js +9 -0
  3. package/Debug/debugLayer.js.map +1 -1
  4. package/Engines/Extensions/engine.renderTarget.js +2 -4
  5. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  6. package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -4
  7. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  8. package/Engines/abstractEngine.d.ts +19 -1
  9. package/Engines/abstractEngine.js +48 -9
  10. package/Engines/abstractEngine.js.map +1 -1
  11. package/Engines/engine.d.ts +1 -1
  12. package/Engines/engine.js +2 -20
  13. package/Engines/engine.js.map +1 -1
  14. package/Engines/renderTargetWrapper.js +2 -2
  15. package/Engines/renderTargetWrapper.js.map +1 -1
  16. package/Engines/thinEngine.js +1 -5
  17. package/Engines/thinEngine.js.map +1 -1
  18. package/Engines/webgpuEngine.js +1 -0
  19. package/Engines/webgpuEngine.js.map +1 -1
  20. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.d.ts +16 -12
  21. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +63 -27
  22. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -1
  23. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.d.ts +72 -0
  24. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +197 -0
  25. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js.map +1 -0
  26. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +4 -0
  27. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +9 -0
  28. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  29. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  30. package/FrameGraph/Node/Blocks/index.js +1 -0
  31. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  32. package/FrameGraph/Node/Types/nodeRenderGraphTypes.d.ts +4 -2
  33. package/FrameGraph/Node/Types/nodeRenderGraphTypes.js +2 -0
  34. package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
  35. package/FrameGraph/Node/nodeRenderGraph.d.ts +3 -2
  36. package/FrameGraph/Node/nodeRenderGraph.js +4 -3
  37. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  38. package/FrameGraph/Node/nodeRenderGraphBlock.js +4 -4
  39. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  40. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.d.ts +8 -0
  41. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +10 -0
  42. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -1
  43. package/FrameGraph/Node/nodeRenderGraphConnectionPointCustomObject.d.ts +21 -0
  44. package/FrameGraph/Node/nodeRenderGraphConnectionPointCustomObject.js +31 -0
  45. package/FrameGraph/Node/nodeRenderGraphConnectionPointCustomObject.js.map +1 -0
  46. package/FrameGraph/Passes/pass.d.ts +1 -0
  47. package/FrameGraph/Passes/pass.js +4 -1
  48. package/FrameGraph/Passes/pass.js.map +1 -1
  49. package/FrameGraph/Tasks/Layers/baseLayerTask.d.ts +81 -0
  50. package/FrameGraph/Tasks/Layers/baseLayerTask.js +304 -0
  51. package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -0
  52. package/FrameGraph/Tasks/Layers/glowLayerTask.d.ts +3 -40
  53. package/FrameGraph/Tasks/Layers/glowLayerTask.js +4 -158
  54. package/FrameGraph/Tasks/Layers/glowLayerTask.js.map +1 -1
  55. package/FrameGraph/Tasks/Layers/highlightLayerTask.d.ts +21 -0
  56. package/FrameGraph/Tasks/Layers/highlightLayerTask.js +32 -0
  57. package/FrameGraph/Tasks/Layers/highlightLayerTask.js.map +1 -0
  58. package/FrameGraph/Tasks/Misc/executeTask.d.ts +2 -2
  59. package/FrameGraph/Tasks/Misc/executeTask.js +1 -0
  60. package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -1
  61. package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js +1 -1
  62. package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js.map +1 -1
  63. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
  64. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  65. package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js +5 -4
  66. package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js.map +1 -1
  67. package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js +5 -4
  68. package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js.map +1 -1
  69. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +2 -4
  70. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
  71. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +4 -2
  72. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  73. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +2 -2
  74. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +1 -0
  75. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  76. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.d.ts +2 -2
  77. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +1 -0
  78. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
  79. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +2 -2
  80. package/FrameGraph/Tasks/Texture/clearTextureTask.js +1 -0
  81. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  82. package/FrameGraph/Tasks/Texture/copyToTextureTask.js +1 -1
  83. package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
  84. package/FrameGraph/frameGraph.d.ts +8 -2
  85. package/FrameGraph/frameGraph.js +31 -5
  86. package/FrameGraph/frameGraph.js.map +1 -1
  87. package/FrameGraph/frameGraphRenderContext.d.ts +10 -0
  88. package/FrameGraph/frameGraphRenderContext.js +14 -0
  89. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  90. package/FrameGraph/frameGraphTask.d.ts +3 -2
  91. package/FrameGraph/frameGraphTask.js +12 -2
  92. package/FrameGraph/frameGraphTask.js.map +1 -1
  93. package/FrameGraph/frameGraphTypes.d.ts +4 -0
  94. package/FrameGraph/frameGraphTypes.js.map +1 -1
  95. package/FrameGraph/index.d.ts +1 -0
  96. package/FrameGraph/index.js +1 -0
  97. package/FrameGraph/index.js.map +1 -1
  98. package/Helpers/environmentHelper.js +7 -6
  99. package/Helpers/environmentHelper.js.map +1 -1
  100. package/Layers/effectLayer.d.ts +1 -1
  101. package/Layers/effectLayer.js.map +1 -1
  102. package/Layers/glowLayer.d.ts +2 -14
  103. package/Layers/glowLayer.js +34 -36
  104. package/Layers/glowLayer.js.map +1 -1
  105. package/Layers/highlightLayer.d.ts +13 -74
  106. package/Layers/highlightLayer.js +123 -309
  107. package/Layers/highlightLayer.js.map +1 -1
  108. package/Layers/index.d.ts +1 -0
  109. package/Layers/index.js +1 -0
  110. package/Layers/index.js.map +1 -1
  111. package/Layers/thinEffectLayer.d.ts +55 -2
  112. package/Layers/thinEffectLayer.js +66 -0
  113. package/Layers/thinEffectLayer.js.map +1 -1
  114. package/Layers/thinGlowLayer.d.ts +3 -6
  115. package/Layers/thinGlowLayer.js +4 -1
  116. package/Layers/thinGlowLayer.js.map +1 -1
  117. package/Layers/thinHighlightLayer.d.ts +197 -0
  118. package/Layers/thinHighlightLayer.js +417 -0
  119. package/Layers/thinHighlightLayer.js.map +1 -0
  120. package/Materials/Node/nodeMaterial.js +2 -1
  121. package/Materials/Node/nodeMaterial.js.map +1 -1
  122. package/Materials/PBR/pbrBRDFConfiguration.d.ts +14 -0
  123. package/Materials/PBR/pbrBRDFConfiguration.js +19 -0
  124. package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
  125. package/Materials/effect.d.ts +5 -0
  126. package/Materials/effect.js +15 -0
  127. package/Materials/effect.js.map +1 -1
  128. package/Meshes/Compression/dracoCompression.d.ts +4 -2
  129. package/Meshes/Compression/dracoCompression.js +24 -11
  130. package/Meshes/Compression/dracoCompression.js.map +1 -1
  131. package/Meshes/Compression/dracoCompressionWorker.js +4 -4
  132. package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
  133. package/Meshes/Compression/dracoEncoder.d.ts +5 -1
  134. package/Meshes/Compression/dracoEncoder.js +23 -17
  135. package/Meshes/Compression/dracoEncoder.js.map +1 -1
  136. package/Meshes/Compression/dracoEncoder.types.d.ts +4 -4
  137. package/Meshes/Compression/dracoEncoder.types.js.map +1 -1
  138. package/Meshes/Compression/meshoptCompression.js +17 -2
  139. package/Meshes/Compression/meshoptCompression.js.map +1 -1
  140. package/Meshes/Compression/test/integration/draco.test.d.ts +1 -0
  141. package/Meshes/Compression/test/integration/draco.test.js +30 -0
  142. package/Meshes/Compression/test/integration/draco.test.js.map +1 -0
  143. package/Meshes/csg.js +4 -0
  144. package/Meshes/csg.js.map +1 -1
  145. package/Meshes/transformNode.d.ts +4 -1
  146. package/Meshes/transformNode.js +4 -1
  147. package/Meshes/transformNode.js.map +1 -1
  148. package/Misc/copyTextureToTexture.js +1 -1
  149. package/Misc/copyTextureToTexture.js.map +1 -1
  150. package/Misc/error.d.ts +6 -0
  151. package/Misc/error.js +10 -0
  152. package/Misc/error.js.map +1 -1
  153. package/Misc/screenshotTools.js +58 -5
  154. package/Misc/screenshotTools.js.map +1 -1
  155. package/Misc/tools.d.ts +21 -1
  156. package/Misc/tools.js +33 -0
  157. package/Misc/tools.js.map +1 -1
  158. package/Particles/particleHelper.js +2 -1
  159. package/Particles/particleHelper.js.map +1 -1
  160. package/Particles/particleSystemSet.d.ts +1 -0
  161. package/Particles/particleSystemSet.js +1 -0
  162. package/Particles/particleSystemSet.js.map +1 -1
  163. package/Particles/webgl2ParticleSystem.d.ts +1 -1
  164. package/Particles/webgl2ParticleSystem.js +1 -2
  165. package/Particles/webgl2ParticleSystem.js.map +1 -1
  166. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +2 -1
  167. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  168. package/Rendering/depthRenderer.js +1 -1
  169. package/Rendering/depthRenderer.js.map +1 -1
  170. package/Rendering/objectRenderer.d.ts +5 -3
  171. package/Rendering/objectRenderer.js +5 -3
  172. package/Rendering/objectRenderer.js.map +1 -1
  173. package/Rendering/renderingManager.d.ts +4 -0
  174. package/Rendering/renderingManager.js +1 -0
  175. package/Rendering/renderingManager.js.map +1 -1
  176. package/Shaders/ShadersInclude/intersectionFunctions.d.ts +5 -0
  177. package/Shaders/ShadersInclude/intersectionFunctions.js +14 -0
  178. package/Shaders/ShadersInclude/intersectionFunctions.js.map +1 -0
  179. package/Shaders/ShadersInclude/pbrBlockReflection.js +7 -1
  180. package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
  181. package/Shaders/background.fragment.d.ts +1 -0
  182. package/Shaders/background.fragment.js +3 -5
  183. package/Shaders/background.fragment.js.map +1 -1
  184. package/Shaders/gaussianSplatting.vertex.d.ts +1 -0
  185. package/Shaders/gaussianSplatting.vertex.js +3 -1
  186. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  187. package/ShadersWGSL/ShadersInclude/intersectionFunctions.d.ts +5 -0
  188. package/ShadersWGSL/ShadersInclude/intersectionFunctions.js +14 -0
  189. package/ShadersWGSL/ShadersInclude/intersectionFunctions.js.map +1 -0
  190. package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js +7 -1
  191. package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js.map +1 -1
  192. package/ShadersWGSL/background.fragment.d.ts +1 -0
  193. package/ShadersWGSL/background.fragment.js +3 -5
  194. package/ShadersWGSL/background.fragment.js.map +1 -1
  195. package/ShadersWGSL/glowMapGeneration.fragment.js +1 -2
  196. package/ShadersWGSL/glowMapGeneration.fragment.js.map +1 -1
  197. package/ShadersWGSL/layer.fragment.js +1 -2
  198. package/ShadersWGSL/layer.fragment.js.map +1 -1
  199. package/XR/features/WebXRHandTracking.js +8 -7
  200. package/XR/features/WebXRHandTracking.js.map +1 -1
  201. package/package.json +1 -1
  202. package/types.d.ts +4 -0
  203. package/types.js.map +1 -1
@@ -0,0 +1,197 @@
1
+ import type { Observer, Nullable, Scene, SubMesh, AbstractMesh, Mesh, Effect, IThinEffectLayerOptions, Color3 } from "../index.js";
2
+ import { Material } from "../Materials/material";
3
+ import { ThinEffectLayer } from "./thinEffectLayer";
4
+ import { Color4 } from "../Maths/math.color";
5
+ /**
6
+ * Highlight layer options. This helps customizing the behaviour
7
+ * of the highlight layer.
8
+ */
9
+ export interface IThinHighlightLayerOptions extends IThinEffectLayerOptions {
10
+ /**
11
+ * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
12
+ * of the picture to blur (the smaller the faster). Default: 0.5
13
+ */
14
+ blurTextureSizeRatio?: number;
15
+ /**
16
+ * How big in texel of the blur texture is the vertical blur. Default: 1
17
+ */
18
+ blurVerticalSize?: number;
19
+ /**
20
+ * How big in texel of the blur texture is the horizontal blur. Default: 1
21
+ */
22
+ blurHorizontalSize?: number;
23
+ /**
24
+ * Should we display highlight as a solid stroke? Default: false
25
+ */
26
+ isStroke?: boolean;
27
+ /**
28
+ * Use the GLSL code generation for the shader (even on WebGPU). Default is false
29
+ */
30
+ forceGLSL?: boolean;
31
+ }
32
+ /**
33
+ * Storage interface grouping all the information required for glowing a mesh.
34
+ */
35
+ interface IHighlightLayerMesh {
36
+ /**
37
+ * The glowy mesh
38
+ */
39
+ mesh: Mesh;
40
+ /**
41
+ * The color of the glow
42
+ */
43
+ color: Color3;
44
+ /**
45
+ * The mesh render callback use to insert stencil information
46
+ */
47
+ observerHighlight: Nullable<Observer<Mesh>>;
48
+ /**
49
+ * The mesh render callback use to come to the default behavior
50
+ */
51
+ observerDefault: Nullable<Observer<Mesh>>;
52
+ /**
53
+ * If it exists, the emissive color of the material will be used to generate the glow.
54
+ * Else it falls back to the current color.
55
+ */
56
+ glowEmissiveOnly: boolean;
57
+ }
58
+ /**
59
+ * Storage interface grouping all the information required for an excluded mesh.
60
+ */
61
+ interface IHighlightLayerExcludedMesh {
62
+ /**
63
+ * The glowy mesh
64
+ */
65
+ mesh: Mesh;
66
+ /**
67
+ * The mesh render callback use to prevent stencil use
68
+ */
69
+ beforeBind: Nullable<Observer<Mesh>>;
70
+ /**
71
+ * The mesh render callback use to restore previous stencil use
72
+ */
73
+ afterRender: Nullable<Observer<Mesh>>;
74
+ /**
75
+ * Current stencil state of the engine
76
+ */
77
+ stencilState: boolean;
78
+ }
79
+ /**
80
+ * @internal
81
+ */
82
+ export declare class ThinHighlightLayer extends ThinEffectLayer {
83
+ /**
84
+ * Effect Name of the highlight layer.
85
+ */
86
+ static readonly EffectName = "HighlightLayer";
87
+ /**
88
+ * The neutral color used during the preparation of the glow effect.
89
+ * This is black by default as the blend operation is a blend operation.
90
+ */
91
+ static NeutralColor: Color4;
92
+ /**
93
+ * Stencil value used for glowing meshes.
94
+ */
95
+ static GlowingMeshStencilReference: number;
96
+ /**
97
+ * Stencil value used for the other meshes in the scene.
98
+ */
99
+ static NormalMeshStencilReference: number;
100
+ /**
101
+ * Specifies whether or not the inner glow is ACTIVE in the layer.
102
+ */
103
+ innerGlow: boolean;
104
+ /**
105
+ * Specifies whether or not the outer glow is ACTIVE in the layer.
106
+ */
107
+ outerGlow: boolean;
108
+ /**
109
+ * Specifies the horizontal size of the blur.
110
+ */
111
+ set blurHorizontalSize(value: number);
112
+ /**
113
+ * Specifies the vertical size of the blur.
114
+ */
115
+ set blurVerticalSize(value: number);
116
+ /**
117
+ * Gets the horizontal size of the blur.
118
+ */
119
+ get blurHorizontalSize(): number;
120
+ /**
121
+ * Gets the vertical size of the blur.
122
+ */
123
+ get blurVerticalSize(): number;
124
+ private _instanceGlowingMeshStencilReference;
125
+ /** @internal */
126
+ _options: Required<IThinHighlightLayerOptions>;
127
+ private _downSamplePostprocess;
128
+ private _horizontalBlurPostprocess;
129
+ private _verticalBlurPostprocess;
130
+ /** @internal */
131
+ _meshes: Nullable<{
132
+ [id: string]: Nullable<IHighlightLayerMesh>;
133
+ }>;
134
+ /** @internal */
135
+ _excludedMeshes: Nullable<{
136
+ [id: string]: Nullable<IHighlightLayerExcludedMesh>;
137
+ }>;
138
+ /** @internal */
139
+ _mainObjectRendererRenderPassId: number;
140
+ /**
141
+ * Instantiates a new highlight Layer and references it to the scene..
142
+ * @param name The name of the layer
143
+ * @param scene The scene to use the layer in
144
+ * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
145
+ * @param dontCheckIfReady Specifies if the layer should disable checking whether all the post processes are ready (default: false). To save performance, this should be set to true and you should call `isReady` manually before rendering to the layer.
146
+ */
147
+ constructor(name: string, scene?: Scene, options?: Partial<IThinHighlightLayerOptions>, dontCheckIfReady?: boolean);
148
+ /**
149
+ * Gets the class name of the effect layer
150
+ * @returns the string with the class name of the effect layer
151
+ */
152
+ getClassName(): string;
153
+ protected _importShadersAsync(): Promise<void>;
154
+ getEffectName(): string;
155
+ _numInternalDraws(): number;
156
+ _createMergeEffect(): Effect;
157
+ _createTextureAndPostProcesses(): void;
158
+ needStencil(): boolean;
159
+ isReady(subMesh: SubMesh, useInstances: boolean): boolean;
160
+ _canRenderMesh(_mesh: AbstractMesh, _material: Material): boolean;
161
+ _internalCompose(effect: Effect, renderIndex: number): void;
162
+ _setEmissiveTextureAndColor(mesh: Mesh, _subMesh: SubMesh, material: Material): void;
163
+ shouldRender(): boolean;
164
+ _shouldRenderMesh(mesh: Mesh): boolean;
165
+ _addCustomEffectDefines(defines: string[]): void;
166
+ /**
167
+ * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
168
+ * @param mesh The mesh to exclude from the highlight layer
169
+ */
170
+ addExcludedMesh(mesh: Mesh): void;
171
+ /**
172
+ * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
173
+ * @param mesh The mesh to highlight
174
+ */
175
+ removeExcludedMesh(mesh: Mesh): void;
176
+ hasMesh(mesh: AbstractMesh): boolean;
177
+ /**
178
+ * Add a mesh in the highlight layer in order to make it glow with the chosen color.
179
+ * @param mesh The mesh to highlight
180
+ * @param color The color of the highlight
181
+ * @param glowEmissiveOnly Extract the glow from the emissive texture
182
+ */
183
+ addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
184
+ /**
185
+ * Remove a mesh from the highlight layer in order to make it stop glowing.
186
+ * @param mesh The mesh to highlight
187
+ */
188
+ removeMesh(mesh: Mesh): void;
189
+ /**
190
+ * Remove all the meshes currently referenced in the highlight layer
191
+ */
192
+ removeAllMeshes(): void;
193
+ private _defaultStencilReference;
194
+ _disposeMesh(mesh: Mesh): void;
195
+ dispose(): void;
196
+ }
197
+ export {};
@@ -0,0 +1,417 @@
1
+ import { Vector2 } from "../Maths/math.vector.js";
2
+ import { VertexBuffer } from "../Buffers/buffer.js";
3
+ import { Material } from "../Materials/material.js";
4
+ import { ThinPassPostProcess } from "../PostProcesses/thinPassPostProcess.js";
5
+ import { ThinEffectLayer, ThinGlowBlurPostProcess } from "./thinEffectLayer.js";
6
+
7
+ import { Color4 } from "../Maths/math.color.js";
8
+ import { ThinBlurPostProcess } from "../PostProcesses/thinBlurPostProcess.js";
9
+ /**
10
+ * @internal
11
+ */
12
+ export class ThinHighlightLayer extends ThinEffectLayer {
13
+ /**
14
+ * Specifies the horizontal size of the blur.
15
+ */
16
+ set blurHorizontalSize(value) {
17
+ this._horizontalBlurPostprocess.kernel = value;
18
+ this._options.blurHorizontalSize = value;
19
+ }
20
+ /**
21
+ * Specifies the vertical size of the blur.
22
+ */
23
+ set blurVerticalSize(value) {
24
+ this._verticalBlurPostprocess.kernel = value;
25
+ this._options.blurVerticalSize = value;
26
+ }
27
+ /**
28
+ * Gets the horizontal size of the blur.
29
+ */
30
+ get blurHorizontalSize() {
31
+ return this._horizontalBlurPostprocess.kernel;
32
+ }
33
+ /**
34
+ * Gets the vertical size of the blur.
35
+ */
36
+ get blurVerticalSize() {
37
+ return this._verticalBlurPostprocess.kernel;
38
+ }
39
+ /**
40
+ * Instantiates a new highlight Layer and references it to the scene..
41
+ * @param name The name of the layer
42
+ * @param scene The scene to use the layer in
43
+ * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
44
+ * @param dontCheckIfReady Specifies if the layer should disable checking whether all the post processes are ready (default: false). To save performance, this should be set to true and you should call `isReady` manually before rendering to the layer.
45
+ */
46
+ constructor(name, scene, options, dontCheckIfReady = false) {
47
+ super(name, scene, options !== undefined ? !!options.forceGLSL : false);
48
+ /**
49
+ * Specifies whether or not the inner glow is ACTIVE in the layer.
50
+ */
51
+ this.innerGlow = true;
52
+ /**
53
+ * Specifies whether or not the outer glow is ACTIVE in the layer.
54
+ */
55
+ this.outerGlow = true;
56
+ this._instanceGlowingMeshStencilReference = ThinHighlightLayer.GlowingMeshStencilReference++;
57
+ /** @internal */
58
+ this._meshes = {};
59
+ /** @internal */
60
+ this._excludedMeshes = {};
61
+ /** @internal */
62
+ this._mainObjectRendererRenderPassId = -1;
63
+ this.neutralColor = ThinHighlightLayer.NeutralColor;
64
+ // Adapt options
65
+ this._options = {
66
+ mainTextureRatio: 0.5,
67
+ blurTextureSizeRatio: 0.5,
68
+ mainTextureFixedSize: 0,
69
+ blurHorizontalSize: 1.0,
70
+ blurVerticalSize: 1.0,
71
+ alphaBlendingMode: 2,
72
+ camera: null,
73
+ renderingGroupId: -1,
74
+ forceGLSL: false,
75
+ mainTextureType: 0,
76
+ isStroke: false,
77
+ ...options,
78
+ };
79
+ // Initialize the layer
80
+ this._init(this._options);
81
+ // Do not render as long as no meshes have been added
82
+ this._shouldRender = false;
83
+ if (dontCheckIfReady) {
84
+ // When dontCheckIfReady is true, we are in the new ThinXXX layer mode, so we must call _createTextureAndPostProcesses ourselves (it is called by EffectLayer otherwise)
85
+ this._createTextureAndPostProcesses();
86
+ }
87
+ }
88
+ /**
89
+ * Gets the class name of the effect layer
90
+ * @returns the string with the class name of the effect layer
91
+ */
92
+ getClassName() {
93
+ return "HighlightLayer";
94
+ }
95
+ async _importShadersAsync() {
96
+ if (this._shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
97
+ await Promise.all([
98
+ import("../ShadersWGSL/glowMapMerge.fragment.js"),
99
+ import("../ShadersWGSL/glowMapMerge.vertex.js"),
100
+ import("../ShadersWGSL/glowBlurPostProcess.fragment.js"),
101
+ ]);
102
+ }
103
+ else {
104
+ await Promise.all([import("../Shaders/glowMapMerge.fragment.js"), import("../Shaders/glowMapMerge.vertex.js"), import("../Shaders/glowBlurPostProcess.fragment.js")]);
105
+ }
106
+ await super._importShadersAsync();
107
+ }
108
+ getEffectName() {
109
+ return ThinHighlightLayer.EffectName;
110
+ }
111
+ _numInternalDraws() {
112
+ return 2; // we need two rendering, one for the inner glow and the other for the outer glow
113
+ }
114
+ _createMergeEffect() {
115
+ return this._engine.createEffect("glowMapMerge", [VertexBuffer.PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined, undefined, undefined, undefined, undefined, this._shaderLanguage, this._shadersLoaded
116
+ ? undefined
117
+ : async () => {
118
+ await this._importShadersAsync();
119
+ this._shadersLoaded = true;
120
+ });
121
+ }
122
+ _createTextureAndPostProcesses() {
123
+ if (this._options.alphaBlendingMode === 2) {
124
+ this._downSamplePostprocess = new ThinPassPostProcess("HighlightLayerPPP", this._scene.getEngine());
125
+ this._horizontalBlurPostprocess = new ThinGlowBlurPostProcess("HighlightLayerHBP", this._scene.getEngine(), new Vector2(1.0, 0), this._options.blurHorizontalSize);
126
+ this._verticalBlurPostprocess = new ThinGlowBlurPostProcess("HighlightLayerVBP", this._scene.getEngine(), new Vector2(0, 1.0), this._options.blurVerticalSize);
127
+ this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
128
+ }
129
+ else {
130
+ this._horizontalBlurPostprocess = new ThinBlurPostProcess("HighlightLayerHBP", this._scene.getEngine(), new Vector2(1.0, 0), this._options.blurHorizontalSize / 2);
131
+ this._verticalBlurPostprocess = new ThinBlurPostProcess("HighlightLayerVBP", this._scene.getEngine(), new Vector2(0, 1.0), this._options.blurVerticalSize / 2);
132
+ this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
133
+ }
134
+ }
135
+ needStencil() {
136
+ return true;
137
+ }
138
+ isReady(subMesh, useInstances) {
139
+ const material = subMesh.getMaterial();
140
+ const mesh = subMesh.getRenderingMesh();
141
+ if (!material || !mesh || !this._meshes) {
142
+ return false;
143
+ }
144
+ let emissiveTexture = null;
145
+ const highlightLayerMesh = this._meshes[mesh.uniqueId];
146
+ if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
147
+ emissiveTexture = material.emissiveTexture;
148
+ }
149
+ return super._isSubMeshReady(subMesh, useInstances, emissiveTexture);
150
+ }
151
+ _canRenderMesh(_mesh, _material) {
152
+ // all meshes can be rendered in the highlight layer, even transparent ones
153
+ return true;
154
+ }
155
+ _internalCompose(effect, renderIndex) {
156
+ // Texture
157
+ this.bindTexturesForCompose(effect);
158
+ // Cache
159
+ const engine = this._engine;
160
+ engine.cacheStencilState();
161
+ // Stencil operations
162
+ engine.setStencilOperationPass(7681);
163
+ engine.setStencilOperationFail(7680);
164
+ engine.setStencilOperationDepthFail(7680);
165
+ // Draw order
166
+ engine.setStencilMask(0x00);
167
+ engine.setStencilBuffer(true);
168
+ engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
169
+ // 2 passes inner outer
170
+ if (this.outerGlow && renderIndex === 0) {
171
+ // the outer glow is rendered the first time _internalRender is called, so when renderIndex == 0 (and only if outerGlow is enabled)
172
+ effect.setFloat("offset", 0);
173
+ engine.setStencilFunction(517);
174
+ engine.drawElementsType(Material.TriangleFillMode, 0, 6);
175
+ }
176
+ if (this.innerGlow && renderIndex === 1) {
177
+ // the inner glow is rendered the second time _internalRender is called, so when renderIndex == 1 (and only if innerGlow is enabled)
178
+ effect.setFloat("offset", 1);
179
+ engine.setStencilFunction(514);
180
+ engine.drawElementsType(Material.TriangleFillMode, 0, 6);
181
+ }
182
+ // Restore Cache
183
+ engine.restoreStencilState();
184
+ }
185
+ _setEmissiveTextureAndColor(mesh, _subMesh, material) {
186
+ const highlightLayerMesh = this._meshes[mesh.uniqueId];
187
+ if (highlightLayerMesh) {
188
+ this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
189
+ }
190
+ else {
191
+ this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
192
+ }
193
+ if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
194
+ this._emissiveTextureAndColor.texture = material.emissiveTexture;
195
+ this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
196
+ }
197
+ else {
198
+ this._emissiveTextureAndColor.texture = null;
199
+ }
200
+ }
201
+ shouldRender() {
202
+ return this._meshes && super.shouldRender() ? true : false;
203
+ }
204
+ _shouldRenderMesh(mesh) {
205
+ if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
206
+ return false;
207
+ }
208
+ return super.hasMesh(mesh);
209
+ }
210
+ _addCustomEffectDefines(defines) {
211
+ defines.push("#define HIGHLIGHT");
212
+ }
213
+ /**
214
+ * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
215
+ * @param mesh The mesh to exclude from the highlight layer
216
+ */
217
+ addExcludedMesh(mesh) {
218
+ if (!this._excludedMeshes) {
219
+ return;
220
+ }
221
+ const meshExcluded = this._excludedMeshes[mesh.uniqueId];
222
+ if (!meshExcluded) {
223
+ const obj = {
224
+ mesh: mesh,
225
+ beforeBind: null,
226
+ afterRender: null,
227
+ stencilState: false,
228
+ };
229
+ obj.beforeBind = mesh.onBeforeBindObservable.add((mesh) => {
230
+ if (this._mainObjectRendererRenderPassId !== -1 && this._mainObjectRendererRenderPassId !== this._engine.currentRenderPassId) {
231
+ return;
232
+ }
233
+ obj.stencilState = mesh.getEngine().getStencilBuffer();
234
+ mesh.getEngine().setStencilBuffer(false);
235
+ });
236
+ obj.afterRender = mesh.onAfterRenderObservable.add((mesh) => {
237
+ if (this._mainObjectRendererRenderPassId !== -1 && this._mainObjectRendererRenderPassId !== this._engine.currentRenderPassId) {
238
+ return;
239
+ }
240
+ mesh.getEngine().setStencilBuffer(obj.stencilState);
241
+ });
242
+ this._excludedMeshes[mesh.uniqueId] = obj;
243
+ }
244
+ }
245
+ /**
246
+ * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
247
+ * @param mesh The mesh to highlight
248
+ */
249
+ removeExcludedMesh(mesh) {
250
+ if (!this._excludedMeshes) {
251
+ return;
252
+ }
253
+ const meshExcluded = this._excludedMeshes[mesh.uniqueId];
254
+ if (meshExcluded) {
255
+ if (meshExcluded.beforeBind) {
256
+ mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
257
+ }
258
+ if (meshExcluded.afterRender) {
259
+ mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
260
+ }
261
+ }
262
+ this._excludedMeshes[mesh.uniqueId] = null;
263
+ }
264
+ hasMesh(mesh) {
265
+ if (!this._meshes || !super.hasMesh(mesh)) {
266
+ return false;
267
+ }
268
+ return !!this._meshes[mesh.uniqueId];
269
+ }
270
+ /**
271
+ * Add a mesh in the highlight layer in order to make it glow with the chosen color.
272
+ * @param mesh The mesh to highlight
273
+ * @param color The color of the highlight
274
+ * @param glowEmissiveOnly Extract the glow from the emissive texture
275
+ */
276
+ addMesh(mesh, color, glowEmissiveOnly = false) {
277
+ if (!this._meshes) {
278
+ return;
279
+ }
280
+ const meshHighlight = this._meshes[mesh.uniqueId];
281
+ if (meshHighlight) {
282
+ meshHighlight.color = color;
283
+ }
284
+ else {
285
+ this._meshes[mesh.uniqueId] = {
286
+ mesh: mesh,
287
+ color: color,
288
+ // Lambda required for capture due to Observable this context
289
+ observerHighlight: mesh.onBeforeBindObservable.add((mesh) => {
290
+ if (this._mainObjectRendererRenderPassId !== -1 && this._mainObjectRendererRenderPassId !== this._engine.currentRenderPassId) {
291
+ return;
292
+ }
293
+ if (this.isEnabled) {
294
+ if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
295
+ this._defaultStencilReference(mesh);
296
+ }
297
+ else {
298
+ mesh.getScene().getEngine().setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
299
+ }
300
+ }
301
+ }),
302
+ observerDefault: mesh.onAfterRenderObservable.add((mesh) => {
303
+ if (this._mainObjectRendererRenderPassId !== -1 && this._mainObjectRendererRenderPassId !== this._engine.currentRenderPassId) {
304
+ return;
305
+ }
306
+ if (this.isEnabled) {
307
+ this._defaultStencilReference(mesh);
308
+ }
309
+ }),
310
+ glowEmissiveOnly: glowEmissiveOnly,
311
+ };
312
+ mesh.onDisposeObservable.add(() => {
313
+ this._disposeMesh(mesh);
314
+ });
315
+ }
316
+ this._shouldRender = true;
317
+ }
318
+ /**
319
+ * Remove a mesh from the highlight layer in order to make it stop glowing.
320
+ * @param mesh The mesh to highlight
321
+ */
322
+ removeMesh(mesh) {
323
+ if (!this._meshes) {
324
+ return;
325
+ }
326
+ const meshHighlight = this._meshes[mesh.uniqueId];
327
+ if (meshHighlight) {
328
+ if (meshHighlight.observerHighlight) {
329
+ mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
330
+ }
331
+ if (meshHighlight.observerDefault) {
332
+ mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
333
+ }
334
+ delete this._meshes[mesh.uniqueId];
335
+ }
336
+ this._shouldRender = false;
337
+ for (const meshHighlightToCheck in this._meshes) {
338
+ if (this._meshes[meshHighlightToCheck]) {
339
+ this._shouldRender = true;
340
+ break;
341
+ }
342
+ }
343
+ }
344
+ /**
345
+ * Remove all the meshes currently referenced in the highlight layer
346
+ */
347
+ removeAllMeshes() {
348
+ if (!this._meshes) {
349
+ return;
350
+ }
351
+ for (const uniqueId in this._meshes) {
352
+ if (Object.prototype.hasOwnProperty.call(this._meshes, uniqueId)) {
353
+ const mesh = this._meshes[uniqueId];
354
+ if (mesh) {
355
+ this.removeMesh(mesh.mesh);
356
+ }
357
+ }
358
+ }
359
+ }
360
+ _defaultStencilReference(mesh) {
361
+ mesh.getScene().getEngine().setStencilFunctionReference(ThinHighlightLayer.NormalMeshStencilReference);
362
+ }
363
+ _disposeMesh(mesh) {
364
+ this.removeMesh(mesh);
365
+ this.removeExcludedMesh(mesh);
366
+ }
367
+ dispose() {
368
+ if (this._meshes) {
369
+ // Clean mesh references
370
+ for (const id in this._meshes) {
371
+ const meshHighlight = this._meshes[id];
372
+ if (meshHighlight && meshHighlight.mesh) {
373
+ if (meshHighlight.observerHighlight) {
374
+ meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
375
+ }
376
+ if (meshHighlight.observerDefault) {
377
+ meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
378
+ }
379
+ }
380
+ }
381
+ this._meshes = null;
382
+ }
383
+ if (this._excludedMeshes) {
384
+ for (const id in this._excludedMeshes) {
385
+ const meshHighlight = this._excludedMeshes[id];
386
+ if (meshHighlight) {
387
+ if (meshHighlight.beforeBind) {
388
+ meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
389
+ }
390
+ if (meshHighlight.afterRender) {
391
+ meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
392
+ }
393
+ }
394
+ }
395
+ this._excludedMeshes = null;
396
+ }
397
+ super.dispose();
398
+ }
399
+ }
400
+ /**
401
+ * Effect Name of the highlight layer.
402
+ */
403
+ ThinHighlightLayer.EffectName = "HighlightLayer";
404
+ /**
405
+ * The neutral color used during the preparation of the glow effect.
406
+ * This is black by default as the blend operation is a blend operation.
407
+ */
408
+ ThinHighlightLayer.NeutralColor = new Color4(0, 0, 0, 0);
409
+ /**
410
+ * Stencil value used for glowing meshes.
411
+ */
412
+ ThinHighlightLayer.GlowingMeshStencilReference = 0x02;
413
+ /**
414
+ * Stencil value used for the other meshes in the scene.
415
+ */
416
+ ThinHighlightLayer.NormalMeshStencilReference = 0x01;
417
+ //# sourceMappingURL=thinHighlightLayer.js.map