@onerjs/procedural-textures 8.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/brick/brickProceduralTexture.d.ts +35 -0
  2. package/brick/brickProceduralTexture.fragment.d.ts +5 -0
  3. package/brick/brickProceduralTexture.fragment.js +24 -0
  4. package/brick/brickProceduralTexture.fragment.js.map +1 -0
  5. package/brick/brickProceduralTexture.js +85 -0
  6. package/brick/brickProceduralTexture.js.map +1 -0
  7. package/brick/index.d.ts +1 -0
  8. package/brick/index.js +2 -0
  9. package/brick/index.js.map +1 -0
  10. package/cloud/cloudProceduralTexture.d.ts +35 -0
  11. package/cloud/cloudProceduralTexture.fragment.d.ts +5 -0
  12. package/cloud/cloudProceduralTexture.fragment.js +22 -0
  13. package/cloud/cloudProceduralTexture.fragment.js.map +1 -0
  14. package/cloud/cloudProceduralTexture.js +85 -0
  15. package/cloud/cloudProceduralTexture.js.map +1 -0
  16. package/cloud/index.d.ts +1 -0
  17. package/cloud/index.js +2 -0
  18. package/cloud/index.js.map +1 -0
  19. package/fire/fireProceduralTexture.d.ts +44 -0
  20. package/fire/fireProceduralTexture.fragment.d.ts +5 -0
  21. package/fire/fireProceduralTexture.fragment.js +15 -0
  22. package/fire/fireProceduralTexture.fragment.js.map +1 -0
  23. package/fire/fireProceduralTexture.js +127 -0
  24. package/fire/fireProceduralTexture.js.map +1 -0
  25. package/fire/index.d.ts +1 -0
  26. package/fire/index.js +2 -0
  27. package/fire/index.js.map +1 -0
  28. package/grass/grassProceduralTexture.d.ts +29 -0
  29. package/grass/grassProceduralTexture.fragment.d.ts +5 -0
  30. package/grass/grassProceduralTexture.fragment.js +20 -0
  31. package/grass/grassProceduralTexture.fragment.js.map +1 -0
  32. package/grass/grassProceduralTexture.js +69 -0
  33. package/grass/grassProceduralTexture.js.map +1 -0
  34. package/grass/index.d.ts +1 -0
  35. package/grass/index.js +2 -0
  36. package/grass/index.js.map +1 -0
  37. package/index.d.ts +10 -0
  38. package/index.js +12 -0
  39. package/index.js.map +1 -0
  40. package/legacy/legacy-brick.d.ts +1 -0
  41. package/legacy/legacy-brick.js +14 -0
  42. package/legacy/legacy-brick.js.map +1 -0
  43. package/legacy/legacy-cloud.d.ts +1 -0
  44. package/legacy/legacy-cloud.js +14 -0
  45. package/legacy/legacy-cloud.js.map +1 -0
  46. package/legacy/legacy-fire.d.ts +1 -0
  47. package/legacy/legacy-fire.js +14 -0
  48. package/legacy/legacy-fire.js.map +1 -0
  49. package/legacy/legacy-grass.d.ts +1 -0
  50. package/legacy/legacy-grass.js +14 -0
  51. package/legacy/legacy-grass.js.map +1 -0
  52. package/legacy/legacy-marble.d.ts +1 -0
  53. package/legacy/legacy-marble.js +14 -0
  54. package/legacy/legacy-marble.js.map +1 -0
  55. package/legacy/legacy-normalMap.d.ts +1 -0
  56. package/legacy/legacy-normalMap.js +14 -0
  57. package/legacy/legacy-normalMap.js.map +1 -0
  58. package/legacy/legacy-perlinNoise.d.ts +1 -0
  59. package/legacy/legacy-perlinNoise.js +14 -0
  60. package/legacy/legacy-perlinNoise.js.map +1 -0
  61. package/legacy/legacy-road.d.ts +1 -0
  62. package/legacy/legacy-road.js +14 -0
  63. package/legacy/legacy-road.js.map +1 -0
  64. package/legacy/legacy-starfield.d.ts +1 -0
  65. package/legacy/legacy-starfield.js +14 -0
  66. package/legacy/legacy-starfield.js.map +1 -0
  67. package/legacy/legacy-wood.d.ts +1 -0
  68. package/legacy/legacy-wood.js +14 -0
  69. package/legacy/legacy-wood.js.map +1 -0
  70. package/legacy/legacy.d.ts +1 -0
  71. package/legacy/legacy.js +17 -0
  72. package/legacy/legacy.js.map +1 -0
  73. package/license.md +71 -0
  74. package/marble/index.d.ts +1 -0
  75. package/marble/index.js +2 -0
  76. package/marble/index.js.map +1 -0
  77. package/marble/marbleProceduralTexture.d.ts +35 -0
  78. package/marble/marbleProceduralTexture.fragment.d.ts +5 -0
  79. package/marble/marbleProceduralTexture.fragment.js +28 -0
  80. package/marble/marbleProceduralTexture.fragment.js.map +1 -0
  81. package/marble/marbleProceduralTexture.js +85 -0
  82. package/marble/marbleProceduralTexture.js.map +1 -0
  83. package/normalMap/index.d.ts +1 -0
  84. package/normalMap/index.js +2 -0
  85. package/normalMap/index.js.map +1 -0
  86. package/normalMap/normalMapProceduralTexture.d.ts +28 -0
  87. package/normalMap/normalMapProceduralTexture.fragment.d.ts +5 -0
  88. package/normalMap/normalMapProceduralTexture.fragment.js +15 -0
  89. package/normalMap/normalMapProceduralTexture.fragment.js.map +1 -0
  90. package/normalMap/normalMapProceduralTexture.js +62 -0
  91. package/normalMap/normalMapProceduralTexture.js.map +1 -0
  92. package/package.json +47 -0
  93. package/perlinNoise/index.d.ts +1 -0
  94. package/perlinNoise/index.js +2 -0
  95. package/perlinNoise/index.js.map +1 -0
  96. package/perlinNoise/perlinNoiseProceduralTexture.d.ts +28 -0
  97. package/perlinNoise/perlinNoiseProceduralTexture.fragment.d.ts +5 -0
  98. package/perlinNoise/perlinNoiseProceduralTexture.fragment.js +59 -0
  99. package/perlinNoise/perlinNoiseProceduralTexture.fragment.js.map +1 -0
  100. package/perlinNoise/perlinNoiseProceduralTexture.js +66 -0
  101. package/perlinNoise/perlinNoiseProceduralTexture.js.map +1 -0
  102. package/readme.md +34 -0
  103. package/road/index.d.ts +1 -0
  104. package/road/index.js +2 -0
  105. package/road/index.js.map +1 -0
  106. package/road/roadProceduralTexture.d.ts +26 -0
  107. package/road/roadProceduralTexture.fragment.d.ts +5 -0
  108. package/road/roadProceduralTexture.fragment.js +21 -0
  109. package/road/roadProceduralTexture.fragment.js.map +1 -0
  110. package/road/roadProceduralTexture.js +49 -0
  111. package/road/roadProceduralTexture.js.map +1 -0
  112. package/starfield/index.d.ts +1 -0
  113. package/starfield/index.js +2 -0
  114. package/starfield/index.js.map +1 -0
  115. package/starfield/starfieldProceduralTexture.d.ts +55 -0
  116. package/starfield/starfieldProceduralTexture.fragment.d.ts +5 -0
  117. package/starfield/starfieldProceduralTexture.fragment.js +26 -0
  118. package/starfield/starfieldProceduralTexture.fragment.js.map +1 -0
  119. package/starfield/starfieldProceduralTexture.js +168 -0
  120. package/starfield/starfieldProceduralTexture.js.map +1 -0
  121. package/wood/index.d.ts +1 -0
  122. package/wood/index.js +2 -0
  123. package/wood/index.js.map +1 -0
  124. package/wood/woodProceduralTexture.d.ts +29 -0
  125. package/wood/woodProceduralTexture.fragment.d.ts +5 -0
  126. package/wood/woodProceduralTexture.fragment.js +20 -0
  127. package/wood/woodProceduralTexture.fragment.js.map +1 -0
  128. package/wood/woodProceduralTexture.js +61 -0
  129. package/wood/woodProceduralTexture.js.map +1 -0
@@ -0,0 +1,35 @@
1
+ import { Color3 } from "@onerjs/core/Maths/math.color.js";
2
+ import type { Texture } from "@onerjs/core/Materials/Textures/texture.js";
3
+ import { ProceduralTexture } from "@onerjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
4
+ import type { Scene } from "@onerjs/core/scene.js";
5
+ import type { Nullable } from "@onerjs/core/types.js";
6
+ import "./brickProceduralTexture.fragment.js";
7
+ export declare class BrickProceduralTexture extends ProceduralTexture {
8
+ private _numberOfBricksHeight;
9
+ private _numberOfBricksWidth;
10
+ private _jointColor;
11
+ private _brickColor;
12
+ constructor(name: string, size: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
13
+ updateShaderUniforms(): void;
14
+ get numberOfBricksHeight(): number;
15
+ set numberOfBricksHeight(value: number);
16
+ get numberOfBricksWidth(): number;
17
+ set numberOfBricksWidth(value: number);
18
+ get jointColor(): Color3;
19
+ set jointColor(value: Color3);
20
+ get brickColor(): Color3;
21
+ set brickColor(value: Color3);
22
+ /**
23
+ * Serializes this brick procedural texture
24
+ * @returns a serialized brick procedural texture object
25
+ */
26
+ serialize(): any;
27
+ /**
28
+ * Creates a Brick Procedural Texture from parsed brick procedural texture data
29
+ * @param parsedTexture defines parsed texture data
30
+ * @param scene defines the current scene
31
+ * @param rootUrl defines the root URL containing brick procedural texture information
32
+ * @returns a parsed Brick Procedural Texture
33
+ */
34
+ static Parse(parsedTexture: any, scene: Scene, rootUrl: string): BrickProceduralTexture;
35
+ }
@@ -0,0 +1,5 @@
1
+ /** @internal */
2
+ export declare const brickProceduralTexturePixelShader: {
3
+ name: string;
4
+ shader: string;
5
+ };
@@ -0,0 +1,24 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "@onerjs/core/Engines/shaderStore.js";
3
+ const name = "brickProceduralTexturePixelShader";
4
+ const shader = `precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float numberOfBricksHeight;uniform float numberOfBricksWidth;uniform vec3 brickColor;uniform vec3 jointColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}
5
+ float noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}
6
+ float fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}
7
+ return total;}
8
+ float roundF(float number){return sign(number)*floor(abs(number)+0.5);}
9
+ #define CUSTOM_FRAGMENT_DEFINITIONS
10
+ void main(void)
11
+ {float brickW=1.0/numberOfBricksWidth;float brickH=1.0/numberOfBricksHeight;float jointWPercentage=0.01;float jointHPercentage=0.05;vec3 color=brickColor;float yi=vUV.y/brickH;float nyi=roundF(yi);float xi=vUV.x/brickW;if (mod(floor(yi),2.0)==0.0){xi=xi-0.5;}
12
+ float nxi=roundF(xi);vec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/ brickW);if (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){color=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);}
13
+ else if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){color=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);}
14
+ else {float brickColorSwitch=mod(floor(yi)+floor(xi),3.0);if (brickColorSwitch==0.0)
15
+ color=mix(color,vec3(0.33,0.33,0.33),0.3);else if (brickColorSwitch==2.0)
16
+ color=mix(color,vec3(0.11,0.11,0.11),0.3);}
17
+ gl_FragColor=vec4(color,1.0);}`;
18
+ // Sideeffect
19
+ if (!ShaderStore.ShadersStore[name]) {
20
+ ShaderStore.ShadersStore[name] = shader;
21
+ }
22
+ /** @internal */
23
+ export const brickProceduralTexturePixelShader = { name, shader };
24
+ //# sourceMappingURL=brickProceduralTexture.fragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brickProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/brick/brickProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AAEvD,MAAM,IAAI,GAAG,mCAAmC,CAAC;AACjD,MAAM,MAAM,GAAG;;;;;;;;;;;;;+BAagB,CAAC;AAChC,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"brickProceduralTexturePixelShader\";\nconst shader = `precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float numberOfBricksHeight;uniform float numberOfBricksWidth;uniform vec3 brickColor;uniform vec3 jointColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\nfloat roundF(float number){return sign(number)*floor(abs(number)+0.5);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float brickW=1.0/numberOfBricksWidth;float brickH=1.0/numberOfBricksHeight;float jointWPercentage=0.01;float jointHPercentage=0.05;vec3 color=brickColor;float yi=vUV.y/brickH;float nyi=roundF(yi);float xi=vUV.x/brickW;if (mod(floor(yi),2.0)==0.0){xi=xi-0.5;}\nfloat nxi=roundF(xi);vec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/ brickW);if (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){color=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);}\nelse if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){color=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);}\nelse {float brickColorSwitch=mod(floor(yi)+floor(xi),3.0);if (brickColorSwitch==0.0)\ncolor=mix(color,vec3(0.33,0.33,0.33),0.3);else if (brickColorSwitch==2.0)\ncolor=mix(color,vec3(0.11,0.11,0.11),0.3);}\ngl_FragColor=vec4(color,1.0);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const brickProceduralTexturePixelShader = { name, shader };\n"]}
@@ -0,0 +1,85 @@
1
+ import { __decorate } from "@onerjs/core/tslib.es6.js";
2
+ import { serialize, serializeAsColor3 } from "@onerjs/core/Misc/decorators.js";
3
+ import { SerializationHelper } from "@onerjs/core/Misc/decorators.serialization.js";
4
+ import { Color3 } from "@onerjs/core/Maths/math.color.js";
5
+ import { ProceduralTexture } from "@onerjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
6
+ import { RegisterClass } from "@onerjs/core/Misc/typeStore.js";
7
+ import "./brickProceduralTexture.fragment.js";
8
+ export class BrickProceduralTexture extends ProceduralTexture {
9
+ constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
10
+ super(name, size, "brickProceduralTexture", scene, fallbackTexture, generateMipMaps);
11
+ this._numberOfBricksHeight = 15;
12
+ this._numberOfBricksWidth = 5;
13
+ this._jointColor = new Color3(0.72, 0.72, 0.72);
14
+ this._brickColor = new Color3(0.77, 0.47, 0.4);
15
+ this.updateShaderUniforms();
16
+ }
17
+ updateShaderUniforms() {
18
+ this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
19
+ this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
20
+ this.setColor3("brickColor", this._brickColor);
21
+ this.setColor3("jointColor", this._jointColor);
22
+ }
23
+ get numberOfBricksHeight() {
24
+ return this._numberOfBricksHeight;
25
+ }
26
+ set numberOfBricksHeight(value) {
27
+ this._numberOfBricksHeight = value;
28
+ this.updateShaderUniforms();
29
+ }
30
+ get numberOfBricksWidth() {
31
+ return this._numberOfBricksWidth;
32
+ }
33
+ set numberOfBricksWidth(value) {
34
+ this._numberOfBricksWidth = value;
35
+ this.updateShaderUniforms();
36
+ }
37
+ get jointColor() {
38
+ return this._jointColor;
39
+ }
40
+ set jointColor(value) {
41
+ this._jointColor = value;
42
+ this.updateShaderUniforms();
43
+ }
44
+ get brickColor() {
45
+ return this._brickColor;
46
+ }
47
+ set brickColor(value) {
48
+ this._brickColor = value;
49
+ this.updateShaderUniforms();
50
+ }
51
+ /**
52
+ * Serializes this brick procedural texture
53
+ * @returns a serialized brick procedural texture object
54
+ */
55
+ serialize() {
56
+ const serializationObject = SerializationHelper.Serialize(this, super.serialize());
57
+ serializationObject.customType = "BABYLON.BrickProceduralTexture";
58
+ return serializationObject;
59
+ }
60
+ /**
61
+ * Creates a Brick Procedural Texture from parsed brick procedural texture data
62
+ * @param parsedTexture defines parsed texture data
63
+ * @param scene defines the current scene
64
+ * @param rootUrl defines the root URL containing brick procedural texture information
65
+ * @returns a parsed Brick Procedural Texture
66
+ */
67
+ static Parse(parsedTexture, scene, rootUrl) {
68
+ const texture = SerializationHelper.Parse(() => new BrickProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
69
+ return texture;
70
+ }
71
+ }
72
+ __decorate([
73
+ serialize()
74
+ ], BrickProceduralTexture.prototype, "numberOfBricksHeight", null);
75
+ __decorate([
76
+ serialize()
77
+ ], BrickProceduralTexture.prototype, "numberOfBricksWidth", null);
78
+ __decorate([
79
+ serializeAsColor3()
80
+ ], BrickProceduralTexture.prototype, "jointColor", null);
81
+ __decorate([
82
+ serializeAsColor3()
83
+ ], BrickProceduralTexture.prototype, "brickColor", null);
84
+ RegisterClass("BABYLON.BrickProceduralTexture", BrickProceduralTexture);
85
+ //# sourceMappingURL=brickProceduralTexture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brickProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/brick/brickProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,wCAA6B;AACpE,OAAO,EAAE,mBAAmB,EAAE,sDAA2C;AACzE,OAAO,EAAE,MAAM,EAAE,yCAA8B;AAE/C,OAAO,EAAE,iBAAiB,EAAE,yEAA8D;AAE1F,OAAO,EAAE,aAAa,EAAE,uCAA4B;AAGpD,OAAO,mCAAmC,CAAC;AAE3C,MAAM,OAAO,sBAAuB,SAAQ,iBAAiB;IAMzD,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;QAN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WAAW,CAAC;IAC5B,CAAC;IAED,IAAW,UAAU,CAAC,KAAa;QAC/B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAED;;;OAGG;IACa,SAAS;QACrB,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QACnF,mBAAmB,CAAC,UAAU,GAAG,gCAAgC,CAAC;QAElE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAU,KAAK,CAAC,aAAkB,EAAE,KAAY,EAAE,OAAe;QAC1E,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CACrC,GAAG,EAAE,CAAC,IAAI,sBAAsB,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC3H,aAAa,EACb,KAAK,EACL,OAAO,CACV,CAAC;QAEF,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAnEG;IADC,SAAS,EAAE;kEAGX;AAQD;IADC,SAAS,EAAE;iEAGX;AAQD;IADC,iBAAiB,EAAE;wDAGnB;AAQD;IADC,iBAAiB,EAAE;wDAGnB;AAqCL,aAAa,CAAC,gCAAgC,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { serialize, 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 \"./brickProceduralTexture.fragment\";\r\n\r\nexport class BrickProceduralTexture extends ProceduralTexture {\r\n private _numberOfBricksHeight: number = 15;\r\n private _numberOfBricksWidth: number = 5;\r\n private _jointColor = new Color3(0.72, 0.72, 0.72);\r\n private _brickColor = new Color3(0.77, 0.47, 0.4);\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"brickProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setFloat(\"numberOfBricksHeight\", this._numberOfBricksHeight);\r\n this.setFloat(\"numberOfBricksWidth\", this._numberOfBricksWidth);\r\n this.setColor3(\"brickColor\", this._brickColor);\r\n this.setColor3(\"jointColor\", this._jointColor);\r\n }\r\n\r\n @serialize()\r\n public get numberOfBricksHeight(): number {\r\n return this._numberOfBricksHeight;\r\n }\r\n\r\n public set numberOfBricksHeight(value: number) {\r\n this._numberOfBricksHeight = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get numberOfBricksWidth(): number {\r\n return this._numberOfBricksWidth;\r\n }\r\n\r\n public set numberOfBricksWidth(value: number) {\r\n this._numberOfBricksWidth = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serializeAsColor3()\r\n public get jointColor(): Color3 {\r\n return this._jointColor;\r\n }\r\n\r\n public set jointColor(value: Color3) {\r\n this._jointColor = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serializeAsColor3()\r\n public get brickColor(): Color3 {\r\n return this._brickColor;\r\n }\r\n\r\n public set brickColor(value: Color3) {\r\n this._brickColor = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this brick procedural texture\r\n * @returns a serialized brick 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.BrickProceduralTexture\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Brick Procedural Texture from parsed brick 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 brick procedural texture information\r\n * @returns a parsed Brick Procedural Texture\r\n */\r\n public static override Parse(parsedTexture: any, scene: Scene, rootUrl: string): BrickProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new BrickProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps),\r\n parsedTexture,\r\n scene,\r\n rootUrl\r\n );\r\n\r\n return texture;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BrickProceduralTexture\", BrickProceduralTexture);\r\n"]}
@@ -0,0 +1 @@
1
+ export * from "./brickProceduralTexture.js";
package/brick/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./brickProceduralTexture.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/brick/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from \"./brickProceduralTexture\";\r\n"]}
@@ -0,0 +1,35 @@
1
+ import { Color4 } from "@onerjs/core/Maths/math.color.js";
2
+ import type { Texture } from "@onerjs/core/Materials/Textures/texture.js";
3
+ import { ProceduralTexture } from "@onerjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
4
+ import type { Scene } from "@onerjs/core/scene.js";
5
+ import type { Nullable } from "@onerjs/core/types.js";
6
+ import "./cloudProceduralTexture.fragment.js";
7
+ export declare class CloudProceduralTexture extends ProceduralTexture {
8
+ private _skyColor;
9
+ private _cloudColor;
10
+ private _amplitude;
11
+ private _numOctaves;
12
+ constructor(name: string, size: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
13
+ updateShaderUniforms(): void;
14
+ get skyColor(): Color4;
15
+ set skyColor(value: Color4);
16
+ get cloudColor(): Color4;
17
+ set cloudColor(value: Color4);
18
+ get amplitude(): number;
19
+ set amplitude(value: number);
20
+ get numOctaves(): number;
21
+ set numOctaves(value: number);
22
+ /**
23
+ * Serializes this cloud procedural texture
24
+ * @returns a serialized cloud procedural texture object
25
+ */
26
+ serialize(): any;
27
+ /**
28
+ * Creates a Cloud Procedural Texture from parsed cloud procedural texture data
29
+ * @param parsedTexture defines parsed texture data
30
+ * @param scene defines the current scene
31
+ * @param rootUrl defines the root URL containing cloud procedural texture information
32
+ * @returns a parsed Cloud Procedural Texture
33
+ */
34
+ static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CloudProceduralTexture;
35
+ }
@@ -0,0 +1,5 @@
1
+ /** @internal */
2
+ export declare const cloudProceduralTexturePixelShader: {
3
+ name: string;
4
+ shader: string;
5
+ };
@@ -0,0 +1,22 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "@onerjs/core/Engines/shaderStore.js";
3
+ const name = "cloudProceduralTexturePixelShader";
4
+ const shader = `precision highp float;varying vec2 vUV;uniform vec4 skyColor;uniform vec4 cloudColor;uniform float amplitude;uniform int numOctaves;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}
5
+ float noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}
6
+ float fbm(vec2 n) {float total=0.0,ampl=amplitude;
7
+ #ifdef WEBGL2
8
+ for (int i=0; i<numOctaves; i++) {
9
+ #else
10
+ for (int i=0; i<4; i++) {
11
+ #endif
12
+ total+=noise(n)*ampl;n+=n;ampl*=0.5;}
13
+ return total;}
14
+ void main() {vec2 p=vUV*12.0;vec4 c=mix(skyColor,cloudColor,fbm(p));gl_FragColor=c;}
15
+ `;
16
+ // Sideeffect
17
+ if (!ShaderStore.ShadersStore[name]) {
18
+ ShaderStore.ShadersStore[name] = shader;
19
+ }
20
+ /** @internal */
21
+ export const cloudProceduralTexturePixelShader = { name, shader };
22
+ //# sourceMappingURL=cloudProceduralTexture.fragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloudProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/cloud/cloudProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AAEvD,MAAM,IAAI,GAAG,mCAAmC,CAAC;AACjD,MAAM,MAAM,GAAG;;;;;;;;;;;CAWd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"cloudProceduralTexturePixelShader\";\nconst shader = `precision highp float;varying vec2 vUV;uniform vec4 skyColor;uniform vec4 cloudColor;uniform float amplitude;uniform int numOctaves;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,ampl=amplitude;\n#ifdef WEBGL2\nfor (int i=0; i<numOctaves; i++) {\n#else\nfor (int i=0; i<4; i++) {\n#endif\ntotal+=noise(n)*ampl;n+=n;ampl*=0.5;}\nreturn total;}\nvoid main() {vec2 p=vUV*12.0;vec4 c=mix(skyColor,cloudColor,fbm(p));gl_FragColor=c;}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const cloudProceduralTexturePixelShader = { name, shader };\n"]}
@@ -0,0 +1,85 @@
1
+ import { __decorate } from "@onerjs/core/tslib.es6.js";
2
+ import { serialize, serializeAsColor4 } from "@onerjs/core/Misc/decorators.js";
3
+ import { SerializationHelper } from "@onerjs/core/Misc/decorators.serialization.js";
4
+ import { Color4 } from "@onerjs/core/Maths/math.color.js";
5
+ import { ProceduralTexture } from "@onerjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
6
+ import { RegisterClass } from "@onerjs/core/Misc/typeStore.js";
7
+ import "./cloudProceduralTexture.fragment.js";
8
+ export class CloudProceduralTexture extends ProceduralTexture {
9
+ constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
10
+ super(name, size, "cloudProceduralTexture", scene, fallbackTexture, generateMipMaps);
11
+ this._skyColor = new Color4(0.15, 0.68, 1.0, 1.0);
12
+ this._cloudColor = new Color4(1, 1, 1, 1.0);
13
+ this._amplitude = 1;
14
+ this._numOctaves = 4;
15
+ this.updateShaderUniforms();
16
+ }
17
+ updateShaderUniforms() {
18
+ this.setColor4("skyColor", this._skyColor);
19
+ this.setColor4("cloudColor", this._cloudColor);
20
+ this.setFloat("amplitude", this._amplitude);
21
+ this.setInt("numOctaves", this._numOctaves);
22
+ }
23
+ get skyColor() {
24
+ return this._skyColor;
25
+ }
26
+ set skyColor(value) {
27
+ this._skyColor = value;
28
+ this.updateShaderUniforms();
29
+ }
30
+ get cloudColor() {
31
+ return this._cloudColor;
32
+ }
33
+ set cloudColor(value) {
34
+ this._cloudColor = value;
35
+ this.updateShaderUniforms();
36
+ }
37
+ get amplitude() {
38
+ return this._amplitude;
39
+ }
40
+ set amplitude(value) {
41
+ this._amplitude = value;
42
+ this.updateShaderUniforms();
43
+ }
44
+ get numOctaves() {
45
+ return this._numOctaves;
46
+ }
47
+ set numOctaves(value) {
48
+ this._numOctaves = value;
49
+ this.updateShaderUniforms();
50
+ }
51
+ /**
52
+ * Serializes this cloud procedural texture
53
+ * @returns a serialized cloud procedural texture object
54
+ */
55
+ serialize() {
56
+ const serializationObject = SerializationHelper.Serialize(this, super.serialize());
57
+ serializationObject.customType = "BABYLON.CloudProceduralTexture";
58
+ return serializationObject;
59
+ }
60
+ /**
61
+ * Creates a Cloud Procedural Texture from parsed cloud procedural texture data
62
+ * @param parsedTexture defines parsed texture data
63
+ * @param scene defines the current scene
64
+ * @param rootUrl defines the root URL containing cloud procedural texture information
65
+ * @returns a parsed Cloud Procedural Texture
66
+ */
67
+ static Parse(parsedTexture, scene, rootUrl) {
68
+ const texture = SerializationHelper.Parse(() => new CloudProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
69
+ return texture;
70
+ }
71
+ }
72
+ __decorate([
73
+ serializeAsColor4()
74
+ ], CloudProceduralTexture.prototype, "skyColor", null);
75
+ __decorate([
76
+ serializeAsColor4()
77
+ ], CloudProceduralTexture.prototype, "cloudColor", null);
78
+ __decorate([
79
+ serialize()
80
+ ], CloudProceduralTexture.prototype, "amplitude", null);
81
+ __decorate([
82
+ serialize()
83
+ ], CloudProceduralTexture.prototype, "numOctaves", null);
84
+ RegisterClass("BABYLON.CloudProceduralTexture", CloudProceduralTexture);
85
+ //# sourceMappingURL=cloudProceduralTexture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloudProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/cloud/cloudProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,wCAA6B;AACpE,OAAO,EAAE,mBAAmB,EAAE,sDAA2C;AACzE,OAAO,EAAE,MAAM,EAAE,yCAA8B;AAE/C,OAAO,EAAE,iBAAiB,EAAE,yEAA8D;AAE1F,OAAO,EAAE,aAAa,EAAE,uCAA4B;AAGpD,OAAO,mCAAmC,CAAC;AAE3C,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OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAGD,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,IAAW,UAAU,CAAC,KAAa;QAC/B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAED;;;OAGG;IACa,SAAS;QACrB,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QACnF,mBAAmB,CAAC,UAAU,GAAG,gCAAgC,CAAC;QAElE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAU,KAAK,CAAC,aAAkB,EAAE,KAAY,EAAE,OAAe;QAC1E,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CACrC,GAAG,EAAE,CAAC,IAAI,sBAAsB,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC3H,aAAa,EACb,KAAK,EACL,OAAO,CACV,CAAC;QAEF,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAnEG;IADC,iBAAiB,EAAE;sDAGnB;AAQD;IADC,iBAAiB,EAAE;wDAGnB;AAQD;IADC,SAAS,EAAE;uDAGX;AAQD;IADC,SAAS,EAAE;wDAGX;AAqCL,aAAa,CAAC,gCAAgC,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { serialize, serializeAsColor4 } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { Color4 } 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 \"./cloudProceduralTexture.fragment\";\r\n\r\nexport class CloudProceduralTexture extends ProceduralTexture {\r\n private _skyColor = new Color4(0.15, 0.68, 1.0, 1.0);\r\n private _cloudColor = new Color4(1, 1, 1, 1.0);\r\n private _amplitude = 1;\r\n private _numOctaves = 4;\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"cloudProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setColor4(\"skyColor\", this._skyColor);\r\n this.setColor4(\"cloudColor\", this._cloudColor);\r\n this.setFloat(\"amplitude\", this._amplitude);\r\n this.setInt(\"numOctaves\", this._numOctaves);\r\n }\r\n\r\n @serializeAsColor4()\r\n public get skyColor(): Color4 {\r\n return this._skyColor;\r\n }\r\n\r\n public set skyColor(value: Color4) {\r\n this._skyColor = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serializeAsColor4()\r\n public get cloudColor(): Color4 {\r\n return this._cloudColor;\r\n }\r\n\r\n public set cloudColor(value: Color4) {\r\n this._cloudColor = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get amplitude(): number {\r\n return this._amplitude;\r\n }\r\n\r\n public set amplitude(value: number) {\r\n this._amplitude = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get numOctaves(): number {\r\n return this._numOctaves;\r\n }\r\n\r\n public set numOctaves(value: number) {\r\n this._numOctaves = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this cloud procedural texture\r\n * @returns a serialized cloud 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.CloudProceduralTexture\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Cloud Procedural Texture from parsed cloud 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 cloud procedural texture information\r\n * @returns a parsed Cloud Procedural Texture\r\n */\r\n public static override Parse(parsedTexture: any, scene: Scene, rootUrl: string): CloudProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new CloudProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps),\r\n parsedTexture,\r\n scene,\r\n rootUrl\r\n );\r\n\r\n return texture;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CloudProceduralTexture\", CloudProceduralTexture);\r\n"]}
@@ -0,0 +1 @@
1
+ export * from "./cloudProceduralTexture.js";
package/cloud/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./cloudProceduralTexture.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/cloud/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from \"./cloudProceduralTexture\";\r\n"]}
@@ -0,0 +1,44 @@
1
+ import { Vector2 } from "@onerjs/core/Maths/math.vector.js";
2
+ import { Color3 } from "@onerjs/core/Maths/math.color.js";
3
+ import type { Texture } from "@onerjs/core/Materials/Textures/texture.js";
4
+ import { ProceduralTexture } from "@onerjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
5
+ import type { Scene } from "@onerjs/core/scene.js";
6
+ import type { Nullable } from "@onerjs/core/types.js";
7
+ import "./fireProceduralTexture.fragment.js";
8
+ export declare class FireProceduralTexture extends ProceduralTexture {
9
+ private _time;
10
+ private _speed;
11
+ private _autoGenerateTime;
12
+ private _fireColors;
13
+ private _alphaThreshold;
14
+ constructor(name: string, size: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
15
+ updateShaderUniforms(): void;
16
+ render(useCameraPostProcess?: boolean): void;
17
+ static get PurpleFireColors(): Color3[];
18
+ static get GreenFireColors(): Color3[];
19
+ static get RedFireColors(): Color3[];
20
+ static get BlueFireColors(): Color3[];
21
+ get autoGenerateTime(): boolean;
22
+ set autoGenerateTime(value: boolean);
23
+ get fireColors(): Color3[];
24
+ set fireColors(value: Color3[]);
25
+ get time(): number;
26
+ set time(value: number);
27
+ get speed(): Vector2;
28
+ set speed(value: Vector2);
29
+ get alphaThreshold(): number;
30
+ set alphaThreshold(value: number);
31
+ /**
32
+ * Serializes this fire procedural texture
33
+ * @returns a serialized fire procedural texture object
34
+ */
35
+ serialize(): any;
36
+ /**
37
+ * Creates a Fire Procedural Texture from parsed fire procedural texture data
38
+ * @param parsedTexture defines parsed texture data
39
+ * @param scene defines the current scene
40
+ * @param rootUrl defines the root URL containing fire procedural texture information
41
+ * @returns a parsed Fire Procedural Texture
42
+ */
43
+ static Parse(parsedTexture: any, scene: Scene, rootUrl: string): FireProceduralTexture;
44
+ }
@@ -0,0 +1,5 @@
1
+ /** @internal */
2
+ export declare const fireProceduralTexturePixelShader: {
3
+ name: string;
4
+ shader: string;
5
+ };
@@ -0,0 +1,15 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "@onerjs/core/Engines/shaderStore.js";
3
+ const name = "fireProceduralTexturePixelShader";
4
+ const shader = `precision highp float;uniform float time;uniform vec3 c1;uniform vec3 c2;uniform vec3 c3;uniform vec3 c4;uniform vec3 c5;uniform vec3 c6;uniform vec2 speed;uniform float shift;uniform float alphaThreshold;varying vec2 vUV;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}
5
+ float noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}
6
+ float fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}
7
+ return total;}
8
+ void main() {vec2 p=vUV*8.0;float q=fbm(p-time*0.1);vec2 r=vec2(fbm(p+q+time*speed.x-p.x-p.y),fbm(p+q-time*speed.y));vec3 c=mix(c1,c2,fbm(p+r))+mix(c3,c4,r.x)-mix(c5,c6,r.y);vec3 color=c*cos(shift*vUV.y);float luminance=dot(color.rgb,vec3(0.3,0.59,0.11));gl_FragColor=vec4(color,luminance*alphaThreshold+(1.0-alphaThreshold));}`;
9
+ // Sideeffect
10
+ if (!ShaderStore.ShadersStore[name]) {
11
+ ShaderStore.ShadersStore[name] = shader;
12
+ }
13
+ /** @internal */
14
+ export const fireProceduralTexturePixelShader = { name, shader };
15
+ //# sourceMappingURL=fireProceduralTexture.fragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fireProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/fire/fireProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AAEvD,MAAM,IAAI,GAAG,kCAAkC,CAAC;AAChD,MAAM,MAAM,GAAG;;;;wUAIyT,CAAC;AACzU,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"fireProceduralTexturePixelShader\";\nconst shader = `precision highp float;uniform float time;uniform vec3 c1;uniform vec3 c2;uniform vec3 c3;uniform vec3 c4;uniform vec3 c5;uniform vec3 c6;uniform vec2 speed;uniform float shift;uniform float alphaThreshold;varying vec2 vUV;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\nvoid main() {vec2 p=vUV*8.0;float q=fbm(p-time*0.1);vec2 r=vec2(fbm(p+q+time*speed.x-p.x-p.y),fbm(p+q-time*speed.y));vec3 c=mix(c1,c2,fbm(p+r))+mix(c3,c4,r.x)-mix(c5,c6,r.y);vec3 color=c*cos(shift*vUV.y);float luminance=dot(color.rgb,vec3(0.3,0.59,0.11));gl_FragColor=vec4(color,luminance*alphaThreshold+(1.0-alphaThreshold));}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const fireProceduralTexturePixelShader = { name, shader };\n"]}
@@ -0,0 +1,127 @@
1
+ import { __decorate } from "@onerjs/core/tslib.es6.js";
2
+ import { serialize, serializeAsVector2 } from "@onerjs/core/Misc/decorators.js";
3
+ import { SerializationHelper } from "@onerjs/core/Misc/decorators.serialization.js";
4
+ import { Vector2 } from "@onerjs/core/Maths/math.vector.js";
5
+ import { Color3 } from "@onerjs/core/Maths/math.color.js";
6
+ import { ProceduralTexture } from "@onerjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
7
+ import { RegisterClass } from "@onerjs/core/Misc/typeStore.js";
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);
126
+ RegisterClass("BABYLON.FireProceduralTexture", FireProceduralTexture);
127
+ //# sourceMappingURL=fireProceduralTexture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fireProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/fire/fireProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,wCAA6B;AACrE,OAAO,EAAE,mBAAmB,EAAE,sDAA2C;AACzE,OAAO,EAAE,OAAO,EAAE,0CAA+B;AACjD,OAAO,EAAE,MAAM,EAAE,yCAA8B;AAE/C,OAAO,EAAE,iBAAiB,EAAE,yEAA8D;AAE1F,OAAO,EAAE,aAAa,EAAE,uCAA4B;AAGpD,OAAO,kCAAkC,CAAC;AAE1C,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IAOxD,YAAY,IAAY,EAAE,IAAY,EAAE,QAAyB,IAAI,EAAE,eAAyB,EAAE,eAAyB;QACvH,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;QAPhF,UAAK,GAAW,GAAG,CAAC;QACpB,WAAM,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC/B,sBAAiB,GAAY,IAAI,CAAC;QAElC,oBAAe,GAAW,GAAG,CAAC;QAIlC,IAAI,CAA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AG,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"]}
@@ -0,0 +1 @@
1
+ export * from "./fireProceduralTexture.js";
package/fire/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./fireProceduralTexture.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/fire/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC","sourcesContent":["export * from \"./fireProceduralTexture\";\r\n"]}