@babylonjs/materials 5.0.0-rc.7 → 5.0.0-rc.9

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 (153) hide show
  1. package/cell/cell.fragment.d.ts +17 -17
  2. package/cell/cell.fragment.js +20 -20
  3. package/cell/cell.vertex.d.ts +18 -18
  4. package/cell/cell.vertex.js +21 -21
  5. package/cell/cellMaterial.d.ts +37 -37
  6. package/cell/cellMaterial.js +304 -304
  7. package/cell/index.d.ts +1 -1
  8. package/cell/index.js +1 -1
  9. package/custom/customMaterial.d.ts +69 -69
  10. package/custom/customMaterial.js +216 -216
  11. package/custom/index.d.ts +2 -2
  12. package/custom/index.js +2 -2
  13. package/custom/pbrCustomMaterial.d.ts +71 -71
  14. package/custom/pbrCustomMaterial.js +241 -241
  15. package/fire/fire.fragment.d.ts +11 -11
  16. package/fire/fire.fragment.js +14 -14
  17. package/fire/fire.vertex.d.ts +15 -15
  18. package/fire/fire.vertex.js +18 -18
  19. package/fire/fireMaterial.d.ts +38 -38
  20. package/fire/fireMaterial.js +342 -342
  21. package/fire/index.d.ts +1 -1
  22. package/fire/index.js +1 -1
  23. package/fur/fur.fragment.d.ts +17 -17
  24. package/fur/fur.fragment.js +20 -20
  25. package/fur/fur.vertex.d.ts +18 -18
  26. package/fur/fur.vertex.js +21 -21
  27. package/fur/furMaterial.d.ts +56 -56
  28. package/fur/furMaterial.js +500 -500
  29. package/fur/index.d.ts +1 -1
  30. package/fur/index.js +1 -1
  31. package/gradient/gradient.fragment.d.ts +17 -17
  32. package/gradient/gradient.fragment.js +20 -20
  33. package/gradient/gradient.vertex.d.ts +18 -18
  34. package/gradient/gradient.vertex.js +21 -21
  35. package/gradient/gradientMaterial.d.ts +37 -37
  36. package/gradient/gradientMaterial.js +275 -275
  37. package/gradient/index.d.ts +1 -1
  38. package/gradient/index.js +1 -1
  39. package/grid/grid.fragment.d.ts +8 -8
  40. package/grid/grid.fragment.js +11 -11
  41. package/grid/grid.vertex.d.ts +9 -9
  42. package/grid/grid.vertex.js +12 -12
  43. package/grid/gridMaterial.d.ts +77 -77
  44. package/grid/gridMaterial.js +276 -276
  45. package/grid/index.d.ts +1 -1
  46. package/grid/index.js +1 -1
  47. package/index.d.ts +15 -15
  48. package/index.js +15 -15
  49. package/lava/index.d.ts +1 -1
  50. package/lava/index.js +1 -1
  51. package/lava/lava.fragment.d.ts +17 -17
  52. package/lava/lava.fragment.js +20 -20
  53. package/lava/lava.vertex.d.ts +18 -18
  54. package/lava/lava.vertex.js +21 -21
  55. package/lava/lavaMaterial.d.ts +45 -45
  56. package/lava/lavaMaterial.js +394 -394
  57. package/legacy/legacy-cell.d.ts +1 -1
  58. package/legacy/legacy-cell.js +12 -12
  59. package/legacy/legacy-custom.d.ts +1 -1
  60. package/legacy/legacy-custom.js +12 -12
  61. package/legacy/legacy-fire.d.ts +1 -1
  62. package/legacy/legacy-fire.js +12 -12
  63. package/legacy/legacy-fur.d.ts +1 -1
  64. package/legacy/legacy-fur.js +12 -12
  65. package/legacy/legacy-gradient.d.ts +1 -1
  66. package/legacy/legacy-gradient.js +12 -12
  67. package/legacy/legacy-grid.d.ts +1 -1
  68. package/legacy/legacy-grid.js +12 -12
  69. package/legacy/legacy-lava.d.ts +1 -1
  70. package/legacy/legacy-lava.js +12 -12
  71. package/legacy/legacy-mix.d.ts +1 -1
  72. package/legacy/legacy-mix.js +12 -12
  73. package/legacy/legacy-normal.d.ts +1 -1
  74. package/legacy/legacy-normal.js +12 -12
  75. package/legacy/legacy-shadowOnly.d.ts +1 -1
  76. package/legacy/legacy-shadowOnly.js +12 -12
  77. package/legacy/legacy-simple.d.ts +1 -1
  78. package/legacy/legacy-simple.js +12 -12
  79. package/legacy/legacy-sky.d.ts +1 -1
  80. package/legacy/legacy-sky.js +12 -12
  81. package/legacy/legacy-terrain.d.ts +1 -1
  82. package/legacy/legacy-terrain.js +12 -12
  83. package/legacy/legacy-triPlanar.d.ts +1 -1
  84. package/legacy/legacy-triPlanar.js +12 -12
  85. package/legacy/legacy-water.d.ts +1 -1
  86. package/legacy/legacy-water.js +12 -12
  87. package/legacy/legacy.d.ts +1 -1
  88. package/legacy/legacy.js +15 -15
  89. package/mix/index.d.ts +1 -1
  90. package/mix/index.js +1 -1
  91. package/mix/mix.fragment.d.ts +17 -17
  92. package/mix/mix.fragment.js +20 -20
  93. package/mix/mix.vertex.d.ts +18 -18
  94. package/mix/mix.vertex.js +21 -21
  95. package/mix/mixMaterial.d.ts +65 -65
  96. package/mix/mixMaterial.js +510 -510
  97. package/normal/index.d.ts +1 -1
  98. package/normal/index.js +1 -1
  99. package/normal/normal.fragment.d.ts +17 -17
  100. package/normal/normal.fragment.js +20 -20
  101. package/normal/normal.vertex.d.ts +18 -18
  102. package/normal/normal.vertex.js +21 -21
  103. package/normal/normalMaterial.d.ts +36 -36
  104. package/normal/normalMaterial.js +336 -336
  105. package/package.json +2 -2
  106. package/shadowOnly/index.d.ts +1 -1
  107. package/shadowOnly/index.js +1 -1
  108. package/shadowOnly/shadowOnly.fragment.d.ts +16 -16
  109. package/shadowOnly/shadowOnly.fragment.js +19 -19
  110. package/shadowOnly/shadowOnly.vertex.d.ts +18 -18
  111. package/shadowOnly/shadowOnly.vertex.js +21 -21
  112. package/shadowOnly/shadowOnlyMaterial.d.ts +30 -30
  113. package/shadowOnly/shadowOnlyMaterial.js +254 -254
  114. package/simple/index.d.ts +1 -1
  115. package/simple/index.js +1 -1
  116. package/simple/simple.fragment.d.ts +17 -17
  117. package/simple/simple.fragment.js +20 -20
  118. package/simple/simple.vertex.d.ts +18 -18
  119. package/simple/simple.vertex.js +21 -21
  120. package/simple/simpleMaterial.d.ts +35 -35
  121. package/simple/simpleMaterial.js +295 -295
  122. package/sky/index.d.ts +1 -1
  123. package/sky/index.js +1 -1
  124. package/sky/sky.fragment.d.ts +10 -10
  125. package/sky/sky.fragment.js +13 -13
  126. package/sky/sky.vertex.d.ts +9 -9
  127. package/sky/sky.vertex.js +12 -12
  128. package/sky/skyMaterial.d.ts +146 -146
  129. package/sky/skyMaterial.js +359 -359
  130. package/terrain/index.d.ts +1 -1
  131. package/terrain/index.js +1 -1
  132. package/terrain/terrain.fragment.d.ts +17 -17
  133. package/terrain/terrain.fragment.js +20 -20
  134. package/terrain/terrain.vertex.d.ts +18 -18
  135. package/terrain/terrain.vertex.js +21 -21
  136. package/terrain/terrainMaterial.d.ts +50 -50
  137. package/terrain/terrainMaterial.js +426 -426
  138. package/triPlanar/index.d.ts +1 -1
  139. package/triPlanar/index.js +1 -1
  140. package/triPlanar/triPlanarMaterial.d.ts +49 -49
  141. package/triPlanar/triPlanarMaterial.js +403 -403
  142. package/triPlanar/triplanar.fragment.d.ts +17 -17
  143. package/triPlanar/triplanar.fragment.js +20 -20
  144. package/triPlanar/triplanar.vertex.d.ts +18 -18
  145. package/triPlanar/triplanar.vertex.js +21 -21
  146. package/water/index.d.ts +1 -1
  147. package/water/index.js +1 -1
  148. package/water/water.fragment.d.ts +19 -19
  149. package/water/water.fragment.js +22 -22
  150. package/water/water.vertex.d.ts +20 -20
  151. package/water/water.vertex.js +23 -23
  152. package/water/waterMaterial.d.ts +135 -135
  153. package/water/waterMaterial.js +736 -736
@@ -1,277 +1,277 @@
1
- import { __decorate, __extends } from "tslib";
2
- /* eslint-disable @typescript-eslint/naming-convention */
3
- import { serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper, serializeAsVector3 } from "@babylonjs/core/Misc/decorators.js";
4
- import { Vector4, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
5
- import { Color3 } from "@babylonjs/core/Maths/math.color.js";
6
- import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
7
- import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
8
- import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
9
- import { MaterialFlags } from "@babylonjs/core/Materials/materialFlags.js";
10
- import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
11
- import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
12
- import "./grid.fragment.js";
13
- import "./grid.vertex.js";
14
- var GridMaterialDefines = /** @class */ (function (_super) {
15
- __extends(GridMaterialDefines, _super);
16
- function GridMaterialDefines() {
17
- var _this = _super.call(this) || this;
18
- _this.OPACITY = false;
19
- _this.TRANSPARENT = false;
20
- _this.FOG = false;
21
- _this.PREMULTIPLYALPHA = false;
22
- _this.MAX_LINE = false;
23
- _this.UV1 = false;
24
- _this.UV2 = false;
25
- _this.INSTANCES = false;
26
- _this.THIN_INSTANCES = false;
27
- _this.IMAGEPROCESSINGPOSTPROCESS = false;
28
- _this.SKIPFINALCOLORCLAMP = false;
29
- _this.rebuild();
30
- return _this;
31
- }
32
- return GridMaterialDefines;
33
- }(MaterialDefines));
34
- /**
35
- * The grid materials allows you to wrap any shape with a grid.
36
- * Colors are customizable.
37
- */
38
- var GridMaterial = /** @class */ (function (_super) {
39
- __extends(GridMaterial, _super);
40
- /**
41
- * constructor
42
- * @param name The name given to the material in order to identify it afterwards.
43
- * @param scene The scene the material is used in.
44
- */
45
- function GridMaterial(name, scene) {
46
- var _this = _super.call(this, name, scene) || this;
47
- /**
48
- * Main color of the grid (e.g. between lines)
49
- */
50
- _this.mainColor = Color3.Black();
51
- /**
52
- * Color of the grid lines.
53
- */
54
- _this.lineColor = Color3.Teal();
55
- /**
56
- * The scale of the grid compared to unit.
57
- */
58
- _this.gridRatio = 1.0;
59
- /**
60
- * Allows setting an offset for the grid lines.
61
- */
62
- _this.gridOffset = Vector3.Zero();
63
- /**
64
- * The frequency of thicker lines.
65
- */
66
- _this.majorUnitFrequency = 10;
67
- /**
68
- * The visibility of minor units in the grid.
69
- */
70
- _this.minorUnitVisibility = 0.33;
71
- /**
72
- * The grid opacity outside of the lines.
73
- */
74
- _this.opacity = 1.0;
75
- /**
76
- * Determine RBG output is premultiplied by alpha value.
77
- */
78
- _this.preMultiplyAlpha = false;
79
- /**
80
- * Determines if the max line value will be used instead of the sum wherever grid lines intersect.
81
- */
82
- _this.useMaxLine = false;
83
- _this._gridControl = new Vector4(_this.gridRatio, _this.majorUnitFrequency, _this.minorUnitVisibility, _this.opacity);
84
- return _this;
85
- }
86
- /**
87
- * Returns whether or not the grid requires alpha blending.
88
- */
89
- GridMaterial.prototype.needAlphaBlending = function () {
90
- return this.opacity < 1.0 || (this._opacityTexture && this._opacityTexture.isReady());
91
- };
92
- GridMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
93
- return mesh.visibility < 1.0 || this.needAlphaBlending();
94
- };
95
- GridMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
96
- if (this.isFrozen) {
97
- if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
98
- return true;
99
- }
100
- }
101
- if (!subMesh.materialDefines) {
102
- subMesh.materialDefines = new GridMaterialDefines();
103
- }
104
- var defines = subMesh.materialDefines;
105
- var scene = this.getScene();
106
- if (this._isReadyForSubMesh(subMesh)) {
107
- return true;
108
- }
109
- if (defines.TRANSPARENT !== this.opacity < 1.0) {
110
- defines.TRANSPARENT = !defines.TRANSPARENT;
111
- defines.markAsUnprocessed();
112
- }
113
- if (defines.PREMULTIPLYALPHA != this.preMultiplyAlpha) {
114
- defines.PREMULTIPLYALPHA = !defines.PREMULTIPLYALPHA;
115
- defines.markAsUnprocessed();
116
- }
117
- if (defines.MAX_LINE !== this.useMaxLine) {
118
- defines.MAX_LINE = !defines.MAX_LINE;
119
- defines.markAsUnprocessed();
120
- }
121
- // Textures
122
- if (defines._areTexturesDirty) {
123
- defines._needUVs = false;
124
- if (scene.texturesEnabled) {
125
- if (this._opacityTexture && MaterialFlags.OpacityTextureEnabled) {
126
- if (!this._opacityTexture.isReady()) {
127
- return false;
128
- }
129
- else {
130
- defines._needUVs = true;
131
- defines.OPACITY = true;
132
- }
133
- }
134
- }
135
- }
136
- MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, false, defines);
137
- // Values that need to be evaluated on every frame
138
- MaterialHelper.PrepareDefinesForFrameBoundValues(scene, scene.getEngine(), defines, !!useInstances);
139
- // Get correct effect
140
- if (defines.isDirty) {
141
- defines.markAsProcessed();
142
- scene.resetCachedMaterial();
143
- // Attributes
144
- MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, false);
145
- var attribs = [VertexBuffer.PositionKind, VertexBuffer.NormalKind];
146
- if (defines.UV1) {
147
- attribs.push(VertexBuffer.UVKind);
148
- }
149
- if (defines.UV2) {
150
- attribs.push(VertexBuffer.UV2Kind);
151
- }
152
- defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
153
- MaterialHelper.PrepareAttributesForInstances(attribs, defines);
154
- // Defines
155
- var join = defines.toString();
156
- subMesh.setEffect(scene
157
- .getEngine()
158
- .createEffect("grid", attribs, [
159
- "projection",
160
- "mainColor",
161
- "lineColor",
162
- "gridControl",
163
- "gridOffset",
164
- "vFogInfos",
165
- "vFogColor",
166
- "world",
167
- "view",
168
- "opacityMatrix",
169
- "vOpacityInfos",
170
- "visibility",
171
- ], ["opacitySampler"], join, undefined, this.onCompiled, this.onError), defines, this._materialContext);
172
- }
173
- if (!subMesh.effect || !subMesh.effect.isReady()) {
174
- return false;
175
- }
176
- defines._renderId = scene.getRenderId();
177
- subMesh.effect._wasPreviouslyReady = true;
178
- return true;
179
- };
180
- GridMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
181
- var scene = this.getScene();
182
- var defines = subMesh.materialDefines;
183
- if (!defines) {
184
- return;
185
- }
186
- var effect = subMesh.effect;
187
- if (!effect) {
188
- return;
189
- }
190
- this._activeEffect = effect;
191
- this._activeEffect.setFloat("visibility", mesh.visibility);
192
- // Matrices
193
- if (!defines.INSTANCES || defines.THIN_INSTANCE) {
194
- this.bindOnlyWorldMatrix(world);
195
- }
196
- this._activeEffect.setMatrix("view", scene.getViewMatrix());
197
- this._activeEffect.setMatrix("projection", scene.getProjectionMatrix());
198
- // Uniforms
199
- if (this._mustRebind(scene, effect)) {
200
- this._activeEffect.setColor3("mainColor", this.mainColor);
201
- this._activeEffect.setColor3("lineColor", this.lineColor);
202
- this._activeEffect.setVector3("gridOffset", this.gridOffset);
203
- this._gridControl.x = this.gridRatio;
204
- this._gridControl.y = Math.round(this.majorUnitFrequency);
205
- this._gridControl.z = this.minorUnitVisibility;
206
- this._gridControl.w = this.opacity;
207
- this._activeEffect.setVector4("gridControl", this._gridControl);
208
- if (this._opacityTexture && MaterialFlags.OpacityTextureEnabled) {
209
- this._activeEffect.setTexture("opacitySampler", this._opacityTexture);
210
- this._activeEffect.setFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
211
- this._activeEffect.setMatrix("opacityMatrix", this._opacityTexture.getTextureMatrix());
212
- }
213
- }
214
- // Fog
215
- MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
216
- this._afterBind(mesh, this._activeEffect);
217
- };
218
- /**
219
- * Dispose the material and its associated resources.
220
- * @param forceDisposeEffect will also dispose the used effect when true
221
- */
222
- GridMaterial.prototype.dispose = function (forceDisposeEffect) {
223
- _super.prototype.dispose.call(this, forceDisposeEffect);
224
- };
225
- GridMaterial.prototype.clone = function (name) {
226
- var _this = this;
227
- return SerializationHelper.Clone(function () { return new GridMaterial(name, _this.getScene()); }, this);
228
- };
229
- GridMaterial.prototype.serialize = function () {
230
- var serializationObject = SerializationHelper.Serialize(this);
231
- serializationObject.customType = "BABYLON.GridMaterial";
232
- return serializationObject;
233
- };
234
- GridMaterial.prototype.getClassName = function () {
235
- return "GridMaterial";
236
- };
237
- GridMaterial.Parse = function (source, scene, rootUrl) {
238
- return SerializationHelper.Parse(function () { return new GridMaterial(source.name, scene); }, source, scene, rootUrl);
239
- };
240
- __decorate([
241
- serializeAsColor3()
242
- ], GridMaterial.prototype, "mainColor", void 0);
243
- __decorate([
244
- serializeAsColor3()
245
- ], GridMaterial.prototype, "lineColor", void 0);
246
- __decorate([
247
- serialize()
248
- ], GridMaterial.prototype, "gridRatio", void 0);
249
- __decorate([
250
- serializeAsVector3()
251
- ], GridMaterial.prototype, "gridOffset", void 0);
252
- __decorate([
253
- serialize()
254
- ], GridMaterial.prototype, "majorUnitFrequency", void 0);
255
- __decorate([
256
- serialize()
257
- ], GridMaterial.prototype, "minorUnitVisibility", void 0);
258
- __decorate([
259
- serialize()
260
- ], GridMaterial.prototype, "opacity", void 0);
261
- __decorate([
262
- serialize()
263
- ], GridMaterial.prototype, "preMultiplyAlpha", void 0);
264
- __decorate([
265
- serialize()
266
- ], GridMaterial.prototype, "useMaxLine", void 0);
267
- __decorate([
268
- serializeAsTexture("opacityTexture")
269
- ], GridMaterial.prototype, "_opacityTexture", void 0);
270
- __decorate([
271
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
272
- ], GridMaterial.prototype, "opacityTexture", void 0);
273
- return GridMaterial;
274
- }(PushMaterial));
275
- export { GridMaterial };
276
- RegisterClass("BABYLON.GridMaterial", GridMaterial);
1
+ import { __decorate, __extends } from "tslib";
2
+ /* eslint-disable @typescript-eslint/naming-convention */
3
+ import { serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper, serializeAsVector3 } from "@babylonjs/core/Misc/decorators.js";
4
+ import { Vector4, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
5
+ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
6
+ import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
7
+ import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
8
+ import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
9
+ import { MaterialFlags } from "@babylonjs/core/Materials/materialFlags.js";
10
+ import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
11
+ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
12
+ import "./grid.fragment";
13
+ import "./grid.vertex";
14
+ var GridMaterialDefines = /** @class */ (function (_super) {
15
+ __extends(GridMaterialDefines, _super);
16
+ function GridMaterialDefines() {
17
+ var _this = _super.call(this) || this;
18
+ _this.OPACITY = false;
19
+ _this.TRANSPARENT = false;
20
+ _this.FOG = false;
21
+ _this.PREMULTIPLYALPHA = false;
22
+ _this.MAX_LINE = false;
23
+ _this.UV1 = false;
24
+ _this.UV2 = false;
25
+ _this.INSTANCES = false;
26
+ _this.THIN_INSTANCES = false;
27
+ _this.IMAGEPROCESSINGPOSTPROCESS = false;
28
+ _this.SKIPFINALCOLORCLAMP = false;
29
+ _this.rebuild();
30
+ return _this;
31
+ }
32
+ return GridMaterialDefines;
33
+ }(MaterialDefines));
34
+ /**
35
+ * The grid materials allows you to wrap any shape with a grid.
36
+ * Colors are customizable.
37
+ */
38
+ var GridMaterial = /** @class */ (function (_super) {
39
+ __extends(GridMaterial, _super);
40
+ /**
41
+ * constructor
42
+ * @param name The name given to the material in order to identify it afterwards.
43
+ * @param scene The scene the material is used in.
44
+ */
45
+ function GridMaterial(name, scene) {
46
+ var _this = _super.call(this, name, scene) || this;
47
+ /**
48
+ * Main color of the grid (e.g. between lines)
49
+ */
50
+ _this.mainColor = Color3.Black();
51
+ /**
52
+ * Color of the grid lines.
53
+ */
54
+ _this.lineColor = Color3.Teal();
55
+ /**
56
+ * The scale of the grid compared to unit.
57
+ */
58
+ _this.gridRatio = 1.0;
59
+ /**
60
+ * Allows setting an offset for the grid lines.
61
+ */
62
+ _this.gridOffset = Vector3.Zero();
63
+ /**
64
+ * The frequency of thicker lines.
65
+ */
66
+ _this.majorUnitFrequency = 10;
67
+ /**
68
+ * The visibility of minor units in the grid.
69
+ */
70
+ _this.minorUnitVisibility = 0.33;
71
+ /**
72
+ * The grid opacity outside of the lines.
73
+ */
74
+ _this.opacity = 1.0;
75
+ /**
76
+ * Determine RBG output is premultiplied by alpha value.
77
+ */
78
+ _this.preMultiplyAlpha = false;
79
+ /**
80
+ * Determines if the max line value will be used instead of the sum wherever grid lines intersect.
81
+ */
82
+ _this.useMaxLine = false;
83
+ _this._gridControl = new Vector4(_this.gridRatio, _this.majorUnitFrequency, _this.minorUnitVisibility, _this.opacity);
84
+ return _this;
85
+ }
86
+ /**
87
+ * Returns whether or not the grid requires alpha blending.
88
+ */
89
+ GridMaterial.prototype.needAlphaBlending = function () {
90
+ return this.opacity < 1.0 || (this._opacityTexture && this._opacityTexture.isReady());
91
+ };
92
+ GridMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
93
+ return mesh.visibility < 1.0 || this.needAlphaBlending();
94
+ };
95
+ GridMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
96
+ if (this.isFrozen) {
97
+ if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
98
+ return true;
99
+ }
100
+ }
101
+ if (!subMesh.materialDefines) {
102
+ subMesh.materialDefines = new GridMaterialDefines();
103
+ }
104
+ var defines = subMesh.materialDefines;
105
+ var scene = this.getScene();
106
+ if (this._isReadyForSubMesh(subMesh)) {
107
+ return true;
108
+ }
109
+ if (defines.TRANSPARENT !== this.opacity < 1.0) {
110
+ defines.TRANSPARENT = !defines.TRANSPARENT;
111
+ defines.markAsUnprocessed();
112
+ }
113
+ if (defines.PREMULTIPLYALPHA != this.preMultiplyAlpha) {
114
+ defines.PREMULTIPLYALPHA = !defines.PREMULTIPLYALPHA;
115
+ defines.markAsUnprocessed();
116
+ }
117
+ if (defines.MAX_LINE !== this.useMaxLine) {
118
+ defines.MAX_LINE = !defines.MAX_LINE;
119
+ defines.markAsUnprocessed();
120
+ }
121
+ // Textures
122
+ if (defines._areTexturesDirty) {
123
+ defines._needUVs = false;
124
+ if (scene.texturesEnabled) {
125
+ if (this._opacityTexture && MaterialFlags.OpacityTextureEnabled) {
126
+ if (!this._opacityTexture.isReady()) {
127
+ return false;
128
+ }
129
+ else {
130
+ defines._needUVs = true;
131
+ defines.OPACITY = true;
132
+ }
133
+ }
134
+ }
135
+ }
136
+ MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, false, defines);
137
+ // Values that need to be evaluated on every frame
138
+ MaterialHelper.PrepareDefinesForFrameBoundValues(scene, scene.getEngine(), defines, !!useInstances);
139
+ // Get correct effect
140
+ if (defines.isDirty) {
141
+ defines.markAsProcessed();
142
+ scene.resetCachedMaterial();
143
+ // Attributes
144
+ MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, false);
145
+ var attribs = [VertexBuffer.PositionKind, VertexBuffer.NormalKind];
146
+ if (defines.UV1) {
147
+ attribs.push(VertexBuffer.UVKind);
148
+ }
149
+ if (defines.UV2) {
150
+ attribs.push(VertexBuffer.UV2Kind);
151
+ }
152
+ defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
153
+ MaterialHelper.PrepareAttributesForInstances(attribs, defines);
154
+ // Defines
155
+ var join = defines.toString();
156
+ subMesh.setEffect(scene
157
+ .getEngine()
158
+ .createEffect("grid", attribs, [
159
+ "projection",
160
+ "mainColor",
161
+ "lineColor",
162
+ "gridControl",
163
+ "gridOffset",
164
+ "vFogInfos",
165
+ "vFogColor",
166
+ "world",
167
+ "view",
168
+ "opacityMatrix",
169
+ "vOpacityInfos",
170
+ "visibility",
171
+ ], ["opacitySampler"], join, undefined, this.onCompiled, this.onError), defines, this._materialContext);
172
+ }
173
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
174
+ return false;
175
+ }
176
+ defines._renderId = scene.getRenderId();
177
+ subMesh.effect._wasPreviouslyReady = true;
178
+ return true;
179
+ };
180
+ GridMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
181
+ var scene = this.getScene();
182
+ var defines = subMesh.materialDefines;
183
+ if (!defines) {
184
+ return;
185
+ }
186
+ var effect = subMesh.effect;
187
+ if (!effect) {
188
+ return;
189
+ }
190
+ this._activeEffect = effect;
191
+ this._activeEffect.setFloat("visibility", mesh.visibility);
192
+ // Matrices
193
+ if (!defines.INSTANCES || defines.THIN_INSTANCE) {
194
+ this.bindOnlyWorldMatrix(world);
195
+ }
196
+ this._activeEffect.setMatrix("view", scene.getViewMatrix());
197
+ this._activeEffect.setMatrix("projection", scene.getProjectionMatrix());
198
+ // Uniforms
199
+ if (this._mustRebind(scene, effect)) {
200
+ this._activeEffect.setColor3("mainColor", this.mainColor);
201
+ this._activeEffect.setColor3("lineColor", this.lineColor);
202
+ this._activeEffect.setVector3("gridOffset", this.gridOffset);
203
+ this._gridControl.x = this.gridRatio;
204
+ this._gridControl.y = Math.round(this.majorUnitFrequency);
205
+ this._gridControl.z = this.minorUnitVisibility;
206
+ this._gridControl.w = this.opacity;
207
+ this._activeEffect.setVector4("gridControl", this._gridControl);
208
+ if (this._opacityTexture && MaterialFlags.OpacityTextureEnabled) {
209
+ this._activeEffect.setTexture("opacitySampler", this._opacityTexture);
210
+ this._activeEffect.setFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
211
+ this._activeEffect.setMatrix("opacityMatrix", this._opacityTexture.getTextureMatrix());
212
+ }
213
+ }
214
+ // Fog
215
+ MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
216
+ this._afterBind(mesh, this._activeEffect);
217
+ };
218
+ /**
219
+ * Dispose the material and its associated resources.
220
+ * @param forceDisposeEffect will also dispose the used effect when true
221
+ */
222
+ GridMaterial.prototype.dispose = function (forceDisposeEffect) {
223
+ _super.prototype.dispose.call(this, forceDisposeEffect);
224
+ };
225
+ GridMaterial.prototype.clone = function (name) {
226
+ var _this = this;
227
+ return SerializationHelper.Clone(function () { return new GridMaterial(name, _this.getScene()); }, this);
228
+ };
229
+ GridMaterial.prototype.serialize = function () {
230
+ var serializationObject = SerializationHelper.Serialize(this);
231
+ serializationObject.customType = "BABYLON.GridMaterial";
232
+ return serializationObject;
233
+ };
234
+ GridMaterial.prototype.getClassName = function () {
235
+ return "GridMaterial";
236
+ };
237
+ GridMaterial.Parse = function (source, scene, rootUrl) {
238
+ return SerializationHelper.Parse(function () { return new GridMaterial(source.name, scene); }, source, scene, rootUrl);
239
+ };
240
+ __decorate([
241
+ serializeAsColor3()
242
+ ], GridMaterial.prototype, "mainColor", void 0);
243
+ __decorate([
244
+ serializeAsColor3()
245
+ ], GridMaterial.prototype, "lineColor", void 0);
246
+ __decorate([
247
+ serialize()
248
+ ], GridMaterial.prototype, "gridRatio", void 0);
249
+ __decorate([
250
+ serializeAsVector3()
251
+ ], GridMaterial.prototype, "gridOffset", void 0);
252
+ __decorate([
253
+ serialize()
254
+ ], GridMaterial.prototype, "majorUnitFrequency", void 0);
255
+ __decorate([
256
+ serialize()
257
+ ], GridMaterial.prototype, "minorUnitVisibility", void 0);
258
+ __decorate([
259
+ serialize()
260
+ ], GridMaterial.prototype, "opacity", void 0);
261
+ __decorate([
262
+ serialize()
263
+ ], GridMaterial.prototype, "preMultiplyAlpha", void 0);
264
+ __decorate([
265
+ serialize()
266
+ ], GridMaterial.prototype, "useMaxLine", void 0);
267
+ __decorate([
268
+ serializeAsTexture("opacityTexture")
269
+ ], GridMaterial.prototype, "_opacityTexture", void 0);
270
+ __decorate([
271
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
272
+ ], GridMaterial.prototype, "opacityTexture", void 0);
273
+ return GridMaterial;
274
+ }(PushMaterial));
275
+ export { GridMaterial };
276
+ RegisterClass("BABYLON.GridMaterial", GridMaterial);
277
277
  //# sourceMappingURL=gridMaterial.js.map
package/grid/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./gridMaterial";
1
+ export * from "./gridMaterial";
package/grid/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./gridMaterial.js";
1
+ export * from "./gridMaterial";
2
2
  //# sourceMappingURL=index.js.map
package/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- export * from "./cell/index";
2
- export * from "./custom/index";
3
- export * from "./fire/index";
4
- export * from "./fur/index";
5
- export * from "./gradient/index";
6
- export * from "./grid/index";
7
- export * from "./lava/index";
8
- export * from "./mix/index";
9
- export * from "./normal/index";
10
- export * from "./shadowOnly/index";
11
- export * from "./simple/index";
12
- export * from "./sky/index";
13
- export * from "./terrain/index";
14
- export * from "./triPlanar/index";
15
- export * from "./water/index";
1
+ export * from "./cell/index";
2
+ export * from "./custom/index";
3
+ export * from "./fire/index";
4
+ export * from "./fur/index";
5
+ export * from "./gradient/index";
6
+ export * from "./grid/index";
7
+ export * from "./lava/index";
8
+ export * from "./mix/index";
9
+ export * from "./normal/index";
10
+ export * from "./shadowOnly/index";
11
+ export * from "./simple/index";
12
+ export * from "./sky/index";
13
+ export * from "./terrain/index";
14
+ export * from "./triPlanar/index";
15
+ export * from "./water/index";
package/index.js CHANGED
@@ -1,16 +1,16 @@
1
- export * from "./cell/index.js";
2
- export * from "./custom/index.js";
3
- export * from "./fire/index.js";
4
- export * from "./fur/index.js";
5
- export * from "./gradient/index.js";
6
- export * from "./grid/index.js";
7
- export * from "./lava/index.js";
8
- export * from "./mix/index.js";
9
- export * from "./normal/index.js";
10
- export * from "./shadowOnly/index.js";
11
- export * from "./simple/index.js";
12
- export * from "./sky/index.js";
13
- export * from "./terrain/index.js";
14
- export * from "./triPlanar/index.js";
15
- export * from "./water/index.js";
1
+ export * from "./cell/index";
2
+ export * from "./custom/index";
3
+ export * from "./fire/index";
4
+ export * from "./fur/index";
5
+ export * from "./gradient/index";
6
+ export * from "./grid/index";
7
+ export * from "./lava/index";
8
+ export * from "./mix/index";
9
+ export * from "./normal/index";
10
+ export * from "./shadowOnly/index";
11
+ export * from "./simple/index";
12
+ export * from "./sky/index";
13
+ export * from "./terrain/index";
14
+ export * from "./triPlanar/index";
15
+ export * from "./water/index";
16
16
  //# sourceMappingURL=index.js.map
package/lava/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./lavaMaterial";
1
+ export * from "./lavaMaterial";
package/lava/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./lavaMaterial.js";
1
+ export * from "./lavaMaterial";
2
2
  //# sourceMappingURL=index.js.map