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