tsl-textures 0.20.0 → 0.21.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsl-textures",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "A collection of Three.js Shading Language (TSL) textures ",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -0,0 +1,51 @@
1
+ 
2
+ // TSL-Textures: Dalmatian coat
3
+
4
+
5
+
6
+ import { Color } from "three";
7
+ import { exp, float, loop, mix, positionLocal, tslFn } from 'three/nodes';
8
+ import { noise } from 'tsl-textures/tsl-utils.js';
9
+
10
+
11
+ var dalmatianSpots = tslFn( ( params )=>{
12
+
13
+ var pos = positionLocal.mul( exp( params.scale ) ).add( params.seed ).sub( 1000 ).toVar( );
14
+
15
+ var k = float( 1 ).toVar();
16
+
17
+ var d = float( 1.5 ).sub( params.density ).mul( 2 ).toVar();
18
+ var count = params.density.mul( 5 ).add( 5 ).toVar();
19
+
20
+ loop( count, ()=> {
21
+
22
+ k.mulAssign( noise( pos ).abs().pow( d ).mul( 100 ).sub( 50 ).clamp( 0, 1 ).oneMinus() );
23
+ pos.assign( pos.mul( 1.01 ) );
24
+ k.mulAssign( noise( pos.yzx ).abs().pow( d ).mul( 100 ).sub( 50 ).clamp( 0, 1 ).oneMinus() );
25
+ pos.assign( pos.mul( 1.01 ) );
26
+ k.mulAssign( noise( pos.zxy ).abs().pow( d ).mul( 100 ).sub( 50 ).clamp( 0, 1 ).oneMinus() );
27
+ pos.assign( pos.mul( 1.01 ) );
28
+
29
+ } );
30
+
31
+ return mix( params.background, params.color, k.clamp( 0, 1 ) );
32
+
33
+ } );
34
+
35
+
36
+ dalmatianSpots.defaults = {
37
+ $name: 'Dalmatian spots',
38
+ $width: 260,
39
+
40
+ scale: 2,
41
+ density: 0.6,
42
+
43
+ color: new Color( 0xFFFFFF ),
44
+ background: new Color( 0x000000 ),
45
+
46
+ seed: 0,
47
+ };
48
+
49
+
50
+
51
+ export { dalmatianSpots };