@babylonjs/materials 5.21.0 → 5.22.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 (121) hide show
  1. package/cell/cell.fragment.js +14 -2
  2. package/cell/cell.fragment.js.map +1 -1
  3. package/cell/cell.vertex.js +45 -3
  4. package/cell/cell.vertex.js.map +1 -1
  5. package/cell/cellMaterial.js +112 -120
  6. package/cell/cellMaterial.js.map +1 -1
  7. package/custom/customMaterial.js +69 -81
  8. package/custom/customMaterial.js.map +1 -1
  9. package/custom/pbrCustomMaterial.js +80 -89
  10. package/custom/pbrCustomMaterial.js.map +1 -1
  11. package/fire/fire.fragment.js +44 -3
  12. package/fire/fire.fragment.js.map +1 -1
  13. package/fire/fire.vertex.js +54 -3
  14. package/fire/fire.vertex.js.map +1 -1
  15. package/fire/fireMaterial.js +101 -109
  16. package/fire/fireMaterial.js.map +1 -1
  17. package/fur/fur.fragment.js +67 -3
  18. package/fur/fur.fragment.js.map +1 -1
  19. package/fur/fur.vertex.js +97 -3
  20. package/fur/fur.vertex.js.map +1 -1
  21. package/fur/furMaterial.js +181 -193
  22. package/fur/furMaterial.js.map +1 -1
  23. package/gradient/gradient.fragment.js +36 -3
  24. package/gradient/gradient.fragment.js.map +1 -1
  25. package/gradient/gradient.vertex.js +41 -3
  26. package/gradient/gradient.vertex.js.map +1 -1
  27. package/gradient/gradientMaterial.js +113 -121
  28. package/gradient/gradientMaterial.js.map +1 -1
  29. package/grid/grid.fragment.js +8 -2
  30. package/grid/grid.fragment.js.map +1 -1
  31. package/grid/grid.vertex.js +22 -3
  32. package/grid/grid.vertex.js.map +1 -1
  33. package/grid/gridMaterial.js +93 -101
  34. package/grid/gridMaterial.js.map +1 -1
  35. package/lava/lava.fragment.js +62 -3
  36. package/lava/lava.fragment.js.map +1 -1
  37. package/lava/lava.vertex.js +84 -3
  38. package/lava/lava.vertex.js.map +1 -1
  39. package/lava/lavaMaterial.js +175 -183
  40. package/lava/lavaMaterial.js.map +1 -1
  41. package/legacy/legacy-cell.js +2 -2
  42. package/legacy/legacy-cell.js.map +1 -1
  43. package/legacy/legacy-custom.js +2 -2
  44. package/legacy/legacy-custom.js.map +1 -1
  45. package/legacy/legacy-fire.js +2 -2
  46. package/legacy/legacy-fire.js.map +1 -1
  47. package/legacy/legacy-fur.js +2 -2
  48. package/legacy/legacy-fur.js.map +1 -1
  49. package/legacy/legacy-gradient.js +2 -2
  50. package/legacy/legacy-gradient.js.map +1 -1
  51. package/legacy/legacy-grid.js +2 -2
  52. package/legacy/legacy-grid.js.map +1 -1
  53. package/legacy/legacy-lava.js +2 -2
  54. package/legacy/legacy-lava.js.map +1 -1
  55. package/legacy/legacy-mix.js +2 -2
  56. package/legacy/legacy-mix.js.map +1 -1
  57. package/legacy/legacy-normal.js +2 -2
  58. package/legacy/legacy-normal.js.map +1 -1
  59. package/legacy/legacy-shadowOnly.js +2 -2
  60. package/legacy/legacy-shadowOnly.js.map +1 -1
  61. package/legacy/legacy-simple.js +2 -2
  62. package/legacy/legacy-simple.js.map +1 -1
  63. package/legacy/legacy-sky.js +2 -2
  64. package/legacy/legacy-sky.js.map +1 -1
  65. package/legacy/legacy-terrain.js +2 -2
  66. package/legacy/legacy-terrain.js.map +1 -1
  67. package/legacy/legacy-triPlanar.js +2 -2
  68. package/legacy/legacy-triPlanar.js.map +1 -1
  69. package/legacy/legacy-water.js +2 -2
  70. package/legacy/legacy-water.js.map +1 -1
  71. package/legacy/legacy.js +2 -2
  72. package/legacy/legacy.js.map +1 -1
  73. package/mix/mix.fragment.js +33 -2
  74. package/mix/mix.fragment.js.map +1 -1
  75. package/mix/mix.vertex.js +67 -3
  76. package/mix/mix.vertex.js.map +1 -1
  77. package/mix/mixMaterial.js +166 -174
  78. package/mix/mixMaterial.js.map +1 -1
  79. package/normal/normal.fragment.js +41 -3
  80. package/normal/normal.fragment.js.map +1 -1
  81. package/normal/normal.vertex.js +42 -3
  82. package/normal/normal.vertex.js.map +1 -1
  83. package/normal/normalMaterial.js +143 -151
  84. package/normal/normalMaterial.js.map +1 -1
  85. package/package.json +2 -5
  86. package/shadowOnly/shadowOnly.fragment.js +21 -3
  87. package/shadowOnly/shadowOnly.fragment.js.map +1 -1
  88. package/shadowOnly/shadowOnly.vertex.js +30 -3
  89. package/shadowOnly/shadowOnly.vertex.js.map +1 -1
  90. package/shadowOnly/shadowOnlyMaterial.js +73 -89
  91. package/shadowOnly/shadowOnlyMaterial.js.map +1 -1
  92. package/simple/simple.fragment.js +36 -3
  93. package/simple/simple.fragment.js.map +1 -1
  94. package/simple/simple.vertex.js +45 -3
  95. package/simple/simple.vertex.js.map +1 -1
  96. package/simple/simpleMaterial.js +102 -110
  97. package/simple/simpleMaterial.js.map +1 -1
  98. package/sky/sky.fragment.js +17 -3
  99. package/sky/sky.fragment.js.map +1 -1
  100. package/sky/sky.vertex.js +20 -3
  101. package/sky/sky.vertex.js.map +1 -1
  102. package/sky/skyMaterial.js +111 -119
  103. package/sky/skyMaterial.js.map +1 -1
  104. package/terrain/terrain.fragment.js +36 -2
  105. package/terrain/terrain.fragment.js.map +1 -1
  106. package/terrain/terrain.vertex.js +67 -3
  107. package/terrain/terrain.vertex.js.map +1 -1
  108. package/terrain/terrainMaterial.js +148 -156
  109. package/terrain/terrainMaterial.js.map +1 -1
  110. package/triPlanar/triPlanarMaterial.js +157 -165
  111. package/triPlanar/triPlanarMaterial.js.map +1 -1
  112. package/triPlanar/triplanar.fragment.js +64 -3
  113. package/triPlanar/triplanar.fragment.js.map +1 -1
  114. package/triPlanar/triplanar.vertex.js +45 -3
  115. package/triPlanar/triplanar.vertex.js.map +1 -1
  116. package/water/water.fragment.js +83 -3
  117. package/water/water.fragment.js.map +1 -1
  118. package/water/water.vertex.js +56 -3
  119. package/water/water.vertex.js.map +1 -1
  120. package/water/waterMaterial.js +283 -313
  121. package/water/waterMaterial.js.map +1 -1
@@ -1,4 +1,4 @@
1
- import { __decorate, __extends } from "tslib";
1
+ import { __decorate } from "@babylonjs/core/tslib.es6.js";
2
2
  import { serializeAsVector2, serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
3
3
  import { Matrix, Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
4
4
  import { Color3 } from "@babylonjs/core/Maths/math.color.js";
@@ -18,233 +18,207 @@ import "./water.fragment.js";
18
18
  import "./water.vertex.js";
19
19
  import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
20
20
  import { CreateGround } from "@babylonjs/core/Meshes/Builders/groundBuilder.js";
21
- var WaterMaterialDefines = /** @class */ (function (_super) {
22
- __extends(WaterMaterialDefines, _super);
23
- function WaterMaterialDefines() {
24
- var _this = _super.call(this) || this;
25
- _this.BUMP = false;
26
- _this.REFLECTION = false;
27
- _this.CLIPPLANE = false;
28
- _this.CLIPPLANE2 = false;
29
- _this.CLIPPLANE3 = false;
30
- _this.CLIPPLANE4 = false;
31
- _this.CLIPPLANE5 = false;
32
- _this.CLIPPLANE6 = false;
33
- _this.ALPHATEST = false;
34
- _this.DEPTHPREPASS = false;
35
- _this.POINTSIZE = false;
36
- _this.FOG = false;
37
- _this.NORMAL = false;
38
- _this.UV1 = false;
39
- _this.UV2 = false;
40
- _this.VERTEXCOLOR = false;
41
- _this.VERTEXALPHA = false;
42
- _this.NUM_BONE_INFLUENCERS = 0;
43
- _this.BonesPerMesh = 0;
44
- _this.INSTANCES = false;
45
- _this.INSTANCESCOLOR = false;
46
- _this.SPECULARTERM = false;
47
- _this.LOGARITHMICDEPTH = false;
48
- _this.USE_REVERSE_DEPTHBUFFER = false;
49
- _this.FRESNELSEPARATE = false;
50
- _this.BUMPSUPERIMPOSE = false;
51
- _this.BUMPAFFECTSREFLECTION = false;
52
- _this.IMAGEPROCESSING = false;
53
- _this.VIGNETTE = false;
54
- _this.VIGNETTEBLENDMODEMULTIPLY = false;
55
- _this.VIGNETTEBLENDMODEOPAQUE = false;
56
- _this.TONEMAPPING = false;
57
- _this.TONEMAPPING_ACES = false;
58
- _this.CONTRAST = false;
59
- _this.EXPOSURE = false;
60
- _this.COLORCURVES = false;
61
- _this.COLORGRADING = false;
62
- _this.COLORGRADING3D = false;
63
- _this.SAMPLER3DGREENDEPTH = false;
64
- _this.SAMPLER3DBGRMAP = false;
65
- _this.IMAGEPROCESSINGPOSTPROCESS = false;
66
- _this.SKIPFINALCOLORCLAMP = false;
67
- _this.rebuild();
68
- return _this;
21
+ class WaterMaterialDefines extends MaterialDefines {
22
+ constructor() {
23
+ super();
24
+ this.BUMP = false;
25
+ this.REFLECTION = false;
26
+ this.CLIPPLANE = false;
27
+ this.CLIPPLANE2 = false;
28
+ this.CLIPPLANE3 = false;
29
+ this.CLIPPLANE4 = false;
30
+ this.CLIPPLANE5 = false;
31
+ this.CLIPPLANE6 = false;
32
+ this.ALPHATEST = false;
33
+ this.DEPTHPREPASS = false;
34
+ this.POINTSIZE = false;
35
+ this.FOG = false;
36
+ this.NORMAL = false;
37
+ this.UV1 = false;
38
+ this.UV2 = false;
39
+ this.VERTEXCOLOR = false;
40
+ this.VERTEXALPHA = false;
41
+ this.NUM_BONE_INFLUENCERS = 0;
42
+ this.BonesPerMesh = 0;
43
+ this.INSTANCES = false;
44
+ this.INSTANCESCOLOR = false;
45
+ this.SPECULARTERM = false;
46
+ this.LOGARITHMICDEPTH = false;
47
+ this.USE_REVERSE_DEPTHBUFFER = false;
48
+ this.FRESNELSEPARATE = false;
49
+ this.BUMPSUPERIMPOSE = false;
50
+ this.BUMPAFFECTSREFLECTION = false;
51
+ this.IMAGEPROCESSING = false;
52
+ this.VIGNETTE = false;
53
+ this.VIGNETTEBLENDMODEMULTIPLY = false;
54
+ this.VIGNETTEBLENDMODEOPAQUE = false;
55
+ this.TONEMAPPING = false;
56
+ this.TONEMAPPING_ACES = false;
57
+ this.CONTRAST = false;
58
+ this.EXPOSURE = false;
59
+ this.COLORCURVES = false;
60
+ this.COLORGRADING = false;
61
+ this.COLORGRADING3D = false;
62
+ this.SAMPLER3DGREENDEPTH = false;
63
+ this.SAMPLER3DBGRMAP = false;
64
+ this.IMAGEPROCESSINGPOSTPROCESS = false;
65
+ this.SKIPFINALCOLORCLAMP = false;
66
+ this.rebuild();
69
67
  }
70
- return WaterMaterialDefines;
71
- }(MaterialDefines));
72
- var WaterMaterial = /** @class */ (function (_super) {
73
- __extends(WaterMaterial, _super);
68
+ }
69
+ export class WaterMaterial extends PushMaterial {
74
70
  /**
75
71
  * Constructor
76
72
  * @param name
77
73
  * @param scene
78
74
  * @param renderTargetSize
79
75
  */
80
- function WaterMaterial(name, scene, renderTargetSize) {
81
- if (renderTargetSize === void 0) { renderTargetSize = new Vector2(512, 512); }
82
- var _this = _super.call(this, name, scene) || this;
83
- _this.renderTargetSize = renderTargetSize;
84
- _this.diffuseColor = new Color3(1, 1, 1);
85
- _this.specularColor = new Color3(0, 0, 0);
86
- _this.specularPower = 64;
87
- _this._disableLighting = false;
88
- _this._maxSimultaneousLights = 4;
76
+ constructor(name, scene, renderTargetSize = new Vector2(512, 512)) {
77
+ super(name, scene);
78
+ this.renderTargetSize = renderTargetSize;
79
+ this.diffuseColor = new Color3(1, 1, 1);
80
+ this.specularColor = new Color3(0, 0, 0);
81
+ this.specularPower = 64;
82
+ this._disableLighting = false;
83
+ this._maxSimultaneousLights = 4;
89
84
  /**
90
85
  * Defines the wind force.
91
86
  */
92
- _this.windForce = 6;
87
+ this.windForce = 6;
93
88
  /**
94
89
  * Defines the direction of the wind in the plane (X, Z).
95
90
  */
96
- _this.windDirection = new Vector2(0, 1);
91
+ this.windDirection = new Vector2(0, 1);
97
92
  /**
98
93
  * Defines the height of the waves.
99
94
  */
100
- _this.waveHeight = 0.4;
95
+ this.waveHeight = 0.4;
101
96
  /**
102
97
  * Defines the bump height related to the bump map.
103
98
  */
104
- _this.bumpHeight = 0.4;
99
+ this.bumpHeight = 0.4;
105
100
  /**
106
101
  * Defines wether or not: to add a smaller moving bump to less steady waves.
107
102
  */
108
- _this._bumpSuperimpose = false;
103
+ this._bumpSuperimpose = false;
109
104
  /**
110
105
  * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
111
106
  */
112
- _this._fresnelSeparate = false;
107
+ this._fresnelSeparate = false;
113
108
  /**
114
109
  * Defines wether or not bump Wwves modify the reflection.
115
110
  */
116
- _this._bumpAffectsReflection = false;
111
+ this._bumpAffectsReflection = false;
117
112
  /**
118
113
  * Defines the water color blended with the refraction (near).
119
114
  */
120
- _this.waterColor = new Color3(0.1, 0.1, 0.6);
115
+ this.waterColor = new Color3(0.1, 0.1, 0.6);
121
116
  /**
122
117
  * Defines the blend factor related to the water color.
123
118
  */
124
- _this.colorBlendFactor = 0.2;
119
+ this.colorBlendFactor = 0.2;
125
120
  /**
126
121
  * Defines the water color blended with the reflection (far).
127
122
  */
128
- _this.waterColor2 = new Color3(0.1, 0.1, 0.6);
123
+ this.waterColor2 = new Color3(0.1, 0.1, 0.6);
129
124
  /**
130
125
  * Defines the blend factor related to the water color (reflection, far).
131
126
  */
132
- _this.colorBlendFactor2 = 0.2;
127
+ this.colorBlendFactor2 = 0.2;
133
128
  /**
134
129
  * Defines the maximum length of a wave.
135
130
  */
136
- _this.waveLength = 0.1;
131
+ this.waveLength = 0.1;
137
132
  /**
138
133
  * Defines the waves speed.
139
134
  */
140
- _this.waveSpeed = 1.0;
135
+ this.waveSpeed = 1.0;
141
136
  /**
142
137
  * Defines the number of times waves are repeated. This is typically used to adjust waves count according to the ground's size where the material is applied on.
143
138
  */
144
- _this.waveCount = 20;
139
+ this.waveCount = 20;
145
140
  /**
146
141
  * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
147
142
  * will avoid calculating useless pixels in the pixel shader of the water material.
148
143
  */
149
- _this.disableClipPlane = false;
150
- _this._renderTargets = new SmartArray(16);
144
+ this.disableClipPlane = false;
145
+ this._renderTargets = new SmartArray(16);
151
146
  /*
152
147
  * Private members
153
148
  */
154
- _this._mesh = null;
155
- _this._reflectionTransform = Matrix.Zero();
156
- _this._lastTime = 0;
157
- _this._lastDeltaTime = 0;
158
- _this._createRenderTargets(_this.getScene(), renderTargetSize);
149
+ this._mesh = null;
150
+ this._reflectionTransform = Matrix.Zero();
151
+ this._lastTime = 0;
152
+ this._lastDeltaTime = 0;
153
+ this._createRenderTargets(this.getScene(), renderTargetSize);
159
154
  // Create render targets
160
- _this.getRenderTargetTextures = function () {
161
- _this._renderTargets.reset();
162
- _this._renderTargets.push(_this._reflectionRTT);
163
- _this._renderTargets.push(_this._refractionRTT);
164
- return _this._renderTargets;
155
+ this.getRenderTargetTextures = () => {
156
+ this._renderTargets.reset();
157
+ this._renderTargets.push(this._reflectionRTT);
158
+ this._renderTargets.push(this._refractionRTT);
159
+ return this._renderTargets;
165
160
  };
166
- _this._imageProcessingConfiguration = _this.getScene().imageProcessingConfiguration;
167
- if (_this._imageProcessingConfiguration) {
168
- _this._imageProcessingObserver = _this._imageProcessingConfiguration.onUpdateParameters.add(function () {
169
- _this._markAllSubMeshesAsImageProcessingDirty();
161
+ this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
162
+ if (this._imageProcessingConfiguration) {
163
+ this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(() => {
164
+ this._markAllSubMeshesAsImageProcessingDirty();
170
165
  });
171
166
  }
172
- return _this;
173
167
  }
174
- Object.defineProperty(WaterMaterial.prototype, "hasRenderTargetTextures", {
175
- /**
176
- * Gets a boolean indicating that current material needs to register RTT
177
- */
178
- get: function () {
179
- return true;
180
- },
181
- enumerable: false,
182
- configurable: true
183
- });
184
- Object.defineProperty(WaterMaterial.prototype, "useLogarithmicDepth", {
185
- get: function () {
186
- return this._useLogarithmicDepth;
187
- },
188
- set: function (value) {
189
- this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
190
- this._markAllSubMeshesAsMiscDirty();
191
- },
192
- enumerable: false,
193
- configurable: true
194
- });
195
- Object.defineProperty(WaterMaterial.prototype, "refractionTexture", {
196
- // Get / Set
197
- get: function () {
198
- return this._refractionRTT;
199
- },
200
- enumerable: false,
201
- configurable: true
202
- });
203
- Object.defineProperty(WaterMaterial.prototype, "reflectionTexture", {
204
- get: function () {
205
- return this._reflectionRTT;
206
- },
207
- enumerable: false,
208
- configurable: true
209
- });
168
+ /**
169
+ * Gets a boolean indicating that current material needs to register RTT
170
+ */
171
+ get hasRenderTargetTextures() {
172
+ return true;
173
+ }
174
+ get useLogarithmicDepth() {
175
+ return this._useLogarithmicDepth;
176
+ }
177
+ set useLogarithmicDepth(value) {
178
+ this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
179
+ this._markAllSubMeshesAsMiscDirty();
180
+ }
181
+ // Get / Set
182
+ get refractionTexture() {
183
+ return this._refractionRTT;
184
+ }
185
+ get reflectionTexture() {
186
+ return this._reflectionRTT;
187
+ }
210
188
  // Methods
211
- WaterMaterial.prototype.addToRenderList = function (node) {
189
+ addToRenderList(node) {
212
190
  if (this._refractionRTT && this._refractionRTT.renderList) {
213
191
  this._refractionRTT.renderList.push(node);
214
192
  }
215
193
  if (this._reflectionRTT && this._reflectionRTT.renderList) {
216
194
  this._reflectionRTT.renderList.push(node);
217
195
  }
218
- };
219
- WaterMaterial.prototype.enableRenderTargets = function (enable) {
220
- var refreshRate = enable ? 1 : 0;
196
+ }
197
+ enableRenderTargets(enable) {
198
+ const refreshRate = enable ? 1 : 0;
221
199
  if (this._refractionRTT) {
222
200
  this._refractionRTT.refreshRate = refreshRate;
223
201
  }
224
202
  if (this._reflectionRTT) {
225
203
  this._reflectionRTT.refreshRate = refreshRate;
226
204
  }
227
- };
228
- WaterMaterial.prototype.getRenderList = function () {
205
+ }
206
+ getRenderList() {
229
207
  return this._refractionRTT ? this._refractionRTT.renderList : [];
230
- };
231
- Object.defineProperty(WaterMaterial.prototype, "renderTargetsEnabled", {
232
- get: function () {
233
- return !(this._refractionRTT && this._refractionRTT.refreshRate === 0);
234
- },
235
- enumerable: false,
236
- configurable: true
237
- });
238
- WaterMaterial.prototype.needAlphaBlending = function () {
208
+ }
209
+ get renderTargetsEnabled() {
210
+ return !(this._refractionRTT && this._refractionRTT.refreshRate === 0);
211
+ }
212
+ needAlphaBlending() {
239
213
  return this.alpha < 1.0;
240
- };
241
- WaterMaterial.prototype.needAlphaTesting = function () {
214
+ }
215
+ needAlphaTesting() {
242
216
  return false;
243
- };
244
- WaterMaterial.prototype.getAlphaTestTexture = function () {
217
+ }
218
+ getAlphaTestTexture() {
245
219
  return null;
246
- };
247
- WaterMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
220
+ }
221
+ isReadyForSubMesh(mesh, subMesh, useInstances) {
248
222
  if (this.isFrozen) {
249
223
  if (subMesh.effect && subMesh.effect._wasPreviouslyReady && subMesh.effect._wasPreviouslyUsingInstances === useInstances) {
250
224
  return true;
@@ -253,12 +227,12 @@ var WaterMaterial = /** @class */ (function (_super) {
253
227
  if (!subMesh.materialDefines) {
254
228
  subMesh.materialDefines = new WaterMaterialDefines();
255
229
  }
256
- var defines = subMesh.materialDefines;
257
- var scene = this.getScene();
230
+ const defines = subMesh.materialDefines;
231
+ const scene = this.getScene();
258
232
  if (this._isReadyForSubMesh(subMesh)) {
259
233
  return true;
260
234
  }
261
- var engine = scene.getEngine();
235
+ const engine = scene.getEngine();
262
236
  // Textures
263
237
  if (defines._areTexturesDirty) {
264
238
  defines._needUVs = false;
@@ -306,7 +280,7 @@ var WaterMaterial = /** @class */ (function (_super) {
306
280
  // Configure this
307
281
  this._mesh = mesh;
308
282
  if (this._waitingRenderList) {
309
- for (var i = 0; i < this._waitingRenderList.length; i++) {
283
+ for (let i = 0; i < this._waitingRenderList.length; i++) {
310
284
  this.addToRenderList(scene.getNodeById(this._waitingRenderList[i]));
311
285
  }
312
286
  this._waitingRenderList = null;
@@ -316,7 +290,7 @@ var WaterMaterial = /** @class */ (function (_super) {
316
290
  defines.markAsProcessed();
317
291
  scene.resetCachedMaterial();
318
292
  // Fallbacks
319
- var fallbacks = new EffectFallbacks();
293
+ const fallbacks = new EffectFallbacks();
320
294
  if (defines.FOG) {
321
295
  fallbacks.addFallback(1, "FOG");
322
296
  }
@@ -328,7 +302,7 @@ var WaterMaterial = /** @class */ (function (_super) {
328
302
  fallbacks.addCPUSkinningFallback(0, mesh);
329
303
  }
330
304
  //Attributes
331
- var attribs = [VertexBuffer.PositionKind];
305
+ const attribs = [VertexBuffer.PositionKind];
332
306
  if (defines.NORMAL) {
333
307
  attribs.push(VertexBuffer.NormalKind);
334
308
  }
@@ -344,9 +318,9 @@ var WaterMaterial = /** @class */ (function (_super) {
344
318
  MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
345
319
  MaterialHelper.PrepareAttributesForInstances(attribs, defines);
346
320
  // Legacy browser patch
347
- var shaderName = "water";
348
- var join = defines.toString();
349
- var uniforms = [
321
+ const shaderName = "water";
322
+ const join = defines.toString();
323
+ const uniforms = [
350
324
  "world",
351
325
  "view",
352
326
  "viewProjection",
@@ -383,13 +357,13 @@ var WaterMaterial = /** @class */ (function (_super) {
383
357
  "waveSpeed",
384
358
  "waveCount",
385
359
  ];
386
- var samplers = [
360
+ const samplers = [
387
361
  "normalSampler",
388
362
  // Water
389
363
  "refractionSampler",
390
364
  "reflectionSampler",
391
365
  ];
392
- var uniformBuffers = new Array();
366
+ const uniformBuffers = new Array();
393
367
  if (ImageProcessingConfiguration) {
394
368
  ImageProcessingConfiguration.PrepareUniforms(uniforms, defines);
395
369
  ImageProcessingConfiguration.PrepareSamplers(samplers, defines);
@@ -420,14 +394,14 @@ var WaterMaterial = /** @class */ (function (_super) {
420
394
  subMesh.effect._wasPreviouslyReady = true;
421
395
  subMesh.effect._wasPreviouslyUsingInstances = !!useInstances;
422
396
  return true;
423
- };
424
- WaterMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
425
- var scene = this.getScene();
426
- var defines = subMesh.materialDefines;
397
+ }
398
+ bindForSubMesh(world, mesh, subMesh) {
399
+ const scene = this.getScene();
400
+ const defines = subMesh.materialDefines;
427
401
  if (!defines) {
428
402
  return;
429
403
  }
430
- var effect = subMesh.effect;
404
+ const effect = subMesh.effect;
431
405
  if (!effect || !this._mesh) {
432
406
  return;
433
407
  }
@@ -472,9 +446,9 @@ var WaterMaterial = /** @class */ (function (_super) {
472
446
  this._activeEffect.setTexture("refractionSampler", this._refractionRTT);
473
447
  this._activeEffect.setTexture("reflectionSampler", this._reflectionRTT);
474
448
  }
475
- var wrvp = this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(scene.getProjectionMatrix());
449
+ const wrvp = this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(scene.getProjectionMatrix());
476
450
  // Add delta time. Prevent adding delta time if it hasn't changed.
477
- var deltaTime = scene.getEngine().getDeltaTime();
451
+ const deltaTime = scene.getEngine().getDeltaTime();
478
452
  if (deltaTime !== this._lastDeltaTime) {
479
453
  this._lastDeltaTime = deltaTime;
480
454
  this._lastTime += this._lastDeltaTime;
@@ -497,9 +471,8 @@ var WaterMaterial = /** @class */ (function (_super) {
497
471
  this._imageProcessingConfiguration.bind(this._activeEffect);
498
472
  }
499
473
  this._afterBind(mesh, this._activeEffect);
500
- };
501
- WaterMaterial.prototype._createRenderTargets = function (scene, renderTargetSize) {
502
- var _this = this;
474
+ }
475
+ _createRenderTargets(scene, renderTargetSize) {
503
476
  // Render targets
504
477
  this._refractionRTT = new RenderTargetTexture(name + "_refraction", { width: renderTargetSize.x, height: renderTargetSize.y }, scene, false, true);
505
478
  this._refractionRTT.wrapU = Constants.TEXTURE_MIRROR_ADDRESSMODE;
@@ -509,53 +482,53 @@ var WaterMaterial = /** @class */ (function (_super) {
509
482
  this._reflectionRTT.wrapU = Constants.TEXTURE_MIRROR_ADDRESSMODE;
510
483
  this._reflectionRTT.wrapV = Constants.TEXTURE_MIRROR_ADDRESSMODE;
511
484
  this._reflectionRTT.ignoreCameraViewport = true;
512
- var isVisible;
513
- var clipPlane = null;
514
- var savedViewMatrix;
515
- var mirrorMatrix = Matrix.Zero();
516
- this._refractionRTT.onBeforeRender = function () {
517
- if (_this._mesh) {
518
- isVisible = _this._mesh.isVisible;
519
- _this._mesh.isVisible = false;
485
+ let isVisible;
486
+ let clipPlane = null;
487
+ let savedViewMatrix;
488
+ const mirrorMatrix = Matrix.Zero();
489
+ this._refractionRTT.onBeforeRender = () => {
490
+ if (this._mesh) {
491
+ isVisible = this._mesh.isVisible;
492
+ this._mesh.isVisible = false;
520
493
  }
521
494
  // Clip plane
522
- if (!_this.disableClipPlane) {
495
+ if (!this.disableClipPlane) {
523
496
  clipPlane = scene.clipPlane;
524
- var positiony = _this._mesh ? _this._mesh.position.y : 0.0;
497
+ const positiony = this._mesh ? this._mesh.position.y : 0.0;
525
498
  scene.clipPlane = Plane.FromPositionAndNormal(new Vector3(0, positiony + 0.05, 0), new Vector3(0, 1, 0));
526
499
  }
527
500
  };
528
- this._refractionRTT.onAfterRender = function () {
529
- if (_this._mesh) {
530
- _this._mesh.isVisible = isVisible;
501
+ this._refractionRTT.onAfterRender = () => {
502
+ if (this._mesh) {
503
+ this._mesh.isVisible = isVisible;
531
504
  }
532
505
  // Clip plane
533
- if (!_this.disableClipPlane) {
506
+ if (!this.disableClipPlane) {
534
507
  scene.clipPlane = clipPlane;
535
508
  }
536
509
  };
537
- this._reflectionRTT.onBeforeRender = function () {
538
- if (_this._mesh) {
539
- isVisible = _this._mesh.isVisible;
540
- _this._mesh.isVisible = false;
510
+ this._reflectionRTT.onBeforeRender = () => {
511
+ if (this._mesh) {
512
+ isVisible = this._mesh.isVisible;
513
+ this._mesh.isVisible = false;
541
514
  }
542
515
  // Clip plane
543
- if (!_this.disableClipPlane) {
516
+ if (!this.disableClipPlane) {
544
517
  clipPlane = scene.clipPlane;
545
- var positiony = _this._mesh ? _this._mesh.position.y : 0.0;
518
+ const positiony = this._mesh ? this._mesh.position.y : 0.0;
546
519
  scene.clipPlane = Plane.FromPositionAndNormal(new Vector3(0, positiony - 0.05, 0), new Vector3(0, -1, 0));
547
520
  Matrix.ReflectionToRef(scene.clipPlane, mirrorMatrix);
548
521
  }
549
522
  // Transform
550
523
  savedViewMatrix = scene.getViewMatrix();
551
- mirrorMatrix.multiplyToRef(savedViewMatrix, _this._reflectionTransform);
552
- scene.setTransformMatrix(_this._reflectionTransform, scene.getProjectionMatrix());
524
+ mirrorMatrix.multiplyToRef(savedViewMatrix, this._reflectionTransform);
525
+ scene.setTransformMatrix(this._reflectionTransform, scene.getProjectionMatrix());
553
526
  scene.getEngine().cullBackFaces = false;
554
527
  scene._mirroredCameraPosition = Vector3.TransformCoordinates(scene.activeCamera.position, mirrorMatrix);
555
528
  };
556
- this._reflectionRTT.onAfterRender = function () {
557
- if (_this._mesh) {
558
- _this._mesh.isVisible = isVisible;
529
+ this._reflectionRTT.onAfterRender = () => {
530
+ if (this._mesh) {
531
+ this._mesh.isVisible = isVisible;
559
532
  }
560
533
  // Clip plane
561
534
  scene.clipPlane = clipPlane;
@@ -564,9 +537,9 @@ var WaterMaterial = /** @class */ (function (_super) {
564
537
  scene.getEngine().cullBackFaces = null;
565
538
  scene._mirroredCameraPosition = null;
566
539
  };
567
- };
568
- WaterMaterial.prototype.getAnimatables = function () {
569
- var results = [];
540
+ }
541
+ getAnimatables() {
542
+ const results = [];
570
543
  if (this.bumpTexture && this.bumpTexture.animations && this.bumpTexture.animations.length > 0) {
571
544
  results.push(this.bumpTexture);
572
545
  }
@@ -577,28 +550,28 @@ var WaterMaterial = /** @class */ (function (_super) {
577
550
  results.push(this._refractionRTT);
578
551
  }
579
552
  return results;
580
- };
581
- WaterMaterial.prototype.getActiveTextures = function () {
582
- var activeTextures = _super.prototype.getActiveTextures.call(this);
553
+ }
554
+ getActiveTextures() {
555
+ const activeTextures = super.getActiveTextures();
583
556
  if (this._bumpTexture) {
584
557
  activeTextures.push(this._bumpTexture);
585
558
  }
586
559
  return activeTextures;
587
- };
588
- WaterMaterial.prototype.hasTexture = function (texture) {
589
- if (_super.prototype.hasTexture.call(this, texture)) {
560
+ }
561
+ hasTexture(texture) {
562
+ if (super.hasTexture(texture)) {
590
563
  return true;
591
564
  }
592
565
  if (this._bumpTexture === texture) {
593
566
  return true;
594
567
  }
595
568
  return false;
596
- };
597
- WaterMaterial.prototype.dispose = function (forceDisposeEffect) {
569
+ }
570
+ dispose(forceDisposeEffect) {
598
571
  if (this.bumpTexture) {
599
572
  this.bumpTexture.dispose();
600
573
  }
601
- var index = this.getScene().customRenderTargets.indexOf(this._refractionRTT);
574
+ let index = this.getScene().customRenderTargets.indexOf(this._refractionRTT);
602
575
  if (index != -1) {
603
576
  this.getScene().customRenderTargets.splice(index, 1);
604
577
  }
@@ -617,122 +590,119 @@ var WaterMaterial = /** @class */ (function (_super) {
617
590
  if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
618
591
  this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
619
592
  }
620
- _super.prototype.dispose.call(this, forceDisposeEffect);
621
- };
622
- WaterMaterial.prototype.clone = function (name) {
623
- var _this = this;
624
- return SerializationHelper.Clone(function () { return new WaterMaterial(name, _this.getScene()); }, this);
625
- };
626
- WaterMaterial.prototype.serialize = function () {
627
- var serializationObject = _super.prototype.serialize.call(this);
593
+ super.dispose(forceDisposeEffect);
594
+ }
595
+ clone(name) {
596
+ return SerializationHelper.Clone(() => new WaterMaterial(name, this.getScene()), this);
597
+ }
598
+ serialize() {
599
+ const serializationObject = super.serialize();
628
600
  serializationObject.customType = "BABYLON.WaterMaterial";
629
601
  serializationObject.renderList = [];
630
602
  if (this._refractionRTT && this._refractionRTT.renderList) {
631
- for (var i = 0; i < this._refractionRTT.renderList.length; i++) {
603
+ for (let i = 0; i < this._refractionRTT.renderList.length; i++) {
632
604
  serializationObject.renderList.push(this._refractionRTT.renderList[i].id);
633
605
  }
634
606
  }
635
607
  return serializationObject;
636
- };
637
- WaterMaterial.prototype.getClassName = function () {
608
+ }
609
+ getClassName() {
638
610
  return "WaterMaterial";
639
- };
611
+ }
640
612
  // Statics
641
- WaterMaterial.Parse = function (source, scene, rootUrl) {
642
- var mat = SerializationHelper.Parse(function () { return new WaterMaterial(source.name, scene); }, source, scene, rootUrl);
613
+ static Parse(source, scene, rootUrl) {
614
+ const mat = SerializationHelper.Parse(() => new WaterMaterial(source.name, scene), source, scene, rootUrl);
643
615
  mat._waitingRenderList = source.renderList;
644
616
  return mat;
645
- };
646
- WaterMaterial.CreateDefaultMesh = function (name, scene) {
647
- var mesh = CreateGround(name, { width: 512, height: 512, subdivisions: 32, updatable: false }, scene);
617
+ }
618
+ static CreateDefaultMesh(name, scene) {
619
+ const mesh = CreateGround(name, { width: 512, height: 512, subdivisions: 32, updatable: false }, scene);
648
620
  return mesh;
649
- };
650
- __decorate([
651
- serializeAsTexture("bumpTexture")
652
- ], WaterMaterial.prototype, "_bumpTexture", void 0);
653
- __decorate([
654
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
655
- ], WaterMaterial.prototype, "bumpTexture", void 0);
656
- __decorate([
657
- serializeAsColor3()
658
- ], WaterMaterial.prototype, "diffuseColor", void 0);
659
- __decorate([
660
- serializeAsColor3()
661
- ], WaterMaterial.prototype, "specularColor", void 0);
662
- __decorate([
663
- serialize()
664
- ], WaterMaterial.prototype, "specularPower", void 0);
665
- __decorate([
666
- serialize("disableLighting")
667
- ], WaterMaterial.prototype, "_disableLighting", void 0);
668
- __decorate([
669
- expandToProperty("_markAllSubMeshesAsLightsDirty")
670
- ], WaterMaterial.prototype, "disableLighting", void 0);
671
- __decorate([
672
- serialize("maxSimultaneousLights")
673
- ], WaterMaterial.prototype, "_maxSimultaneousLights", void 0);
674
- __decorate([
675
- expandToProperty("_markAllSubMeshesAsLightsDirty")
676
- ], WaterMaterial.prototype, "maxSimultaneousLights", void 0);
677
- __decorate([
678
- serialize()
679
- ], WaterMaterial.prototype, "windForce", void 0);
680
- __decorate([
681
- serializeAsVector2()
682
- ], WaterMaterial.prototype, "windDirection", void 0);
683
- __decorate([
684
- serialize()
685
- ], WaterMaterial.prototype, "waveHeight", void 0);
686
- __decorate([
687
- serialize()
688
- ], WaterMaterial.prototype, "bumpHeight", void 0);
689
- __decorate([
690
- serialize("bumpSuperimpose")
691
- ], WaterMaterial.prototype, "_bumpSuperimpose", void 0);
692
- __decorate([
693
- expandToProperty("_markAllSubMeshesAsMiscDirty")
694
- ], WaterMaterial.prototype, "bumpSuperimpose", void 0);
695
- __decorate([
696
- serialize("fresnelSeparate")
697
- ], WaterMaterial.prototype, "_fresnelSeparate", void 0);
698
- __decorate([
699
- expandToProperty("_markAllSubMeshesAsMiscDirty")
700
- ], WaterMaterial.prototype, "fresnelSeparate", void 0);
701
- __decorate([
702
- serialize("bumpAffectsReflection")
703
- ], WaterMaterial.prototype, "_bumpAffectsReflection", void 0);
704
- __decorate([
705
- expandToProperty("_markAllSubMeshesAsMiscDirty")
706
- ], WaterMaterial.prototype, "bumpAffectsReflection", void 0);
707
- __decorate([
708
- serializeAsColor3()
709
- ], WaterMaterial.prototype, "waterColor", void 0);
710
- __decorate([
711
- serialize()
712
- ], WaterMaterial.prototype, "colorBlendFactor", void 0);
713
- __decorate([
714
- serializeAsColor3()
715
- ], WaterMaterial.prototype, "waterColor2", void 0);
716
- __decorate([
717
- serialize()
718
- ], WaterMaterial.prototype, "colorBlendFactor2", void 0);
719
- __decorate([
720
- serialize()
721
- ], WaterMaterial.prototype, "waveLength", void 0);
722
- __decorate([
723
- serialize()
724
- ], WaterMaterial.prototype, "waveSpeed", void 0);
725
- __decorate([
726
- serialize()
727
- ], WaterMaterial.prototype, "waveCount", void 0);
728
- __decorate([
729
- serialize()
730
- ], WaterMaterial.prototype, "disableClipPlane", void 0);
731
- __decorate([
732
- serialize()
733
- ], WaterMaterial.prototype, "useLogarithmicDepth", null);
734
- return WaterMaterial;
735
- }(PushMaterial));
736
- export { WaterMaterial };
621
+ }
622
+ }
623
+ __decorate([
624
+ serializeAsTexture("bumpTexture")
625
+ ], WaterMaterial.prototype, "_bumpTexture", void 0);
626
+ __decorate([
627
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
628
+ ], WaterMaterial.prototype, "bumpTexture", void 0);
629
+ __decorate([
630
+ serializeAsColor3()
631
+ ], WaterMaterial.prototype, "diffuseColor", void 0);
632
+ __decorate([
633
+ serializeAsColor3()
634
+ ], WaterMaterial.prototype, "specularColor", void 0);
635
+ __decorate([
636
+ serialize()
637
+ ], WaterMaterial.prototype, "specularPower", void 0);
638
+ __decorate([
639
+ serialize("disableLighting")
640
+ ], WaterMaterial.prototype, "_disableLighting", void 0);
641
+ __decorate([
642
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
643
+ ], WaterMaterial.prototype, "disableLighting", void 0);
644
+ __decorate([
645
+ serialize("maxSimultaneousLights")
646
+ ], WaterMaterial.prototype, "_maxSimultaneousLights", void 0);
647
+ __decorate([
648
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
649
+ ], WaterMaterial.prototype, "maxSimultaneousLights", void 0);
650
+ __decorate([
651
+ serialize()
652
+ ], WaterMaterial.prototype, "windForce", void 0);
653
+ __decorate([
654
+ serializeAsVector2()
655
+ ], WaterMaterial.prototype, "windDirection", void 0);
656
+ __decorate([
657
+ serialize()
658
+ ], WaterMaterial.prototype, "waveHeight", void 0);
659
+ __decorate([
660
+ serialize()
661
+ ], WaterMaterial.prototype, "bumpHeight", void 0);
662
+ __decorate([
663
+ serialize("bumpSuperimpose")
664
+ ], WaterMaterial.prototype, "_bumpSuperimpose", void 0);
665
+ __decorate([
666
+ expandToProperty("_markAllSubMeshesAsMiscDirty")
667
+ ], WaterMaterial.prototype, "bumpSuperimpose", void 0);
668
+ __decorate([
669
+ serialize("fresnelSeparate")
670
+ ], WaterMaterial.prototype, "_fresnelSeparate", void 0);
671
+ __decorate([
672
+ expandToProperty("_markAllSubMeshesAsMiscDirty")
673
+ ], WaterMaterial.prototype, "fresnelSeparate", void 0);
674
+ __decorate([
675
+ serialize("bumpAffectsReflection")
676
+ ], WaterMaterial.prototype, "_bumpAffectsReflection", void 0);
677
+ __decorate([
678
+ expandToProperty("_markAllSubMeshesAsMiscDirty")
679
+ ], WaterMaterial.prototype, "bumpAffectsReflection", void 0);
680
+ __decorate([
681
+ serializeAsColor3()
682
+ ], WaterMaterial.prototype, "waterColor", void 0);
683
+ __decorate([
684
+ serialize()
685
+ ], WaterMaterial.prototype, "colorBlendFactor", void 0);
686
+ __decorate([
687
+ serializeAsColor3()
688
+ ], WaterMaterial.prototype, "waterColor2", void 0);
689
+ __decorate([
690
+ serialize()
691
+ ], WaterMaterial.prototype, "colorBlendFactor2", void 0);
692
+ __decorate([
693
+ serialize()
694
+ ], WaterMaterial.prototype, "waveLength", void 0);
695
+ __decorate([
696
+ serialize()
697
+ ], WaterMaterial.prototype, "waveSpeed", void 0);
698
+ __decorate([
699
+ serialize()
700
+ ], WaterMaterial.prototype, "waveCount", void 0);
701
+ __decorate([
702
+ serialize()
703
+ ], WaterMaterial.prototype, "disableClipPlane", void 0);
704
+ __decorate([
705
+ serialize()
706
+ ], WaterMaterial.prototype, "useLogarithmicDepth", null);
737
707
  RegisterClass("BABYLON.WaterMaterial", WaterMaterial);
738
708
  //# sourceMappingURL=waterMaterial.js.map