laymur 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/README.md +20 -3
- package/dist/_virtual/2d.js +3 -0
- package/dist/_virtual/3d.js +3 -0
- package/dist/_virtual/4d.js +3 -0
- package/dist/_virtual/mod.js +5 -0
- package/dist/_virtual/mod2.js +3 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +0 -1
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +0 -1
- package/dist/core/elements/UIElement/UIElement.Internal.d.ts +22 -0
- package/dist/core/elements/UIElement/UIElement.Internal.js +21 -1
- package/dist/core/elements/UIElement/UIElement.d.ts +24 -0
- package/dist/core/elements/UIElement/UIElement.js +61 -2
- package/dist/core/elements/UIProgress/UIProgress.js +2 -1
- package/dist/core/elements/UIText/UIText.js +1 -8
- package/dist/core/index.d.ts +1 -0
- package/dist/core/miscellaneous/UIBlendMode.d.ts +7 -0
- package/dist/core/miscellaneous/UIBlendMode.js +10 -0
- package/dist/core/miscellaneous/UIRelation.d.ts +2 -2
- package/dist/core/miscellaneous/UIRelation.js +2 -2
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +50 -6
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +3 -1
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +80 -60
- package/dist/core/miscellaneous/generic-plane/shared.d.ts +9 -0
- package/dist/core/miscellaneous/generic-plane/shared.js +66 -2
- package/dist/core/miscellaneous/webglCapabilities.js +0 -1
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +2 -0
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +4 -2
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.d.ts +4 -2
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +8 -2
- package/dist/debug/UIAspectDebug.js +1 -1
- package/dist/index.js +1 -0
- package/dist/node_modules/fast-simplex-noise/lib/2d.js +93 -0
- package/dist/node_modules/fast-simplex-noise/lib/3d.js +142 -0
- package/dist/node_modules/fast-simplex-noise/lib/4d.js +196 -0
- package/dist/node_modules/fast-simplex-noise/lib/mod.js +24 -0
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +3 -3
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +3 -3
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +0 -3
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +0 -1
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +0 -1
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +1 -3
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +0 -1
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +1 -3
- package/dist/particles/miscellaneous/miscellaneous.d.ts +1 -1
- package/dist/particles/miscellaneous/miscellaneous.js +2 -4
- package/package.json +5 -3
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { __exports as _3d } from '../../../_virtual/3d.js';
|
|
2
|
+
|
|
3
|
+
var hasRequired_3d;
|
|
4
|
+
|
|
5
|
+
function require_3d () {
|
|
6
|
+
if (hasRequired_3d) return _3d;
|
|
7
|
+
hasRequired_3d = 1;
|
|
8
|
+
/*
|
|
9
|
+
* Based on example code by Stefan Gustavson (stegu@itn.liu.se).
|
|
10
|
+
* Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).
|
|
11
|
+
* Better rank ordering method by Stefan Gustavson in 2012.
|
|
12
|
+
*
|
|
13
|
+
* This code was placed in the public domain by its original author,
|
|
14
|
+
* Stefan Gustavson. You may use it as you see fit, but
|
|
15
|
+
* attribution is appreciated.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(_3d, "__esModule", { value: true });
|
|
18
|
+
_3d.makeNoise3D = void 0;
|
|
19
|
+
var G3 = 1.0 / 6.0;
|
|
20
|
+
var Grad = [
|
|
21
|
+
[1, 1, 0],
|
|
22
|
+
[-1, 1, 0],
|
|
23
|
+
[1, -1, 0],
|
|
24
|
+
[-1, -1, 0],
|
|
25
|
+
[1, 0, 1],
|
|
26
|
+
[-1, 0, 1],
|
|
27
|
+
[1, 0, -1],
|
|
28
|
+
[-1, 0, -1],
|
|
29
|
+
[0, 1, 1],
|
|
30
|
+
[0, -1, -1],
|
|
31
|
+
[0, 1, -1],
|
|
32
|
+
[0, -1, -1],
|
|
33
|
+
];
|
|
34
|
+
function makeNoise3D(random) {
|
|
35
|
+
if (random === void 0) { random = Math.random; }
|
|
36
|
+
var p = new Uint8Array(256);
|
|
37
|
+
for (var i = 0; i < 256; i++)
|
|
38
|
+
p[i] = i;
|
|
39
|
+
var n;
|
|
40
|
+
var q;
|
|
41
|
+
for (var i = 255; i > 0; i--) {
|
|
42
|
+
n = Math.floor((i + 1) * random());
|
|
43
|
+
q = p[i];
|
|
44
|
+
p[i] = p[n];
|
|
45
|
+
p[n] = q;
|
|
46
|
+
}
|
|
47
|
+
var perm = new Uint8Array(512);
|
|
48
|
+
var permMod12 = new Uint8Array(512);
|
|
49
|
+
for (var i = 0; i < 512; i++) {
|
|
50
|
+
perm[i] = p[i & 255];
|
|
51
|
+
permMod12[i] = perm[i] % 12;
|
|
52
|
+
}
|
|
53
|
+
return function (x, y, z) {
|
|
54
|
+
// Skew the input space to determine which simplex cell we're in
|
|
55
|
+
var s = (x + y + z) / 3.0; // Very nice and simple skew factor for 3D
|
|
56
|
+
var i = Math.floor(x + s);
|
|
57
|
+
var j = Math.floor(y + s);
|
|
58
|
+
var k = Math.floor(z + s);
|
|
59
|
+
var t = (i + j + k) * G3;
|
|
60
|
+
var X0 = i - t; // Unskew the cell origin back to (x,y,z) space
|
|
61
|
+
var Y0 = j - t;
|
|
62
|
+
var Z0 = k - t;
|
|
63
|
+
var x0 = x - X0; // The x,y,z distances from the cell origin
|
|
64
|
+
var y0 = y - Y0;
|
|
65
|
+
var z0 = z - Z0;
|
|
66
|
+
// Deterine which simplex we are in
|
|
67
|
+
var i1, j1, k1 // Offsets for second corner of simplex in (i,j,k) coords
|
|
68
|
+
;
|
|
69
|
+
var i2, j2, k2 // Offsets for third corner of simplex in (i,j,k) coords
|
|
70
|
+
;
|
|
71
|
+
if (x0 >= y0) {
|
|
72
|
+
if (y0 >= z0) {
|
|
73
|
+
i1 = i2 = j2 = 1;
|
|
74
|
+
j1 = k1 = k2 = 0;
|
|
75
|
+
}
|
|
76
|
+
else if (x0 >= z0) {
|
|
77
|
+
i1 = i2 = k2 = 1;
|
|
78
|
+
j1 = k1 = j2 = 0;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
k1 = i2 = k2 = 1;
|
|
82
|
+
i1 = j1 = j2 = 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
if (y0 < z0) {
|
|
87
|
+
k1 = j2 = k2 = 1;
|
|
88
|
+
i1 = j1 = i2 = 0;
|
|
89
|
+
}
|
|
90
|
+
else if (x0 < z0) {
|
|
91
|
+
j1 = j2 = k2 = 1;
|
|
92
|
+
i1 = k1 = i2 = 0;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
j1 = i2 = j2 = 1;
|
|
96
|
+
i1 = k1 = k2 = 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
var x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords
|
|
100
|
+
var y1 = y0 - j1 + G3;
|
|
101
|
+
var z1 = z0 - k1 + G3;
|
|
102
|
+
var x2 = x0 - i2 + 2.0 * G3; // Offsets for third corner in (x,y,z) coords
|
|
103
|
+
var y2 = y0 - j2 + 2.0 * G3;
|
|
104
|
+
var z2 = z0 - k2 + 2.0 * G3;
|
|
105
|
+
var x3 = x0 - 1.0 + 3.0 * G3; // Offsets for last corner in (x,y,z) coords
|
|
106
|
+
var y3 = y0 - 1.0 + 3.0 * G3;
|
|
107
|
+
var z3 = z0 - 1.0 + 3.0 * G3;
|
|
108
|
+
// Work out the hashed gradient indices of the four simplex corners
|
|
109
|
+
var ii = i & 255;
|
|
110
|
+
var jj = j & 255;
|
|
111
|
+
var kk = k & 255;
|
|
112
|
+
var g0 = Grad[permMod12[ii + perm[jj + perm[kk]]]];
|
|
113
|
+
var g1 = Grad[permMod12[ii + i1 + perm[jj + j1 + perm[kk + k1]]]];
|
|
114
|
+
var g2 = Grad[permMod12[ii + i2 + perm[jj + j2 + perm[kk + k2]]]];
|
|
115
|
+
var g3 = Grad[permMod12[ii + 1 + perm[jj + 1 + perm[kk + 1]]]];
|
|
116
|
+
// Calculate the contribution from the four corners
|
|
117
|
+
var t0 = 0.5 - x0 * x0 - y0 * y0 - z0 * z0;
|
|
118
|
+
var n0 = t0 < 0
|
|
119
|
+
? 0.0
|
|
120
|
+
: Math.pow(t0, 4) * (g0[0] * x0 + g0[1] * y0 + g0[2] * z0);
|
|
121
|
+
var t1 = 0.5 - x1 * x1 - y1 * y1 - z1 * z1;
|
|
122
|
+
var n1 = t1 < 0
|
|
123
|
+
? 0.0
|
|
124
|
+
: Math.pow(t1, 4) * (g1[0] * x1 + g1[1] * y1 + g1[2] * z1);
|
|
125
|
+
var t2 = 0.5 - x2 * x2 - y2 * y2 - z2 * z2;
|
|
126
|
+
var n2 = t2 < 0
|
|
127
|
+
? 0.0
|
|
128
|
+
: Math.pow(t2, 4) * (g2[0] * x2 + g2[1] * y2 + g2[2] * z2);
|
|
129
|
+
var t3 = 0.5 - x3 * x3 - y3 * y3 - z3 * z3;
|
|
130
|
+
var n3 = t3 < 0
|
|
131
|
+
? 0.0
|
|
132
|
+
: Math.pow(t3, 4) * (g3[0] * x3 + g3[1] * y3 + g3[2] * z3);
|
|
133
|
+
// Add contributions from each corner to get the final noise value.
|
|
134
|
+
// The result is scaled to stay just inside [-1,1]
|
|
135
|
+
return 94.68493150681972 * (n0 + n1 + n2 + n3);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
_3d.makeNoise3D = makeNoise3D;
|
|
139
|
+
return _3d;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export { require_3d as __require };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { __exports as _4d } from '../../../_virtual/4d.js';
|
|
2
|
+
|
|
3
|
+
var hasRequired_4d;
|
|
4
|
+
|
|
5
|
+
function require_4d () {
|
|
6
|
+
if (hasRequired_4d) return _4d;
|
|
7
|
+
hasRequired_4d = 1;
|
|
8
|
+
/*
|
|
9
|
+
* Based on example code by Stefan Gustavson (stegu@itn.liu.se).
|
|
10
|
+
* Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).
|
|
11
|
+
* Better rank ordering method by Stefan Gustavson in 2012.
|
|
12
|
+
*
|
|
13
|
+
* This code was placed in the public domain by its original author,
|
|
14
|
+
* Stefan Gustavson. You may use it as you see fit, but
|
|
15
|
+
* attribution is appreciated.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(_4d, "__esModule", { value: true });
|
|
18
|
+
_4d.makeNoise4D = void 0;
|
|
19
|
+
var G4 = (5.0 - Math.sqrt(5.0)) / 20.0;
|
|
20
|
+
var Grad = [
|
|
21
|
+
[0, 1, 1, 1],
|
|
22
|
+
[0, 1, 1, -1],
|
|
23
|
+
[0, 1, -1, 1],
|
|
24
|
+
[0, 1, -1, -1],
|
|
25
|
+
[0, -1, 1, 1],
|
|
26
|
+
[0, -1, 1, -1],
|
|
27
|
+
[0, -1, -1, 1],
|
|
28
|
+
[0, -1, -1, -1],
|
|
29
|
+
[1, 0, 1, 1],
|
|
30
|
+
[1, 0, 1, -1],
|
|
31
|
+
[1, 0, -1, 1],
|
|
32
|
+
[1, 0, -1, -1],
|
|
33
|
+
[-1, 0, 1, 1],
|
|
34
|
+
[-1, 0, 1, -1],
|
|
35
|
+
[-1, 0, -1, 1],
|
|
36
|
+
[-1, 0, -1, -1],
|
|
37
|
+
[1, 1, 0, 1],
|
|
38
|
+
[1, 1, 0, -1],
|
|
39
|
+
[1, -1, 0, 1],
|
|
40
|
+
[1, -1, 0, -1],
|
|
41
|
+
[-1, 1, 0, 1],
|
|
42
|
+
[-1, 1, 0, -1],
|
|
43
|
+
[-1, -1, 0, 1],
|
|
44
|
+
[-1, -1, 0, -1],
|
|
45
|
+
[1, 1, 1, 0],
|
|
46
|
+
[1, 1, -1, 0],
|
|
47
|
+
[1, -1, 1, 0],
|
|
48
|
+
[1, -1, -1, 0],
|
|
49
|
+
[-1, 1, 1, 0],
|
|
50
|
+
[-1, 1, -1, 0],
|
|
51
|
+
[-1, -1, 1, 0],
|
|
52
|
+
[-1, -1, -1, 0],
|
|
53
|
+
];
|
|
54
|
+
function makeNoise4D(random) {
|
|
55
|
+
if (random === void 0) { random = Math.random; }
|
|
56
|
+
var p = new Uint8Array(256);
|
|
57
|
+
for (var i = 0; i < 256; i++)
|
|
58
|
+
p[i] = i;
|
|
59
|
+
var n;
|
|
60
|
+
var q;
|
|
61
|
+
for (var i = 255; i > 0; i--) {
|
|
62
|
+
n = Math.floor((i + 1) * random());
|
|
63
|
+
q = p[i];
|
|
64
|
+
p[i] = p[n];
|
|
65
|
+
p[n] = q;
|
|
66
|
+
}
|
|
67
|
+
var perm = new Uint8Array(512);
|
|
68
|
+
var permMod12 = new Uint8Array(512);
|
|
69
|
+
for (var i = 0; i < 512; i++) {
|
|
70
|
+
perm[i] = p[i & 255];
|
|
71
|
+
permMod12[i] = perm[i] % 12;
|
|
72
|
+
}
|
|
73
|
+
return function (x, y, z, w) {
|
|
74
|
+
// Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in
|
|
75
|
+
var s = (x + y + z + w) * (Math.sqrt(5.0) - 1.0) / 4.0; // Factor for 4D skewing
|
|
76
|
+
var i = Math.floor(x + s);
|
|
77
|
+
var j = Math.floor(y + s);
|
|
78
|
+
var k = Math.floor(z + s);
|
|
79
|
+
var l = Math.floor(w + s);
|
|
80
|
+
var t = (i + j + k + l) * G4; // Factor for 4D unskewing
|
|
81
|
+
var X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space
|
|
82
|
+
var Y0 = j - t;
|
|
83
|
+
var Z0 = k - t;
|
|
84
|
+
var W0 = l - t;
|
|
85
|
+
var x0 = x - X0; // The x,y,z,w distances from the cell origin
|
|
86
|
+
var y0 = y - Y0;
|
|
87
|
+
var z0 = z - Z0;
|
|
88
|
+
var w0 = w - W0;
|
|
89
|
+
// To find out which of the 24 possible simplices we're in, we need to determine the
|
|
90
|
+
// magnitude ordering of x0, y0, z0 and w0. Six pair-wise comparisons are performed between
|
|
91
|
+
// each possible pair of the four coordinates, and the results are used to rank the numbers.
|
|
92
|
+
var rankx = 0;
|
|
93
|
+
var ranky = 0;
|
|
94
|
+
var rankz = 0;
|
|
95
|
+
var rankw = 0;
|
|
96
|
+
if (x0 > y0)
|
|
97
|
+
rankx++;
|
|
98
|
+
else
|
|
99
|
+
ranky++;
|
|
100
|
+
if (x0 > z0)
|
|
101
|
+
rankx++;
|
|
102
|
+
else
|
|
103
|
+
rankz++;
|
|
104
|
+
if (x0 > w0)
|
|
105
|
+
rankx++;
|
|
106
|
+
else
|
|
107
|
+
rankw++;
|
|
108
|
+
if (y0 > z0)
|
|
109
|
+
ranky++;
|
|
110
|
+
else
|
|
111
|
+
rankz++;
|
|
112
|
+
if (y0 > w0)
|
|
113
|
+
ranky++;
|
|
114
|
+
else
|
|
115
|
+
rankw++;
|
|
116
|
+
if (z0 > w0)
|
|
117
|
+
rankz++;
|
|
118
|
+
else
|
|
119
|
+
rankw++;
|
|
120
|
+
// simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order.
|
|
121
|
+
// Many values of c will never occur, since e.g. x>y>z>w makes x<z, y<w and x<w
|
|
122
|
+
// impossible. Only the 24 indices which have non-zero entries make any sense.
|
|
123
|
+
// We use a thresholding to set the coordinates in turn from the largest magnitude.
|
|
124
|
+
// Rank 3 denotes the largest coordinate.
|
|
125
|
+
var i1 = rankx >= 3 ? 1 : 0;
|
|
126
|
+
var j1 = ranky >= 3 ? 1 : 0;
|
|
127
|
+
var k1 = rankz >= 3 ? 1 : 0;
|
|
128
|
+
var l1 = rankw >= 3 ? 1 : 0;
|
|
129
|
+
// Rank 2 denotes the second largest coordinate.
|
|
130
|
+
var i2 = rankx >= 2 ? 1 : 0;
|
|
131
|
+
var j2 = ranky >= 2 ? 1 : 0;
|
|
132
|
+
var k2 = rankz >= 2 ? 1 : 0;
|
|
133
|
+
var l2 = rankw >= 2 ? 1 : 0;
|
|
134
|
+
// Rank 1 denotes the second smallest coordinate.
|
|
135
|
+
var i3 = rankx >= 1 ? 1 : 0;
|
|
136
|
+
var j3 = ranky >= 1 ? 1 : 0;
|
|
137
|
+
var k3 = rankz >= 1 ? 1 : 0;
|
|
138
|
+
var l3 = rankw >= 1 ? 1 : 0;
|
|
139
|
+
// The fifth corner has all coordinate offsets = 1, so no need to compute that.
|
|
140
|
+
var x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords
|
|
141
|
+
var y1 = y0 - j1 + G4;
|
|
142
|
+
var z1 = z0 - k1 + G4;
|
|
143
|
+
var w1 = w0 - l1 + G4;
|
|
144
|
+
var x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords
|
|
145
|
+
var y2 = y0 - j2 + 2.0 * G4;
|
|
146
|
+
var z2 = z0 - k2 + 2.0 * G4;
|
|
147
|
+
var w2 = w0 - l2 + 2.0 * G4;
|
|
148
|
+
var x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords
|
|
149
|
+
var y3 = y0 - j3 + 3.0 * G4;
|
|
150
|
+
var z3 = z0 - k3 + 3.0 * G4;
|
|
151
|
+
var w3 = w0 - l3 + 3.0 * G4;
|
|
152
|
+
var x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords
|
|
153
|
+
var y4 = y0 - 1.0 + 4.0 * G4;
|
|
154
|
+
var z4 = z0 - 1.0 + 4.0 * G4;
|
|
155
|
+
var w4 = w0 - 1.0 + 4.0 * G4;
|
|
156
|
+
// Work out the hashed gradient indices of the five simplex corners
|
|
157
|
+
var ii = i & 255;
|
|
158
|
+
var jj = j & 255;
|
|
159
|
+
var kk = k & 255;
|
|
160
|
+
var ll = l & 255;
|
|
161
|
+
var g0 = Grad[perm[ii + perm[jj + perm[kk + perm[ll]]]] %
|
|
162
|
+
32];
|
|
163
|
+
var g1 = Grad[perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32];
|
|
164
|
+
var g2 = Grad[perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32];
|
|
165
|
+
var g3 = Grad[perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32];
|
|
166
|
+
var g4 = Grad[perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32];
|
|
167
|
+
// Calculate the contribution from the five corners
|
|
168
|
+
var t0 = 0.5 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
|
|
169
|
+
var n0 = t0 < 0
|
|
170
|
+
? 0.0
|
|
171
|
+
: Math.pow(t0, 4) * (g0[0] * x0 + g0[1] * y0 + g0[2] * z0 + g0[3] * w0);
|
|
172
|
+
var t1 = 0.5 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
|
|
173
|
+
var n1 = t1 < 0
|
|
174
|
+
? 0.0
|
|
175
|
+
: Math.pow(t1, 4) * (g1[0] * x1 + g1[1] * y1 + g1[2] * z1 + g1[3] * w1);
|
|
176
|
+
var t2 = 0.5 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
|
|
177
|
+
var n2 = t2 < 0
|
|
178
|
+
? 0.0
|
|
179
|
+
: Math.pow(t2, 4) * (g2[0] * x2 + g2[1] * y2 + g2[2] * z2 + g2[3] * w2);
|
|
180
|
+
var t3 = 0.5 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
|
|
181
|
+
var n3 = t3 < 0
|
|
182
|
+
? 0.0
|
|
183
|
+
: Math.pow(t3, 4) * (g3[0] * x3 + g3[1] * y3 + g3[2] * z3 + g3[3] * w3);
|
|
184
|
+
var t4 = 0.5 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
|
|
185
|
+
var n4 = t4 < 0
|
|
186
|
+
? 0.0
|
|
187
|
+
: Math.pow(t4, 4) * (g4[0] * x4 + g4[1] * y4 + g4[2] * z4 + g4[3] * w4);
|
|
188
|
+
// Sum up and scale the result to cover the range [-1,1]
|
|
189
|
+
return 72.37855765153665 * (n0 + n1 + n2 + n3 + n4);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
_4d.makeNoise4D = makeNoise4D;
|
|
193
|
+
return _4d;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { require_4d as __require };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __exports as mod } from '../../../_virtual/mod2.js';
|
|
2
|
+
import { __require as require_2d } from './2d.js';
|
|
3
|
+
import { __require as require_3d } from './3d.js';
|
|
4
|
+
import { __require as require_4d } from './4d.js';
|
|
5
|
+
|
|
6
|
+
var hasRequiredMod;
|
|
7
|
+
|
|
8
|
+
function requireMod () {
|
|
9
|
+
if (hasRequiredMod) return mod;
|
|
10
|
+
hasRequiredMod = 1;
|
|
11
|
+
(function (exports$1) {
|
|
12
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
13
|
+
exports$1.makeNoise4D = exports$1.makeNoise3D = exports$1.makeNoise2D = void 0;
|
|
14
|
+
var _2d_1 = require_2d();
|
|
15
|
+
Object.defineProperty(exports$1, "makeNoise2D", { enumerable: true, get: function () { return _2d_1.makeNoise2D; } });
|
|
16
|
+
var _3d_1 = require_3d();
|
|
17
|
+
Object.defineProperty(exports$1, "makeNoise3D", { enumerable: true, get: function () { return _3d_1.makeNoise3D; } });
|
|
18
|
+
var _4d_1 = require_4d();
|
|
19
|
+
Object.defineProperty(exports$1, "makeNoise4D", { enumerable: true, get: function () { return _4d_1.makeNoise4D; } });
|
|
20
|
+
} (mod));
|
|
21
|
+
return mod;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { requireMod as __require };
|
|
@@ -11,11 +11,11 @@ export declare class UIBehaviorDirectionalGravity extends UIBehaviorModule<{
|
|
|
11
11
|
}> {
|
|
12
12
|
private directionInternal;
|
|
13
13
|
/**
|
|
14
|
-
* @param direction - Acceleration vector in units/second
|
|
14
|
+
* @param direction - Acceleration vector in units/second^2
|
|
15
15
|
*/
|
|
16
16
|
constructor(direction: Vector2Like);
|
|
17
|
-
/** Acceleration vector in units/second
|
|
17
|
+
/** Acceleration vector in units/second^2 */
|
|
18
18
|
get direction(): Vector2Like;
|
|
19
|
-
/** Acceleration vector in units/second
|
|
19
|
+
/** Acceleration vector in units/second^2 */
|
|
20
20
|
set direction(value: UIVector2Config);
|
|
21
21
|
}
|
|
@@ -9,7 +9,7 @@ import { UIBehaviorModule } from './UIBehaviorModule.js';
|
|
|
9
9
|
*/
|
|
10
10
|
class UIBehaviorDirectionalGravity extends UIBehaviorModule {
|
|
11
11
|
/**
|
|
12
|
-
* @param direction - Acceleration vector in units/second
|
|
12
|
+
* @param direction - Acceleration vector in units/second^2
|
|
13
13
|
*/
|
|
14
14
|
constructor(direction) {
|
|
15
15
|
super();
|
|
@@ -19,11 +19,11 @@ class UIBehaviorDirectionalGravity extends UIBehaviorModule {
|
|
|
19
19
|
assertValidNumber(this._private_directionInternal.x, "UIBehaviorDirectionalGravity.constructor.direction.x");
|
|
20
20
|
assertValidNumber(this._private_directionInternal.y, "UIBehaviorDirectionalGravity.constructor.direction.y");
|
|
21
21
|
}
|
|
22
|
-
/** Acceleration vector in units/second
|
|
22
|
+
/** Acceleration vector in units/second^2 */
|
|
23
23
|
get direction() {
|
|
24
24
|
return this._private_directionInternal;
|
|
25
25
|
}
|
|
26
|
-
/** Acceleration vector in units/second
|
|
26
|
+
/** Acceleration vector in units/second^2 */
|
|
27
27
|
set direction(value) {
|
|
28
28
|
this._private_directionInternal = resolveUIVector2Config(value);
|
|
29
29
|
assertValidNumber(this._private_directionInternal.x, "UIBehaviorDirectionalGravity.direction.x");
|
|
@@ -80,7 +80,6 @@ class UIBehaviorPointGravity extends UIBehaviorModule {
|
|
|
80
80
|
const itemOffset = i * itemSize;
|
|
81
81
|
const dx = this._private_centerInternal.x - array[itemOffset + BUILTIN_OFFSET_POSITION_X];
|
|
82
82
|
const dy = this._private_centerInternal.y - array[itemOffset + BUILTIN_OFFSET_POSITION_Y];
|
|
83
|
-
// Constant over the life of a particle but different for each particle
|
|
84
83
|
const thresholdT = array[itemOffset + BUILTIN_OFFSET_RANDOM_A];
|
|
85
84
|
const threshold = MathUtils.lerp(this.threshold.min, this.threshold.max, thresholdT);
|
|
86
85
|
const thresholdSquared = threshold * threshold;
|
|
@@ -88,10 +87,8 @@ class UIBehaviorPointGravity extends UIBehaviorModule {
|
|
|
88
87
|
if (distanceSquared < thresholdSquared) {
|
|
89
88
|
continue;
|
|
90
89
|
}
|
|
91
|
-
// Constant over the life of a particle but different for each particle
|
|
92
90
|
const strengthT = array[itemOffset + BUILTIN_OFFSET_RANDOM_B];
|
|
93
91
|
const strength = MathUtils.lerp(this._private_strengthInternal.min, this._private_strengthInternal.max, strengthT);
|
|
94
|
-
// Constant over the life of a particle but different for each particle
|
|
95
92
|
const exponentT = array[itemOffset + BUILTIN_OFFSET_RANDOM_C];
|
|
96
93
|
const exponent = MathUtils.lerp(this._private_exponentInternal.min, this._private_exponentInternal.max, exponentT);
|
|
97
94
|
const distance = Math.sqrt(distanceSquared);
|
|
@@ -48,7 +48,6 @@ class UIBehaviorScaleOverLife extends UIBehaviorModule {
|
|
|
48
48
|
const lifeT = Math.min(array[itemOffset + BUILTIN_OFFSET_AGE] / array[itemOffset + BUILTIN_OFFSET_LIFETIME], 1);
|
|
49
49
|
const segment = (this._private_scales.length - 1) * lifeT;
|
|
50
50
|
const index = Math.floor(segment);
|
|
51
|
-
// Constant over the life of a particle but different for each particle
|
|
52
51
|
const scaleT = array[itemOffset + BUILTIN_OFFSET_RANDOM_D];
|
|
53
52
|
const localT = segment - index;
|
|
54
53
|
const scaleRange0 = this._private_scales[index];
|
|
@@ -36,7 +36,6 @@ class UIBehaviorTorqueDamping extends UIBehaviorModule {
|
|
|
36
36
|
const { array, itemSize } = builtin;
|
|
37
37
|
for (let i = 0; i < instanceCount; i++) {
|
|
38
38
|
const itemOffset = i * itemSize;
|
|
39
|
-
// Constant over the life of a particle but different for each particle
|
|
40
39
|
const dampingT = array[itemOffset + BUILTIN_OFFSET_RANDOM_E];
|
|
41
40
|
const dampingFactor = Math.pow(1 - MathUtils.lerp(this._private_dampingInternal.min, this._private_dampingInternal.max, dampingT), deltaTime);
|
|
42
41
|
array[itemOffset + BUILTIN_OFFSET_TORQUE] *= dampingFactor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MathUtils } from 'three';
|
|
2
2
|
import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../../core/miscellaneous/asserts.js';
|
|
3
|
-
import { resolveUIRangeConfig, BUILTIN_OFFSET_RANDOM_F, generateNoise2D,
|
|
3
|
+
import { resolveUIRangeConfig, BUILTIN_OFFSET_RANDOM_F, generateNoise2D, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_TORQUE } from '../miscellaneous/miscellaneous.js';
|
|
4
4
|
import { UIBehaviorModule } from './UIBehaviorModule.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -50,11 +50,9 @@ class UIBehaviorTorqueNoise extends UIBehaviorModule {
|
|
|
50
50
|
const { array, itemSize } = builtin;
|
|
51
51
|
for (let i = 0; i < instanceCount; i++) {
|
|
52
52
|
const itemOffset = i * itemSize;
|
|
53
|
-
// Constant over the life of a particle but different for each particle
|
|
54
53
|
const scaleT = array[itemOffset + BUILTIN_OFFSET_RANDOM_F];
|
|
55
54
|
const scale = MathUtils.lerp(this._private_scaleInternal.min, this._private_scaleInternal.max, scaleT);
|
|
56
55
|
const noise = generateNoise2D(array[itemOffset + BUILTIN_OFFSET_POSITION_X] * scale, array[itemOffset + BUILTIN_OFFSET_POSITION_Y] * scale);
|
|
57
|
-
// Constant over the life of a particle but different for each particle
|
|
58
56
|
const strengthT = array[itemOffset + BUILTIN_OFFSET_RANDOM_A];
|
|
59
57
|
const strength = MathUtils.lerp(this._private_strengthInternal.min, this._private_strengthInternal.max, strengthT);
|
|
60
58
|
array[itemOffset + BUILTIN_OFFSET_TORQUE] += noise * strength * deltaTime;
|
|
@@ -36,7 +36,6 @@ class UIBehaviorVelocityDamping extends UIBehaviorModule {
|
|
|
36
36
|
const { array, itemSize } = builtin;
|
|
37
37
|
for (let i = 0; i < instanceCount; i++) {
|
|
38
38
|
const itemOffset = i * itemSize;
|
|
39
|
-
// Constant over the life of a particle but different for each particle
|
|
40
39
|
const dampingT = array[itemOffset + BUILTIN_OFFSET_RANDOM_B];
|
|
41
40
|
const dampingFactor = Math.pow(1 - MathUtils.lerp(this._private_dampingInternal.min, this._private_dampingInternal.max, dampingT), deltaTime);
|
|
42
41
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] *= dampingFactor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MathUtils } from 'three';
|
|
2
2
|
import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../../core/miscellaneous/asserts.js';
|
|
3
|
-
import { resolveUIRangeConfig, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_RANDOM_D, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y
|
|
3
|
+
import { resolveUIRangeConfig, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_RANDOM_C, generateNoise2D, BUILTIN_OFFSET_RANDOM_D, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y } from '../miscellaneous/miscellaneous.js';
|
|
4
4
|
import { UIBehaviorModule } from './UIBehaviorModule.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -52,12 +52,10 @@ class UIBehaviorVelocityNoise extends UIBehaviorModule {
|
|
|
52
52
|
const itemOffset = i * itemSize;
|
|
53
53
|
const x = array[itemOffset + BUILTIN_OFFSET_POSITION_X];
|
|
54
54
|
const y = array[itemOffset + BUILTIN_OFFSET_POSITION_Y];
|
|
55
|
-
// Constant over the life of a particle but different for each particle
|
|
56
55
|
const scaleT = array[itemOffset + BUILTIN_OFFSET_RANDOM_C];
|
|
57
56
|
const scale = MathUtils.lerp(this._private_scaleInternal.min, this._private_scaleInternal.max, scaleT);
|
|
58
57
|
const noiseX = generateNoise2D(x * scale, y * scale);
|
|
59
58
|
const noiseY = generateNoise2D((x + 100) * scale, (y + 100) * scale);
|
|
60
|
-
// Constant over the life of a particle but different for each particle
|
|
61
59
|
const strengthT = array[itemOffset + BUILTIN_OFFSET_RANDOM_D];
|
|
62
60
|
const strength = MathUtils.lerp(this._private_strengthInternal.min, this._private_strengthInternal.max, strengthT);
|
|
63
61
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] += noiseX * strength * deltaTime;
|
|
@@ -13,7 +13,7 @@ export type UIAspectConfig = number | UITextureConfig;
|
|
|
13
13
|
export declare function resolveUIRangeConfig(config: UIRangeConfig): UIRange;
|
|
14
14
|
export declare function resolveUIVector2Config(config: UIVector2Config): Vector2Like;
|
|
15
15
|
export declare function resolveAspect(config: number | UITextureConfig): number;
|
|
16
|
-
export declare
|
|
16
|
+
export declare const generateNoise2D: (x: number, y: number) => number;
|
|
17
17
|
export declare function buildGradientTexture(colors: UIColor[]): DataTexture;
|
|
18
18
|
export declare const BUILTIN_OFFSET_POSITION_X = 0;
|
|
19
19
|
export declare const BUILTIN_OFFSET_POSITION_Y = 1;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { m as modExports } from '../../_virtual/mod.js';
|
|
1
2
|
import { Texture, DataTexture, RGBAFormat, UnsignedByteType, UVMapping, ClampToEdgeWrapping, LinearFilter, SRGBColorSpace } from 'three';
|
|
2
3
|
|
|
3
4
|
function resolveUIRangeConfig(config) {
|
|
@@ -27,10 +28,7 @@ function resolveAspect(config) {
|
|
|
27
28
|
}
|
|
28
29
|
return config.sourceSize.w / config.sourceSize.h;
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
const noise = Math.sin(x * 12.9898 + y * 78.233) * 43758.5453123;
|
|
32
|
-
return (noise - Math.floor(noise)) * 2 - 1;
|
|
33
|
-
}
|
|
31
|
+
const generateNoise2D = modExports.makeNoise2D();
|
|
34
32
|
function buildGradientTexture(colors) {
|
|
35
33
|
const width = colors.length;
|
|
36
34
|
const height = 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "laymur",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Constraint-based UI library for Three.js mobile advertisements",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -46,11 +46,13 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"three": ">=0.157.0 <0.180.0",
|
|
50
49
|
"@lume/kiwi": "^0.4.4",
|
|
51
|
-
"
|
|
50
|
+
"fast-simplex-noise": "^4.0.0",
|
|
51
|
+
"ferrsign": "^0.0.4",
|
|
52
|
+
"three": ">=0.157.0 <0.180.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
55
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
54
56
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
55
57
|
"@types/node": "^25.0.2",
|
|
56
58
|
"@types/three": "^0.157.0",
|