@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
@@ -4,8 +4,6 @@ import { serialize } from "../Misc/decorators.js";
4
4
  import { Observable } from "../Misc/observable.js";
5
5
  import { Scene } from "../scene.js";
6
6
  import { Vector2 } from "../Maths/math.vector.js";
7
- import { VertexBuffer } from "../Buffers/buffer.js";
8
- import { Material } from "../Materials/material.js";
9
7
  import { Texture } from "../Materials/Textures/texture.js";
10
8
  import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture.js";
11
9
  import { PostProcess } from "../PostProcesses/postProcess.js";
@@ -15,9 +13,11 @@ import { EffectLayer } from "./effectLayer.js";
15
13
 
16
14
  import { Logger } from "../Misc/logger.js";
17
15
  import { RegisterClass } from "../Misc/typeStore.js";
18
- import { Color4, Color3 } from "../Maths/math.color.js";
16
+ import { Color3 } from "../Maths/math.color.js";
19
17
  import { SerializationHelper } from "../Misc/decorators.serialization.js";
20
18
  import { GetExponentOfTwo } from "../Misc/tools.functions.js";
19
+ import { ThinHighlightLayer } from "./thinHighlightLayer.js";
20
+ import { ThinGlowBlurPostProcess } from "./thinEffectLayer.js";
21
21
  Scene.prototype.getHighlightLayerByName = function (name) {
22
22
  for (let index = 0; index < this.effectLayers?.length; index++) {
23
23
  if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
@@ -31,14 +31,25 @@ Scene.prototype.getHighlightLayerByName = function (name) {
31
31
  * It enforces keeping the most luminous color in the color channel.
32
32
  */
33
33
  class GlowBlurPostProcess extends PostProcess {
34
- constructor(name, direction, kernel, options, camera, samplingMode = Texture.BILINEAR_SAMPLINGMODE, engine, reusable) {
35
- super(name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable);
34
+ constructor(name, direction, kernel, options, camera = null, samplingMode = Texture.BILINEAR_SAMPLINGMODE, engine, reusable) {
35
+ const localOptions = {
36
+ uniforms: ThinGlowBlurPostProcess.Uniforms,
37
+ size: typeof options === "number" ? options : undefined,
38
+ camera,
39
+ samplingMode,
40
+ engine,
41
+ reusable,
42
+ ...options,
43
+ };
44
+ super(name, ThinGlowBlurPostProcess.FragmentUrl, {
45
+ effectWrapper: typeof options === "number" || !options.effectWrapper ? new ThinGlowBlurPostProcess(name, engine, direction, kernel, localOptions) : undefined,
46
+ ...localOptions,
47
+ });
36
48
  this.direction = direction;
37
49
  this.kernel = kernel;
38
- this.onApplyObservable.add((effect) => {
39
- effect.setFloat2("screenSize", this.width, this.height);
40
- effect.setVector2("direction", this.direction);
41
- effect.setFloat("blurWidth", this.kernel);
50
+ this.onApplyObservable.add(() => {
51
+ this._effectWrapper.textureWidth = this.width;
52
+ this._effectWrapper.textureHeight = this.height;
42
53
  });
43
54
  }
44
55
  _gatherImports(useWebGPU, list) {
@@ -61,31 +72,57 @@ class GlowBlurPostProcess extends PostProcess {
61
72
  * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
62
73
  */
63
74
  export class HighlightLayer extends EffectLayer {
75
+ /**
76
+ * The neutral color used during the preparation of the glow effect.
77
+ * This is black by default as the blend operation is a blend operation.
78
+ */
79
+ static get NeutralColor() {
80
+ return ThinHighlightLayer.NeutralColor;
81
+ }
82
+ static set NeutralColor(value) {
83
+ ThinHighlightLayer.NeutralColor = value;
84
+ }
85
+ /**
86
+ * Specifies whether or not the inner glow is ACTIVE in the layer.
87
+ */
88
+ get innerGlow() {
89
+ return this._thinEffectLayer.innerGlow;
90
+ }
91
+ set innerGlow(value) {
92
+ this._thinEffectLayer.innerGlow = value;
93
+ }
94
+ /**
95
+ * Specifies whether or not the outer glow is ACTIVE in the layer.
96
+ */
97
+ get outerGlow() {
98
+ return this._thinEffectLayer.outerGlow;
99
+ }
100
+ set outerGlow(value) {
101
+ this._thinEffectLayer.outerGlow = value;
102
+ }
64
103
  /**
65
104
  * Specifies the horizontal size of the blur.
66
105
  */
67
106
  set blurHorizontalSize(value) {
68
- this._horizontalBlurPostprocess.kernel = value;
69
- this._options.blurHorizontalSize = value;
107
+ this._thinEffectLayer.blurHorizontalSize = value;
70
108
  }
71
109
  /**
72
110
  * Specifies the vertical size of the blur.
73
111
  */
74
112
  set blurVerticalSize(value) {
75
- this._verticalBlurPostprocess.kernel = value;
76
- this._options.blurVerticalSize = value;
113
+ this._thinEffectLayer.blurVerticalSize = value;
77
114
  }
78
115
  /**
79
116
  * Gets the horizontal size of the blur.
80
117
  */
81
118
  get blurHorizontalSize() {
82
- return this._horizontalBlurPostprocess.kernel;
119
+ return this._thinEffectLayer.blurHorizontalSize;
83
120
  }
84
121
  /**
85
122
  * Gets the vertical size of the blur.
86
123
  */
87
124
  get blurVerticalSize() {
88
- return this._verticalBlurPostprocess.kernel;
125
+ return this._thinEffectLayer.blurVerticalSize;
89
126
  }
90
127
  /**
91
128
  * Instantiates a new highlight Layer and references it to the scene..
@@ -94,15 +131,7 @@ export class HighlightLayer extends EffectLayer {
94
131
  * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
95
132
  */
96
133
  constructor(name, scene, options) {
97
- super(name, scene, options !== undefined ? !!options.forceGLSL : false);
98
- /**
99
- * Specifies whether or not the inner glow is ACTIVE in the layer.
100
- */
101
- this.innerGlow = true;
102
- /**
103
- * Specifies whether or not the outer glow is ACTIVE in the layer.
104
- */
105
- this.outerGlow = true;
134
+ super(name, scene, options !== undefined ? !!options.forceGLSL : false, new ThinHighlightLayer(name, scene, options));
106
135
  /**
107
136
  * An event triggered when the highlight layer is being blurred.
108
137
  */
@@ -111,10 +140,6 @@ export class HighlightLayer extends EffectLayer {
111
140
  * An event triggered when the highlight layer has been blurred.
112
141
  */
113
142
  this.onAfterBlurObservable = new Observable();
114
- this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
115
- this._meshes = {};
116
- this._excludedMeshes = {};
117
- this.neutralColor = HighlightLayer.NeutralColor;
118
143
  // Warn on stencil
119
144
  if (!this._engine.isStencilEnable) {
120
145
  Logger.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }");
@@ -123,6 +148,7 @@ export class HighlightLayer extends EffectLayer {
123
148
  this._options = {
124
149
  mainTextureRatio: 0.5,
125
150
  blurTextureSizeRatio: 0.5,
151
+ mainTextureFixedSize: 0,
126
152
  blurHorizontalSize: 1.0,
127
153
  blurVerticalSize: 1.0,
128
154
  alphaBlendingMode: 2,
@@ -130,33 +156,14 @@ export class HighlightLayer extends EffectLayer {
130
156
  renderingGroupId: -1,
131
157
  mainTextureType: 0,
132
158
  forceGLSL: false,
159
+ isStroke: false,
133
160
  ...options,
134
161
  };
135
162
  // Initialize the layer
136
- this._init({
137
- alphaBlendingMode: this._options.alphaBlendingMode,
138
- camera: this._options.camera,
139
- mainTextureFixedSize: this._options.mainTextureFixedSize,
140
- mainTextureRatio: this._options.mainTextureRatio,
141
- renderingGroupId: this._options.renderingGroupId,
142
- mainTextureType: this._options.mainTextureType,
143
- });
163
+ this._init(this._options);
144
164
  // Do not render as long as no meshes have been added
145
165
  this._shouldRender = false;
146
166
  }
147
- async _importShadersAsync() {
148
- if (this._shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
149
- await Promise.all([
150
- import("../ShadersWGSL/glowMapMerge.fragment.js"),
151
- import("../ShadersWGSL/glowMapMerge.vertex.js"),
152
- import("../ShadersWGSL/glowBlurPostProcess.fragment.js"),
153
- ]);
154
- }
155
- else {
156
- await Promise.all([import("../Shaders/glowMapMerge.fragment.js"), import("../Shaders/glowMapMerge.vertex.js"), import("../Shaders/glowBlurPostProcess.fragment.js")]);
157
- }
158
- await super._importShadersAsync();
159
- }
160
167
  /**
161
168
  * Get the effect name of the layer.
162
169
  * @returns The effect name
@@ -173,13 +180,7 @@ export class HighlightLayer extends EffectLayer {
173
180
  * @returns The effect created
174
181
  */
175
182
  _createMergeEffect() {
176
- // Effect
177
- return this._engine.createEffect("glowMapMerge", [VertexBuffer.PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined, undefined, undefined, undefined, undefined, this._shaderLanguage, this._shadersLoaded
178
- ? undefined
179
- : async () => {
180
- await this._importShadersAsync();
181
- this._shadersLoaded = true;
182
- });
183
+ return this._thinEffectLayer._createMergeEffect();
183
184
  }
184
185
  /**
185
186
  * Creates the render target textures and post processes used in the highlight layer.
@@ -207,17 +208,34 @@ export class HighlightLayer extends EffectLayer {
207
208
  this._blurTexture.renderParticles = false;
208
209
  this._blurTexture.ignoreCameraViewport = true;
209
210
  this._textures = [this._blurTexture];
211
+ this._thinEffectLayer.bindTexturesForCompose = (effect) => {
212
+ effect.setTexture("textureSampler", this._blurTexture);
213
+ };
214
+ this._thinEffectLayer._createTextureAndPostProcesses();
210
215
  if (this._options.alphaBlendingMode === 2) {
211
- this._downSamplePostprocess = new PassPostProcess("HighlightLayerPPP", this._options.blurTextureSizeRatio, null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine());
216
+ this._downSamplePostprocess = new PassPostProcess("HighlightLayerPPP", {
217
+ size: this._options.blurTextureSizeRatio,
218
+ samplingMode: Texture.BILINEAR_SAMPLINGMODE,
219
+ engine: this._scene.getEngine(),
220
+ effectWrapper: this._thinEffectLayer._postProcesses[0],
221
+ });
212
222
  this._downSamplePostprocess.externalTextureSamplerBinding = true;
213
223
  this._downSamplePostprocess.onApplyObservable.add((effect) => {
214
224
  effect.setTexture("textureSampler", this._mainTexture);
215
225
  });
216
- this._horizontalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerHBP", new Vector2(1.0, 0), this._options.blurHorizontalSize, 1, null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine());
226
+ this._horizontalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerHBP", new Vector2(1.0, 0), this._options.blurHorizontalSize, {
227
+ samplingMode: Texture.BILINEAR_SAMPLINGMODE,
228
+ engine: this._scene.getEngine(),
229
+ effectWrapper: this._thinEffectLayer._postProcesses[1],
230
+ });
217
231
  this._horizontalBlurPostprocess.onApplyObservable.add((effect) => {
218
232
  effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
219
233
  });
220
- this._verticalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerVBP", new Vector2(0, 1.0), this._options.blurVerticalSize, 1, null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine());
234
+ this._verticalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerVBP", new Vector2(0, 1.0), this._options.blurVerticalSize, {
235
+ samplingMode: Texture.BILINEAR_SAMPLINGMODE,
236
+ engine: this._scene.getEngine(),
237
+ effectWrapper: this._thinEffectLayer._postProcesses[2],
238
+ });
221
239
  this._verticalBlurPostprocess.onApplyObservable.add((effect) => {
222
240
  effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
223
241
  });
@@ -225,20 +243,30 @@ export class HighlightLayer extends EffectLayer {
225
243
  }
226
244
  else {
227
245
  this._horizontalBlurPostprocess = new BlurPostProcess("HighlightLayerHBP", new Vector2(1.0, 0), this._options.blurHorizontalSize / 2, {
228
- width: blurTextureWidth,
229
- height: blurTextureHeight,
230
- }, null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
231
- const horizontalBlurPostprocess = this._horizontalBlurPostprocess;
232
- horizontalBlurPostprocess.width = blurTextureWidth;
233
- horizontalBlurPostprocess.height = blurTextureHeight;
234
- horizontalBlurPostprocess.externalTextureSamplerBinding = true;
235
- horizontalBlurPostprocess.onApplyObservable.add((effect) => {
246
+ size: {
247
+ width: blurTextureWidth,
248
+ height: blurTextureHeight,
249
+ },
250
+ samplingMode: Texture.BILINEAR_SAMPLINGMODE,
251
+ engine: this._scene.getEngine(),
252
+ textureType,
253
+ effectWrapper: this._thinEffectLayer._postProcesses[0],
254
+ });
255
+ this._horizontalBlurPostprocess.width = blurTextureWidth;
256
+ this._horizontalBlurPostprocess.height = blurTextureHeight;
257
+ this._horizontalBlurPostprocess.externalTextureSamplerBinding = true;
258
+ this._horizontalBlurPostprocess.onApplyObservable.add((effect) => {
236
259
  effect.setTexture("textureSampler", this._mainTexture);
237
260
  });
238
261
  this._verticalBlurPostprocess = new BlurPostProcess("HighlightLayerVBP", new Vector2(0, 1.0), this._options.blurVerticalSize / 2, {
239
- width: blurTextureWidth,
240
- height: blurTextureHeight,
241
- }, null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
262
+ size: {
263
+ width: blurTextureWidth,
264
+ height: blurTextureHeight,
265
+ },
266
+ samplingMode: Texture.BILINEAR_SAMPLINGMODE,
267
+ engine: this._scene.getEngine(),
268
+ textureType,
269
+ });
242
270
  this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
243
271
  }
244
272
  this._mainTexture.onAfterUnbindObservable.add(() => {
@@ -259,7 +287,7 @@ export class HighlightLayer extends EffectLayer {
259
287
  * @returns whether or not the layer needs stencil enabled during the mesh rendering.
260
288
  */
261
289
  needStencil() {
262
- return true;
290
+ return this._thinEffectLayer.needStencil();
263
291
  }
264
292
  /**
265
293
  * Checks for the readiness of the element composing the layer.
@@ -268,17 +296,7 @@ export class HighlightLayer extends EffectLayer {
268
296
  * @returns true if ready otherwise, false
269
297
  */
270
298
  isReady(subMesh, useInstances) {
271
- const material = subMesh.getMaterial();
272
- const mesh = subMesh.getRenderingMesh();
273
- if (!material || !mesh || !this._meshes) {
274
- return false;
275
- }
276
- let emissiveTexture = null;
277
- const highlightLayerMesh = this._meshes[mesh.uniqueId];
278
- if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
279
- emissiveTexture = material.emissiveTexture;
280
- }
281
- return super._isReady(subMesh, useInstances, emissiveTexture);
299
+ return this._thinEffectLayer.isReady(subMesh, useInstances);
282
300
  }
283
301
  /**
284
302
  * Implementation specific of rendering the generating effect on the main canvas.
@@ -286,43 +304,13 @@ export class HighlightLayer extends EffectLayer {
286
304
  * @param renderIndex
287
305
  */
288
306
  _internalRender(effect, renderIndex) {
289
- // Texture
290
- effect.setTexture("textureSampler", this._blurTexture);
291
- // Cache
292
- const engine = this._engine;
293
- engine.cacheStencilState();
294
- // Stencil operations
295
- engine.setStencilOperationPass(7681);
296
- engine.setStencilOperationFail(7680);
297
- engine.setStencilOperationDepthFail(7680);
298
- // Draw order
299
- engine.setStencilMask(0x00);
300
- engine.setStencilBuffer(true);
301
- engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
302
- // 2 passes inner outer
303
- if (this.outerGlow && renderIndex === 0) {
304
- // the outer glow is rendered the first time _internalRender is called, so when renderIndex == 0 (and only if outerGlow is enabled)
305
- effect.setFloat("offset", 0);
306
- engine.setStencilFunction(517);
307
- engine.drawElementsType(Material.TriangleFillMode, 0, 6);
308
- }
309
- if (this.innerGlow && renderIndex === 1) {
310
- // the inner glow is rendered the second time _internalRender is called, so when renderIndex == 1 (and only if innerGlow is enabled)
311
- effect.setFloat("offset", 1);
312
- engine.setStencilFunction(514);
313
- engine.drawElementsType(Material.TriangleFillMode, 0, 6);
314
- }
315
- // Restore Cache
316
- engine.restoreStencilState();
307
+ this._thinEffectLayer._internalCompose(effect, renderIndex);
317
308
  }
318
309
  /**
319
310
  * @returns true if the layer contains information to display, otherwise false.
320
311
  */
321
312
  shouldRender() {
322
- if (super.shouldRender()) {
323
- return this._meshes ? true : false;
324
- }
325
- return false;
313
+ return this._thinEffectLayer.shouldRender();
326
314
  }
327
315
  /**
328
316
  * Returns true if the mesh should render, otherwise false.
@@ -330,14 +318,7 @@ export class HighlightLayer extends EffectLayer {
330
318
  * @returns true if it should render otherwise false
331
319
  */
332
320
  _shouldRenderMesh(mesh) {
333
- // Excluded Mesh
334
- if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
335
- return false;
336
- }
337
- if (!super.hasMesh(mesh)) {
338
- return false;
339
- }
340
- return true;
321
+ return this._thinEffectLayer._shouldRenderMesh(mesh);
341
322
  }
342
323
  /**
343
324
  * Returns true if the mesh can be rendered, otherwise false.
@@ -346,15 +327,14 @@ export class HighlightLayer extends EffectLayer {
346
327
  * @returns true if it can be rendered otherwise false
347
328
  */
348
329
  _canRenderMesh(mesh, material) {
349
- // all meshes can be rendered in the highlight layer, even transparent ones
350
- return true;
330
+ return this._thinEffectLayer._canRenderMesh(mesh, material);
351
331
  }
352
332
  /**
353
333
  * Adds specific effects defines.
354
334
  * @param defines The defines to add specifics to.
355
335
  */
356
336
  _addCustomEffectDefines(defines) {
357
- defines.push("#define HIGHLIGHT");
337
+ this._thinEffectLayer._addCustomEffectDefines(defines);
358
338
  }
359
339
  /**
360
340
  * Sets the required values for both the emissive texture and and the main color.
@@ -363,65 +343,21 @@ export class HighlightLayer extends EffectLayer {
363
343
  * @param material
364
344
  */
365
345
  _setEmissiveTextureAndColor(mesh, subMesh, material) {
366
- const highlightLayerMesh = this._meshes[mesh.uniqueId];
367
- if (highlightLayerMesh) {
368
- this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
369
- }
370
- else {
371
- this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
372
- }
373
- if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
374
- this._emissiveTextureAndColor.texture = material.emissiveTexture;
375
- this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
376
- }
377
- else {
378
- this._emissiveTextureAndColor.texture = null;
379
- }
346
+ this._thinEffectLayer._setEmissiveTextureAndColor(mesh, subMesh, material);
380
347
  }
381
348
  /**
382
349
  * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
383
350
  * @param mesh The mesh to exclude from the highlight layer
384
351
  */
385
352
  addExcludedMesh(mesh) {
386
- if (!this._excludedMeshes) {
387
- return;
388
- }
389
- const meshExcluded = this._excludedMeshes[mesh.uniqueId];
390
- if (!meshExcluded) {
391
- const obj = {
392
- mesh: mesh,
393
- beforeBind: null,
394
- afterRender: null,
395
- stencilState: false,
396
- };
397
- obj.beforeBind = mesh.onBeforeBindObservable.add((mesh) => {
398
- obj.stencilState = mesh.getEngine().getStencilBuffer();
399
- mesh.getEngine().setStencilBuffer(false);
400
- });
401
- obj.afterRender = mesh.onAfterRenderObservable.add((mesh) => {
402
- mesh.getEngine().setStencilBuffer(obj.stencilState);
403
- });
404
- this._excludedMeshes[mesh.uniqueId] = obj;
405
- }
353
+ this._thinEffectLayer.addExcludedMesh(mesh);
406
354
  }
407
355
  /**
408
356
  * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
409
357
  * @param mesh The mesh to highlight
410
358
  */
411
359
  removeExcludedMesh(mesh) {
412
- if (!this._excludedMeshes) {
413
- return;
414
- }
415
- const meshExcluded = this._excludedMeshes[mesh.uniqueId];
416
- if (meshExcluded) {
417
- if (meshExcluded.beforeBind) {
418
- mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
419
- }
420
- if (meshExcluded.afterRender) {
421
- mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
422
- }
423
- }
424
- this._excludedMeshes[mesh.uniqueId] = null;
360
+ this._thinEffectLayer.removeExcludedMesh(mesh);
425
361
  }
426
362
  /**
427
363
  * Determine if a given mesh will be highlighted by the current HighlightLayer
@@ -429,13 +365,7 @@ export class HighlightLayer extends EffectLayer {
429
365
  * @returns true if the mesh will be highlighted by the current HighlightLayer
430
366
  */
431
367
  hasMesh(mesh) {
432
- if (!this._meshes) {
433
- return false;
434
- }
435
- if (!super.hasMesh(mesh)) {
436
- return false;
437
- }
438
- return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
368
+ return this._thinEffectLayer.hasMesh(mesh);
439
369
  }
440
370
  /**
441
371
  * Add a mesh in the highlight layer in order to make it glow with the chosen color.
@@ -444,89 +374,20 @@ export class HighlightLayer extends EffectLayer {
444
374
  * @param glowEmissiveOnly Extract the glow from the emissive texture
445
375
  */
446
376
  addMesh(mesh, color, glowEmissiveOnly = false) {
447
- if (!this._meshes) {
448
- return;
449
- }
450
- const meshHighlight = this._meshes[mesh.uniqueId];
451
- if (meshHighlight) {
452
- meshHighlight.color = color;
453
- }
454
- else {
455
- this._meshes[mesh.uniqueId] = {
456
- mesh: mesh,
457
- color: color,
458
- // Lambda required for capture due to Observable this context
459
- observerHighlight: mesh.onBeforeBindObservable.add((mesh) => {
460
- if (this.isEnabled) {
461
- if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
462
- this._defaultStencilReference(mesh);
463
- }
464
- else {
465
- mesh.getScene().getEngine().setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
466
- }
467
- }
468
- }),
469
- observerDefault: mesh.onAfterRenderObservable.add((mesh) => {
470
- if (this.isEnabled) {
471
- this._defaultStencilReference(mesh);
472
- }
473
- }),
474
- glowEmissiveOnly: glowEmissiveOnly,
475
- };
476
- mesh.onDisposeObservable.add(() => {
477
- this._disposeMesh(mesh);
478
- });
479
- }
480
- this._shouldRender = true;
377
+ this._thinEffectLayer.addMesh(mesh, color, glowEmissiveOnly);
481
378
  }
482
379
  /**
483
380
  * Remove a mesh from the highlight layer in order to make it stop glowing.
484
381
  * @param mesh The mesh to highlight
485
382
  */
486
383
  removeMesh(mesh) {
487
- if (!this._meshes) {
488
- return;
489
- }
490
- const meshHighlight = this._meshes[mesh.uniqueId];
491
- if (meshHighlight) {
492
- if (meshHighlight.observerHighlight) {
493
- mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
494
- }
495
- if (meshHighlight.observerDefault) {
496
- mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
497
- }
498
- delete this._meshes[mesh.uniqueId];
499
- }
500
- this._shouldRender = false;
501
- for (const meshHighlightToCheck in this._meshes) {
502
- if (this._meshes[meshHighlightToCheck]) {
503
- this._shouldRender = true;
504
- break;
505
- }
506
- }
384
+ this._thinEffectLayer.removeMesh(mesh);
507
385
  }
508
386
  /**
509
387
  * Remove all the meshes currently referenced in the highlight layer
510
388
  */
511
389
  removeAllMeshes() {
512
- if (!this._meshes) {
513
- return;
514
- }
515
- for (const uniqueId in this._meshes) {
516
- if (Object.prototype.hasOwnProperty.call(this._meshes, uniqueId)) {
517
- const mesh = this._meshes[uniqueId];
518
- if (mesh) {
519
- this.removeMesh(mesh.mesh);
520
- }
521
- }
522
- }
523
- }
524
- /**
525
- * Force the stencil to the normal expected value for none glowing parts
526
- * @param mesh
527
- */
528
- _defaultStencilReference(mesh) {
529
- mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
390
+ this._thinEffectLayer.removeAllMeshes();
530
391
  }
531
392
  /**
532
393
  * Free any resources and references associated to a mesh.
@@ -535,43 +396,7 @@ export class HighlightLayer extends EffectLayer {
535
396
  * @internal
536
397
  */
537
398
  _disposeMesh(mesh) {
538
- this.removeMesh(mesh);
539
- this.removeExcludedMesh(mesh);
540
- }
541
- /**
542
- * Dispose the highlight layer and free resources.
543
- */
544
- dispose() {
545
- if (this._meshes) {
546
- // Clean mesh references
547
- for (const id in this._meshes) {
548
- const meshHighlight = this._meshes[id];
549
- if (meshHighlight && meshHighlight.mesh) {
550
- if (meshHighlight.observerHighlight) {
551
- meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
552
- }
553
- if (meshHighlight.observerDefault) {
554
- meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
555
- }
556
- }
557
- }
558
- this._meshes = null;
559
- }
560
- if (this._excludedMeshes) {
561
- for (const id in this._excludedMeshes) {
562
- const meshHighlight = this._excludedMeshes[id];
563
- if (meshHighlight) {
564
- if (meshHighlight.beforeBind) {
565
- meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
566
- }
567
- if (meshHighlight.afterRender) {
568
- meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
569
- }
570
- }
571
- }
572
- this._excludedMeshes = null;
573
- }
574
- super.dispose();
399
+ this._thinEffectLayer._disposeMesh(mesh);
575
400
  }
576
401
  /**
577
402
  * Gets the class name of the effect layer
@@ -589,9 +414,10 @@ export class HighlightLayer extends EffectLayer {
589
414
  serializationObject.customType = "BABYLON.HighlightLayer";
590
415
  // Highlighted meshes
591
416
  serializationObject.meshes = [];
592
- if (this._meshes) {
593
- for (const m in this._meshes) {
594
- const mesh = this._meshes[m];
417
+ const meshes = this._thinEffectLayer._meshes;
418
+ if (meshes) {
419
+ for (const m in meshes) {
420
+ const mesh = meshes[m];
595
421
  if (mesh) {
596
422
  serializationObject.meshes.push({
597
423
  glowEmissiveOnly: mesh.glowEmissiveOnly,
@@ -603,9 +429,10 @@ export class HighlightLayer extends EffectLayer {
603
429
  }
604
430
  // Excluded meshes
605
431
  serializationObject.excludedMeshes = [];
606
- if (this._excludedMeshes) {
607
- for (const e in this._excludedMeshes) {
608
- const excludedMesh = this._excludedMeshes[e];
432
+ const excludedMeshes = this._thinEffectLayer._excludedMeshes;
433
+ if (excludedMeshes) {
434
+ for (const e in excludedMeshes) {
435
+ const excludedMesh = excludedMeshes[e];
609
436
  if (excludedMesh) {
610
437
  serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
611
438
  }
@@ -645,25 +472,12 @@ export class HighlightLayer extends EffectLayer {
645
472
  * Effect Name of the highlight layer.
646
473
  */
647
474
  HighlightLayer.EffectName = "HighlightLayer";
648
- /**
649
- * The neutral color used during the preparation of the glow effect.
650
- * This is black by default as the blend operation is a blend operation.
651
- */
652
- HighlightLayer.NeutralColor = new Color4(0, 0, 0, 0);
653
- /**
654
- * Stencil value used for glowing meshes.
655
- */
656
- HighlightLayer.GlowingMeshStencilReference = 0x02;
657
- /**
658
- * Stencil value used for the other meshes in the scene.
659
- */
660
- HighlightLayer.NormalMeshStencilReference = 0x01;
661
475
  __decorate([
662
476
  serialize()
663
- ], HighlightLayer.prototype, "innerGlow", void 0);
477
+ ], HighlightLayer.prototype, "innerGlow", null);
664
478
  __decorate([
665
479
  serialize()
666
- ], HighlightLayer.prototype, "outerGlow", void 0);
480
+ ], HighlightLayer.prototype, "outerGlow", null);
667
481
  __decorate([
668
482
  serialize()
669
483
  ], HighlightLayer.prototype, "blurHorizontalSize", null);