@babylonjs/procedural-textures 9.14.0 → 9.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/brick/brickProceduralTexture.js +88 -77
- package/brick/brickProceduralTexture.js.map +1 -1
- package/cloud/cloudProceduralTexture.js +88 -77
- package/cloud/cloudProceduralTexture.js.map +1 -1
- package/fire/fireProceduralTexture.js +129 -118
- package/fire/fireProceduralTexture.js.map +1 -1
- package/grass/grassProceduralTexture.js +73 -61
- package/grass/grassProceduralTexture.js.map +1 -1
- package/marble/marbleProceduralTexture.js +88 -77
- package/marble/marbleProceduralTexture.js.map +1 -1
- package/normalMap/normalMapProceduralTexture.js +67 -55
- package/normalMap/normalMapProceduralTexture.js.map +1 -1
- package/package.json +2 -2
- package/perlinNoise/perlinNoiseProceduralTexture.js +75 -59
- package/perlinNoise/perlinNoiseProceduralTexture.js.map +1 -1
- package/road/roadProceduralTexture.js +52 -41
- package/road/roadProceduralTexture.js.map +1 -1
- package/starfield/starfieldProceduralTexture.js +172 -161
- package/starfield/starfieldProceduralTexture.js.map +1 -1
- package/wood/woodProceduralTexture.js +64 -53
- package/wood/woodProceduralTexture.js.map +1 -1
|
@@ -1,85 +1,96 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __esDecorate, __runInitializers } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { serialize } from "@babylonjs/core/Misc/decorators.js";
|
|
3
3
|
import { SerializationHelper } from "@babylonjs/core/Misc/decorators.serialization.js";
|
|
4
4
|
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
|
5
5
|
import { ProceduralTexture } from "@babylonjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
|
|
6
6
|
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
|
7
7
|
import "./marbleProceduralTexture.fragment.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
8
|
+
let MarbleProceduralTexture = (() => {
|
|
9
|
+
var _a;
|
|
10
|
+
let _classSuper = ProceduralTexture;
|
|
11
|
+
let _instanceExtraInitializers = [];
|
|
12
|
+
let _get_numberOfTilesHeight_decorators;
|
|
13
|
+
let _get_amplitude_decorators;
|
|
14
|
+
let _get_numberOfTilesWidth_decorators;
|
|
15
|
+
let _get_jointColor_decorators;
|
|
16
|
+
return _a = class MarbleProceduralTexture extends _classSuper {
|
|
17
|
+
constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
|
|
18
|
+
super(name, size, "marbleProceduralTexture", scene, fallbackTexture, generateMipMaps);
|
|
19
|
+
this._numberOfTilesHeight = (__runInitializers(this, _instanceExtraInitializers), 3);
|
|
20
|
+
this._numberOfTilesWidth = 3;
|
|
21
|
+
this._amplitude = 9.0;
|
|
22
|
+
this._jointColor = new Color3(0.72, 0.72, 0.72);
|
|
23
|
+
this.updateShaderUniforms();
|
|
24
|
+
}
|
|
25
|
+
updateShaderUniforms() {
|
|
26
|
+
this.setFloat("numberOfTilesHeight", this._numberOfTilesHeight);
|
|
27
|
+
this.setFloat("numberOfTilesWidth", this._numberOfTilesWidth);
|
|
28
|
+
this.setFloat("amplitude", this._amplitude);
|
|
29
|
+
this.setColor3("jointColor", this._jointColor);
|
|
30
|
+
}
|
|
31
|
+
get numberOfTilesHeight() {
|
|
32
|
+
return this._numberOfTilesHeight;
|
|
33
|
+
}
|
|
34
|
+
set numberOfTilesHeight(value) {
|
|
35
|
+
this._numberOfTilesHeight = value;
|
|
36
|
+
this.updateShaderUniforms();
|
|
37
|
+
}
|
|
38
|
+
get amplitude() {
|
|
39
|
+
return this._amplitude;
|
|
40
|
+
}
|
|
41
|
+
set amplitude(value) {
|
|
42
|
+
this._amplitude = value;
|
|
43
|
+
this.updateShaderUniforms();
|
|
44
|
+
}
|
|
45
|
+
get numberOfTilesWidth() {
|
|
46
|
+
return this._numberOfTilesWidth;
|
|
47
|
+
}
|
|
48
|
+
set numberOfTilesWidth(value) {
|
|
49
|
+
this._numberOfTilesWidth = value;
|
|
50
|
+
this.updateShaderUniforms();
|
|
51
|
+
}
|
|
52
|
+
get jointColor() {
|
|
53
|
+
return this._jointColor;
|
|
54
|
+
}
|
|
55
|
+
set jointColor(value) {
|
|
56
|
+
this._jointColor = value;
|
|
57
|
+
this.updateShaderUniforms();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Serializes this marble procedural texture
|
|
61
|
+
* @returns a serialized marble procedural texture object
|
|
62
|
+
*/
|
|
63
|
+
serialize() {
|
|
64
|
+
const serializationObject = SerializationHelper.Serialize(this, super.serialize());
|
|
65
|
+
serializationObject.customType = "BABYLON.MarbleProceduralTexture";
|
|
66
|
+
return serializationObject;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates a Marble Procedural Texture from parsed marble procedural texture data
|
|
70
|
+
* @param parsedTexture defines parsed texture data
|
|
71
|
+
* @param scene defines the current scene
|
|
72
|
+
* @param rootUrl defines the root URL containing marble procedural texture information
|
|
73
|
+
* @returns a parsed Marble Procedural Texture
|
|
74
|
+
*/
|
|
75
|
+
static Parse(parsedTexture, scene, rootUrl) {
|
|
76
|
+
const texture = SerializationHelper.Parse(() => new _a(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
|
|
77
|
+
return texture;
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
(() => {
|
|
81
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
82
|
+
_get_numberOfTilesHeight_decorators = [serialize()];
|
|
83
|
+
_get_amplitude_decorators = [serialize()];
|
|
84
|
+
_get_numberOfTilesWidth_decorators = [serialize()];
|
|
85
|
+
_get_jointColor_decorators = [serialize()];
|
|
86
|
+
__esDecorate(_a, null, _get_numberOfTilesHeight_decorators, { kind: "getter", name: "numberOfTilesHeight", static: false, private: false, access: { has: obj => "numberOfTilesHeight" in obj, get: obj => obj.numberOfTilesHeight }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
87
|
+
__esDecorate(_a, null, _get_amplitude_decorators, { kind: "getter", name: "amplitude", static: false, private: false, access: { has: obj => "amplitude" in obj, get: obj => obj.amplitude }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
88
|
+
__esDecorate(_a, null, _get_numberOfTilesWidth_decorators, { kind: "getter", name: "numberOfTilesWidth", static: false, private: false, access: { has: obj => "numberOfTilesWidth" in obj, get: obj => obj.numberOfTilesWidth }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
89
|
+
__esDecorate(_a, null, _get_jointColor_decorators, { kind: "getter", name: "jointColor", static: false, private: false, access: { has: obj => "jointColor" in obj, get: obj => obj.jointColor }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
90
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
91
|
+
})(),
|
|
92
|
+
_a;
|
|
93
|
+
})();
|
|
94
|
+
export { MarbleProceduralTexture };
|
|
84
95
|
RegisterClass("BABYLON.MarbleProceduralTexture", MarbleProceduralTexture);
|
|
85
96
|
//# sourceMappingURL=marbleProceduralTexture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marbleProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/marble/marbleProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"marbleProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/marble/marbleProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,oCAAoC,CAAC;IAE/B,uBAAuB;;sBAAS,iBAAi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\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 \"./marbleProceduralTexture.fragment\";\r\n\r\nexport class MarbleProceduralTexture extends ProceduralTexture {\r\n private _numberOfTilesHeight: number = 3;\r\n private _numberOfTilesWidth: number = 3;\r\n private _amplitude: number = 9.0;\r\n private _jointColor = new Color3(0.72, 0.72, 0.72);\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"marbleProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setFloat(\"numberOfTilesHeight\", this._numberOfTilesHeight);\r\n this.setFloat(\"numberOfTilesWidth\", this._numberOfTilesWidth);\r\n this.setFloat(\"amplitude\", this._amplitude);\r\n this.setColor3(\"jointColor\", this._jointColor);\r\n }\r\n\r\n @serialize()\r\n public get numberOfTilesHeight(): number {\r\n return this._numberOfTilesHeight;\r\n }\r\n\r\n public set numberOfTilesHeight(value: number) {\r\n this._numberOfTilesHeight = 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 numberOfTilesWidth(): number {\r\n return this._numberOfTilesWidth;\r\n }\r\n\r\n public set numberOfTilesWidth(value: number) {\r\n this._numberOfTilesWidth = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\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 /**\r\n * Serializes this marble procedural texture\r\n * @returns a serialized marble 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.MarbleProceduralTexture\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Marble Procedural Texture from parsed marble 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 marble procedural texture information\r\n * @returns a parsed Marble Procedural Texture\r\n */\r\n public static override Parse(parsedTexture: any, scene: Scene, rootUrl: string): MarbleProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new MarbleProceduralTexture(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.MarbleProceduralTexture\", MarbleProceduralTexture);\r\n"]}
|
|
@@ -1,62 +1,74 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __esDecorate, __runInitializers } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { serializeAsTexture } from "@babylonjs/core/Misc/decorators.js";
|
|
3
3
|
import { SerializationHelper } from "@babylonjs/core/Misc/decorators.serialization.js";
|
|
4
4
|
import { ProceduralTexture } from "@babylonjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
|
|
5
5
|
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
|
6
6
|
import "./normalMapProceduralTexture.fragment.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
7
|
+
let NormalMapProceduralTexture = (() => {
|
|
8
|
+
var _a;
|
|
9
|
+
let _classSuper = ProceduralTexture;
|
|
10
|
+
let _instanceExtraInitializers = [];
|
|
11
|
+
let _get_baseTexture_decorators;
|
|
12
|
+
return _a = class NormalMapProceduralTexture extends _classSuper {
|
|
13
|
+
constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
|
|
14
|
+
super(name, size, "normalMapProceduralTexture", scene, fallbackTexture, generateMipMaps);
|
|
15
|
+
this._baseTexture = __runInitializers(this, _instanceExtraInitializers);
|
|
16
|
+
this.updateShaderUniforms();
|
|
17
|
+
}
|
|
18
|
+
updateShaderUniforms() {
|
|
19
|
+
this.setTexture("baseSampler", this._baseTexture);
|
|
20
|
+
this.setFloat("size", this.getRenderSize());
|
|
21
|
+
}
|
|
22
|
+
render(useCameraPostProcess) {
|
|
23
|
+
super.render(useCameraPostProcess);
|
|
24
|
+
}
|
|
25
|
+
resize(size, generateMipMaps) {
|
|
26
|
+
super.resize(size, generateMipMaps);
|
|
27
|
+
// We need to update the "size" uniform
|
|
28
|
+
this.updateShaderUniforms();
|
|
29
|
+
}
|
|
30
|
+
isReady() {
|
|
31
|
+
if (!this._baseTexture || !this._baseTexture.isReady()) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return super.isReady();
|
|
35
|
+
}
|
|
36
|
+
get baseTexture() {
|
|
37
|
+
return this._baseTexture;
|
|
38
|
+
}
|
|
39
|
+
set baseTexture(texture) {
|
|
40
|
+
this._baseTexture = texture;
|
|
41
|
+
this.updateShaderUniforms();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Serializes this normal map procedural texture
|
|
45
|
+
* @returns a serialized normal map procedural texture object
|
|
46
|
+
*/
|
|
47
|
+
serialize() {
|
|
48
|
+
const serializationObject = SerializationHelper.Serialize(this, super.serialize());
|
|
49
|
+
serializationObject.customType = "BABYLON.NormalMapProceduralTexture";
|
|
50
|
+
return serializationObject;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates a Normal Map Procedural Texture from parsed normal map procedural texture data
|
|
54
|
+
* @param parsedTexture defines parsed texture data
|
|
55
|
+
* @param scene defines the current scene
|
|
56
|
+
* @param rootUrl defines the root URL containing normal map procedural texture information
|
|
57
|
+
* @returns a parsed Normal Map Procedural Texture
|
|
58
|
+
*/
|
|
59
|
+
static Parse(parsedTexture, scene, rootUrl) {
|
|
60
|
+
const texture = SerializationHelper.Parse(() => new _a(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
|
|
61
|
+
return texture;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
(() => {
|
|
65
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
66
|
+
_get_baseTexture_decorators = [serializeAsTexture()];
|
|
67
|
+
__esDecorate(_a, null, _get_baseTexture_decorators, { kind: "getter", name: "baseTexture", static: false, private: false, access: { has: obj => "baseTexture" in obj, get: obj => obj.baseTexture }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
68
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
69
|
+
})(),
|
|
70
|
+
_a;
|
|
71
|
+
})();
|
|
72
|
+
export { NormalMapProceduralTexture };
|
|
61
73
|
RegisterClass("BABYLON.NormalMapProceduralTexture", NormalMapProceduralTexture);
|
|
62
74
|
//# sourceMappingURL=normalMapProceduralTexture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalMapProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/normalMap/normalMapProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"normalMapProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/normalMap/normalMapProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,uCAAuC,CAAC;IAElC,0BAA0B;;sBAAS,iBAAiB;;;sBAApD,0BAA2B,SAAQ,WAAiB;YAG7D,YAAY,IAAY,EAAE,IAAY,EAAE,QAAyB,IAAI,EAAE,eAAyB,EAAE,eAAyB;gBACvH,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,4BAA4B,EAAE,KAAK,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;gBAHrF,iBAAY,GADX,mDAA0B,CACL;gBAI1B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AG,EAAE,CAAC,IAAI,EAA0B,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;gBAEF,OAAO,OAAO,CAAC;YACnB,CAAC;;;;2CArCA,kBAAkB,EAAE;YACrB,sLAAW,WAAW,6DAErB;;;;;SAnCQ,0BAA0B;AAwEvC,aAAa,CAAC,oCAAoC,EAAE,0BAA0B,CAAC,CAAC","sourcesContent":["import { serializeAsTexture } 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 \"./normalMapProceduralTexture.fragment\";\r\n\r\nexport class NormalMapProceduralTexture extends ProceduralTexture {\r\n private _baseTexture: Texture;\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"normalMapProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setTexture(\"baseSampler\", this._baseTexture);\r\n this.setFloat(\"size\", this.getRenderSize() as number);\r\n }\r\n\r\n public override render(useCameraPostProcess?: boolean) {\r\n super.render(useCameraPostProcess);\r\n }\r\n\r\n public override resize(size: any, generateMipMaps: any): void {\r\n super.resize(size, generateMipMaps);\r\n\r\n // We need to update the \"size\" uniform\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public override isReady(): boolean {\r\n if (!this._baseTexture || !this._baseTexture.isReady()) {\r\n return false;\r\n }\r\n\r\n return super.isReady();\r\n }\r\n\r\n @serializeAsTexture()\r\n public get baseTexture(): Texture {\r\n return this._baseTexture;\r\n }\r\n\r\n public set baseTexture(texture: Texture) {\r\n this._baseTexture = texture;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this normal map procedural texture\r\n * @returns a serialized normal map 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.NormalMapProceduralTexture\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Normal Map Procedural Texture from parsed normal map 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 normal map procedural texture information\r\n * @returns a parsed Normal Map Procedural Texture\r\n */\r\n public static override Parse(parsedTexture: any, scene: Scene, rootUrl: string): NormalMapProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new NormalMapProceduralTexture(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.NormalMapProceduralTexture\", NormalMapProceduralTexture);\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babylonjs/procedural-textures",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.16.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@babylonjs/core": "9.
|
|
21
|
+
"@babylonjs/core": "9.16.0",
|
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
|
23
23
|
"@dev/procedural-textures": "^1.0.0"
|
|
24
24
|
},
|
|
@@ -1,66 +1,82 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __esDecorate, __runInitializers } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { serialize } from "@babylonjs/core/Misc/decorators.js";
|
|
3
3
|
import { SerializationHelper } from "@babylonjs/core/Misc/decorators.serialization.js";
|
|
4
4
|
import { ProceduralTexture } from "@babylonjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
|
|
5
5
|
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
|
6
6
|
import "./perlinNoiseProceduralTexture.fragment.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
7
|
+
let PerlinNoiseProceduralTexture = (() => {
|
|
8
|
+
var _a;
|
|
9
|
+
let _classSuper = ProceduralTexture;
|
|
10
|
+
let _time_decorators;
|
|
11
|
+
let _time_initializers = [];
|
|
12
|
+
let _time_extraInitializers = [];
|
|
13
|
+
let _timeScale_decorators;
|
|
14
|
+
let _timeScale_initializers = [];
|
|
15
|
+
let _timeScale_extraInitializers = [];
|
|
16
|
+
let _translationSpeed_decorators;
|
|
17
|
+
let _translationSpeed_initializers = [];
|
|
18
|
+
let _translationSpeed_extraInitializers = [];
|
|
19
|
+
return _a = class PerlinNoiseProceduralTexture extends _classSuper {
|
|
20
|
+
constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
|
|
21
|
+
super(name, size, "perlinNoiseProceduralTexture", scene, fallbackTexture, generateMipMaps);
|
|
22
|
+
this.time = __runInitializers(this, _time_initializers, 0.0);
|
|
23
|
+
this.timeScale = (__runInitializers(this, _time_extraInitializers), __runInitializers(this, _timeScale_initializers, 1.0));
|
|
24
|
+
this.translationSpeed = (__runInitializers(this, _timeScale_extraInitializers), __runInitializers(this, _translationSpeed_initializers, 1.0));
|
|
25
|
+
this._currentTranslation = (__runInitializers(this, _translationSpeed_extraInitializers), 0);
|
|
26
|
+
this.updateShaderUniforms();
|
|
27
|
+
}
|
|
28
|
+
updateShaderUniforms() {
|
|
29
|
+
this.setFloat("size", this.getRenderSize());
|
|
30
|
+
const scene = this.getScene();
|
|
31
|
+
if (!scene) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const deltaTime = scene.getEngine().getDeltaTime();
|
|
35
|
+
this.time += deltaTime;
|
|
36
|
+
this.setFloat("time", (this.time * this.timeScale) / 1000);
|
|
37
|
+
this._currentTranslation += (deltaTime * this.translationSpeed) / 1000.0;
|
|
38
|
+
this.setFloat("translationSpeed", this._currentTranslation);
|
|
39
|
+
}
|
|
40
|
+
render(useCameraPostProcess) {
|
|
41
|
+
this.updateShaderUniforms();
|
|
42
|
+
super.render(useCameraPostProcess);
|
|
43
|
+
}
|
|
44
|
+
resize(size, generateMipMaps) {
|
|
45
|
+
super.resize(size, generateMipMaps);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Serializes this perlin noise procedural texture
|
|
49
|
+
* @returns a serialized perlin noise procedural texture object
|
|
50
|
+
*/
|
|
51
|
+
serialize() {
|
|
52
|
+
const serializationObject = SerializationHelper.Serialize(this, super.serialize());
|
|
53
|
+
serializationObject.customType = "BABYLON.PerlinNoiseProceduralTexture";
|
|
54
|
+
return serializationObject;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a Perlin Noise Procedural Texture from parsed perlin noise procedural texture data
|
|
58
|
+
* @param parsedTexture defines parsed texture data
|
|
59
|
+
* @param scene defines the current scene
|
|
60
|
+
* @param rootUrl defines the root URL containing perlin noise procedural texture information
|
|
61
|
+
* @returns a parsed Perlin Noise Procedural Texture
|
|
62
|
+
*/
|
|
63
|
+
static Parse(parsedTexture, scene, rootUrl) {
|
|
64
|
+
const texture = SerializationHelper.Parse(() => new _a(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
|
|
65
|
+
return texture;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
(() => {
|
|
69
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
70
|
+
_time_decorators = [serialize()];
|
|
71
|
+
_timeScale_decorators = [serialize()];
|
|
72
|
+
_translationSpeed_decorators = [serialize()];
|
|
73
|
+
__esDecorate(null, null, _time_decorators, { kind: "field", name: "time", static: false, private: false, access: { has: obj => "time" in obj, get: obj => obj.time, set: (obj, value) => { obj.time = value; } }, metadata: _metadata }, _time_initializers, _time_extraInitializers);
|
|
74
|
+
__esDecorate(null, null, _timeScale_decorators, { kind: "field", name: "timeScale", static: false, private: false, access: { has: obj => "timeScale" in obj, get: obj => obj.timeScale, set: (obj, value) => { obj.timeScale = value; } }, metadata: _metadata }, _timeScale_initializers, _timeScale_extraInitializers);
|
|
75
|
+
__esDecorate(null, null, _translationSpeed_decorators, { kind: "field", name: "translationSpeed", static: false, private: false, access: { has: obj => "translationSpeed" in obj, get: obj => obj.translationSpeed, set: (obj, value) => { obj.translationSpeed = value; } }, metadata: _metadata }, _translationSpeed_initializers, _translationSpeed_extraInitializers);
|
|
76
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
77
|
+
})(),
|
|
78
|
+
_a;
|
|
79
|
+
})();
|
|
80
|
+
export { PerlinNoiseProceduralTexture };
|
|
65
81
|
RegisterClass("BABYLON.PerlinNoiseProceduralTexture", PerlinNoiseProceduralTexture);
|
|
66
82
|
//# sourceMappingURL=perlinNoiseProceduralTexture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perlinNoiseProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/perlinNoise/perlinNoiseProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"perlinNoiseProceduralTexture.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/perlinNoise/perlinNoiseProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,yCAAyC,CAAC;IAEpC,4BAA4B;;sBAAS,iBAAiB;;;;;;;;;;sBAAtD,4BAA6B,SAAQ,WAAiB;YAY/D,YAAY,IAAY,EAAE,IAAY,EAAE,QAAyB,IAAI,EAAE,eAAyB,E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mB,GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;gBACnF,mBAAmB,CAAC,UAAU,GAAG,sCAAsC,CAAC;gBAExE,OAAO,mBAAmB,CAAC;YAC/B,CAAC;YAED;;;;;;eAMG;YACI,MAAM,CAAU,KAAK,CAAC,aAAkB,EAAE,KAAY,EAAE,OAAe;gBAC1E,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CACrC,GAAG,EAAE,CAAC,IAAI,EAA4B,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EACjI,aAAa,EACb,KAAK,EACL,OAAO,CACV,CAAC;gBAEF,OAAO,OAAO,CAAC;YACnB,CAAC;;;;gCArEA,SAAS,EAAE;qCAGX,SAAS,EAAE;4CAGX,SAAS,EAAE;YALZ,8JAAO,IAAI,6BAAJ,IAAI,mFAAe;YAG1B,6KAAO,SAAS,6BAAT,SAAS,6FAAe;YAG/B,kMAAO,gBAAgB,6BAAhB,gBAAgB,2GAAe;;;;;SAR7B,4BAA4B;AAyEzC,aAAa,CAAC,sCAAsC,EAAE,4BAA4B,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 \"./perlinNoiseProceduralTexture.fragment\";\r\n\r\nexport class PerlinNoiseProceduralTexture extends ProceduralTexture {\r\n @serialize()\r\n public time: number = 0.0;\r\n\r\n @serialize()\r\n public timeScale: number = 1.0;\r\n\r\n @serialize()\r\n public translationSpeed: number = 1.0;\r\n\r\n private _currentTranslation: number = 0;\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"perlinNoiseProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setFloat(\"size\", this.getRenderSize() as number);\r\n\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n const deltaTime = scene.getEngine().getDeltaTime();\r\n\r\n this.time += deltaTime;\r\n this.setFloat(\"time\", (this.time * this.timeScale) / 1000);\r\n\r\n this._currentTranslation += (deltaTime * this.translationSpeed) / 1000.0;\r\n this.setFloat(\"translationSpeed\", this._currentTranslation);\r\n }\r\n\r\n public override render(useCameraPostProcess?: boolean) {\r\n this.updateShaderUniforms();\r\n super.render(useCameraPostProcess);\r\n }\r\n\r\n public override resize(size: any, generateMipMaps: any): void {\r\n super.resize(size, generateMipMaps);\r\n }\r\n\r\n /**\r\n * Serializes this perlin noise procedural texture\r\n * @returns a serialized perlin noise 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.PerlinNoiseProceduralTexture\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Perlin Noise Procedural Texture from parsed perlin noise 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 perlin noise procedural texture information\r\n * @returns a parsed Perlin Noise Procedural Texture\r\n */\r\n public static override Parse(parsedTexture: any, scene: Scene, rootUrl: string): PerlinNoiseProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new PerlinNoiseProceduralTexture(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.PerlinNoiseProceduralTexture\", PerlinNoiseProceduralTexture);\r\n"]}
|