@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,276 +1,276 @@
1
- import { __decorate, __extends } from "tslib";
2
- import { serialize, expandToProperty, serializeAsColor3, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
3
- import { Color3 } from "@babylonjs/core/Maths/math.color.js";
4
- import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
5
- import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
6
- import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
7
- import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
8
- import { Scene } from "@babylonjs/core/scene.js";
9
- import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
10
- import "./gradient.fragment.js";
11
- import "./gradient.vertex.js";
12
- import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
13
- var GradientMaterialDefines = /** @class */ (function (_super) {
14
- __extends(GradientMaterialDefines, _super);
15
- function GradientMaterialDefines() {
16
- var _this = _super.call(this) || this;
17
- _this.EMISSIVE = false;
18
- _this.CLIPPLANE = false;
19
- _this.CLIPPLANE2 = false;
20
- _this.CLIPPLANE3 = false;
21
- _this.CLIPPLANE4 = false;
22
- _this.CLIPPLANE5 = false;
23
- _this.CLIPPLANE6 = false;
24
- _this.ALPHATEST = false;
25
- _this.DEPTHPREPASS = false;
26
- _this.POINTSIZE = false;
27
- _this.FOG = false;
28
- _this.NORMAL = false;
29
- _this.UV1 = false;
30
- _this.UV2 = false;
31
- _this.VERTEXCOLOR = false;
32
- _this.VERTEXALPHA = false;
33
- _this.NUM_BONE_INFLUENCERS = 0;
34
- _this.BonesPerMesh = 0;
35
- _this.INSTANCES = false;
36
- _this.INSTANCESCOLOR = false;
37
- _this.IMAGEPROCESSINGPOSTPROCESS = false;
38
- _this.SKIPFINALCOLORCLAMP = false;
39
- _this.rebuild();
40
- return _this;
41
- }
42
- return GradientMaterialDefines;
43
- }(MaterialDefines));
44
- var GradientMaterial = /** @class */ (function (_super) {
45
- __extends(GradientMaterial, _super);
46
- function GradientMaterial(name, scene) {
47
- var _this = _super.call(this, name, scene) || this;
48
- _this._maxSimultaneousLights = 4;
49
- // The gradient top color, red by default
50
- _this.topColor = new Color3(1, 0, 0);
51
- _this.topColorAlpha = 1.0;
52
- // The gradient top color, blue by default
53
- _this.bottomColor = new Color3(0, 0, 1);
54
- _this.bottomColorAlpha = 1.0;
55
- // Gradient offset
56
- _this.offset = 0;
57
- _this.scale = 1.0;
58
- _this.smoothness = 1.0;
59
- _this._disableLighting = false;
60
- return _this;
61
- }
62
- GradientMaterial.prototype.needAlphaBlending = function () {
63
- return this.alpha < 1.0 || this.topColorAlpha < 1.0 || this.bottomColorAlpha < 1.0;
64
- };
65
- GradientMaterial.prototype.needAlphaTesting = function () {
66
- return true;
67
- };
68
- GradientMaterial.prototype.getAlphaTestTexture = function () {
69
- return null;
70
- };
71
- // Methods
72
- GradientMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
73
- if (this.isFrozen) {
74
- if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
75
- return true;
76
- }
77
- }
78
- if (!subMesh.materialDefines) {
79
- subMesh.materialDefines = new GradientMaterialDefines();
80
- }
81
- var defines = subMesh.materialDefines;
82
- var scene = this.getScene();
83
- if (this._isReadyForSubMesh(subMesh)) {
84
- return true;
85
- }
86
- var engine = scene.getEngine();
87
- MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
88
- MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
89
- defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
90
- defines.EMISSIVE = this._disableLighting;
91
- // Attribs
92
- MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
93
- // Get correct effect
94
- if (defines.isDirty) {
95
- defines.markAsProcessed();
96
- scene.resetCachedMaterial();
97
- // Fallbacks
98
- var fallbacks = new EffectFallbacks();
99
- if (defines.FOG) {
100
- fallbacks.addFallback(1, "FOG");
101
- }
102
- MaterialHelper.HandleFallbacksForShadows(defines, fallbacks);
103
- if (defines.NUM_BONE_INFLUENCERS > 0) {
104
- fallbacks.addCPUSkinningFallback(0, mesh);
105
- }
106
- defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
107
- //Attributes
108
- var attribs = [VertexBuffer.PositionKind];
109
- if (defines.NORMAL) {
110
- attribs.push(VertexBuffer.NormalKind);
111
- }
112
- if (defines.UV1) {
113
- attribs.push(VertexBuffer.UVKind);
114
- }
115
- if (defines.UV2) {
116
- attribs.push(VertexBuffer.UV2Kind);
117
- }
118
- if (defines.VERTEXCOLOR) {
119
- attribs.push(VertexBuffer.ColorKind);
120
- }
121
- MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
122
- MaterialHelper.PrepareAttributesForInstances(attribs, defines);
123
- // Legacy browser patch
124
- var shaderName = "gradient";
125
- var join = defines.toString();
126
- var uniforms = [
127
- "world",
128
- "view",
129
- "viewProjection",
130
- "vEyePosition",
131
- "vLightsType",
132
- "vFogInfos",
133
- "vFogColor",
134
- "pointSize",
135
- "mBones",
136
- "vClipPlane",
137
- "vClipPlane2",
138
- "vClipPlane3",
139
- "vClipPlane4",
140
- "vClipPlane5",
141
- "vClipPlane6",
142
- "topColor",
143
- "bottomColor",
144
- "offset",
145
- "smoothness",
146
- "scale",
147
- ];
148
- var samplers = [];
149
- var uniformBuffers = new Array();
150
- MaterialHelper.PrepareUniformsAndSamplersList({
151
- uniformsNames: uniforms,
152
- uniformBuffersNames: uniformBuffers,
153
- samplers: samplers,
154
- defines: defines,
155
- maxSimultaneousLights: 4,
156
- });
157
- subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
158
- attributes: attribs,
159
- uniformsNames: uniforms,
160
- uniformBuffersNames: uniformBuffers,
161
- samplers: samplers,
162
- defines: join,
163
- fallbacks: fallbacks,
164
- onCompiled: this.onCompiled,
165
- onError: this.onError,
166
- indexParameters: { maxSimultaneousLights: 4 },
167
- }, engine), defines, this._materialContext);
168
- }
169
- if (!subMesh.effect || !subMesh.effect.isReady()) {
170
- return false;
171
- }
172
- defines._renderId = scene.getRenderId();
173
- subMesh.effect._wasPreviouslyReady = true;
174
- return true;
175
- };
176
- GradientMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
177
- var scene = this.getScene();
178
- var defines = subMesh.materialDefines;
179
- if (!defines) {
180
- return;
181
- }
182
- var effect = subMesh.effect;
183
- if (!effect) {
184
- return;
185
- }
186
- this._activeEffect = effect;
187
- // Matrices
188
- this.bindOnlyWorldMatrix(world);
189
- this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
190
- // Bones
191
- MaterialHelper.BindBonesParameters(mesh, effect);
192
- if (this._mustRebind(scene, effect)) {
193
- // Clip plane
194
- MaterialHelper.BindClipPlane(effect, scene);
195
- // Point size
196
- if (this.pointsCloud) {
197
- this._activeEffect.setFloat("pointSize", this.pointSize);
198
- }
199
- scene.bindEyePosition(effect);
200
- }
201
- if (scene.lightsEnabled && !this.disableLighting) {
202
- MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
203
- }
204
- // View
205
- if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
206
- this._activeEffect.setMatrix("view", scene.getViewMatrix());
207
- }
208
- // Fog
209
- MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
210
- this._activeEffect.setColor4("topColor", this.topColor, this.topColorAlpha);
211
- this._activeEffect.setColor4("bottomColor", this.bottomColor, this.bottomColorAlpha);
212
- this._activeEffect.setFloat("offset", this.offset);
213
- this._activeEffect.setFloat("scale", this.scale);
214
- this._activeEffect.setFloat("smoothness", this.smoothness);
215
- this._afterBind(mesh, this._activeEffect);
216
- };
217
- GradientMaterial.prototype.getAnimatables = function () {
218
- return [];
219
- };
220
- GradientMaterial.prototype.dispose = function (forceDisposeEffect) {
221
- _super.prototype.dispose.call(this, forceDisposeEffect);
222
- };
223
- GradientMaterial.prototype.clone = function (name) {
224
- var _this = this;
225
- return SerializationHelper.Clone(function () { return new GradientMaterial(name, _this.getScene()); }, this);
226
- };
227
- GradientMaterial.prototype.serialize = function () {
228
- var serializationObject = _super.prototype.serialize.call(this);
229
- serializationObject.customType = "BABYLON.GradientMaterial";
230
- return serializationObject;
231
- };
232
- GradientMaterial.prototype.getClassName = function () {
233
- return "GradientMaterial";
234
- };
235
- // Statics
236
- GradientMaterial.Parse = function (source, scene, rootUrl) {
237
- return SerializationHelper.Parse(function () { return new GradientMaterial(source.name, scene); }, source, scene, rootUrl);
238
- };
239
- __decorate([
240
- serialize("maxSimultaneousLights")
241
- ], GradientMaterial.prototype, "_maxSimultaneousLights", void 0);
242
- __decorate([
243
- expandToProperty("_markAllSubMeshesAsLightsDirty")
244
- ], GradientMaterial.prototype, "maxSimultaneousLights", void 0);
245
- __decorate([
246
- serializeAsColor3()
247
- ], GradientMaterial.prototype, "topColor", void 0);
248
- __decorate([
249
- serialize()
250
- ], GradientMaterial.prototype, "topColorAlpha", void 0);
251
- __decorate([
252
- serializeAsColor3()
253
- ], GradientMaterial.prototype, "bottomColor", void 0);
254
- __decorate([
255
- serialize()
256
- ], GradientMaterial.prototype, "bottomColorAlpha", void 0);
257
- __decorate([
258
- serialize()
259
- ], GradientMaterial.prototype, "offset", void 0);
260
- __decorate([
261
- serialize()
262
- ], GradientMaterial.prototype, "scale", void 0);
263
- __decorate([
264
- serialize()
265
- ], GradientMaterial.prototype, "smoothness", void 0);
266
- __decorate([
267
- serialize("disableLighting")
268
- ], GradientMaterial.prototype, "_disableLighting", void 0);
269
- __decorate([
270
- expandToProperty("_markAllSubMeshesAsLightsDirty")
271
- ], GradientMaterial.prototype, "disableLighting", void 0);
272
- return GradientMaterial;
273
- }(PushMaterial));
274
- export { GradientMaterial };
275
- RegisterClass("BABYLON.GradientMaterial", GradientMaterial);
1
+ import { __decorate, __extends } from "tslib";
2
+ import { serialize, expandToProperty, serializeAsColor3, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
3
+ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
4
+ import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
5
+ import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
6
+ import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
7
+ import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
8
+ import { Scene } from "@babylonjs/core/scene.js";
9
+ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
10
+ import "./gradient.fragment";
11
+ import "./gradient.vertex";
12
+ import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
13
+ var GradientMaterialDefines = /** @class */ (function (_super) {
14
+ __extends(GradientMaterialDefines, _super);
15
+ function GradientMaterialDefines() {
16
+ var _this = _super.call(this) || this;
17
+ _this.EMISSIVE = false;
18
+ _this.CLIPPLANE = false;
19
+ _this.CLIPPLANE2 = false;
20
+ _this.CLIPPLANE3 = false;
21
+ _this.CLIPPLANE4 = false;
22
+ _this.CLIPPLANE5 = false;
23
+ _this.CLIPPLANE6 = false;
24
+ _this.ALPHATEST = false;
25
+ _this.DEPTHPREPASS = false;
26
+ _this.POINTSIZE = false;
27
+ _this.FOG = false;
28
+ _this.NORMAL = false;
29
+ _this.UV1 = false;
30
+ _this.UV2 = false;
31
+ _this.VERTEXCOLOR = false;
32
+ _this.VERTEXALPHA = false;
33
+ _this.NUM_BONE_INFLUENCERS = 0;
34
+ _this.BonesPerMesh = 0;
35
+ _this.INSTANCES = false;
36
+ _this.INSTANCESCOLOR = false;
37
+ _this.IMAGEPROCESSINGPOSTPROCESS = false;
38
+ _this.SKIPFINALCOLORCLAMP = false;
39
+ _this.rebuild();
40
+ return _this;
41
+ }
42
+ return GradientMaterialDefines;
43
+ }(MaterialDefines));
44
+ var GradientMaterial = /** @class */ (function (_super) {
45
+ __extends(GradientMaterial, _super);
46
+ function GradientMaterial(name, scene) {
47
+ var _this = _super.call(this, name, scene) || this;
48
+ _this._maxSimultaneousLights = 4;
49
+ // The gradient top color, red by default
50
+ _this.topColor = new Color3(1, 0, 0);
51
+ _this.topColorAlpha = 1.0;
52
+ // The gradient top color, blue by default
53
+ _this.bottomColor = new Color3(0, 0, 1);
54
+ _this.bottomColorAlpha = 1.0;
55
+ // Gradient offset
56
+ _this.offset = 0;
57
+ _this.scale = 1.0;
58
+ _this.smoothness = 1.0;
59
+ _this._disableLighting = false;
60
+ return _this;
61
+ }
62
+ GradientMaterial.prototype.needAlphaBlending = function () {
63
+ return this.alpha < 1.0 || this.topColorAlpha < 1.0 || this.bottomColorAlpha < 1.0;
64
+ };
65
+ GradientMaterial.prototype.needAlphaTesting = function () {
66
+ return true;
67
+ };
68
+ GradientMaterial.prototype.getAlphaTestTexture = function () {
69
+ return null;
70
+ };
71
+ // Methods
72
+ GradientMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
73
+ if (this.isFrozen) {
74
+ if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
75
+ return true;
76
+ }
77
+ }
78
+ if (!subMesh.materialDefines) {
79
+ subMesh.materialDefines = new GradientMaterialDefines();
80
+ }
81
+ var defines = subMesh.materialDefines;
82
+ var scene = this.getScene();
83
+ if (this._isReadyForSubMesh(subMesh)) {
84
+ return true;
85
+ }
86
+ var engine = scene.getEngine();
87
+ MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
88
+ MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
89
+ defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
90
+ defines.EMISSIVE = this._disableLighting;
91
+ // Attribs
92
+ MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
93
+ // Get correct effect
94
+ if (defines.isDirty) {
95
+ defines.markAsProcessed();
96
+ scene.resetCachedMaterial();
97
+ // Fallbacks
98
+ var fallbacks = new EffectFallbacks();
99
+ if (defines.FOG) {
100
+ fallbacks.addFallback(1, "FOG");
101
+ }
102
+ MaterialHelper.HandleFallbacksForShadows(defines, fallbacks);
103
+ if (defines.NUM_BONE_INFLUENCERS > 0) {
104
+ fallbacks.addCPUSkinningFallback(0, mesh);
105
+ }
106
+ defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
107
+ //Attributes
108
+ var attribs = [VertexBuffer.PositionKind];
109
+ if (defines.NORMAL) {
110
+ attribs.push(VertexBuffer.NormalKind);
111
+ }
112
+ if (defines.UV1) {
113
+ attribs.push(VertexBuffer.UVKind);
114
+ }
115
+ if (defines.UV2) {
116
+ attribs.push(VertexBuffer.UV2Kind);
117
+ }
118
+ if (defines.VERTEXCOLOR) {
119
+ attribs.push(VertexBuffer.ColorKind);
120
+ }
121
+ MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
122
+ MaterialHelper.PrepareAttributesForInstances(attribs, defines);
123
+ // Legacy browser patch
124
+ var shaderName = "gradient";
125
+ var join = defines.toString();
126
+ var uniforms = [
127
+ "world",
128
+ "view",
129
+ "viewProjection",
130
+ "vEyePosition",
131
+ "vLightsType",
132
+ "vFogInfos",
133
+ "vFogColor",
134
+ "pointSize",
135
+ "mBones",
136
+ "vClipPlane",
137
+ "vClipPlane2",
138
+ "vClipPlane3",
139
+ "vClipPlane4",
140
+ "vClipPlane5",
141
+ "vClipPlane6",
142
+ "topColor",
143
+ "bottomColor",
144
+ "offset",
145
+ "smoothness",
146
+ "scale",
147
+ ];
148
+ var samplers = [];
149
+ var uniformBuffers = new Array();
150
+ MaterialHelper.PrepareUniformsAndSamplersList({
151
+ uniformsNames: uniforms,
152
+ uniformBuffersNames: uniformBuffers,
153
+ samplers: samplers,
154
+ defines: defines,
155
+ maxSimultaneousLights: 4,
156
+ });
157
+ subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
158
+ attributes: attribs,
159
+ uniformsNames: uniforms,
160
+ uniformBuffersNames: uniformBuffers,
161
+ samplers: samplers,
162
+ defines: join,
163
+ fallbacks: fallbacks,
164
+ onCompiled: this.onCompiled,
165
+ onError: this.onError,
166
+ indexParameters: { maxSimultaneousLights: 4 },
167
+ }, engine), defines, this._materialContext);
168
+ }
169
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
170
+ return false;
171
+ }
172
+ defines._renderId = scene.getRenderId();
173
+ subMesh.effect._wasPreviouslyReady = true;
174
+ return true;
175
+ };
176
+ GradientMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
177
+ var scene = this.getScene();
178
+ var defines = subMesh.materialDefines;
179
+ if (!defines) {
180
+ return;
181
+ }
182
+ var effect = subMesh.effect;
183
+ if (!effect) {
184
+ return;
185
+ }
186
+ this._activeEffect = effect;
187
+ // Matrices
188
+ this.bindOnlyWorldMatrix(world);
189
+ this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
190
+ // Bones
191
+ MaterialHelper.BindBonesParameters(mesh, effect);
192
+ if (this._mustRebind(scene, effect)) {
193
+ // Clip plane
194
+ MaterialHelper.BindClipPlane(effect, scene);
195
+ // Point size
196
+ if (this.pointsCloud) {
197
+ this._activeEffect.setFloat("pointSize", this.pointSize);
198
+ }
199
+ scene.bindEyePosition(effect);
200
+ }
201
+ if (scene.lightsEnabled && !this.disableLighting) {
202
+ MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
203
+ }
204
+ // View
205
+ if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
206
+ this._activeEffect.setMatrix("view", scene.getViewMatrix());
207
+ }
208
+ // Fog
209
+ MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
210
+ this._activeEffect.setColor4("topColor", this.topColor, this.topColorAlpha);
211
+ this._activeEffect.setColor4("bottomColor", this.bottomColor, this.bottomColorAlpha);
212
+ this._activeEffect.setFloat("offset", this.offset);
213
+ this._activeEffect.setFloat("scale", this.scale);
214
+ this._activeEffect.setFloat("smoothness", this.smoothness);
215
+ this._afterBind(mesh, this._activeEffect);
216
+ };
217
+ GradientMaterial.prototype.getAnimatables = function () {
218
+ return [];
219
+ };
220
+ GradientMaterial.prototype.dispose = function (forceDisposeEffect) {
221
+ _super.prototype.dispose.call(this, forceDisposeEffect);
222
+ };
223
+ GradientMaterial.prototype.clone = function (name) {
224
+ var _this = this;
225
+ return SerializationHelper.Clone(function () { return new GradientMaterial(name, _this.getScene()); }, this);
226
+ };
227
+ GradientMaterial.prototype.serialize = function () {
228
+ var serializationObject = _super.prototype.serialize.call(this);
229
+ serializationObject.customType = "BABYLON.GradientMaterial";
230
+ return serializationObject;
231
+ };
232
+ GradientMaterial.prototype.getClassName = function () {
233
+ return "GradientMaterial";
234
+ };
235
+ // Statics
236
+ GradientMaterial.Parse = function (source, scene, rootUrl) {
237
+ return SerializationHelper.Parse(function () { return new GradientMaterial(source.name, scene); }, source, scene, rootUrl);
238
+ };
239
+ __decorate([
240
+ serialize("maxSimultaneousLights")
241
+ ], GradientMaterial.prototype, "_maxSimultaneousLights", void 0);
242
+ __decorate([
243
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
244
+ ], GradientMaterial.prototype, "maxSimultaneousLights", void 0);
245
+ __decorate([
246
+ serializeAsColor3()
247
+ ], GradientMaterial.prototype, "topColor", void 0);
248
+ __decorate([
249
+ serialize()
250
+ ], GradientMaterial.prototype, "topColorAlpha", void 0);
251
+ __decorate([
252
+ serializeAsColor3()
253
+ ], GradientMaterial.prototype, "bottomColor", void 0);
254
+ __decorate([
255
+ serialize()
256
+ ], GradientMaterial.prototype, "bottomColorAlpha", void 0);
257
+ __decorate([
258
+ serialize()
259
+ ], GradientMaterial.prototype, "offset", void 0);
260
+ __decorate([
261
+ serialize()
262
+ ], GradientMaterial.prototype, "scale", void 0);
263
+ __decorate([
264
+ serialize()
265
+ ], GradientMaterial.prototype, "smoothness", void 0);
266
+ __decorate([
267
+ serialize("disableLighting")
268
+ ], GradientMaterial.prototype, "_disableLighting", void 0);
269
+ __decorate([
270
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
271
+ ], GradientMaterial.prototype, "disableLighting", void 0);
272
+ return GradientMaterial;
273
+ }(PushMaterial));
274
+ export { GradientMaterial };
275
+ RegisterClass("BABYLON.GradientMaterial", GradientMaterial);
276
276
  //# sourceMappingURL=gradientMaterial.js.map
@@ -1 +1 @@
1
- export * from "./gradientMaterial";
1
+ export * from "./gradientMaterial";
package/gradient/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./gradientMaterial.js";
1
+ export * from "./gradientMaterial";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,8 @@
1
- import "@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.js";
2
- import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js";
3
- import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js";
4
- /** @hidden */
5
- export declare const gridPixelShader: {
6
- name: string;
7
- shader: string;
8
- };
1
+ import "@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.js";
2
+ import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js";
3
+ import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js";
4
+ /** @hidden */
5
+ export declare const gridPixelShader: {
6
+ name: string;
7
+ shader: string;
8
+ };
@@ -1,12 +1,12 @@
1
- // Do not edit.
2
- import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
3
- import "@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.js";
4
- import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js";
5
- import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js";
6
- var name = "gridPixelShader";
7
- var shader = "#extension GL_OES_standard_derivatives : enable\n#define SQRT2 1.41421356\n#define PI 3.14159\nprecision highp float;\nuniform float visibility;\nuniform vec3 mainColor;\nuniform vec3 lineColor;\nuniform vec4 gridControl;\nuniform vec3 gridOffset;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogFragmentDeclaration>\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\nuniform vec2 vOpacityInfos;\n#endif\nfloat getDynamicVisibility(float position) {\nfloat majorGridFrequency=gridControl.y;\nif (floor(position+0.5)==floor(position/majorGridFrequency+0.5)*majorGridFrequency)\n{\nreturn 1.0;\n} \nreturn gridControl.z;\n}\nfloat getAnisotropicAttenuation(float differentialLength) {\nconst float maxNumberOfLines=10.0;\nreturn clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);\n}\nfloat isPointOnLine(float position,float differentialLength) {\nfloat fractionPartOfPosition=position-floor(position+0.5); \nfractionPartOfPosition/=differentialLength; \nfractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);\nfloat result=0.5+0.5*cos(fractionPartOfPosition*PI); \nreturn result; \n}\nfloat contributionOnAxis(float position) {\nfloat differentialLength=length(vec2(dFdx(position),dFdy(position)));\ndifferentialLength*=SQRT2; \nfloat result=isPointOnLine(position,differentialLength);\nfloat dynamicVisibility=getDynamicVisibility(position);\nresult*=dynamicVisibility;\nfloat anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);\nresult*=anisotropicAttenuation;\nreturn result;\n}\nfloat normalImpactOnAxis(float x) {\nfloat normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);\nreturn normalImpact;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nfloat gridRatio=gridControl.x;\nvec3 gridPos=(vPosition+gridOffset.xyz)/gridRatio;\nfloat x=contributionOnAxis(gridPos.x);\nfloat y=contributionOnAxis(gridPos.y);\nfloat z=contributionOnAxis(gridPos.z);\nvec3 normal=normalize(vNormal);\nx*=normalImpactOnAxis(normal.x);\ny*=normalImpactOnAxis(normal.y);\nz*=normalImpactOnAxis(normal.z);\n#ifdef MAX_LINE \nfloat grid=clamp(max(max(x,y),z),0.,1.);\n#else\nfloat grid=clamp(x+y+z,0.,1.);\n#endif\nvec3 color=mix(mainColor,lineColor,grid);\n#ifdef FOG\n#include<fogFragment>\n#endif\nfloat opacity=1.0;\n#ifdef TRANSPARENT\nopacity=clamp(grid,0.08,gridControl.w*grid);\n#endif \n#ifdef OPACITY\nopacity*=texture2D(opacitySampler,vOpacityUV).a;\n#endif \ngl_FragColor=vec4(color.rgb,opacity*visibility);\n#ifdef TRANSPARENT\n#ifdef PREMULTIPLYALPHA\ngl_FragColor.rgb*=opacity;\n#endif\n#else \n#endif\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
8
- // Sideeffect
9
- ShaderStore.ShadersStore[name] = shader;
10
- /** @hidden */
11
- export var gridPixelShader = { name: name, shader: shader };
1
+ // Do not edit.
2
+ import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
3
+ import "@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.js";
4
+ import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js";
5
+ import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js";
6
+ var name = "gridPixelShader";
7
+ var shader = "#extension GL_OES_standard_derivatives : enable\n#define SQRT2 1.41421356\n#define PI 3.14159\nprecision highp float;\nuniform float visibility;\nuniform vec3 mainColor;\nuniform vec3 lineColor;\nuniform vec4 gridControl;\nuniform vec3 gridOffset;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogFragmentDeclaration>\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\nuniform vec2 vOpacityInfos;\n#endif\nfloat getDynamicVisibility(float position) {\nfloat majorGridFrequency=gridControl.y;\nif (floor(position+0.5)==floor(position/majorGridFrequency+0.5)*majorGridFrequency)\n{\nreturn 1.0;\n} \nreturn gridControl.z;\n}\nfloat getAnisotropicAttenuation(float differentialLength) {\nconst float maxNumberOfLines=10.0;\nreturn clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);\n}\nfloat isPointOnLine(float position,float differentialLength) {\nfloat fractionPartOfPosition=position-floor(position+0.5); \nfractionPartOfPosition/=differentialLength; \nfractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);\nfloat result=0.5+0.5*cos(fractionPartOfPosition*PI); \nreturn result; \n}\nfloat contributionOnAxis(float position) {\nfloat differentialLength=length(vec2(dFdx(position),dFdy(position)));\ndifferentialLength*=SQRT2; \nfloat result=isPointOnLine(position,differentialLength);\nfloat dynamicVisibility=getDynamicVisibility(position);\nresult*=dynamicVisibility;\nfloat anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);\nresult*=anisotropicAttenuation;\nreturn result;\n}\nfloat normalImpactOnAxis(float x) {\nfloat normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);\nreturn normalImpact;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nfloat gridRatio=gridControl.x;\nvec3 gridPos=(vPosition+gridOffset.xyz)/gridRatio;\nfloat x=contributionOnAxis(gridPos.x);\nfloat y=contributionOnAxis(gridPos.y);\nfloat z=contributionOnAxis(gridPos.z);\nvec3 normal=normalize(vNormal);\nx*=normalImpactOnAxis(normal.x);\ny*=normalImpactOnAxis(normal.y);\nz*=normalImpactOnAxis(normal.z);\n#ifdef MAX_LINE \nfloat grid=clamp(max(max(x,y),z),0.,1.);\n#else\nfloat grid=clamp(x+y+z,0.,1.);\n#endif\nvec3 color=mix(mainColor,lineColor,grid);\n#ifdef FOG\n#include<fogFragment>\n#endif\nfloat opacity=1.0;\n#ifdef TRANSPARENT\nopacity=clamp(grid,0.08,gridControl.w*grid);\n#endif \n#ifdef OPACITY\nopacity*=texture2D(opacitySampler,vOpacityUV).a;\n#endif \ngl_FragColor=vec4(color.rgb,opacity*visibility);\n#ifdef TRANSPARENT\n#ifdef PREMULTIPLYALPHA\ngl_FragColor.rgb*=opacity;\n#endif\n#else \n#endif\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
8
+ // Sideeffect
9
+ ShaderStore.ShadersStore[name] = shader;
10
+ /** @hidden */
11
+ export var gridPixelShader = { name: name, shader: shader };
12
12
  //# sourceMappingURL=grid.fragment.js.map
@@ -1,9 +1,9 @@
1
- import "@babylonjs/core/Shaders/ShadersInclude/instancesDeclaration.js";
2
- import "@babylonjs/core/Shaders/ShadersInclude/fogVertexDeclaration.js";
3
- import "@babylonjs/core/Shaders/ShadersInclude/instancesVertex.js";
4
- import "@babylonjs/core/Shaders/ShadersInclude/fogVertex.js";
5
- /** @hidden */
6
- export declare const gridVertexShader: {
7
- name: string;
8
- shader: string;
9
- };
1
+ import "@babylonjs/core/Shaders/ShadersInclude/instancesDeclaration.js";
2
+ import "@babylonjs/core/Shaders/ShadersInclude/fogVertexDeclaration.js";
3
+ import "@babylonjs/core/Shaders/ShadersInclude/instancesVertex.js";
4
+ import "@babylonjs/core/Shaders/ShadersInclude/fogVertex.js";
5
+ /** @hidden */
6
+ export declare const gridVertexShader: {
7
+ name: string;
8
+ shader: string;
9
+ };