@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 @@
1
+ {"version":3,"file":"roadProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/road/roadProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AAEvD,MAAM,IAAI,GAAG,kCAAkC,CAAC;AAChD,MAAM,MAAM,GAAG;;;;;;;;;;EAUb,CAAC;AACH,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 = \"roadProceduralTexturePixelShader\";\nconst shader = `precision highp float;varying vec2 vUV; \nuniform vec3 roadColor;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;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nfloat ratioy=mod(gl_FragCoord.y*100.0 ,fbm(vUV*2.0));vec3 color=roadColor*ratioy;gl_FragColor=vec4(color,1.0);\n#define CUSTOM_FRAGMENT_MAIN_END\n}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const roadProceduralTexturePixelShader = { name, shader };\n"]}
@@ -0,0 +1,49 @@
1
+ import { __decorate } from "@onerjs/core/tslib.es6.js";
2
+ import { 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 "./roadProceduralTexture.fragment.js";
8
+ export class RoadProceduralTexture extends ProceduralTexture {
9
+ constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
10
+ super(name, size, "roadProceduralTexture", scene, fallbackTexture, generateMipMaps);
11
+ this._roadColor = new Color3(0.53, 0.53, 0.53);
12
+ this.updateShaderUniforms();
13
+ }
14
+ updateShaderUniforms() {
15
+ this.setColor3("roadColor", this._roadColor);
16
+ }
17
+ get roadColor() {
18
+ return this._roadColor;
19
+ }
20
+ set roadColor(value) {
21
+ this._roadColor = value;
22
+ this.updateShaderUniforms();
23
+ }
24
+ /**
25
+ * Serializes this road procedural texture
26
+ * @returns a serialized road procedural texture object
27
+ */
28
+ serialize() {
29
+ const serializationObject = SerializationHelper.Serialize(this, super.serialize());
30
+ serializationObject.customType = "BABYLON.RoadProceduralTexture";
31
+ return serializationObject;
32
+ }
33
+ /**
34
+ * Creates a Road Procedural Texture from parsed road procedural texture data
35
+ * @param parsedTexture defines parsed texture data
36
+ * @param scene defines the current scene
37
+ * @param rootUrl defines the root URL containing road procedural texture information
38
+ * @returns a parsed Road Procedural Texture
39
+ */
40
+ static Parse(parsedTexture, scene, rootUrl) {
41
+ const texture = SerializationHelper.Parse(() => new RoadProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
42
+ return texture;
43
+ }
44
+ }
45
+ __decorate([
46
+ serializeAsColor3()
47
+ ], RoadProceduralTexture.prototype, "roadColor", null);
48
+ RegisterClass("BABYLON.RoadProceduralTexture", RoadProceduralTexture);
49
+ //# sourceMappingURL=roadProceduralTexture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roadProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/road/roadProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,wCAA6B;AACzD,OAAO,EAAE,mBAAmB,EAAE,sDAA2C;AACzE,OAAO,EAAE,MAAM,EAAE,yCAA8B;AAE/C,OAAO,EAAE,iBAAiB,EAAE,yEAA8D;AAE1F,OAAO,EAAE,aAAa,EAAE,uCAA4B;AAEpD,OAAO,kCAAkC,CAAC;AAE1C,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IAGxD,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;QAHhF,eAAU,GAAG,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAI9C,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAEM,oBAAoB;QACvB,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAGD,IAAW,SAAS;QAChB,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;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,+BAA+B,CAAC;QAEjE,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,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,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AArCG;IADC,iBAAiB,EAAE;sDAGnB;AAqCL,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,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\nimport \"./roadProceduralTexture.fragment\";\r\n\r\nexport class RoadProceduralTexture extends ProceduralTexture {\r\n private _roadColor = new Color3(0.53, 0.53, 0.53);\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"roadProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setColor3(\"roadColor\", this._roadColor);\r\n }\r\n\r\n @serializeAsColor3()\r\n public get roadColor(): Color3 {\r\n return this._roadColor;\r\n }\r\n\r\n public set roadColor(value: Color3) {\r\n this._roadColor = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this road procedural texture\r\n * @returns a serialized road 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.RoadProceduralTexture\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Road Procedural Texture from parsed road 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 road procedural texture information\r\n * @returns a parsed Road Procedural Texture\r\n */\r\n public static override Parse(parsedTexture: any, scene: Scene, rootUrl: string): RoadProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new RoadProceduralTexture(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.RoadProceduralTexture\", RoadProceduralTexture);\r\n"]}
@@ -0,0 +1 @@
1
+ export * from "./starfieldProceduralTexture.js";
@@ -0,0 +1,2 @@
1
+ export * from "./starfieldProceduralTexture.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/starfield/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC","sourcesContent":["export * from \"./starfieldProceduralTexture\";\r\n"]}
@@ -0,0 +1,55 @@
1
+ import type { Texture } from "@onerjs/core/Materials/Textures/texture.js";
2
+ import { ProceduralTexture } from "@onerjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
3
+ import type { Scene } from "@onerjs/core/scene.js";
4
+ import type { Nullable } from "@onerjs/core/types.js";
5
+ import "./starfieldProceduralTexture.fragment.js";
6
+ export declare class StarfieldProceduralTexture extends ProceduralTexture {
7
+ private _time;
8
+ private _alpha;
9
+ private _beta;
10
+ private _zoom;
11
+ private _formuparam;
12
+ private _stepsize;
13
+ private _tile;
14
+ private _brightness;
15
+ private _darkmatter;
16
+ private _distfading;
17
+ private _saturation;
18
+ constructor(name: string, size: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
19
+ updateShaderUniforms(): void;
20
+ get time(): number;
21
+ set time(value: number);
22
+ get alpha(): number;
23
+ set alpha(value: number);
24
+ get beta(): number;
25
+ set beta(value: number);
26
+ get formuparam(): number;
27
+ set formuparam(value: number);
28
+ get stepsize(): number;
29
+ set stepsize(value: number);
30
+ get zoom(): number;
31
+ set zoom(value: number);
32
+ get tile(): number;
33
+ set tile(value: number);
34
+ get brightness(): number;
35
+ set brightness(value: number);
36
+ get darkmatter(): number;
37
+ set darkmatter(value: number);
38
+ get distfading(): number;
39
+ set distfading(value: number);
40
+ get saturation(): number;
41
+ set saturation(value: number);
42
+ /**
43
+ * Serializes this starfield procedural texture
44
+ * @returns a serialized starfield procedural texture object
45
+ */
46
+ serialize(): any;
47
+ /**
48
+ * Creates a Starfield Procedural Texture from parsed startfield procedural texture data
49
+ * @param parsedTexture defines parsed texture data
50
+ * @param scene defines the current scene
51
+ * @param rootUrl defines the root URL containing startfield procedural texture information
52
+ * @returns a parsed Starfield Procedural Texture
53
+ */
54
+ static Parse(parsedTexture: any, scene: Scene, rootUrl: string): StarfieldProceduralTexture;
55
+ }
@@ -0,0 +1,5 @@
1
+ /** @internal */
2
+ export declare const starfieldProceduralTexturePixelShader: {
3
+ name: string;
4
+ shader: string;
5
+ };
@@ -0,0 +1,26 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "@onerjs/core/Engines/shaderStore.js";
3
+ const name = "starfieldProceduralTexturePixelShader";
4
+ const shader = `precision highp float;
5
+ #define volsteps 20
6
+ #define iterations 15
7
+ varying vec2 vPosition;varying vec2 vUV;uniform float time;uniform float alpha;uniform float beta;uniform float zoom;uniform float formuparam;uniform float stepsize;uniform float tile;uniform float brightness;uniform float darkmatter;uniform float distfading;uniform float saturation;void main()
8
+ {vec3 dir=vec3(vUV*zoom,1.);float localTime=time*0.0001;mat2 rot1=mat2(cos(alpha),sin(alpha),-sin(alpha),cos(alpha));mat2 rot2=mat2(cos(beta),sin(beta),-sin(beta),cos(beta));dir.xz*=rot1;dir.xy*=rot2;vec3 from_=vec3(1.,.5,0.5);from_+=vec3(-2.,localTime*2.,localTime);from_.xz*=rot1;from_.xy*=rot2;float s=0.1,fade=1.;vec3 v=vec3(0.);for (int r=0; r<volsteps; r++) {vec3 p=from_+s*dir*.5;p=abs(vec3(tile)-mod(p,vec3(tile*2.)));
9
+ float pa,a=pa=0.;for (int i=0; i<iterations; i++) {p=abs(p)/dot(p,p)-formuparam;
10
+ a+=abs(length(p)-pa);
11
+ pa=length(p);}
12
+ float dm=max(0.,darkmatter-a*a*.001);
13
+ a*=a*a;
14
+ if (r>6) fade*=1.-dm;
15
+ v+=fade;v+=vec3(s,s*s,s*s*s*s)*a*brightness*fade;
16
+ fade*=distfading;
17
+ s+=stepsize;}
18
+ v=mix(vec3(length(v)),v,saturation);
19
+ gl_FragColor=vec4(v*.01,1.);}`;
20
+ // Sideeffect
21
+ if (!ShaderStore.ShadersStore[name]) {
22
+ ShaderStore.ShadersStore[name] = shader;
23
+ }
24
+ /** @internal */
25
+ export const starfieldProceduralTexturePixelShader = { name, shader };
26
+ //# sourceMappingURL=starfieldProceduralTexture.fragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"starfieldProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/starfield/starfieldProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AAEvD,MAAM,IAAI,GAAG,uCAAuC,CAAC;AACrD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;8BAee,CAAC;AAC/B,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,qCAAqC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"starfieldProceduralTexturePixelShader\";\nconst shader = `precision highp float;\n#define volsteps 20\n#define iterations 15\nvarying vec2 vPosition;varying vec2 vUV;uniform float time;uniform float alpha;uniform float beta;uniform float zoom;uniform float formuparam;uniform float stepsize;uniform float tile;uniform float brightness;uniform float darkmatter;uniform float distfading;uniform float saturation;void main()\n{vec3 dir=vec3(vUV*zoom,1.);float localTime=time*0.0001;mat2 rot1=mat2(cos(alpha),sin(alpha),-sin(alpha),cos(alpha));mat2 rot2=mat2(cos(beta),sin(beta),-sin(beta),cos(beta));dir.xz*=rot1;dir.xy*=rot2;vec3 from_=vec3(1.,.5,0.5);from_+=vec3(-2.,localTime*2.,localTime);from_.xz*=rot1;from_.xy*=rot2;float s=0.1,fade=1.;vec3 v=vec3(0.);for (int r=0; r<volsteps; r++) {vec3 p=from_+s*dir*.5;p=abs(vec3(tile)-mod(p,vec3(tile*2.))); \nfloat pa,a=pa=0.;for (int i=0; i<iterations; i++) {p=abs(p)/dot(p,p)-formuparam; \na+=abs(length(p)-pa); \npa=length(p);}\nfloat dm=max(0.,darkmatter-a*a*.001); \na*=a*a; \nif (r>6) fade*=1.-dm; \nv+=fade;v+=vec3(s,s*s,s*s*s*s)*a*brightness*fade; \nfade*=distfading; \ns+=stepsize;}\nv=mix(vec3(length(v)),v,saturation); \ngl_FragColor=vec4(v*.01,1.);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const starfieldProceduralTexturePixelShader = { name, shader };\n"]}
@@ -0,0 +1,168 @@
1
+ import { __decorate } from "@onerjs/core/tslib.es6.js";
2
+ import { serialize } from "@onerjs/core/Misc/decorators.js";
3
+ import { SerializationHelper } from "@onerjs/core/Misc/decorators.serialization.js";
4
+ import { ProceduralTexture } from "@onerjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
5
+ import { RegisterClass } from "@onerjs/core/Misc/typeStore.js";
6
+ import "./starfieldProceduralTexture.fragment.js";
7
+ export class StarfieldProceduralTexture extends ProceduralTexture {
8
+ constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
9
+ super(name, size, "starfieldProceduralTexture", scene, fallbackTexture, generateMipMaps);
10
+ this._time = 1;
11
+ this._alpha = 0.5;
12
+ this._beta = 0.8;
13
+ this._zoom = 0.8;
14
+ this._formuparam = 0.53;
15
+ this._stepsize = 0.1;
16
+ this._tile = 0.85;
17
+ this._brightness = 0.0015;
18
+ this._darkmatter = 0.4;
19
+ this._distfading = 0.73;
20
+ this._saturation = 0.85;
21
+ this.updateShaderUniforms();
22
+ }
23
+ updateShaderUniforms() {
24
+ this.setFloat("time", this._time);
25
+ this.setFloat("alpha", this._alpha);
26
+ this.setFloat("beta", this._beta);
27
+ this.setFloat("zoom", this._zoom);
28
+ this.setFloat("formuparam", this._formuparam);
29
+ this.setFloat("stepsize", this._stepsize);
30
+ this.setFloat("tile", this._tile);
31
+ this.setFloat("brightness", this._brightness);
32
+ this.setFloat("darkmatter", this._darkmatter);
33
+ this.setFloat("distfading", this._distfading);
34
+ this.setFloat("saturation", this._saturation);
35
+ }
36
+ get time() {
37
+ return this._time;
38
+ }
39
+ set time(value) {
40
+ this._time = value;
41
+ this.updateShaderUniforms();
42
+ }
43
+ get alpha() {
44
+ return this._alpha;
45
+ }
46
+ set alpha(value) {
47
+ this._alpha = value;
48
+ this.updateShaderUniforms();
49
+ }
50
+ get beta() {
51
+ return this._beta;
52
+ }
53
+ set beta(value) {
54
+ this._beta = value;
55
+ this.updateShaderUniforms();
56
+ }
57
+ get formuparam() {
58
+ return this._formuparam;
59
+ }
60
+ set formuparam(value) {
61
+ this._formuparam = value;
62
+ this.updateShaderUniforms();
63
+ }
64
+ get stepsize() {
65
+ return this._stepsize;
66
+ }
67
+ set stepsize(value) {
68
+ this._stepsize = value;
69
+ this.updateShaderUniforms();
70
+ }
71
+ get zoom() {
72
+ return this._zoom;
73
+ }
74
+ set zoom(value) {
75
+ this._zoom = value;
76
+ this.updateShaderUniforms();
77
+ }
78
+ get tile() {
79
+ return this._tile;
80
+ }
81
+ set tile(value) {
82
+ this._tile = value;
83
+ this.updateShaderUniforms();
84
+ }
85
+ get brightness() {
86
+ return this._brightness;
87
+ }
88
+ set brightness(value) {
89
+ this._brightness = value;
90
+ this.updateShaderUniforms();
91
+ }
92
+ get darkmatter() {
93
+ return this._darkmatter;
94
+ }
95
+ set darkmatter(value) {
96
+ this._darkmatter = value;
97
+ this.updateShaderUniforms();
98
+ }
99
+ get distfading() {
100
+ return this._distfading;
101
+ }
102
+ set distfading(value) {
103
+ this._distfading = value;
104
+ this.updateShaderUniforms();
105
+ }
106
+ get saturation() {
107
+ return this._saturation;
108
+ }
109
+ set saturation(value) {
110
+ this._saturation = value;
111
+ this.updateShaderUniforms();
112
+ }
113
+ /**
114
+ * Serializes this starfield procedural texture
115
+ * @returns a serialized starfield procedural texture object
116
+ */
117
+ serialize() {
118
+ const serializationObject = SerializationHelper.Serialize(this, super.serialize());
119
+ serializationObject.customType = "BABYLON.StarfieldProceduralTexture";
120
+ return serializationObject;
121
+ }
122
+ /**
123
+ * Creates a Starfield Procedural Texture from parsed startfield procedural texture data
124
+ * @param parsedTexture defines parsed texture data
125
+ * @param scene defines the current scene
126
+ * @param rootUrl defines the root URL containing startfield procedural texture information
127
+ * @returns a parsed Starfield Procedural Texture
128
+ */
129
+ static Parse(parsedTexture, scene, rootUrl) {
130
+ const texture = SerializationHelper.Parse(() => new StarfieldProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
131
+ return texture;
132
+ }
133
+ }
134
+ __decorate([
135
+ serialize()
136
+ ], StarfieldProceduralTexture.prototype, "time", null);
137
+ __decorate([
138
+ serialize()
139
+ ], StarfieldProceduralTexture.prototype, "alpha", null);
140
+ __decorate([
141
+ serialize()
142
+ ], StarfieldProceduralTexture.prototype, "beta", null);
143
+ __decorate([
144
+ serialize()
145
+ ], StarfieldProceduralTexture.prototype, "formuparam", null);
146
+ __decorate([
147
+ serialize()
148
+ ], StarfieldProceduralTexture.prototype, "stepsize", null);
149
+ __decorate([
150
+ serialize()
151
+ ], StarfieldProceduralTexture.prototype, "zoom", null);
152
+ __decorate([
153
+ serialize()
154
+ ], StarfieldProceduralTexture.prototype, "tile", null);
155
+ __decorate([
156
+ serialize()
157
+ ], StarfieldProceduralTexture.prototype, "brightness", null);
158
+ __decorate([
159
+ serialize()
160
+ ], StarfieldProceduralTexture.prototype, "darkmatter", null);
161
+ __decorate([
162
+ serialize()
163
+ ], StarfieldProceduralTexture.prototype, "distfading", null);
164
+ __decorate([
165
+ serialize()
166
+ ], StarfieldProceduralTexture.prototype, "saturation", null);
167
+ RegisterClass("BABYLON.StarfieldProceduralTexture", StarfieldProceduralTexture);
168
+ //# sourceMappingURL=starfieldProceduralTexture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"starfieldProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralText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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,oCAAoC,CAAC;QAEtE,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,0BAA0B,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC/H,aAAa,EACb,KAAK,EACL,OAAO,CACV,CAAC;QAEF,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAzIG;IADC,SAAS,EAAE;sDAGX;AAQD;IADC,SAAS,EAAE;uDAGX;AAQD;IADC,SAAS,EAAE;sDAGX;AAQD;IADC,SAAS,EAAE;4DAGX;AAQD;IADC,SAAS,EAAE;0DAGX;AAQD;IADC,SAAS,EAAE;sDAGX;AAQD;IADC,SAAS,EAAE;sDAGX;AAQD;IADC,SAAS,EAAE;4DAGX;AAQD;IADC,SAAS,EAAE;4DAGX;AAQD;IADC,SAAS,EAAE;4DAGX;AAQD;IADC,SAAS,EAAE;4DAGX;AAqCL,aAAa,CAAC,oCAAoC,EAAE,0BAA0B,CAAC,CAAC","sourcesContent":["import { serialize } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\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\nimport \"./starfieldProceduralTexture.fragment\";\r\n\r\nexport class StarfieldProceduralTexture extends ProceduralTexture {\r\n private _time = 1;\r\n private _alpha = 0.5;\r\n private _beta = 0.8;\r\n private _zoom = 0.8;\r\n private _formuparam = 0.53;\r\n private _stepsize = 0.1;\r\n private _tile = 0.85;\r\n private _brightness = 0.0015;\r\n private _darkmatter = 0.4;\r\n private _distfading = 0.73;\r\n private _saturation = 0.85;\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"starfieldProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setFloat(\"time\", this._time);\r\n this.setFloat(\"alpha\", this._alpha);\r\n this.setFloat(\"beta\", this._beta);\r\n this.setFloat(\"zoom\", this._zoom);\r\n this.setFloat(\"formuparam\", this._formuparam);\r\n this.setFloat(\"stepsize\", this._stepsize);\r\n this.setFloat(\"tile\", this._tile);\r\n this.setFloat(\"brightness\", this._brightness);\r\n this.setFloat(\"darkmatter\", this._darkmatter);\r\n this.setFloat(\"distfading\", this._distfading);\r\n this.setFloat(\"saturation\", this._saturation);\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 @serialize()\r\n public get alpha(): number {\r\n return this._alpha;\r\n }\r\n\r\n public set alpha(value: number) {\r\n this._alpha = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get beta(): number {\r\n return this._beta;\r\n }\r\n\r\n public set beta(value: number) {\r\n this._beta = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get formuparam(): number {\r\n return this._formuparam;\r\n }\r\n\r\n public set formuparam(value: number) {\r\n this._formuparam = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get stepsize(): number {\r\n return this._stepsize;\r\n }\r\n\r\n public set stepsize(value: number) {\r\n this._stepsize = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get zoom(): number {\r\n return this._zoom;\r\n }\r\n\r\n public set zoom(value: number) {\r\n this._zoom = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get tile(): number {\r\n return this._tile;\r\n }\r\n\r\n public set tile(value: number) {\r\n this._tile = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get brightness(): number {\r\n return this._brightness;\r\n }\r\n\r\n public set brightness(value: number) {\r\n this._brightness = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get darkmatter(): number {\r\n return this._darkmatter;\r\n }\r\n\r\n public set darkmatter(value: number) {\r\n this._darkmatter = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get distfading(): number {\r\n return this._distfading;\r\n }\r\n\r\n public set distfading(value: number) {\r\n this._distfading = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get saturation(): number {\r\n return this._saturation;\r\n }\r\n\r\n public set saturation(value: number) {\r\n this._saturation = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this starfield procedural texture\r\n * @returns a serialized starfield 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.StarfieldProceduralTexture\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Starfield Procedural Texture from parsed startfield 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 startfield procedural texture information\r\n * @returns a parsed Starfield Procedural Texture\r\n */\r\n public static override Parse(parsedTexture: any, scene: Scene, rootUrl: string): StarfieldProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new StarfieldProceduralTexture(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.StarfieldProceduralTexture\", StarfieldProceduralTexture);\r\n"]}
@@ -0,0 +1 @@
1
+ export * from "./woodProceduralTexture.js";
package/wood/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./woodProceduralTexture.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/wood/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC","sourcesContent":["export * from \"./woodProceduralTexture\";\r\n"]}
@@ -0,0 +1,29 @@
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 "./woodProceduralTexture.fragment.js";
7
+ export declare class WoodProceduralTexture extends ProceduralTexture {
8
+ private _ampScale;
9
+ private _woodColor;
10
+ constructor(name: string, size: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
11
+ updateShaderUniforms(): void;
12
+ get ampScale(): number;
13
+ set ampScale(value: number);
14
+ get woodColor(): Color3;
15
+ set woodColor(value: Color3);
16
+ /**
17
+ * Serializes this wood procedural texture
18
+ * @returns a serialized wood procedural texture object
19
+ */
20
+ serialize(): any;
21
+ /**
22
+ * Creates a Wood Procedural Texture from parsed wood procedural texture data
23
+ * @param parsedTexture defines parsed texture data
24
+ * @param scene defines the current scene
25
+ * @param rootUrl defines the root URL containing wood procedural texture information
26
+ * @returns a parsed Wood Procedural Texture
27
+ */
28
+ static Parse(parsedTexture: any, scene: Scene, rootUrl: string): WoodProceduralTexture;
29
+ }
@@ -0,0 +1,5 @@
1
+ /** @internal */
2
+ export declare const woodProceduralTexturePixelShader: {
3
+ name: string;
4
+ shader: string;
5
+ };
@@ -0,0 +1,20 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "@onerjs/core/Engines/shaderStore.js";
3
+ const name = "woodProceduralTexturePixelShader";
4
+ const shader = `precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float ampScale;uniform vec3 woodColor;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
+ #define CUSTOM_FRAGMENT_DEFINITIONS
9
+ void main(void) {
10
+ #define CUSTOM_FRAGMENT_MAIN_BEGIN
11
+ float ratioy=mod(vUV.x*ampScale,2.0+fbm(vUV*0.8));vec3 wood=woodColor*ratioy;gl_FragColor=vec4(wood,1.0);
12
+ #define CUSTOM_FRAGMENT_MAIN_END
13
+ }`;
14
+ // Sideeffect
15
+ if (!ShaderStore.ShadersStore[name]) {
16
+ ShaderStore.ShadersStore[name] = shader;
17
+ }
18
+ /** @internal */
19
+ export const woodProceduralTexturePixelShader = { name, shader };
20
+ //# sourceMappingURL=woodProceduralTexture.fragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"woodProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/wood/woodProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AAEvD,MAAM,IAAI,GAAG,kCAAkC,CAAC;AAChD,MAAM,MAAM,GAAG;;;;;;;;;EASb,CAAC;AACH,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 = \"woodProceduralTexturePixelShader\";\nconst shader = `precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float ampScale;uniform vec3 woodColor;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;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nfloat ratioy=mod(vUV.x*ampScale,2.0+fbm(vUV*0.8));vec3 wood=woodColor*ratioy;gl_FragColor=vec4(wood,1.0);\n#define CUSTOM_FRAGMENT_MAIN_END\n}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const woodProceduralTexturePixelShader = { name, shader };\n"]}
@@ -0,0 +1,61 @@
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 "./woodProceduralTexture.fragment.js";
8
+ export class WoodProceduralTexture extends ProceduralTexture {
9
+ constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
10
+ super(name, size, "woodProceduralTexture", scene, fallbackTexture, generateMipMaps);
11
+ this._ampScale = 100.0;
12
+ this._woodColor = new Color3(0.32, 0.17, 0.09);
13
+ this.updateShaderUniforms();
14
+ }
15
+ updateShaderUniforms() {
16
+ this.setFloat("ampScale", this._ampScale);
17
+ this.setColor3("woodColor", this._woodColor);
18
+ }
19
+ get ampScale() {
20
+ return this._ampScale;
21
+ }
22
+ set ampScale(value) {
23
+ this._ampScale = value;
24
+ this.updateShaderUniforms();
25
+ }
26
+ get woodColor() {
27
+ return this._woodColor;
28
+ }
29
+ set woodColor(value) {
30
+ this._woodColor = value;
31
+ this.updateShaderUniforms();
32
+ }
33
+ /**
34
+ * Serializes this wood procedural texture
35
+ * @returns a serialized wood procedural texture object
36
+ */
37
+ serialize() {
38
+ const serializationObject = SerializationHelper.Serialize(this, super.serialize());
39
+ serializationObject.customType = "BABYLON.WoodProceduralTexture";
40
+ return serializationObject;
41
+ }
42
+ /**
43
+ * Creates a Wood Procedural Texture from parsed wood procedural texture data
44
+ * @param parsedTexture defines parsed texture data
45
+ * @param scene defines the current scene
46
+ * @param rootUrl defines the root URL containing wood procedural texture information
47
+ * @returns a parsed Wood Procedural Texture
48
+ */
49
+ static Parse(parsedTexture, scene, rootUrl) {
50
+ const texture = SerializationHelper.Parse(() => new WoodProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
51
+ return texture;
52
+ }
53
+ }
54
+ __decorate([
55
+ serialize()
56
+ ], WoodProceduralTexture.prototype, "ampScale", null);
57
+ __decorate([
58
+ serializeAsColor3()
59
+ ], WoodProceduralTexture.prototype, "woodColor", null);
60
+ RegisterClass("BABYLON.WoodProceduralTexture", WoodProceduralTexture);
61
+ //# sourceMappingURL=woodProceduralTexture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"woodProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/wood/woodProceduralTexture.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;AAEpD,OAAO,kCAAkC,CAAC;AAE1C,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IAIxD,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;QAJhF,cAAS,GAAW,KAAK,CAAC;QAC1B,eAAU,GAAW,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAItD,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAEM,oBAAoB;QACvB,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAGD,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,QAAQ,CAAC,KAAa;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAGD,IAAW,SAAS;QAChB,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;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,+BAA+B,CAAC;QAEjE,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,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,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA/CG;IADC,SAAS,EAAE;qDAGX;AAQD;IADC,iBAAiB,EAAE;sDAGnB;AAqCL,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,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\nimport \"./woodProceduralTexture.fragment\";\r\n\r\nexport class WoodProceduralTexture extends ProceduralTexture {\r\n private _ampScale: number = 100.0;\r\n private _woodColor: Color3 = new Color3(0.32, 0.17, 0.09);\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"woodProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setFloat(\"ampScale\", this._ampScale);\r\n this.setColor3(\"woodColor\", this._woodColor);\r\n }\r\n\r\n @serialize()\r\n public get ampScale(): number {\r\n return this._ampScale;\r\n }\r\n\r\n public set ampScale(value: number) {\r\n this._ampScale = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serializeAsColor3()\r\n public get woodColor(): Color3 {\r\n return this._woodColor;\r\n }\r\n\r\n public set woodColor(value: Color3) {\r\n this._woodColor = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this wood procedural texture\r\n * @returns a serialized wood 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.WoodProceduralTexture\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Wood Procedural Texture from parsed wood 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 wood procedural texture information\r\n * @returns a parsed Wood Procedural Texture\r\n */\r\n public static override Parse(parsedTexture: any, scene: Scene, rootUrl: string): WoodProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new WoodProceduralTexture(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.WoodProceduralTexture\", WoodProceduralTexture);\r\n"]}