@babylonjs/procedural-textures 9.15.0 → 9.16.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.
@@ -1,4 +1,4 @@
1
- import { __decorate } from "@babylonjs/core/tslib.es6.js";
1
+ import { __esDecorate, __runInitializers } from "@babylonjs/core/tslib.es6.js";
2
2
  import { serialize, serializeAsVector2 } from "@babylonjs/core/Misc/decorators.js";
3
3
  import { SerializationHelper } from "@babylonjs/core/Misc/decorators.serialization.js";
4
4
  import { Vector2 } from "@babylonjs/core/Maths/math.vector.js";
@@ -6,122 +6,133 @@ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
6
6
  import { ProceduralTexture } from "@babylonjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
7
7
  import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
8
8
  import "./fireProceduralTexture.fragment.js";
9
- export class FireProceduralTexture extends ProceduralTexture {
10
- constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
11
- super(name, size, "fireProceduralTexture", scene, fallbackTexture, generateMipMaps);
12
- this._time = 0.0;
13
- this._speed = new Vector2(0.5, 0.3);
14
- this._autoGenerateTime = true;
15
- this._alphaThreshold = 0.5;
16
- this._fireColors = FireProceduralTexture.RedFireColors;
17
- this.updateShaderUniforms();
18
- }
19
- updateShaderUniforms() {
20
- this.setFloat("time", this._time);
21
- this.setVector2("speed", this._speed);
22
- this.setColor3("c1", this._fireColors[0]);
23
- this.setColor3("c2", this._fireColors[1]);
24
- this.setColor3("c3", this._fireColors[2]);
25
- this.setColor3("c4", this._fireColors[3]);
26
- this.setColor3("c5", this._fireColors[4]);
27
- this.setColor3("c6", this._fireColors[5]);
28
- this.setFloat("alphaThreshold", this._alphaThreshold);
29
- }
30
- render(useCameraPostProcess) {
31
- const scene = this.getScene();
32
- if (this._autoGenerateTime && scene) {
33
- this._time += scene.getAnimationRatio() * 0.03;
34
- this.updateShaderUniforms();
35
- }
36
- super.render(useCameraPostProcess);
37
- }
38
- static get PurpleFireColors() {
39
- return [new Color3(0.5, 0.0, 1.0), new Color3(0.9, 0.0, 1.0), new Color3(0.2, 0.0, 1.0), new Color3(1.0, 0.9, 1.0), new Color3(0.1, 0.1, 1.0), new Color3(0.9, 0.9, 1.0)];
40
- }
41
- static get GreenFireColors() {
42
- return [new Color3(0.5, 1.0, 0.0), new Color3(0.5, 1.0, 0.0), new Color3(0.3, 0.4, 0.0), new Color3(0.5, 1.0, 0.0), new Color3(0.2, 0.0, 0.0), new Color3(0.5, 1.0, 0.0)];
43
- }
44
- static get RedFireColors() {
45
- return [new Color3(0.5, 0.0, 0.1), new Color3(0.9, 0.0, 0.0), new Color3(0.2, 0.0, 0.0), new Color3(1.0, 0.9, 0.0), new Color3(0.1, 0.1, 0.1), new Color3(0.9, 0.9, 0.9)];
46
- }
47
- static get BlueFireColors() {
48
- return [new Color3(0.1, 0.0, 0.5), new Color3(0.0, 0.0, 0.5), new Color3(0.1, 0.0, 0.2), new Color3(0.0, 0.0, 1.0), new Color3(0.1, 0.2, 0.3), new Color3(0.0, 0.2, 0.9)];
49
- }
50
- get autoGenerateTime() {
51
- return this._autoGenerateTime;
52
- }
53
- set autoGenerateTime(value) {
54
- this._autoGenerateTime = value;
55
- }
56
- get fireColors() {
57
- return this._fireColors;
58
- }
59
- set fireColors(value) {
60
- this._fireColors = value;
61
- this.updateShaderUniforms();
62
- }
63
- get time() {
64
- return this._time;
65
- }
66
- set time(value) {
67
- this._time = value;
68
- this.updateShaderUniforms();
69
- }
70
- get speed() {
71
- return this._speed;
72
- }
73
- set speed(value) {
74
- this._speed = value;
75
- this.updateShaderUniforms();
76
- }
77
- get alphaThreshold() {
78
- return this._alphaThreshold;
79
- }
80
- set alphaThreshold(value) {
81
- this._alphaThreshold = value;
82
- this.updateShaderUniforms();
83
- }
84
- /**
85
- * Serializes this fire procedural texture
86
- * @returns a serialized fire procedural texture object
87
- */
88
- serialize() {
89
- const serializationObject = SerializationHelper.Serialize(this, super.serialize());
90
- serializationObject.customType = "BABYLON.FireProceduralTexture";
91
- serializationObject.fireColors = [];
92
- for (let i = 0; i < this._fireColors.length; i++) {
93
- serializationObject.fireColors.push(this._fireColors[i].asArray());
94
- }
95
- return serializationObject;
96
- }
97
- /**
98
- * Creates a Fire Procedural Texture from parsed fire procedural texture data
99
- * @param parsedTexture defines parsed texture data
100
- * @param scene defines the current scene
101
- * @param rootUrl defines the root URL containing fire procedural texture information
102
- * @returns a parsed Fire Procedural Texture
103
- */
104
- static Parse(parsedTexture, scene, rootUrl) {
105
- const texture = SerializationHelper.Parse(() => new FireProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
106
- const colors = [];
107
- for (let i = 0; i < parsedTexture.fireColors.length; i++) {
108
- colors.push(Color3.FromArray(parsedTexture.fireColors[i]));
109
- }
110
- texture.fireColors = colors;
111
- return texture;
112
- }
113
- }
114
- __decorate([
115
- serialize()
116
- ], FireProceduralTexture.prototype, "autoGenerateTime", null);
117
- __decorate([
118
- serialize()
119
- ], FireProceduralTexture.prototype, "time", null);
120
- __decorate([
121
- serializeAsVector2()
122
- ], FireProceduralTexture.prototype, "speed", null);
123
- __decorate([
124
- serialize()
125
- ], FireProceduralTexture.prototype, "alphaThreshold", null);
9
+ let FireProceduralTexture = (() => {
10
+ var _a;
11
+ let _classSuper = ProceduralTexture;
12
+ let _instanceExtraInitializers = [];
13
+ let _get_autoGenerateTime_decorators;
14
+ let _get_time_decorators;
15
+ let _get_speed_decorators;
16
+ let _get_alphaThreshold_decorators;
17
+ return _a = class FireProceduralTexture extends _classSuper {
18
+ constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
19
+ super(name, size, "fireProceduralTexture", scene, fallbackTexture, generateMipMaps);
20
+ this._time = (__runInitializers(this, _instanceExtraInitializers), 0.0);
21
+ this._speed = new Vector2(0.5, 0.3);
22
+ this._autoGenerateTime = true;
23
+ this._alphaThreshold = 0.5;
24
+ this._fireColors = _a.RedFireColors;
25
+ this.updateShaderUniforms();
26
+ }
27
+ updateShaderUniforms() {
28
+ this.setFloat("time", this._time);
29
+ this.setVector2("speed", this._speed);
30
+ this.setColor3("c1", this._fireColors[0]);
31
+ this.setColor3("c2", this._fireColors[1]);
32
+ this.setColor3("c3", this._fireColors[2]);
33
+ this.setColor3("c4", this._fireColors[3]);
34
+ this.setColor3("c5", this._fireColors[4]);
35
+ this.setColor3("c6", this._fireColors[5]);
36
+ this.setFloat("alphaThreshold", this._alphaThreshold);
37
+ }
38
+ render(useCameraPostProcess) {
39
+ const scene = this.getScene();
40
+ if (this._autoGenerateTime && scene) {
41
+ this._time += scene.getAnimationRatio() * 0.03;
42
+ this.updateShaderUniforms();
43
+ }
44
+ super.render(useCameraPostProcess);
45
+ }
46
+ static get PurpleFireColors() {
47
+ return [new Color3(0.5, 0.0, 1.0), new Color3(0.9, 0.0, 1.0), new Color3(0.2, 0.0, 1.0), new Color3(1.0, 0.9, 1.0), new Color3(0.1, 0.1, 1.0), new Color3(0.9, 0.9, 1.0)];
48
+ }
49
+ static get GreenFireColors() {
50
+ return [new Color3(0.5, 1.0, 0.0), new Color3(0.5, 1.0, 0.0), new Color3(0.3, 0.4, 0.0), new Color3(0.5, 1.0, 0.0), new Color3(0.2, 0.0, 0.0), new Color3(0.5, 1.0, 0.0)];
51
+ }
52
+ static get RedFireColors() {
53
+ return [new Color3(0.5, 0.0, 0.1), new Color3(0.9, 0.0, 0.0), new Color3(0.2, 0.0, 0.0), new Color3(1.0, 0.9, 0.0), new Color3(0.1, 0.1, 0.1), new Color3(0.9, 0.9, 0.9)];
54
+ }
55
+ static get BlueFireColors() {
56
+ return [new Color3(0.1, 0.0, 0.5), new Color3(0.0, 0.0, 0.5), new Color3(0.1, 0.0, 0.2), new Color3(0.0, 0.0, 1.0), new Color3(0.1, 0.2, 0.3), new Color3(0.0, 0.2, 0.9)];
57
+ }
58
+ get autoGenerateTime() {
59
+ return this._autoGenerateTime;
60
+ }
61
+ set autoGenerateTime(value) {
62
+ this._autoGenerateTime = value;
63
+ }
64
+ get fireColors() {
65
+ return this._fireColors;
66
+ }
67
+ set fireColors(value) {
68
+ this._fireColors = value;
69
+ this.updateShaderUniforms();
70
+ }
71
+ get time() {
72
+ return this._time;
73
+ }
74
+ set time(value) {
75
+ this._time = value;
76
+ this.updateShaderUniforms();
77
+ }
78
+ get speed() {
79
+ return this._speed;
80
+ }
81
+ set speed(value) {
82
+ this._speed = value;
83
+ this.updateShaderUniforms();
84
+ }
85
+ get alphaThreshold() {
86
+ return this._alphaThreshold;
87
+ }
88
+ set alphaThreshold(value) {
89
+ this._alphaThreshold = value;
90
+ this.updateShaderUniforms();
91
+ }
92
+ /**
93
+ * Serializes this fire procedural texture
94
+ * @returns a serialized fire procedural texture object
95
+ */
96
+ serialize() {
97
+ const serializationObject = SerializationHelper.Serialize(this, super.serialize());
98
+ serializationObject.customType = "BABYLON.FireProceduralTexture";
99
+ serializationObject.fireColors = [];
100
+ for (let i = 0; i < this._fireColors.length; i++) {
101
+ serializationObject.fireColors.push(this._fireColors[i].asArray());
102
+ }
103
+ return serializationObject;
104
+ }
105
+ /**
106
+ * Creates a Fire Procedural Texture from parsed fire procedural texture data
107
+ * @param parsedTexture defines parsed texture data
108
+ * @param scene defines the current scene
109
+ * @param rootUrl defines the root URL containing fire procedural texture information
110
+ * @returns a parsed Fire Procedural Texture
111
+ */
112
+ static Parse(parsedTexture, scene, rootUrl) {
113
+ const texture = SerializationHelper.Parse(() => new _a(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
114
+ const colors = [];
115
+ for (let i = 0; i < parsedTexture.fireColors.length; i++) {
116
+ colors.push(Color3.FromArray(parsedTexture.fireColors[i]));
117
+ }
118
+ texture.fireColors = colors;
119
+ return texture;
120
+ }
121
+ },
122
+ (() => {
123
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
124
+ _get_autoGenerateTime_decorators = [serialize()];
125
+ _get_time_decorators = [serialize()];
126
+ _get_speed_decorators = [serializeAsVector2()];
127
+ _get_alphaThreshold_decorators = [serialize()];
128
+ __esDecorate(_a, null, _get_autoGenerateTime_decorators, { kind: "getter", name: "autoGenerateTime", static: false, private: false, access: { has: obj => "autoGenerateTime" in obj, get: obj => obj.autoGenerateTime }, metadata: _metadata }, null, _instanceExtraInitializers);
129
+ __esDecorate(_a, null, _get_time_decorators, { kind: "getter", name: "time", static: false, private: false, access: { has: obj => "time" in obj, get: obj => obj.time }, metadata: _metadata }, null, _instanceExtraInitializers);
130
+ __esDecorate(_a, null, _get_speed_decorators, { kind: "getter", name: "speed", static: false, private: false, access: { has: obj => "speed" in obj, get: obj => obj.speed }, metadata: _metadata }, null, _instanceExtraInitializers);
131
+ __esDecorate(_a, null, _get_alphaThreshold_decorators, { kind: "getter", name: "alphaThreshold", static: false, private: false, access: { has: obj => "alphaThreshold" in obj, get: obj => obj.alphaThreshold }, metadata: _metadata }, null, _instanceExtraInitializers);
132
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
133
+ })(),
134
+ _a;
135
+ })();
136
+ export { FireProceduralTexture };
126
137
  RegisterClass("BABYLON.FireProceduralTexture", FireProceduralTexture);
127
138
  //# sourceMappingURL=fireProceduralTexture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fireProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/fire/fireProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,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AAC,KAAK,CACrC,GAAG,EAAE,CAAC,IAAI,qBAAqB,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC1H,aAAa,EACb,KAAK,EACL,OAAO,CACV,CAAC;QAEF,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/D,CAAC;QAED,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC;QAE5B,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAvFG;IADC,SAAS,EAAE;6DAGX;AAgBD;IADC,SAAS,EAAE;iDAGX;AAQD;IADC,kBAAkB,EAAE;kDAGpB;AAQD;IADC,SAAS,EAAE;2DAGX;AAiDL,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { serialize, serializeAsVector2 } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { type Texture } from \"core/Materials/Textures/texture\";\r\nimport { ProceduralTexture } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { type Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { type Nullable } from \"core/types\";\r\n\r\nimport \"./fireProceduralTexture.fragment\";\r\n\r\nexport class FireProceduralTexture extends ProceduralTexture {\r\n private _time: number = 0.0;\r\n private _speed = new Vector2(0.5, 0.3);\r\n private _autoGenerateTime: boolean = true;\r\n private _fireColors: Color3[];\r\n private _alphaThreshold: number = 0.5;\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"fireProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this._fireColors = FireProceduralTexture.RedFireColors;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setFloat(\"time\", this._time);\r\n this.setVector2(\"speed\", this._speed);\r\n this.setColor3(\"c1\", this._fireColors[0]);\r\n this.setColor3(\"c2\", this._fireColors[1]);\r\n this.setColor3(\"c3\", this._fireColors[2]);\r\n this.setColor3(\"c4\", this._fireColors[3]);\r\n this.setColor3(\"c5\", this._fireColors[4]);\r\n this.setColor3(\"c6\", this._fireColors[5]);\r\n this.setFloat(\"alphaThreshold\", this._alphaThreshold);\r\n }\r\n\r\n public override render(useCameraPostProcess?: boolean) {\r\n const scene = this.getScene();\r\n if (this._autoGenerateTime && scene) {\r\n this._time += scene.getAnimationRatio() * 0.03;\r\n this.updateShaderUniforms();\r\n }\r\n super.render(useCameraPostProcess);\r\n }\r\n\r\n public static get PurpleFireColors(): Color3[] {\r\n return [new Color3(0.5, 0.0, 1.0), new Color3(0.9, 0.0, 1.0), new Color3(0.2, 0.0, 1.0), new Color3(1.0, 0.9, 1.0), new Color3(0.1, 0.1, 1.0), new Color3(0.9, 0.9, 1.0)];\r\n }\r\n\r\n public static get GreenFireColors(): Color3[] {\r\n return [new Color3(0.5, 1.0, 0.0), new Color3(0.5, 1.0, 0.0), new Color3(0.3, 0.4, 0.0), new Color3(0.5, 1.0, 0.0), new Color3(0.2, 0.0, 0.0), new Color3(0.5, 1.0, 0.0)];\r\n }\r\n\r\n public static get RedFireColors(): Color3[] {\r\n return [new Color3(0.5, 0.0, 0.1), new Color3(0.9, 0.0, 0.0), new Color3(0.2, 0.0, 0.0), new Color3(1.0, 0.9, 0.0), new Color3(0.1, 0.1, 0.1), new Color3(0.9, 0.9, 0.9)];\r\n }\r\n\r\n public static get BlueFireColors(): Color3[] {\r\n return [new Color3(0.1, 0.0, 0.5), new Color3(0.0, 0.0, 0.5), new Color3(0.1, 0.0, 0.2), new Color3(0.0, 0.0, 1.0), new Color3(0.1, 0.2, 0.3), new Color3(0.0, 0.2, 0.9)];\r\n }\r\n\r\n @serialize()\r\n public get autoGenerateTime(): boolean {\r\n return this._autoGenerateTime;\r\n }\r\n\r\n public set autoGenerateTime(value: boolean) {\r\n this._autoGenerateTime = value;\r\n }\r\n\r\n public get fireColors(): Color3[] {\r\n return this._fireColors;\r\n }\r\n\r\n public set fireColors(value: Color3[]) {\r\n this._fireColors = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get time(): number {\r\n return this._time;\r\n }\r\n\r\n public set time(value: number) {\r\n this._time = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serializeAsVector2()\r\n public get speed(): Vector2 {\r\n return this._speed;\r\n }\r\n\r\n public set speed(value: Vector2) {\r\n this._speed = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get alphaThreshold(): number {\r\n return this._alphaThreshold;\r\n }\r\n\r\n public set alphaThreshold(value: number) {\r\n this._alphaThreshold = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this fire procedural texture\r\n * @returns a serialized fire procedural texture object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this, super.serialize());\r\n serializationObject.customType = \"BABYLON.FireProceduralTexture\";\r\n\r\n serializationObject.fireColors = [];\r\n for (let i = 0; i < this._fireColors.length; i++) {\r\n serializationObject.fireColors.push(this._fireColors[i].asArray());\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Fire Procedural Texture from parsed fire procedural texture data\r\n * @param parsedTexture defines parsed texture data\r\n * @param scene defines the current scene\r\n * @param rootUrl defines the root URL containing fire procedural texture information\r\n * @returns a parsed Fire Procedural Texture\r\n */\r\n public static override Parse(parsedTexture: any, scene: Scene, rootUrl: string): FireProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new FireProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps),\r\n parsedTexture,\r\n scene,\r\n rootUrl\r\n );\r\n\r\n const colors: Color3[] = [];\r\n for (let i = 0; i < parsedTexture.fireColors.length; i++) {\r\n colors.push(Color3.FromArray(parsedTexture.fireColors[i]));\r\n }\r\n\r\n texture.fireColors = colors;\r\n\r\n return texture;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.FireProceduralTexture\", FireProceduralTexture);\r\n"]}
1
+ {"version":3,"file":"fireProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/fire/fireProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,kCAAkC,CAAC;IAE7B,qBAAqB;;sBAAS,iBAAiB;;;;;;sBAA/C,qBAAsB,SAAQ,WAAiB;YAOxD,YAAY,IAAY,EAAE,IAAY,EAAE,QAAyB,IAAI,EAAE,eAAyB,EAAE,eAAyB;gBACvH,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;gBAPhF,UAAK,IADJ,mDAAqB,EACN,GAAG,EAAC;gBACpB,WAAM,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;gBAC/B,sBAAiB,GAAY,IAAI,CAAC;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AS,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC/D,CAAC;gBAED,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC;gBAE5B,OAAO,OAAO,CAAC;YACnB,CAAC;;;;gDAvFA,SAAS,EAAE;oCAkBX,SAAS,EAAE;qCAUX,kBAAkB,EAAE;8CAUpB,SAAS,EAAE;YArCZ,qMAAW,gBAAgB,6DAE1B;YAgBD,iKAAW,IAAI,6DAEd;YAQD,oKAAW,KAAK,6DAEf;YAQD,+LAAW,cAAc,6DAExB;;;;;SA3FQ,qBAAqB;AA4IlC,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { serialize, serializeAsVector2 } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { type Texture } from \"core/Materials/Textures/texture\";\r\nimport { ProceduralTexture } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { type Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { type Nullable } from \"core/types\";\r\n\r\nimport \"./fireProceduralTexture.fragment\";\r\n\r\nexport class FireProceduralTexture extends ProceduralTexture {\r\n private _time: number = 0.0;\r\n private _speed = new Vector2(0.5, 0.3);\r\n private _autoGenerateTime: boolean = true;\r\n private _fireColors: Color3[];\r\n private _alphaThreshold: number = 0.5;\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"fireProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this._fireColors = FireProceduralTexture.RedFireColors;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setFloat(\"time\", this._time);\r\n this.setVector2(\"speed\", this._speed);\r\n this.setColor3(\"c1\", this._fireColors[0]);\r\n this.setColor3(\"c2\", this._fireColors[1]);\r\n this.setColor3(\"c3\", this._fireColors[2]);\r\n this.setColor3(\"c4\", this._fireColors[3]);\r\n this.setColor3(\"c5\", this._fireColors[4]);\r\n this.setColor3(\"c6\", this._fireColors[5]);\r\n this.setFloat(\"alphaThreshold\", this._alphaThreshold);\r\n }\r\n\r\n public override render(useCameraPostProcess?: boolean) {\r\n const scene = this.getScene();\r\n if (this._autoGenerateTime && scene) {\r\n this._time += scene.getAnimationRatio() * 0.03;\r\n this.updateShaderUniforms();\r\n }\r\n super.render(useCameraPostProcess);\r\n }\r\n\r\n public static get PurpleFireColors(): Color3[] {\r\n return [new Color3(0.5, 0.0, 1.0), new Color3(0.9, 0.0, 1.0), new Color3(0.2, 0.0, 1.0), new Color3(1.0, 0.9, 1.0), new Color3(0.1, 0.1, 1.0), new Color3(0.9, 0.9, 1.0)];\r\n }\r\n\r\n public static get GreenFireColors(): Color3[] {\r\n return [new Color3(0.5, 1.0, 0.0), new Color3(0.5, 1.0, 0.0), new Color3(0.3, 0.4, 0.0), new Color3(0.5, 1.0, 0.0), new Color3(0.2, 0.0, 0.0), new Color3(0.5, 1.0, 0.0)];\r\n }\r\n\r\n public static get RedFireColors(): Color3[] {\r\n return [new Color3(0.5, 0.0, 0.1), new Color3(0.9, 0.0, 0.0), new Color3(0.2, 0.0, 0.0), new Color3(1.0, 0.9, 0.0), new Color3(0.1, 0.1, 0.1), new Color3(0.9, 0.9, 0.9)];\r\n }\r\n\r\n public static get BlueFireColors(): Color3[] {\r\n return [new Color3(0.1, 0.0, 0.5), new Color3(0.0, 0.0, 0.5), new Color3(0.1, 0.0, 0.2), new Color3(0.0, 0.0, 1.0), new Color3(0.1, 0.2, 0.3), new Color3(0.0, 0.2, 0.9)];\r\n }\r\n\r\n @serialize()\r\n public get autoGenerateTime(): boolean {\r\n return this._autoGenerateTime;\r\n }\r\n\r\n public set autoGenerateTime(value: boolean) {\r\n this._autoGenerateTime = value;\r\n }\r\n\r\n public get fireColors(): Color3[] {\r\n return this._fireColors;\r\n }\r\n\r\n public set fireColors(value: Color3[]) {\r\n this._fireColors = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get time(): number {\r\n return this._time;\r\n }\r\n\r\n public set time(value: number) {\r\n this._time = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serializeAsVector2()\r\n public get speed(): Vector2 {\r\n return this._speed;\r\n }\r\n\r\n public set speed(value: Vector2) {\r\n this._speed = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get alphaThreshold(): number {\r\n return this._alphaThreshold;\r\n }\r\n\r\n public set alphaThreshold(value: number) {\r\n this._alphaThreshold = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this fire procedural texture\r\n * @returns a serialized fire procedural texture object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this, super.serialize());\r\n serializationObject.customType = \"BABYLON.FireProceduralTexture\";\r\n\r\n serializationObject.fireColors = [];\r\n for (let i = 0; i < this._fireColors.length; i++) {\r\n serializationObject.fireColors.push(this._fireColors[i].asArray());\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Fire Procedural Texture from parsed fire procedural texture data\r\n * @param parsedTexture defines parsed texture data\r\n * @param scene defines the current scene\r\n * @param rootUrl defines the root URL containing fire procedural texture information\r\n * @returns a parsed Fire Procedural Texture\r\n */\r\n public static override Parse(parsedTexture: any, scene: Scene, rootUrl: string): FireProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new FireProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps),\r\n parsedTexture,\r\n scene,\r\n rootUrl\r\n );\r\n\r\n const colors: Color3[] = [];\r\n for (let i = 0; i < parsedTexture.fireColors.length; i++) {\r\n colors.push(Color3.FromArray(parsedTexture.fireColors[i]));\r\n }\r\n\r\n texture.fireColors = colors;\r\n\r\n return texture;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.FireProceduralTexture\", FireProceduralTexture);\r\n"]}
@@ -1,69 +1,81 @@
1
- import { __decorate } from "@babylonjs/core/tslib.es6.js";
1
+ import { __esDecorate, __runInitializers } from "@babylonjs/core/tslib.es6.js";
2
2
  import { serializeAsColor3 } from "@babylonjs/core/Misc/decorators.js";
3
3
  import { SerializationHelper } from "@babylonjs/core/Misc/decorators.serialization.js";
4
4
  import { Color3 } from "@babylonjs/core/Maths/math.color.js";
5
5
  import { ProceduralTexture } from "@babylonjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
6
6
  import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
7
7
  import "./grassProceduralTexture.fragment.js";
8
- export class GrassProceduralTexture extends ProceduralTexture {
9
- constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
10
- super(name, size, "grassProceduralTexture", scene, fallbackTexture, generateMipMaps);
11
- this._groundColor = new Color3(1, 1, 1);
12
- this._grassColors = [new Color3(0.29, 0.38, 0.02), new Color3(0.36, 0.49, 0.09), new Color3(0.51, 0.6, 0.28)];
13
- this.updateShaderUniforms();
14
- }
15
- updateShaderUniforms() {
16
- this.setColor3("herb1Color", this._grassColors[0]);
17
- this.setColor3("herb2Color", this._grassColors[1]);
18
- this.setColor3("herb3Color", this._grassColors[2]);
19
- this.setColor3("groundColor", this._groundColor);
20
- }
21
- get grassColors() {
22
- return this._grassColors;
23
- }
24
- set grassColors(value) {
25
- this._grassColors = value;
26
- this.updateShaderUniforms();
27
- }
28
- get groundColor() {
29
- return this._groundColor;
30
- }
31
- set groundColor(value) {
32
- this._groundColor = value;
33
- this.updateShaderUniforms();
34
- }
35
- /**
36
- * Serializes this grass procedural texture
37
- * @returns a serialized grass procedural texture object
38
- */
39
- serialize() {
40
- const serializationObject = SerializationHelper.Serialize(this, super.serialize());
41
- serializationObject.customType = "BABYLON.GrassProceduralTexture";
42
- serializationObject.grassColors = [];
43
- for (let i = 0; i < this._grassColors.length; i++) {
44
- serializationObject.grassColors.push(this._grassColors[i].asArray());
45
- }
46
- return serializationObject;
47
- }
48
- /**
49
- * Creates a Grass Procedural Texture from parsed grass procedural texture data
50
- * @param parsedTexture defines parsed texture data
51
- * @param scene defines the current scene
52
- * @param rootUrl defines the root URL containing grass procedural texture information
53
- * @returns a parsed Grass Procedural Texture
54
- */
55
- static Parse(parsedTexture, scene, rootUrl) {
56
- const texture = SerializationHelper.Parse(() => new GrassProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
57
- const colors = [];
58
- for (let i = 0; i < parsedTexture.grassColors.length; i++) {
59
- colors.push(Color3.FromArray(parsedTexture.grassColors[i]));
60
- }
61
- texture.grassColors = colors;
62
- return texture;
63
- }
64
- }
65
- __decorate([
66
- serializeAsColor3()
67
- ], GrassProceduralTexture.prototype, "groundColor", null);
8
+ let GrassProceduralTexture = (() => {
9
+ var _a;
10
+ let _classSuper = ProceduralTexture;
11
+ let _instanceExtraInitializers = [];
12
+ let _get_groundColor_decorators;
13
+ return _a = class GrassProceduralTexture extends _classSuper {
14
+ constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
15
+ super(name, size, "grassProceduralTexture", scene, fallbackTexture, generateMipMaps);
16
+ this._grassColors = __runInitializers(this, _instanceExtraInitializers);
17
+ this._groundColor = new Color3(1, 1, 1);
18
+ this._grassColors = [new Color3(0.29, 0.38, 0.02), new Color3(0.36, 0.49, 0.09), new Color3(0.51, 0.6, 0.28)];
19
+ this.updateShaderUniforms();
20
+ }
21
+ updateShaderUniforms() {
22
+ this.setColor3("herb1Color", this._grassColors[0]);
23
+ this.setColor3("herb2Color", this._grassColors[1]);
24
+ this.setColor3("herb3Color", this._grassColors[2]);
25
+ this.setColor3("groundColor", this._groundColor);
26
+ }
27
+ get grassColors() {
28
+ return this._grassColors;
29
+ }
30
+ set grassColors(value) {
31
+ this._grassColors = value;
32
+ this.updateShaderUniforms();
33
+ }
34
+ get groundColor() {
35
+ return this._groundColor;
36
+ }
37
+ set groundColor(value) {
38
+ this._groundColor = value;
39
+ this.updateShaderUniforms();
40
+ }
41
+ /**
42
+ * Serializes this grass procedural texture
43
+ * @returns a serialized grass procedural texture object
44
+ */
45
+ serialize() {
46
+ const serializationObject = SerializationHelper.Serialize(this, super.serialize());
47
+ serializationObject.customType = "BABYLON.GrassProceduralTexture";
48
+ serializationObject.grassColors = [];
49
+ for (let i = 0; i < this._grassColors.length; i++) {
50
+ serializationObject.grassColors.push(this._grassColors[i].asArray());
51
+ }
52
+ return serializationObject;
53
+ }
54
+ /**
55
+ * Creates a Grass Procedural Texture from parsed grass procedural texture data
56
+ * @param parsedTexture defines parsed texture data
57
+ * @param scene defines the current scene
58
+ * @param rootUrl defines the root URL containing grass procedural texture information
59
+ * @returns a parsed Grass Procedural Texture
60
+ */
61
+ static Parse(parsedTexture, scene, rootUrl) {
62
+ const texture = SerializationHelper.Parse(() => new _a(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
63
+ const colors = [];
64
+ for (let i = 0; i < parsedTexture.grassColors.length; i++) {
65
+ colors.push(Color3.FromArray(parsedTexture.grassColors[i]));
66
+ }
67
+ texture.grassColors = colors;
68
+ return texture;
69
+ }
70
+ },
71
+ (() => {
72
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
73
+ _get_groundColor_decorators = [serializeAsColor3()];
74
+ __esDecorate(_a, null, _get_groundColor_decorators, { kind: "getter", name: "groundColor", static: false, private: false, access: { has: obj => "groundColor" in obj, get: obj => obj.groundColor }, metadata: _metadata }, null, _instanceExtraInitializers);
75
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
76
+ })(),
77
+ _a;
78
+ })();
79
+ export { GrassProceduralTexture };
68
80
  RegisterClass("BABYLON.GrassProceduralTexture", GrassProceduralTexture);
69
81
  //# sourceMappingURL=grassProceduralTexture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"grassProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/grass/grassProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,mCAAmC,CAAC;AAE3C,MAAM,OAAO,sBAAuB,SAAQ,iBAAiB;IAIzD,YAAY,IAAY,EAAE,IAAY,EAAE,QAAyB,IAAI,EAAE,eAAyB,EAAE,eAAyB;QACvH,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,wBAAwB,EAAE,KAAK,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;QAHjF,iBAAY,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAKvC,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;QAE9G,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAEM,oBAAoB;QACvB,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,C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AC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC3H,aAAa,EACb,KAAK,EACL,OAAO,CACV,CAAC;QAEF,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACxD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC;QAE7B,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAjDG;IADC,iBAAiB,EAAE;yDAGnB;AAiDL,aAAa,CAAC,gCAAgC,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { serializeAsColor3 } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { type Texture } from \"core/Materials/Textures/texture\";\r\nimport { ProceduralTexture } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { type Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { type Nullable } from \"core/types\";\r\n\r\nimport \"./grassProceduralTexture.fragment\";\r\n\r\nexport class GrassProceduralTexture extends ProceduralTexture {\r\n private _grassColors: Color3[];\r\n private _groundColor = new Color3(1, 1, 1);\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"grassProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n\r\n this._grassColors = [new Color3(0.29, 0.38, 0.02), new Color3(0.36, 0.49, 0.09), new Color3(0.51, 0.6, 0.28)];\r\n\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setColor3(\"herb1Color\", this._grassColors[0]);\r\n this.setColor3(\"herb2Color\", this._grassColors[1]);\r\n this.setColor3(\"herb3Color\", this._grassColors[2]);\r\n this.setColor3(\"groundColor\", this._groundColor);\r\n }\r\n\r\n public get grassColors(): Color3[] {\r\n return this._grassColors;\r\n }\r\n\r\n public set grassColors(value: Color3[]) {\r\n this._grassColors = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serializeAsColor3()\r\n public get groundColor(): Color3 {\r\n return this._groundColor;\r\n }\r\n\r\n public set groundColor(value: Color3) {\r\n this._groundColor = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this grass procedural texture\r\n * @returns a serialized grass procedural texture object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this, super.serialize());\r\n serializationObject.customType = \"BABYLON.GrassProceduralTexture\";\r\n\r\n serializationObject.grassColors = [];\r\n for (let i = 0; i < this._grassColors.length; i++) {\r\n serializationObject.grassColors.push(this._grassColors[i].asArray());\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Grass Procedural Texture from parsed grass procedural texture data\r\n * @param parsedTexture defines parsed texture data\r\n * @param scene defines the current scene\r\n * @param rootUrl defines the root URL containing grass procedural texture information\r\n * @returns a parsed Grass Procedural Texture\r\n */\r\n public static override Parse(parsedTexture: any, scene: Scene, rootUrl: string): GrassProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new GrassProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps),\r\n parsedTexture,\r\n scene,\r\n rootUrl\r\n );\r\n\r\n const colors: Color3[] = [];\r\n for (let i = 0; i < parsedTexture.grassColors.length; i++) {\r\n colors.push(Color3.FromArray(parsedTexture.grassColors[i]));\r\n }\r\n\r\n texture.grassColors = colors;\r\n\r\n return texture;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GrassProceduralTexture\", GrassProceduralTexture);\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AAa,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC3H,aAAa,EACb,KAAK,EACL,OAAO,CACV,CAAC;gBAEF,MAAM,MAAM,GAAa,EAAE,CAAC;gBAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBACxD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAChE,CAAC;gBAED,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC;gBAE7B,OAAO,OAAO,CAAC;YACnB,CAAC;;;;2CAjDA,iBAAiB,EAAE;YACpB,sLAAW,WAAW,6DAErB;;;;;SA/BQ,sBAAsB;AAgFnC,aAAa,CAAC,gCAAgC,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { serializeAsColor3 } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { type Texture } from \"core/Materials/Textures/texture\";\r\nimport { ProceduralTexture } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { type Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { type Nullable } from \"core/types\";\r\n\r\nimport \"./grassProceduralTexture.fragment\";\r\n\r\nexport class GrassProceduralTexture extends ProceduralTexture {\r\n private _grassColors: Color3[];\r\n private _groundColor = new Color3(1, 1, 1);\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"grassProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n\r\n this._grassColors = [new Color3(0.29, 0.38, 0.02), new Color3(0.36, 0.49, 0.09), new Color3(0.51, 0.6, 0.28)];\r\n\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setColor3(\"herb1Color\", this._grassColors[0]);\r\n this.setColor3(\"herb2Color\", this._grassColors[1]);\r\n this.setColor3(\"herb3Color\", this._grassColors[2]);\r\n this.setColor3(\"groundColor\", this._groundColor);\r\n }\r\n\r\n public get grassColors(): Color3[] {\r\n return this._grassColors;\r\n }\r\n\r\n public set grassColors(value: Color3[]) {\r\n this._grassColors = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serializeAsColor3()\r\n public get groundColor(): Color3 {\r\n return this._groundColor;\r\n }\r\n\r\n public set groundColor(value: Color3) {\r\n this._groundColor = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this grass procedural texture\r\n * @returns a serialized grass procedural texture object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this, super.serialize());\r\n serializationObject.customType = \"BABYLON.GrassProceduralTexture\";\r\n\r\n serializationObject.grassColors = [];\r\n for (let i = 0; i < this._grassColors.length; i++) {\r\n serializationObject.grassColors.push(this._grassColors[i].asArray());\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Grass Procedural Texture from parsed grass procedural texture data\r\n * @param parsedTexture defines parsed texture data\r\n * @param scene defines the current scene\r\n * @param rootUrl defines the root URL containing grass procedural texture information\r\n * @returns a parsed Grass Procedural Texture\r\n */\r\n public static override Parse(parsedTexture: any, scene: Scene, rootUrl: string): GrassProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new GrassProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps),\r\n parsedTexture,\r\n scene,\r\n rootUrl\r\n );\r\n\r\n const colors: Color3[] = [];\r\n for (let i = 0; i < parsedTexture.grassColors.length; i++) {\r\n colors.push(Color3.FromArray(parsedTexture.grassColors[i]));\r\n }\r\n\r\n texture.grassColors = colors;\r\n\r\n return texture;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GrassProceduralTexture\", GrassProceduralTexture);\r\n"]}