tsl-textures 0.4.0 → 0.6.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 +1 -1
- package/src/--concrete.js +37 -0
- package/src/grid.js +49 -0
- package/src/marble.js +1 -0
- package/src/neon-lights.js +77 -0
- package/src/planet.js +130 -0
- package/src/scepter-head.js +66 -0
- package/src/scream.js +46 -0
- package/src/tsl-utils.js +36 -2
package/package.json
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
// TSL-Textures: Concrete
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
//import { Color } from "three";
|
|
7
|
+
import { abs, /*add, div,*/ exp, /*If, MeshLambertNodeMaterial, mix,*/ mul, /*oneMinus,*/ positionLocal, pow, remap, tslFn } from 'three/nodes';
|
|
8
|
+
import { /*hsl,*/ noise } from 'tsl-textures/tsl-utils.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var concrete = tslFn( ( params ) => {
|
|
13
|
+
|
|
14
|
+
var pos = positionLocal.mul( exp( params.scale ) ).add( params.seed ).toVar( );
|
|
15
|
+
|
|
16
|
+
var k = noise( pos );
|
|
17
|
+
|
|
18
|
+
//return hsl( 0, 0, mul(params.bump,pow(abs(k.div(2).add(0.5)),remap(params.density,0,1,10,0.5))) );
|
|
19
|
+
return mul( params.bump, pow( abs( k.div( 2 ).add( 0.5 ) ), remap( params.density, 0, 1, 10, 0.5 ) ) );
|
|
20
|
+
|
|
21
|
+
} );
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
concrete.defaults = {
|
|
26
|
+
$name: 'Concrete',
|
|
27
|
+
|
|
28
|
+
scale: 2,
|
|
29
|
+
density: 1,
|
|
30
|
+
bump: 1,
|
|
31
|
+
|
|
32
|
+
seed: 0,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
export { concrete };
|
package/src/grid.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
// TSL-Textures: Grid
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { Color } from "three";
|
|
7
|
+
import { abs, add, div, equirectUV, min, mix, mul, oneMinus, positionLocal, pow, remapClamp, round, sin, smoothstep, sub, tslFn } from 'three/nodes';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var grid = tslFn( ( params ) => {
|
|
12
|
+
|
|
13
|
+
var uv = equirectUV( positionLocal.normalize() ).toVar(),
|
|
14
|
+
a = mul( uv.x, 2*Math.PI ),
|
|
15
|
+
b = mul( uv.y, Math.PI ).toVar();
|
|
16
|
+
|
|
17
|
+
var uTo = div( round( mul( uv.x, params.countU ) ), params.countU ),
|
|
18
|
+
vTo = div( round( mul( uv.y, params.countV ) ), params.countV ),
|
|
19
|
+
aTo = mul( uTo, 2*Math.PI ),
|
|
20
|
+
bTo = mul( vTo, Math.PI );
|
|
21
|
+
|
|
22
|
+
var angleU = abs( sub( a, aTo ) ).mul( sin( b ) ),
|
|
23
|
+
angleV = abs( sub( b, bTo ) ),
|
|
24
|
+
angle = min( angleU, angleV );
|
|
25
|
+
|
|
26
|
+
var treshold = mul( min( div( 2*Math.PI, params.countU ), div( Math.PI, params.countV ) ), remapClamp( pow( params.thinness, 0.5 ), 0, 1, 0.9, 0.04 ), 0.5 );
|
|
27
|
+
var k = oneMinus( smoothstep( sub( treshold, 0.002 ), add( treshold, 0.002 ), angle ) );
|
|
28
|
+
|
|
29
|
+
return mix( params.background, params.color, k );
|
|
30
|
+
|
|
31
|
+
} );
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
grid.defaults = {
|
|
36
|
+
$name: 'Grid',
|
|
37
|
+
|
|
38
|
+
countU: 32,
|
|
39
|
+
countV: 16,
|
|
40
|
+
|
|
41
|
+
thinness: 0.8,
|
|
42
|
+
|
|
43
|
+
color: new Color( 0x000000 ),
|
|
44
|
+
background: new Color( 0xFFFFFF ),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export { grid };
|
package/src/marble.js
CHANGED
|
@@ -8,6 +8,7 @@ import { add, div, exp, If, mix, mul, oneMinus, positionLocal, pow, tslFn } from
|
|
|
8
8
|
import { noise } from 'tsl-textures/tsl-utils.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
|
|
11
12
|
var marble = tslFn( ( params ) => {
|
|
12
13
|
|
|
13
14
|
var pos = positionLocal.mul( exp( params.scale ) ).add( params.seed ).toVar( );
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
|
|
2
|
+
// TSL-Textures: Neon Lights
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { Color } from "three";
|
|
7
|
+
import { abs, cond, exp, oneMinus, positionLocal, sqrt, tslFn, vec3 } from 'three/nodes';
|
|
8
|
+
import { hsl, noise, toHsl } from 'tsl-textures/tsl-utils.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var neonLights = tslFn( ( params ) => {
|
|
13
|
+
|
|
14
|
+
var pos = positionLocal;//.mul( exp( params.scale ) ).add( params.seed ).toVar( );
|
|
15
|
+
|
|
16
|
+
var scale = exp( params.scale.remap( 0, 4, 2, -2 ) ).toVar();
|
|
17
|
+
var thinness = exp( params.thinness.remap( 0, 1, 1.5, 0 ) ).toVar();
|
|
18
|
+
|
|
19
|
+
var color = params.background.toVar();
|
|
20
|
+
var neon = vec3( 0 ).toVar();
|
|
21
|
+
|
|
22
|
+
var x = noise( pos.xyz ).toVar();
|
|
23
|
+
var y = noise( pos.yzx ).toVar();
|
|
24
|
+
var z = noise( pos.zxy ).toVar();
|
|
25
|
+
|
|
26
|
+
var k = noise( vec3( x, y, z ).mul( scale ).add( params.seed ) ).toVar();
|
|
27
|
+
k.assign( oneMinus( sqrt( abs( k ) ) ).pow( 3 ) );
|
|
28
|
+
|
|
29
|
+
neon.assign( params.colorA );
|
|
30
|
+
var HSL = toHsl( neon );
|
|
31
|
+
neon.assign( hsl( HSL.x, HSL.y, HSL.z.mul( k ) ) );
|
|
32
|
+
|
|
33
|
+
color.addAssign( cond( params.mode.equal( 0 ), neon, neon.negate() ).mul( thinness ) );
|
|
34
|
+
|
|
35
|
+
k.assign( noise( vec3( y, z, x ).mul( scale ).sub( params.seed ) ) );
|
|
36
|
+
k.assign( oneMinus( sqrt( abs( k ) ) ).pow( 3 ) );
|
|
37
|
+
|
|
38
|
+
neon.assign( params.colorB );
|
|
39
|
+
var HSL = toHsl( neon );
|
|
40
|
+
neon.assign( hsl( HSL.x, HSL.y, HSL.z.mul( k ) ) );
|
|
41
|
+
|
|
42
|
+
color.addAssign( cond( params.mode.equal( 0 ), neon, neon.negate() ).mul( thinness ) );
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
k.assign( noise( vec3( z, x, y.negate() ).mul( scale ).add( params.seed ) ) );
|
|
46
|
+
k.assign( oneMinus( sqrt( abs( k ) ) ).pow( 3 ) );
|
|
47
|
+
|
|
48
|
+
neon.assign( params.colorC );
|
|
49
|
+
var HSL = toHsl( neon );
|
|
50
|
+
neon.assign( hsl( HSL.x, HSL.y, HSL.z.mul( k ) ) );
|
|
51
|
+
|
|
52
|
+
color.addAssign( cond( params.mode.equal( 0 ), neon, neon.negate() ).mul( thinness ) );
|
|
53
|
+
|
|
54
|
+
return color;
|
|
55
|
+
|
|
56
|
+
} );
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
neonLights.defaults = {
|
|
61
|
+
$name: 'Neon Lights',
|
|
62
|
+
|
|
63
|
+
scale: 1.5,
|
|
64
|
+
thinness: 0.8,
|
|
65
|
+
mode: 0, // 0=additive, 1=subtractive
|
|
66
|
+
|
|
67
|
+
colorA: new Color( 0xFF0000 ),
|
|
68
|
+
colorB: new Color( 0x00FF00 ),
|
|
69
|
+
colorC: new Color( 0x0000FF ),
|
|
70
|
+
background: new Color( 0x000000 ),
|
|
71
|
+
|
|
72
|
+
seed: 0,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
export { neonLights };
|
package/src/planet.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
|
|
2
|
+
// TSL-Textures: Planet
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { Color } from 'three';
|
|
7
|
+
import { exp, float, If, loop, mix, mul, positionLocal, remap, smoothstep, tslFn, vec3 } from 'three/nodes';
|
|
8
|
+
import { noise } from 'tsl-textures/tsl-utils.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var planet = tslFn( ( params )=>{
|
|
14
|
+
|
|
15
|
+
var k = float( 0 ).toVar(),
|
|
16
|
+
sum = float( 0 ).toVar(),
|
|
17
|
+
scale = exp( params.scale.sub( 2 ) ).toVar(),
|
|
18
|
+
power = float( 2 ).toVar();
|
|
19
|
+
|
|
20
|
+
loop( params.iterations.add( 10 ), ()=>{
|
|
21
|
+
|
|
22
|
+
k.addAssign( mul( power, noise( positionLocal.mul( scale ).add( params.seed ) ) ) );
|
|
23
|
+
sum.addAssign( power );
|
|
24
|
+
scale.mulAssign( 1.5 );
|
|
25
|
+
power.mulAssign( 0.8 );
|
|
26
|
+
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
k.assign( mul( k, k, 0.5 ).div( sum ) );
|
|
30
|
+
|
|
31
|
+
var levelSea = params.levelSea.pow( 2 ).toVar();
|
|
32
|
+
var levelMountain = params.levelMountain.pow( 2 ).toVar();
|
|
33
|
+
var levelSand = mix( levelSea, levelMountain, params.balanceSand ).toVar();
|
|
34
|
+
var levelCoast = mix( levelSea, levelSand, 0.4 ).toVar();
|
|
35
|
+
var levelGrass = mix( levelSea, levelSand, 0.6 ).toVar();
|
|
36
|
+
|
|
37
|
+
var color = vec3().toVar();
|
|
38
|
+
|
|
39
|
+
// process water
|
|
40
|
+
If( k.lessThan( levelSea ), ()=>{
|
|
41
|
+
|
|
42
|
+
// deep-shallow
|
|
43
|
+
color.assign( mix(
|
|
44
|
+
params.colorDeep,
|
|
45
|
+
params.colorShallow,
|
|
46
|
+
remap( k, 0, levelSea, 0, 1 ).pow( exp( params.balanceWater.mul( -8 ).add( 4 ) ) )
|
|
47
|
+
) );
|
|
48
|
+
|
|
49
|
+
} )
|
|
50
|
+
.elseif( k.lessThan( levelCoast ), ()=>{
|
|
51
|
+
|
|
52
|
+
// shallow-sand
|
|
53
|
+
color.assign( mix(
|
|
54
|
+
params.colorShallow,
|
|
55
|
+
params.colorBeach,
|
|
56
|
+
remap( k, levelSea, levelCoast )
|
|
57
|
+
) );
|
|
58
|
+
|
|
59
|
+
} )
|
|
60
|
+
.elseif( k.lessThan( levelGrass ), ()=>{
|
|
61
|
+
|
|
62
|
+
// sand
|
|
63
|
+
color.assign( params.colorBeach );
|
|
64
|
+
|
|
65
|
+
} )
|
|
66
|
+
.elseif( k.lessThan( levelSand ), ()=>{
|
|
67
|
+
|
|
68
|
+
// shallow-sand-grass
|
|
69
|
+
color.assign( mix(
|
|
70
|
+
params.colorBeach,
|
|
71
|
+
params.colorGrass,
|
|
72
|
+
remap( k, levelGrass, levelSand )
|
|
73
|
+
) );
|
|
74
|
+
|
|
75
|
+
} )
|
|
76
|
+
.elseif( k.lessThan( levelMountain ), ()=>{
|
|
77
|
+
|
|
78
|
+
// grass-forest
|
|
79
|
+
color.assign( mix(
|
|
80
|
+
params.colorGrass,
|
|
81
|
+
params.colorForest,
|
|
82
|
+
remap( k, levelSand, levelMountain ).pow( 0.75 )
|
|
83
|
+
) );
|
|
84
|
+
|
|
85
|
+
} )
|
|
86
|
+
.else( ()=>{
|
|
87
|
+
|
|
88
|
+
// forest-snow
|
|
89
|
+
var levelSnow = mix( 1, levelMountain, params.balanceSnow );
|
|
90
|
+
color.assign( mix(
|
|
91
|
+
params.colorForest,
|
|
92
|
+
params.colorSnow,
|
|
93
|
+
smoothstep( mix( levelSnow, levelMountain, params.balanceSnow.pow( 0.5 ) ), levelSnow, k )
|
|
94
|
+
) );
|
|
95
|
+
|
|
96
|
+
} );
|
|
97
|
+
|
|
98
|
+
return color;
|
|
99
|
+
|
|
100
|
+
} );
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
planet.defaults = {
|
|
105
|
+
$name: 'Planet',
|
|
106
|
+
|
|
107
|
+
scale: 2,
|
|
108
|
+
|
|
109
|
+
iterations: 5,
|
|
110
|
+
|
|
111
|
+
levelSea: 0.3,
|
|
112
|
+
levelMountain: 0.7,
|
|
113
|
+
|
|
114
|
+
balanceWater: 0.3,
|
|
115
|
+
balanceSand: 0.2,
|
|
116
|
+
balanceSnow: 0.8,
|
|
117
|
+
|
|
118
|
+
colorDeep: new Color( 0x123a59 ).convertLinearToSRGB(), // SteelBlue
|
|
119
|
+
colorShallow: new Color( 0x87CEEB ).convertLinearToSRGB(), // SkyBlue
|
|
120
|
+
colorBeach: new Color( 0xFFFACD ).convertLinearToSRGB(), // LemonChiffon
|
|
121
|
+
colorGrass: new Color( 0x3CB371 ).convertLinearToSRGB(), // MediumSeaGreen
|
|
122
|
+
colorForest: new Color( 0x003000 ).convertLinearToSRGB(), // Dark green
|
|
123
|
+
colorSnow: new Color( 0xF0FFFF ).convertLinearToSRGB(), // Azure
|
|
124
|
+
|
|
125
|
+
seed: 0,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
export { planet };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
|
|
2
|
+
// TSL-Textures: Scepter Head
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { Color } from "three";
|
|
7
|
+
import { abs, add, cos, floor, max, mix, mul, positionLocal, remapClamp, sign, tan, tslFn, vec3 } from 'three/nodes';
|
|
8
|
+
import { hsl, mod, noise, remapExp, toHsl } from 'tsl-textures/tsl-utils.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var scepterHead = tslFn( ( params ) => {
|
|
13
|
+
|
|
14
|
+
var pos = positionLocal;
|
|
15
|
+
|
|
16
|
+
var fx = pos.x.mul( remapExp( params.xFactor, 0, 100, 1.35, 30 ) ).toVar( ),
|
|
17
|
+
fy = pos.y.mul( remapExp( params.yFactor, 0, 100, 1.35, 30 ) ).toVar( ),
|
|
18
|
+
fz = pos.z.mul( remapExp( params.zFactor, 0, 100, 1.35, 30 ) ).toVar( );
|
|
19
|
+
|
|
20
|
+
var cosX = cos( fx ).toVar(),
|
|
21
|
+
cosY = cos( fy ).toVar(),
|
|
22
|
+
cosZ = cos( fz ).toVar();
|
|
23
|
+
|
|
24
|
+
var k = noise( vec3( pos.x.div( cosX ), pos.y.div( cosY ), pos.z.div( cosZ ) ) );
|
|
25
|
+
|
|
26
|
+
k = sign( k ).mul( abs( k ).pow( 0.75 ) );
|
|
27
|
+
|
|
28
|
+
var dx = abs( mul( fx, tan( fx ) ).add( 1 ).div( cos( fx ) ) ),
|
|
29
|
+
dy = abs( mul( fy, tan( fy ) ).add( 1 ).div( cos( fy ) ) ),
|
|
30
|
+
dz = abs( mul( fz, tan( fz ) ).add( 1 ).div( cos( fz ) ) );
|
|
31
|
+
|
|
32
|
+
var HSL = vec3().toVar();
|
|
33
|
+
|
|
34
|
+
var indexX = ( abs( floor( ( fx.mul( 2/Math.PI ).add( 1 ) ).div( 2 ) ) ) ),
|
|
35
|
+
indexY = ( abs( floor( ( fy.mul( 2/Math.PI ).add( 1 ) ).div( 2 ) ) ) ),
|
|
36
|
+
indexZ = ( abs( floor( ( fz.mul( 2/Math.PI ).add( 1 ) ).div( 2 ) ) ) );
|
|
37
|
+
|
|
38
|
+
var index = mod( ( add( indexX, indexY, indexZ ) ), 2 );
|
|
39
|
+
|
|
40
|
+
HSL.assign( toHsl( mix( params.colorA, params.colorB, index ) ) );
|
|
41
|
+
var color1 = hsl( HSL.x, HSL.y, HSL.z.mul( k ) ).toVar();
|
|
42
|
+
|
|
43
|
+
HSL.assign( toHsl( params.colorRim ) );
|
|
44
|
+
var color2 = hsl( HSL.x, HSL.y, mul( 2, k, HSL.z ) ).toVar();
|
|
45
|
+
|
|
46
|
+
return mix( color1, color2, remapClamp( max( dx, max( dy, dz ) ), 55-10, 55+10 ) );
|
|
47
|
+
|
|
48
|
+
} );
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
scepterHead.defaults = {
|
|
53
|
+
$name: 'Scepter head',
|
|
54
|
+
|
|
55
|
+
xFactor: 10,
|
|
56
|
+
yFactor: 22,
|
|
57
|
+
zFactor: 10,
|
|
58
|
+
|
|
59
|
+
colorRim: new Color( 0xFFFFFF ),
|
|
60
|
+
colorA: new Color( 0x70E0FF ),
|
|
61
|
+
colorB: new Color( 0x3000FF ),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
export { scepterHead };
|
package/src/scream.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
// TSL-Textures: Scream
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { Color } from "three";
|
|
7
|
+
import { add, cos, exp, mix, positionLocal, sin, tslFn } from 'three/nodes';
|
|
8
|
+
import { hsl, noise, toHsl } from 'tsl-textures/tsl-utils.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var scream = tslFn( ( params ) => {
|
|
13
|
+
|
|
14
|
+
var pos = positionLocal.mul( exp( params.scale ) ).add( params.seed ).toVar( );
|
|
15
|
+
|
|
16
|
+
var k = noise( add( sin( pos.xyz ), cos( pos.yzx ) ) );
|
|
17
|
+
|
|
18
|
+
pos.assign( positionLocal.mul( exp( params.scale ).mul( k ) ).add( params.seed ) );
|
|
19
|
+
|
|
20
|
+
var k = noise( add( sin( pos.xyz ), cos( pos.yzx ) ).mul( 2 ) );
|
|
21
|
+
|
|
22
|
+
var col = mix( params.background, params.color, k ).toVar();
|
|
23
|
+
|
|
24
|
+
var HSL = toHsl( col ).toVar();
|
|
25
|
+
|
|
26
|
+
return hsl( add( HSL.x, params.variety.mul( sin( k.mul( Math.PI ) ) ).mul( 0.5 ) ), HSL.y, HSL.z );
|
|
27
|
+
|
|
28
|
+
} );
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
scream.defaults = {
|
|
33
|
+
$name: 'Scream',
|
|
34
|
+
|
|
35
|
+
scale: 2,
|
|
36
|
+
variety: 1,
|
|
37
|
+
|
|
38
|
+
color: new Color( 0xF0F060 ),
|
|
39
|
+
background: new Color( 0xD09090 ),
|
|
40
|
+
|
|
41
|
+
seed: 0,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export { scream };
|
package/src/tsl-utils.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
import { add, cond, cos, cross, float, If, max, min, mul, sin, sub, tslFn, uniform, vec3, vec4 } from 'three/nodes';
|
|
11
|
+
import { add, cond, cos, cross, div, float, floor, If, log2, max, min, mul, pow, remap, sin, sub, tslFn, uniform, vec3, vec4 } from 'three/nodes';
|
|
12
12
|
import { mx_perlin_noise_float as noise } from 'three/addons/nodes/materialx/lib/mx_noise.js';
|
|
13
13
|
|
|
14
14
|
|
|
@@ -187,6 +187,38 @@ const applyQuaternion = tslFn( ([ vec, quat ]) => {
|
|
|
187
187
|
} );
|
|
188
188
|
|
|
189
189
|
|
|
190
|
+
// calculate modulo (missing in TSL?)
|
|
191
|
+
const mod = tslFn( ([ x, y ]) => {
|
|
192
|
+
|
|
193
|
+
return sub( x, floor( div( x, y ) ).mul( y ) );
|
|
194
|
+
|
|
195
|
+
} );
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
// exponential version of remap
|
|
200
|
+
const remapExp = tslFn( ([ x, fromMin, fromMax, toMin, toMax ]) => {
|
|
201
|
+
|
|
202
|
+
x = remap( x, fromMin, fromMax, 0, 1 );
|
|
203
|
+
x = pow( 2, mul( x, log2( toMax.div( toMin ) ) ).add( log2( toMin ) ) );
|
|
204
|
+
return x;
|
|
205
|
+
/*
|
|
206
|
+
|
|
207
|
+
function mapExp( x, toMin, toMax, fromMin=0, fromMax=100 ) {
|
|
208
|
+
|
|
209
|
+
x = map( x, 0, 1, fromMin, fromMax );
|
|
210
|
+
x = 2**( x * Math.log2( toMax/toMin ) + Math.log2( toMin ) );
|
|
211
|
+
|
|
212
|
+
return x;
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
} );
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
190
222
|
export
|
|
191
223
|
{
|
|
192
224
|
noise,
|
|
@@ -194,5 +226,7 @@ export
|
|
|
194
226
|
toHsl,
|
|
195
227
|
dynamic,
|
|
196
228
|
spherical,
|
|
197
|
-
applyEuler
|
|
229
|
+
applyEuler,
|
|
230
|
+
mod,
|
|
231
|
+
remapExp
|
|
198
232
|
};
|