tsl-textures 3.0.0 → 3.0.4
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/dist/cjs/{tsl-textures.js → tsl-textures.cjs} +549 -162
- package/dist/cjs/{tsl-textures.min.js → tsl-textures.min.cjs} +2 -2
- package/dist/tsl-textures.js +546 -165
- package/dist/tsl-textures.min.js +2 -2
- package/package.json +4 -3
- package/src/halftone.js +252 -0
- package/src/protozoa.js +1 -1
- package/src/tsl-textures.js +7 -2
- package/src/tsl-utils.js +1 -0
- package/src/waves.js +150 -0
package/src/tsl-textures.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
if ( typeof window !== 'undefined' ) {
|
|
2
|
+
|
|
3
|
+
window.__TSL_TEXTURES__ = 3.0;
|
|
4
|
+
|
|
5
|
+
}
|
|
3
6
|
|
|
4
7
|
export * from './tsl-utils.js';
|
|
5
8
|
|
|
@@ -45,6 +48,7 @@ export { translator } from './translator.js';
|
|
|
45
48
|
export { voronoiCells } from './voronoi-cells.js';
|
|
46
49
|
export { waterDrops } from './water-drops.js';
|
|
47
50
|
export { watermelon } from './watermelon.js';
|
|
51
|
+
export { waves } from './waves.js';
|
|
48
52
|
export { wood } from './wood.js';
|
|
49
53
|
export { zebraLines } from './zebra-lines.js';
|
|
50
54
|
export { circleDecor } from './circle-decor.js';
|
|
@@ -55,4 +59,5 @@ export { isolayers } from './isolayers.js';
|
|
|
55
59
|
export { turbulentSmoke } from './turbulent-smoke.js';
|
|
56
60
|
export { caustics } from './caustics.js';
|
|
57
61
|
export { bricks } from './bricks.js';
|
|
62
|
+
export { halftone } from './halftone.js';
|
|
58
63
|
//export { aaa } from './aaa.js';
|
package/src/tsl-utils.js
CHANGED
package/src/waves.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
|
|
2
|
+
// TSL-Textures: Waves
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { Color } from "three";
|
|
7
|
+
import { exp, float, Fn, mix, positionGeometry, time, vec3 } from 'three/tsl';
|
|
8
|
+
import { fractal } from './tsl-utils.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var defaults = {
|
|
12
|
+
$name: 'Waves',
|
|
13
|
+
|
|
14
|
+
position: positionGeometry,
|
|
15
|
+
scale: 2,
|
|
16
|
+
speed: 0,
|
|
17
|
+
time: time,
|
|
18
|
+
level: -0.4,
|
|
19
|
+
rough: 10,
|
|
20
|
+
height: 0.5,
|
|
21
|
+
|
|
22
|
+
foamSize: 0.2,
|
|
23
|
+
foamEdge: 0.5,
|
|
24
|
+
|
|
25
|
+
color: new Color( 0xFFFFFF ),
|
|
26
|
+
background: new Color( 0x2060FF ),
|
|
27
|
+
|
|
28
|
+
seed: 0,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
var waves_core = Fn( ([ position, scale, speed, time, level, rough, height, foamSize, /*foamEdge,*/ seed ]) => {
|
|
34
|
+
|
|
35
|
+
const xscale = exp( scale.sub( 1 ) ).toVar();
|
|
36
|
+
const pos = position.mul( xscale ).add( seed ).toVar( 'pos' );
|
|
37
|
+
const xtime = time.mul( speed.exp() );
|
|
38
|
+
|
|
39
|
+
var posXZ = vec3( pos.x, 0, pos.z ).div( 3 );
|
|
40
|
+
|
|
41
|
+
const xfoamSize = foamSize.mul( fractal( pos, rough.div( 2 ) ).div( 2 ).add( 1 ).div( 2 ) );
|
|
42
|
+
|
|
43
|
+
var xheight = height.div( xscale, 0.8 ).toVar();
|
|
44
|
+
|
|
45
|
+
var wave = position.y.sub( level )
|
|
46
|
+
.add( fractal( posXZ, 1 ).mul( 2*3.14 ).add( xtime ).sin().div( 2 ).mul( xheight ) )
|
|
47
|
+
.sub( fractal( pos, rough ).mul( 2*3.14 ).add( xtime.mul( 2 ) ).sin().sub( 1 ).div( 5 ).mul( xheight ) )
|
|
48
|
+
.smoothstep( float( 0.5 ).sub( xfoamSize ), float( 0.5 ).add( xfoamSize ) )
|
|
49
|
+
.toVar();
|
|
50
|
+
|
|
51
|
+
return wave;
|
|
52
|
+
|
|
53
|
+
} ).setLayout( {
|
|
54
|
+
name: 'waves_core',
|
|
55
|
+
type: 'float',
|
|
56
|
+
inputs: [
|
|
57
|
+
{ name: 'position', type: 'vec3' },
|
|
58
|
+
{ name: 'scale', type: 'float' },
|
|
59
|
+
{ name: 'speed', type: 'float' },
|
|
60
|
+
{ name: 'time', type: 'float' },
|
|
61
|
+
{ name: 'level', type: 'float' },
|
|
62
|
+
{ name: 'rough', type: 'float' },
|
|
63
|
+
{ name: 'height', type: 'float' },
|
|
64
|
+
{ name: 'foamSize', type: 'float' },
|
|
65
|
+
/*{ name: 'foamEdge', type: 'float' },*/
|
|
66
|
+
{ name: 'seed', type: 'float' },
|
|
67
|
+
] }
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
var wavesRaw = Fn( ([ position, scale, speed, time, level, rough, height, foamSize, /*foamEdge,*/ color, background, seed ]) => {
|
|
73
|
+
|
|
74
|
+
var k = waves_core( position, scale, speed, time, level, rough, height, foamSize, /*foamEdge,*/ seed );
|
|
75
|
+
return mix( background, color, k.clamp( 0, 1 ) );
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
} ).setLayout( {
|
|
79
|
+
name: 'wavesRaw',
|
|
80
|
+
type: 'vec3',
|
|
81
|
+
inputs: [
|
|
82
|
+
{ name: 'position', type: 'vec3' },
|
|
83
|
+
{ name: 'scale', type: 'float' },
|
|
84
|
+
{ name: 'speed', type: 'float' },
|
|
85
|
+
{ name: 'time', type: 'float' },
|
|
86
|
+
{ name: 'level', type: 'float' },
|
|
87
|
+
{ name: 'rough', type: 'float' },
|
|
88
|
+
{ name: 'height', type: 'float' },
|
|
89
|
+
{ name: 'foamSize', type: 'float' },
|
|
90
|
+
/*{ name: 'foamEdge', type: 'float' },*/
|
|
91
|
+
{ name: 'color', type: 'vec3' },
|
|
92
|
+
{ name: 'background', type: 'vec3' },
|
|
93
|
+
{ name: 'seed', type: 'float' },
|
|
94
|
+
] }
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
var wavesOpacityRaw = Fn( ([ position, scale, speed, time, level, rough, height, foamSize, foamEdge, /*color,background,*/ seed ]) => {
|
|
100
|
+
|
|
101
|
+
var k = waves_core( position, scale, speed, time, level, rough, height, foamSize, /*foamEdge,*/ seed ).oneMinus();
|
|
102
|
+
|
|
103
|
+
return k.smoothstep( 0, foamEdge.oneMinus().div( 10 ) );
|
|
104
|
+
|
|
105
|
+
} ).setLayout( {
|
|
106
|
+
name: 'wavesOpacityRaw',
|
|
107
|
+
type: 'float',
|
|
108
|
+
inputs: [
|
|
109
|
+
{ name: 'position', type: 'vec3' },
|
|
110
|
+
{ name: 'scale', type: 'float' },
|
|
111
|
+
{ name: 'speed', type: 'float' },
|
|
112
|
+
{ name: 'time', type: 'float' },
|
|
113
|
+
{ name: 'level', type: 'float' },
|
|
114
|
+
{ name: 'rough', type: 'float' },
|
|
115
|
+
{ name: 'height', type: 'float' },
|
|
116
|
+
{ name: 'foamSize', type: 'float' },
|
|
117
|
+
{ name: 'foamEdge', type: 'float' },
|
|
118
|
+
/*{ name: 'color', type: 'vec3' },*/
|
|
119
|
+
/*{ name: 'subcolor', type: 'vec3' },*/
|
|
120
|
+
{ name: 'seed', type: 'float' },
|
|
121
|
+
] }
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
function waves( params={} ) {
|
|
127
|
+
|
|
128
|
+
var { position, scale, speed, time, level, rough, height, foamSize, /*foamEdge,*/ color, background, seed } = { ...defaults, ...params };
|
|
129
|
+
|
|
130
|
+
return wavesRaw( position, scale, speed, time, level, rough, height, foamSize, /*foamEdge,*/ color, background, seed );
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
waves.opacity = function ( params={} ) {
|
|
137
|
+
|
|
138
|
+
var { position, scale, speed, time, level, rough, height, foamSize, foamEdge, /*color,background,*/seed } = { ...defaults, ...params };
|
|
139
|
+
|
|
140
|
+
return wavesOpacityRaw( position, scale, speed, time, level, rough, height, foamSize, foamEdge, /*color,background,*/seed );
|
|
141
|
+
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
waves.defaults = defaults;
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
export { waves };
|