Skip to content

Commit 9ca9fbe

Browse files
fix to the automation, and style fiexs
1 parent f206316 commit 9ca9fbe

File tree

3 files changed

+54
-17
lines changed

3 files changed

+54
-17
lines changed

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@
167167
"require": "./lib/simple-lightmap/index.js",
168168
"types": "./lib/simple-lightmap/index.d.ts"
169169
},
170+
"./simplex-noise": {
171+
"import": "./lib/simplex-noise/index.mjs",
172+
"require": "./lib/simplex-noise/index.js",
173+
"types": "./lib/simplex-noise/index.d.ts"
174+
},
170175
"./tilt-shift": {
171176
"import": "./lib/tilt-shift/index.mjs",
172177
"require": "./lib/tilt-shift/index.js",

scripts/screenshots/config.json

+8
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,14 @@
585585
"arguments": {
586586
"strength": 4
587587
}
588+
},
589+
{
590+
"name": "SimplexNoiseFilter",
591+
"filename": "simplex-noise",
592+
"arguments": {
593+
"strength": 0.5,
594+
"noiseScale": 10
595+
}
588596
}
589597
]
590598
}

src/simplex-noise/SimplexNoiseFilter.ts

+41-17
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,48 @@ import { vertex, wgslVertex } from '../defaults';
33
import fragment from './simplex.frag';
44
import source from './simplex.wgsl';
55

6-
76
/** Options for the SimplexNoiseFilter constructor. */
87
export interface SimplexNoiseFilterOptions
98
{
109
/**
1110
* Noise map strength.
1211
* @default 0.5
1312
*/
14-
strength?: 0.5;
13+
strength?: number;
1514
/**
1615
* Noise map scale.
17-
* @default 10
16+
* @default 10.0
1817
*/
19-
noiseScale?: 10;
18+
noiseScale?: number;
2019
/**
21-
* Horizontal offset for the noise map.
20+
* Horizontal offset for the noise map.
2221
* @default 0
2322
*/
24-
offsetX?: 0;
23+
offsetX?: number;
2524
/**
2625
* Vertical offset for the noise map.
2726
* @default 0
2827
*/
29-
offsetY?: 0;
28+
offsetY?: number;
3029
/**
3130
* Depth offset for the noise map.
3231
* @default 0
3332
*/
34-
offsetZ?: 0;
33+
offsetZ?: number;
3534
/**
3635
* The threshold used with the step function to create a blocky effect in the noise pattern.
37-
* When this is greater than 0, the step function is used to compare the noise value to this threshold.
36+
* When this is greater than 0, the step function is used to compare the noise value to this threshold.
3837
* @default -1
3938
*/
40-
step?: -1;
39+
step?: number;
4140
}
4241

4342
/**
4443
* The SimplexNoiseFilter multiplies simplex noise with the current texture data. <br>
4544
*
46-
*
4745
* @class
4846
* @extends Filter
47+
* @see {@link https://www.npmjs.com/package/pixi-filters|pixi-filters}
4948
*/
5049
export class SimplexNoiseFilter extends Filter
5150
{
@@ -88,32 +87,57 @@ export class SimplexNoiseFilter extends Filter
8887
glProgram,
8988
resources: {
9089
simplexUniforms: {
91-
uStrength: { value: options.strength ?? 0, type: 'f32' },
92-
uNoiseScale: { value: options.noiseScale ?? 0, type: 'f32' },
93-
uOffsetX: { value: options.offsetX ?? 0, type: 'f32' },
94-
uOffsetY: { value: options.offsetY ?? 0, type: 'f32' },
95-
uOffsetZ: { value: options.offsetZ ?? 0, type: 'f32' },
96-
uStep: { value: options.step ?? 0, type: 'f32' },
90+
uStrength: { value: options?.strength ?? 0, type: 'f32' },
91+
uNoiseScale: { value: options?.noiseScale ?? 0, type: 'f32' },
92+
uOffsetX: { value: options?.offsetX ?? 0, type: 'f32' },
93+
uOffsetY: { value: options?.offsetY ?? 0, type: 'f32' },
94+
uOffsetZ: { value: options?.offsetZ ?? 0, type: 'f32' },
95+
uStep: { value: options?.step ?? 0, type: 'f32' },
9796
}
9897
}
9998
});
10099
}
101100

101+
/**
102+
* Strength of the noise (color = (noiseMap + strength) * texture)
103+
* @default 0.5
104+
*/
102105
get strength(): number { return this.resources.simplexUniforms.uniforms.uStrength; }
103106
set strength(value: number) { this.resources.simplexUniforms.uniforms.uStrength = value; }
104107

108+
/**
109+
* Noise map scale.
110+
* @default 10
111+
*/
105112
get noiseScale(): number { return this.resources.simplexUniforms.uniforms.uNoiseScale; }
106113
set noiseScale(value: number) { this.resources.simplexUniforms.uniforms.uNoiseScale = value; }
107114

115+
/**
116+
* Horizontal offset for the noise map.
117+
* @default 0
118+
*/
108119
get offsetX(): number { return this.resources.simplexUniforms.uniforms.uOffsetX; }
109120
set offsetX(value: number) { this.resources.simplexUniforms.uniforms.uOffsetX = value; }
110121

122+
/**
123+
* Vertical offset for the noise map.
124+
* @default 0
125+
*/
111126
get offsetY(): number { return this.resources.simplexUniforms.uniforms.uOffsetY; }
112127
set offsetY(value: number) { this.resources.simplexUniforms.uniforms.uOffsetY = value; }
113128

129+
/**
130+
* Depth offset for the noise map.
131+
* @default 0
132+
*/
114133
get offsetZ(): number { return this.resources.simplexUniforms.uniforms.uOffsetZ; }
115134
set offsetZ(value: number) { this.resources.simplexUniforms.uniforms.uOffsetZ = value; }
116135

136+
/**
137+
* The threshold used with the step function to create a blocky effect in the noise pattern.
138+
* When this is greater than 0, the step function is used to compare the noise value to this threshold.
139+
* @default -1
140+
*/
117141
get step(): number { return this.resources.simplexUniforms.uniforms.uStep; }
118142
set step(value: number) { this.resources.simplexUniforms.uniforms.uStep = value; }
119143
}

0 commit comments

Comments
 (0)