@babylonjs-toolkit/next 9.0.1

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.
Files changed (131) hide show
  1. package/README.md +319 -0
  2. package/lib/blendtreeposition.d.ts +5 -0
  3. package/lib/blendtreeposition.d.ts.map +1 -0
  4. package/lib/blendtreeposition.js +5 -0
  5. package/lib/channelmixerplugin.d.ts +11 -0
  6. package/lib/channelmixerplugin.d.ts.map +1 -0
  7. package/lib/channelmixerplugin.js +34 -0
  8. package/lib/collisioncontact.d.ts +7 -0
  9. package/lib/collisioncontact.d.ts.map +1 -0
  10. package/lib/collisioncontact.js +7 -0
  11. package/lib/collisionfilters.d.ts +10 -0
  12. package/lib/collisionfilters.d.ts.map +1 -0
  13. package/lib/collisionfilters.js +10 -0
  14. package/lib/collisionflags.d.ts +14 -0
  15. package/lib/collisionflags.d.ts.map +1 -0
  16. package/lib/collisionflags.js +14 -0
  17. package/lib/collisionstate.d.ts +8 -0
  18. package/lib/collisionstate.d.ts.map +1 -0
  19. package/lib/collisionstate.js +8 -0
  20. package/lib/customloadingscreen.d.ts +16 -0
  21. package/lib/customloadingscreen.d.ts.map +1 -0
  22. package/lib/customloadingscreen.js +48 -0
  23. package/lib/entitycontroller.d.ts +11 -0
  24. package/lib/entitycontroller.d.ts.map +1 -0
  25. package/lib/entitycontroller.js +41 -0
  26. package/lib/fontmanifestentry.d.ts +8 -0
  27. package/lib/fontmanifestentry.d.ts.map +1 -0
  28. package/lib/fontmanifestentry.js +1 -0
  29. package/lib/handedness.d.ts +6 -0
  30. package/lib/handedness.d.ts.map +1 -0
  31. package/lib/handedness.js +6 -0
  32. package/lib/ianimationcurve.d.ts +14 -0
  33. package/lib/ianimationcurve.d.ts.map +1 -0
  34. package/lib/ianimationcurve.js +1 -0
  35. package/lib/index.d.ts +43 -0
  36. package/lib/index.d.ts.map +1 -0
  37. package/lib/index.js +42 -0
  38. package/lib/intersectionprecision.d.ts +5 -0
  39. package/lib/intersectionprecision.d.ts.map +1 -0
  40. package/lib/intersectionprecision.js +5 -0
  41. package/lib/iparticlesystemtransform.d.ts +9 -0
  42. package/lib/iparticlesystemtransform.d.ts.map +1 -0
  43. package/lib/iparticlesystemtransform.js +1 -0
  44. package/lib/irecastnavigationplugin.d.ts +92 -0
  45. package/lib/irecastnavigationplugin.d.ts.map +1 -0
  46. package/lib/irecastnavigationplugin.js +1 -0
  47. package/lib/linesmeshrenderer.d.ts +22 -0
  48. package/lib/linesmeshrenderer.d.ts.map +1 -0
  49. package/lib/linesmeshrenderer.js +79 -0
  50. package/lib/localmessagebus.d.ts +9 -0
  51. package/lib/localmessagebus.d.ts.map +1 -0
  52. package/lib/localmessagebus.js +44 -0
  53. package/lib/lutblendplugin.d.ts +13 -0
  54. package/lib/lutblendplugin.d.ts.map +1 -0
  55. package/lib/lutblendplugin.js +153 -0
  56. package/lib/mousebuttonmode.d.ts +6 -0
  57. package/lib/mousebuttonmode.d.ts.map +1 -0
  58. package/lib/mousebuttonmode.js +6 -0
  59. package/lib/movementtype.d.ts +5 -0
  60. package/lib/movementtype.d.ts.map +1 -0
  61. package/lib/movementtype.js +5 -0
  62. package/lib/noisefunction2d.d.ts +2 -0
  63. package/lib/noisefunction2d.d.ts.map +1 -0
  64. package/lib/noisefunction2d.js +1 -0
  65. package/lib/noisefunction3d.d.ts +2 -0
  66. package/lib/noisefunction3d.d.ts.map +1 -0
  67. package/lib/noisefunction3d.js +1 -0
  68. package/lib/noisefunction4d.d.ts +2 -0
  69. package/lib/noisefunction4d.d.ts.map +1 -0
  70. package/lib/noisefunction4d.js +1 -0
  71. package/lib/perlin2d.d.ts +9 -0
  72. package/lib/perlin2d.d.ts.map +1 -0
  73. package/lib/perlin2d.js +45 -0
  74. package/lib/playercontrol.d.ts +5 -0
  75. package/lib/playercontrol.d.ts.map +1 -0
  76. package/lib/playercontrol.js +5 -0
  77. package/lib/prefabobjectpool.d.ts +20 -0
  78. package/lib/prefabobjectpool.d.ts.map +1 -0
  79. package/lib/prefabobjectpool.js +96 -0
  80. package/lib/randomfn.d.ts +2 -0
  81. package/lib/randomfn.d.ts.map +1 -0
  82. package/lib/randomfn.js +1 -0
  83. package/lib/raycasthitresult.d.ts +21 -0
  84. package/lib/raycasthitresult.d.ts.map +1 -0
  85. package/lib/raycasthitresult.js +36 -0
  86. package/lib/recastclassctor.d.ts +2 -0
  87. package/lib/recastclassctor.d.ts.map +1 -0
  88. package/lib/recastclassctor.js +1 -0
  89. package/lib/roomerrormessage.d.ts +5 -0
  90. package/lib/roomerrormessage.d.ts.map +1 -0
  91. package/lib/roomerrormessage.js +2 -0
  92. package/lib/scenemanager.d.ts +4141 -0
  93. package/lib/scenemanager.d.ts.map +1 -0
  94. package/lib/scenemanager.js +29628 -0
  95. package/lib/simplexnoise.d.ts +21 -0
  96. package/lib/simplexnoise.d.ts.map +1 -0
  97. package/lib/simplexnoise.js +362 -0
  98. package/lib/touchjoystickhandler.d.ts +39 -0
  99. package/lib/touchjoystickhandler.d.ts.map +1 -0
  100. package/lib/touchjoystickhandler.js +175 -0
  101. package/lib/touchmousebutton.d.ts +6 -0
  102. package/lib/touchmousebutton.d.ts.map +1 -0
  103. package/lib/touchmousebutton.js +6 -0
  104. package/lib/treebranchmaterial.d.ts +31 -0
  105. package/lib/treebranchmaterial.d.ts.map +1 -0
  106. package/lib/treebranchmaterial.js +369 -0
  107. package/lib/triggervolume.d.ts +6 -0
  108. package/lib/triggervolume.d.ts.map +1 -0
  109. package/lib/triggervolume.js +6 -0
  110. package/lib/unitydropdownmenu.d.ts +20 -0
  111. package/lib/unitydropdownmenu.d.ts.map +1 -0
  112. package/lib/unitydropdownmenu.js +144 -0
  113. package/lib/unityscrollbar.d.ts +11 -0
  114. package/lib/unityscrollbar.d.ts.map +1 -0
  115. package/lib/unityscrollbar.js +38 -0
  116. package/lib/unityslider.d.ts +4 -0
  117. package/lib/unityslider.d.ts.map +1 -0
  118. package/lib/unityslider.js +3 -0
  119. package/lib/universalcharactercontroller.d.ts +3 -0
  120. package/lib/universalcharactercontroller.d.ts.map +1 -0
  121. package/lib/universalcharactercontroller.js +1 -0
  122. package/lib/universalterrainmaterial.d.ts +48 -0
  123. package/lib/universalterrainmaterial.d.ts.map +1 -0
  124. package/lib/universalterrainmaterial.js +639 -0
  125. package/lib/userinputpointer.d.ts +6 -0
  126. package/lib/userinputpointer.d.ts.map +1 -0
  127. package/lib/userinputpointer.js +6 -0
  128. package/lib/xbox360trigger.d.ts +5 -0
  129. package/lib/xbox360trigger.d.ts.map +1 -0
  130. package/lib/xbox360trigger.js +5 -0
  131. package/package.json +211 -0
@@ -0,0 +1,21 @@
1
+ import { RandomFn } from './randomfn';
2
+ import { NoiseFunction2D } from './noisefunction2d';
3
+ import { NoiseFunction3D } from './noisefunction3d';
4
+ import { NoiseFunction4D } from './noisefunction4d';
5
+ export declare class SimplexNoise {
6
+ private static readonly F2;
7
+ private static readonly G2;
8
+ private static readonly F3;
9
+ private static readonly G3;
10
+ private static readonly F4;
11
+ private static readonly G4;
12
+ private static readonly grad2;
13
+ private static readonly grad3;
14
+ private static readonly grad4;
15
+ private static fastFloor;
16
+ static createNoise2D(random?: RandomFn): NoiseFunction2D;
17
+ static createNoise3D(random?: RandomFn): NoiseFunction3D;
18
+ static createNoise4D(random?: RandomFn): NoiseFunction4D;
19
+ static buildPermutationTable(random: RandomFn): Uint8Array;
20
+ }
21
+ //# sourceMappingURL=simplexnoise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simplexnoise.d.ts","sourceRoot":"","sources":["../src/simplexnoise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,YAAY;IAErB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAA8C;IACxE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAA8C;IACxE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAa;IACvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAa;IACvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAA8C;IACxE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAA+C;IAEzE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAcnB;IAIV,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAcf;IAGd,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAO8B;IAK3D,OAAO,CAAC,MAAM,CAAC,SAAS;WASV,aAAa,CAAC,MAAM,GAAE,QAAsB,GAAG,eAAe;WA+E9D,aAAa,CAAC,MAAM,GAAE,QAAsB,GAAG,eAAe;WAqI9D,aAAa,CAAC,MAAM,GAAE,QAAsB,GAAG,eAAe;WA0I9D,qBAAqB,CAAC,MAAM,EAAE,QAAQ,GAAG,UAAU;CAiBlE"}
@@ -0,0 +1,362 @@
1
+ export class SimplexNoise {
2
+ static fastFloor(x) {
3
+ return Math.floor(x) | 0;
4
+ }
5
+ static createNoise2D(random = Math.random) {
6
+ const perm = SimplexNoise.buildPermutationTable(random);
7
+ const permGrad2x = new Float64Array(perm).map(v => SimplexNoise.grad2[(v % 12) * 2]);
8
+ const permGrad2y = new Float64Array(perm).map(v => SimplexNoise.grad2[(v % 12) * 2 + 1]);
9
+ return function noise2D(x, y) {
10
+ let n0 = 0;
11
+ let n1 = 0;
12
+ let n2 = 0;
13
+ const s = (x + y) * SimplexNoise.F2;
14
+ const i = SimplexNoise.fastFloor(x + s);
15
+ const j = SimplexNoise.fastFloor(y + s);
16
+ const t = (i + j) * SimplexNoise.G2;
17
+ const X0 = i - t;
18
+ const Y0 = j - t;
19
+ const x0 = x - X0;
20
+ const y0 = y - Y0;
21
+ let i1, j1;
22
+ if (x0 > y0) {
23
+ i1 = 1;
24
+ j1 = 0;
25
+ }
26
+ else {
27
+ i1 = 0;
28
+ j1 = 1;
29
+ }
30
+ const x1 = x0 - i1 + SimplexNoise.G2;
31
+ const y1 = y0 - j1 + SimplexNoise.G2;
32
+ const x2 = x0 - 1.0 + 2.0 * SimplexNoise.G2;
33
+ const y2 = y0 - 1.0 + 2.0 * SimplexNoise.G2;
34
+ const ii = i & 255;
35
+ const jj = j & 255;
36
+ let t0 = 0.5 - x0 * x0 - y0 * y0;
37
+ if (t0 >= 0) {
38
+ const gi0 = ii + perm[jj];
39
+ const g0x = permGrad2x[gi0];
40
+ const g0y = permGrad2y[gi0];
41
+ t0 *= t0;
42
+ n0 = t0 * t0 * (g0x * x0 + g0y * y0);
43
+ }
44
+ let t1 = 0.5 - x1 * x1 - y1 * y1;
45
+ if (t1 >= 0) {
46
+ const gi1 = ii + i1 + perm[jj + j1];
47
+ const g1x = permGrad2x[gi1];
48
+ const g1y = permGrad2y[gi1];
49
+ t1 *= t1;
50
+ n1 = t1 * t1 * (g1x * x1 + g1y * y1);
51
+ }
52
+ let t2 = 0.5 - x2 * x2 - y2 * y2;
53
+ if (t2 >= 0) {
54
+ const gi2 = ii + 1 + perm[jj + 1];
55
+ const g2x = permGrad2x[gi2];
56
+ const g2y = permGrad2y[gi2];
57
+ t2 *= t2;
58
+ n2 = t2 * t2 * (g2x * x2 + g2y * y2);
59
+ }
60
+ return 70.0 * (n0 + n1 + n2);
61
+ };
62
+ }
63
+ static createNoise3D(random = Math.random) {
64
+ const perm = SimplexNoise.buildPermutationTable(random);
65
+ const permGrad3x = new Float64Array(perm).map(v => SimplexNoise.grad3[(v % 12) * 3]);
66
+ const permGrad3y = new Float64Array(perm).map(v => SimplexNoise.grad3[(v % 12) * 3 + 1]);
67
+ const permGrad3z = new Float64Array(perm).map(v => SimplexNoise.grad3[(v % 12) * 3 + 2]);
68
+ return function noise3D(x, y, z) {
69
+ let n0, n1, n2, n3;
70
+ const s = (x + y + z) * SimplexNoise.F3;
71
+ const i = SimplexNoise.fastFloor(x + s);
72
+ const j = SimplexNoise.fastFloor(y + s);
73
+ const k = SimplexNoise.fastFloor(z + s);
74
+ const t = (i + j + k) * SimplexNoise.G3;
75
+ const X0 = i - t;
76
+ const Y0 = j - t;
77
+ const Z0 = k - t;
78
+ const x0 = x - X0;
79
+ const y0 = y - Y0;
80
+ const z0 = z - Z0;
81
+ let i1, j1, k1;
82
+ let i2, j2, k2;
83
+ if (x0 >= y0) {
84
+ if (y0 >= z0) {
85
+ i1 = 1;
86
+ j1 = 0;
87
+ k1 = 0;
88
+ i2 = 1;
89
+ j2 = 1;
90
+ k2 = 0;
91
+ }
92
+ else if (x0 >= z0) {
93
+ i1 = 1;
94
+ j1 = 0;
95
+ k1 = 0;
96
+ i2 = 1;
97
+ j2 = 0;
98
+ k2 = 1;
99
+ }
100
+ else {
101
+ i1 = 0;
102
+ j1 = 0;
103
+ k1 = 1;
104
+ i2 = 1;
105
+ j2 = 0;
106
+ k2 = 1;
107
+ }
108
+ }
109
+ else {
110
+ if (y0 < z0) {
111
+ i1 = 0;
112
+ j1 = 0;
113
+ k1 = 1;
114
+ i2 = 0;
115
+ j2 = 1;
116
+ k2 = 1;
117
+ }
118
+ else if (x0 < z0) {
119
+ i1 = 0;
120
+ j1 = 1;
121
+ k1 = 0;
122
+ i2 = 0;
123
+ j2 = 1;
124
+ k2 = 1;
125
+ }
126
+ else {
127
+ i1 = 0;
128
+ j1 = 1;
129
+ k1 = 0;
130
+ i2 = 1;
131
+ j2 = 1;
132
+ k2 = 0;
133
+ }
134
+ }
135
+ const x1 = x0 - i1 + SimplexNoise.G3;
136
+ const y1 = y0 - j1 + SimplexNoise.G3;
137
+ const z1 = z0 - k1 + SimplexNoise.G3;
138
+ const x2 = x0 - i2 + 2.0 * SimplexNoise.G3;
139
+ const y2 = y0 - j2 + 2.0 * SimplexNoise.G3;
140
+ const z2 = z0 - k2 + 2.0 * SimplexNoise.G3;
141
+ const x3 = x0 - 1.0 + 3.0 * SimplexNoise.G3;
142
+ const y3 = y0 - 1.0 + 3.0 * SimplexNoise.G3;
143
+ const z3 = z0 - 1.0 + 3.0 * SimplexNoise.G3;
144
+ const ii = i & 255;
145
+ const jj = j & 255;
146
+ const kk = k & 255;
147
+ let t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0;
148
+ if (t0 < 0)
149
+ n0 = 0.0;
150
+ else {
151
+ const gi0 = ii + perm[jj + perm[kk]];
152
+ t0 *= t0;
153
+ n0 = t0 * t0 * (permGrad3x[gi0] * x0 + permGrad3y[gi0] * y0 + permGrad3z[gi0] * z0);
154
+ }
155
+ let t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1;
156
+ if (t1 < 0)
157
+ n1 = 0.0;
158
+ else {
159
+ const gi1 = ii + i1 + perm[jj + j1 + perm[kk + k1]];
160
+ t1 *= t1;
161
+ n1 = t1 * t1 * (permGrad3x[gi1] * x1 + permGrad3y[gi1] * y1 + permGrad3z[gi1] * z1);
162
+ }
163
+ let t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2;
164
+ if (t2 < 0)
165
+ n2 = 0.0;
166
+ else {
167
+ const gi2 = ii + i2 + perm[jj + j2 + perm[kk + k2]];
168
+ t2 *= t2;
169
+ n2 = t2 * t2 * (permGrad3x[gi2] * x2 + permGrad3y[gi2] * y2 + permGrad3z[gi2] * z2);
170
+ }
171
+ let t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3;
172
+ if (t3 < 0)
173
+ n3 = 0.0;
174
+ else {
175
+ const gi3 = ii + 1 + perm[jj + 1 + perm[kk + 1]];
176
+ t3 *= t3;
177
+ n3 = t3 * t3 * (permGrad3x[gi3] * x3 + permGrad3y[gi3] * y3 + permGrad3z[gi3] * z3);
178
+ }
179
+ return 32.0 * (n0 + n1 + n2 + n3);
180
+ };
181
+ }
182
+ static createNoise4D(random = Math.random) {
183
+ const perm = SimplexNoise.buildPermutationTable(random);
184
+ const permGrad4x = new Float64Array(perm).map(v => SimplexNoise.grad4[(v % 32) * 4]);
185
+ const permGrad4y = new Float64Array(perm).map(v => SimplexNoise.grad4[(v % 32) * 4 + 1]);
186
+ const permGrad4z = new Float64Array(perm).map(v => SimplexNoise.grad4[(v % 32) * 4 + 2]);
187
+ const permGrad4w = new Float64Array(perm).map(v => SimplexNoise.grad4[(v % 32) * 4 + 3]);
188
+ return function noise4D(x, y, z, w) {
189
+ let n0, n1, n2, n3, n4;
190
+ const s = (x + y + z + w) * SimplexNoise.F4;
191
+ const i = SimplexNoise.fastFloor(x + s);
192
+ const j = SimplexNoise.fastFloor(y + s);
193
+ const k = SimplexNoise.fastFloor(z + s);
194
+ const l = SimplexNoise.fastFloor(w + s);
195
+ const t = (i + j + k + l) * SimplexNoise.G4;
196
+ const X0 = i - t;
197
+ const Y0 = j - t;
198
+ const Z0 = k - t;
199
+ const W0 = l - t;
200
+ const x0 = x - X0;
201
+ const y0 = y - Y0;
202
+ const z0 = z - Z0;
203
+ const w0 = w - W0;
204
+ let rankx = 0;
205
+ let ranky = 0;
206
+ let rankz = 0;
207
+ let rankw = 0;
208
+ if (x0 > y0)
209
+ rankx++;
210
+ else
211
+ ranky++;
212
+ if (x0 > z0)
213
+ rankx++;
214
+ else
215
+ rankz++;
216
+ if (x0 > w0)
217
+ rankx++;
218
+ else
219
+ rankw++;
220
+ if (y0 > z0)
221
+ ranky++;
222
+ else
223
+ rankz++;
224
+ if (y0 > w0)
225
+ ranky++;
226
+ else
227
+ rankw++;
228
+ if (z0 > w0)
229
+ rankz++;
230
+ else
231
+ rankw++;
232
+ const i1 = rankx >= 3 ? 1 : 0;
233
+ const j1 = ranky >= 3 ? 1 : 0;
234
+ const k1 = rankz >= 3 ? 1 : 0;
235
+ const l1 = rankw >= 3 ? 1 : 0;
236
+ const i2 = rankx >= 2 ? 1 : 0;
237
+ const j2 = ranky >= 2 ? 1 : 0;
238
+ const k2 = rankz >= 2 ? 1 : 0;
239
+ const l2 = rankw >= 2 ? 1 : 0;
240
+ const i3 = rankx >= 1 ? 1 : 0;
241
+ const j3 = ranky >= 1 ? 1 : 0;
242
+ const k3 = rankz >= 1 ? 1 : 0;
243
+ const l3 = rankw >= 1 ? 1 : 0;
244
+ const x1 = x0 - i1 + SimplexNoise.G4;
245
+ const y1 = y0 - j1 + SimplexNoise.G4;
246
+ const z1 = z0 - k1 + SimplexNoise.G4;
247
+ const w1 = w0 - l1 + SimplexNoise.G4;
248
+ const x2 = x0 - i2 + 2.0 * SimplexNoise.G4;
249
+ const y2 = y0 - j2 + 2.0 * SimplexNoise.G4;
250
+ const z2 = z0 - k2 + 2.0 * SimplexNoise.G4;
251
+ const w2 = w0 - l2 + 2.0 * SimplexNoise.G4;
252
+ const x3 = x0 - i3 + 3.0 * SimplexNoise.G4;
253
+ const y3 = y0 - j3 + 3.0 * SimplexNoise.G4;
254
+ const z3 = z0 - k3 + 3.0 * SimplexNoise.G4;
255
+ const w3 = w0 - l3 + 3.0 * SimplexNoise.G4;
256
+ const x4 = x0 - 1.0 + 4.0 * SimplexNoise.G4;
257
+ const y4 = y0 - 1.0 + 4.0 * SimplexNoise.G4;
258
+ const z4 = z0 - 1.0 + 4.0 * SimplexNoise.G4;
259
+ const w4 = w0 - 1.0 + 4.0 * SimplexNoise.G4;
260
+ const ii = i & 255;
261
+ const jj = j & 255;
262
+ const kk = k & 255;
263
+ const ll = l & 255;
264
+ let t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
265
+ if (t0 < 0)
266
+ n0 = 0.0;
267
+ else {
268
+ const gi0 = ii + perm[jj + perm[kk + perm[ll]]];
269
+ t0 *= t0;
270
+ n0 = t0 * t0 * (permGrad4x[gi0] * x0 + permGrad4y[gi0] * y0 + permGrad4z[gi0] * z0 + permGrad4w[gi0] * w0);
271
+ }
272
+ let t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
273
+ if (t1 < 0)
274
+ n1 = 0.0;
275
+ else {
276
+ const gi1 = ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]];
277
+ t1 *= t1;
278
+ n1 = t1 * t1 * (permGrad4x[gi1] * x1 + permGrad4y[gi1] * y1 + permGrad4z[gi1] * z1 + permGrad4w[gi1] * w1);
279
+ }
280
+ let t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
281
+ if (t2 < 0)
282
+ n2 = 0.0;
283
+ else {
284
+ const gi2 = ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]];
285
+ t2 *= t2;
286
+ n2 = t2 * t2 * (permGrad4x[gi2] * x2 + permGrad4y[gi2] * y2 + permGrad4z[gi2] * z2 + permGrad4w[gi2] * w2);
287
+ }
288
+ let t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
289
+ if (t3 < 0)
290
+ n3 = 0.0;
291
+ else {
292
+ const gi3 = ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]];
293
+ t3 *= t3;
294
+ n3 = t3 * t3 * (permGrad4x[gi3] * x3 + permGrad4y[gi3] * y3 + permGrad4z[gi3] * z3 + permGrad4w[gi3] * w3);
295
+ }
296
+ let t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
297
+ if (t4 < 0)
298
+ n4 = 0.0;
299
+ else {
300
+ const gi4 = ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]];
301
+ t4 *= t4;
302
+ n4 = t4 * t4 * (permGrad4x[gi4] * x4 + permGrad4y[gi4] * y4 + permGrad4z[gi4] * z4 + permGrad4w[gi4] * w4);
303
+ }
304
+ return 27.0 * (n0 + n1 + n2 + n3 + n4);
305
+ };
306
+ }
307
+ static buildPermutationTable(random) {
308
+ const tableSize = 512;
309
+ const p = new Uint8Array(tableSize);
310
+ for (let i = 0; i < tableSize / 2; i++) {
311
+ p[i] = i;
312
+ }
313
+ for (let i = 0; i < tableSize / 2 - 1; i++) {
314
+ const r = i + ~~(random() * (256 - i));
315
+ const aux = p[i];
316
+ p[i] = p[r];
317
+ p[r] = aux;
318
+ }
319
+ for (let i = 256; i < tableSize; i++) {
320
+ p[i] = p[i - 256];
321
+ }
322
+ return p;
323
+ }
324
+ }
325
+ SimplexNoise.F2 = 0.5 * (Math.sqrt(3.0) - 1.0);
326
+ SimplexNoise.G2 = (3.0 - Math.sqrt(3.0)) / 6.0;
327
+ SimplexNoise.F3 = 1.0 / 3.0;
328
+ SimplexNoise.G3 = 1.0 / 6.0;
329
+ SimplexNoise.F4 = (Math.sqrt(5.0) - 1.0) / 4.0;
330
+ SimplexNoise.G4 = (5.0 - Math.sqrt(5.0)) / 20.0;
331
+ SimplexNoise.grad2 = new Float64Array([1, 1,
332
+ -1, 1,
333
+ 1, -1,
334
+ -1, -1,
335
+ 1, 0,
336
+ -1, 0,
337
+ 1, 0,
338
+ -1, 0,
339
+ 0, 1,
340
+ 0, -1,
341
+ 0, 1,
342
+ 0, -1]);
343
+ SimplexNoise.grad3 = new Float64Array([1, 1, 0,
344
+ -1, 1, 0,
345
+ 1, -1, 0,
346
+ -1, -1, 0,
347
+ 1, 0, 1,
348
+ -1, 0, 1,
349
+ 1, 0, -1,
350
+ -1, 0, -1,
351
+ 0, 1, 1,
352
+ 0, -1, 1,
353
+ 0, 1, -1,
354
+ 0, -1, -1]);
355
+ SimplexNoise.grad4 = new Float64Array([0, 1, 1, 1, 0, 1, 1, -1, 0, 1, -1, 1, 0, 1, -1, -1,
356
+ 0, -1, 1, 1, 0, -1, 1, -1, 0, -1, -1, 1, 0, -1, -1, -1,
357
+ 1, 0, 1, 1, 1, 0, 1, -1, 1, 0, -1, 1, 1, 0, -1, -1,
358
+ -1, 0, 1, 1, -1, 0, 1, -1, -1, 0, -1, 1, -1, 0, -1, -1,
359
+ 1, 1, 0, 1, 1, 1, 0, -1, 1, -1, 0, 1, 1, -1, 0, -1,
360
+ -1, 1, 0, 1, -1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, -1,
361
+ 1, 1, 1, 0, 1, 1, -1, 0, 1, -1, 1, 0, 1, -1, -1, 0,
362
+ -1, 1, 1, 0, -1, 1, -1, 0, -1, -1, 1, 0, -1, -1, -1, 0]);
@@ -0,0 +1,39 @@
1
+ import { TouchMouseButton } from './touchmousebutton';
2
+ export declare class TouchJoystickHandler {
3
+ private isFixed;
4
+ private touchId;
5
+ private pointerId;
6
+ private dragStart;
7
+ private mouseButton;
8
+ private maxDistance;
9
+ private deadZone;
10
+ private xvalue;
11
+ private yvalue;
12
+ private stick;
13
+ private base;
14
+ private active;
15
+ enabled: boolean;
16
+ updateElements: boolean;
17
+ preventDefault: boolean;
18
+ stopPropagation: boolean;
19
+ baseElementOpacity: string;
20
+ stickElementOpacity: string;
21
+ onHandleDown: (event: any) => void;
22
+ onHandleMove: (event: any) => void;
23
+ onHandleUp: (event: any) => void;
24
+ constructor(stickid: string, maxdistance: number, deadzone: number, fixed?: boolean, button?: TouchMouseButton, baseid?: string);
25
+ dispose(): void;
26
+ isActive(): boolean;
27
+ getValueX(): number;
28
+ getValueY(): number;
29
+ getMouseButton(): TouchMouseButton;
30
+ getBaseElement(): HTMLElement;
31
+ getStickElement(): HTMLElement;
32
+ isFixedJoystick(): boolean;
33
+ protected handleDown(event: any): void;
34
+ protected handleMove(event: any): void;
35
+ protected handleUp(event: any): void;
36
+ protected showBaseElement(event: any): void;
37
+ hideBaseElement(): void;
38
+ }
39
+ //# sourceMappingURL=touchjoystickhandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"touchjoystickhandler.d.ts","sourceRoot":"","sources":["../src/touchjoystickhandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,qBAAa,oBAAoB;IACzB,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,SAAS,CAAyC;IAC1D,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,MAAM,CAAkB;IACzB,OAAO,EAAE,OAAO,CAAQ;IACxB,cAAc,EAAE,OAAO,CAAQ;IAC/B,cAAc,EAAE,OAAO,CAAQ;IAC/B,eAAe,EAAE,OAAO,CAAQ;IAChC,kBAAkB,EAAE,MAAM,CAAO;IACjC,mBAAmB,EAAE,MAAM,CAAO;IAClC,YAAY,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAQ;IAC1C,YAAY,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAQ;IAC1C,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAQ;gBAEnC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,GAAE,OAAc,EAAE,MAAM,GAAE,gBAAqB,EAAE,MAAM,GAAE,MAAa;IAyBxI,OAAO,IAAI,IAAI;IAIf,QAAQ,IAAI,OAAO;IACnB,SAAS,IAAI,MAAM;IACnB,SAAS,IAAI,MAAM;IACnB,cAAc,IAAI,gBAAgB;IAClC,cAAc,IAAI,WAAW;IAC7B,eAAe,IAAI,WAAW;IAC9B,eAAe,IAAI,OAAO;IAEjC,SAAS,CAAC,UAAU,CAAC,KAAK,KAAA,GAAG,IAAI;IA0BjC,SAAS,CAAC,UAAU,CAAC,KAAK,KAAA,GAAG,IAAI;IAuCjC,SAAS,CAAC,QAAQ,CAAC,KAAK,KAAA,GAAG,IAAI;IAuB/B,SAAS,CAAC,eAAe,CAAC,KAAK,KAAA,GAAG,IAAI;IAgB/B,eAAe,IAAI,IAAI;CAYjC"}
@@ -0,0 +1,175 @@
1
+ import { TouchMouseButton } from './touchmousebutton';
2
+ export class TouchJoystickHandler {
3
+ constructor(stickid, maxdistance, deadzone, fixed = true, button = -1, baseid = null) {
4
+ this.isFixed = true;
5
+ this.touchId = null;
6
+ this.pointerId = null;
7
+ this.dragStart = null;
8
+ this.mouseButton = -1;
9
+ this.maxDistance = 48;
10
+ this.deadZone = 2;
11
+ this.xvalue = 0;
12
+ this.yvalue = 0;
13
+ this.stick = null;
14
+ this.base = null;
15
+ this.active = false;
16
+ this.enabled = true;
17
+ this.updateElements = true;
18
+ this.preventDefault = true;
19
+ this.stopPropagation = true;
20
+ this.baseElementOpacity = "1";
21
+ this.stickElementOpacity = "1";
22
+ this.onHandleDown = null;
23
+ this.onHandleMove = null;
24
+ this.onHandleUp = null;
25
+ this.isFixed = fixed;
26
+ this.deadZone = deadzone;
27
+ this.maxDistance = maxdistance;
28
+ this.mouseButton = button;
29
+ if (baseid)
30
+ this.base = document.getElementById(baseid);
31
+ if (stickid)
32
+ this.stick = document.getElementById(stickid);
33
+ if (this.base)
34
+ this.base.oncontextmenu = (e) => false;
35
+ if (this.stick)
36
+ this.stick.oncontextmenu = (e) => false;
37
+ if (this.isFixed) {
38
+ if (this.stick) {
39
+ this.stick.addEventListener("pointerdown", (e) => this.handleDown(e));
40
+ }
41
+ else {
42
+ console.warn("Failed to locate fixed joystick element: " + stickid);
43
+ }
44
+ }
45
+ else {
46
+ if (this.base)
47
+ this.base.style.opacity = "0";
48
+ if (this.stick)
49
+ this.stick.style.opacity = "0";
50
+ document.documentElement.addEventListener("pointerdown", (e) => this.handleDown(e));
51
+ }
52
+ document.documentElement.addEventListener("pointermove", (e) => this.handleMove(e), { passive: false });
53
+ document.documentElement.addEventListener("pointerup", (e) => this.handleUp(e));
54
+ }
55
+ dispose() {
56
+ }
57
+ isActive() { return this.active; }
58
+ getValueX() { return this.xvalue; }
59
+ getValueY() { return this.yvalue; }
60
+ getMouseButton() { return this.mouseButton; }
61
+ getBaseElement() { return this.base; }
62
+ getStickElement() { return this.stick; }
63
+ isFixedJoystick() { return this.isFixed; }
64
+ handleDown(event) {
65
+ if (!this.enabled)
66
+ return;
67
+ const leftButtonDown = (event.buttons & 1) === 1;
68
+ const rightButtonDown = (event.buttons & 2) === 2;
69
+ if (this.mouseButton === TouchMouseButton.Left && !leftButtonDown)
70
+ return;
71
+ if (this.mouseButton === TouchMouseButton.Right && !rightButtonDown)
72
+ return;
73
+ this.active = true;
74
+ this.pointerId = event.pointerId;
75
+ this.showBaseElement(event);
76
+ if (this.stick)
77
+ this.stick.style.transition = "0s";
78
+ if (this.active && this.preventDefault)
79
+ event.preventDefault();
80
+ if (event.changedTouches) {
81
+ this.dragStart = { x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY };
82
+ this.touchId = event.changedTouches[0].identifier;
83
+ }
84
+ else {
85
+ this.dragStart = { x: event.clientX, y: event.clientY };
86
+ }
87
+ if (this.onHandleDown)
88
+ this.onHandleDown(event);
89
+ if (this.stopPropagation)
90
+ event.stopPropagation();
91
+ }
92
+ handleMove(event) {
93
+ if (!this.enabled || !this.active || event.pointerId !== this.pointerId)
94
+ return;
95
+ if (event.changedTouches) {
96
+ let touchmoveId = null;
97
+ for (let i = 0; i < event.changedTouches.length; i++) {
98
+ if (this.touchId === event.changedTouches[i].identifier) {
99
+ touchmoveId = i;
100
+ event.clientX = event.changedTouches[i].clientX;
101
+ event.clientY = event.changedTouches[i].clientY;
102
+ }
103
+ }
104
+ if (touchmoveId === null)
105
+ return;
106
+ }
107
+ const xDiff = event.clientX - this.dragStart.x;
108
+ const yDiff = event.clientY - this.dragStart.y;
109
+ const angle = Math.atan2(yDiff, xDiff);
110
+ const distance = Math.min(this.maxDistance, Math.hypot(xDiff, yDiff));
111
+ const xPosition = distance * Math.cos(angle);
112
+ const yPosition = distance * Math.sin(angle);
113
+ if (this.stick)
114
+ this.stick.style.transform = `translate3d(${xPosition}px, ${yPosition}px, 0px)`;
115
+ const distance2 = (distance < this.deadZone) ? 0 : this.maxDistance / (this.maxDistance - this.deadZone) * (distance - this.deadZone);
116
+ const xPosition2 = distance2 * Math.cos(angle);
117
+ const yPosition2 = distance2 * Math.sin(angle);
118
+ const xPercent = parseFloat((xPosition2 / this.maxDistance).toFixed(4));
119
+ const yPercent = parseFloat((yPosition2 / this.maxDistance).toFixed(4));
120
+ this.xvalue = xPercent;
121
+ this.yvalue = yPercent;
122
+ if (this.onHandleMove)
123
+ this.onHandleMove(event);
124
+ if (this.stopPropagation)
125
+ event.stopPropagation();
126
+ }
127
+ handleUp(event) {
128
+ if (!this.enabled || !this.active || event.pointerId !== this.pointerId)
129
+ return;
130
+ if (event.changedTouches && this.touchId !== event.changedTouches[0].identifier)
131
+ return;
132
+ if (this.stick) {
133
+ this.stick.style.transition = ".2s";
134
+ this.stick.style.transform = `translate3d(0px, 0px, 0px)`;
135
+ }
136
+ this.xvalue = 0;
137
+ this.yvalue = 0;
138
+ this.touchId = null;
139
+ this.pointerId = null;
140
+ this.active = false;
141
+ this.hideBaseElement();
142
+ if (this.onHandleUp)
143
+ this.onHandleUp(event);
144
+ if (this.stopPropagation)
145
+ event.stopPropagation();
146
+ }
147
+ showBaseElement(event) {
148
+ if (!this.isFixed && this.updateElements) {
149
+ if (this.base && this.base.style.opacity !== this.baseElementOpacity) {
150
+ const baseRect = this.base.getBoundingClientRect();
151
+ this.base.style.left = event.clientX - baseRect.width / 2 + "px";
152
+ this.base.style.top = event.clientY - baseRect.height / 2 + "px";
153
+ this.base.style.opacity = this.baseElementOpacity;
154
+ }
155
+ if (this.stick && this.stick.style.opacity !== this.stickElementOpacity) {
156
+ this.stick.style.opacity = this.stickElementOpacity;
157
+ }
158
+ }
159
+ else if (!this.isFixed && !this.updateElements) {
160
+ this.hideBaseElement();
161
+ }
162
+ }
163
+ hideBaseElement() {
164
+ if (!this.isFixed) {
165
+ if (this.base && this.base.style.opacity !== "0") {
166
+ this.base.style.opacity = "0";
167
+ this.base.style.left = "-1000px";
168
+ this.base.style.top = "-1000px";
169
+ }
170
+ if (this.stick && this.stick.style.opacity !== "0") {
171
+ this.stick.style.opacity = "0";
172
+ }
173
+ }
174
+ }
175
+ }
@@ -0,0 +1,6 @@
1
+ export declare enum TouchMouseButton {
2
+ Any = -1,
3
+ Left = 0,
4
+ Right = 1
5
+ }
6
+ //# sourceMappingURL=touchmousebutton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"touchmousebutton.d.ts","sourceRoot":"","sources":["../src/touchmousebutton.ts"],"names":[],"mappings":"AAEA,oBAAY,gBAAgB;IACpB,GAAG,KAAK;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACZ"}
@@ -0,0 +1,6 @@
1
+ export var TouchMouseButton;
2
+ (function (TouchMouseButton) {
3
+ TouchMouseButton[TouchMouseButton["Any"] = -1] = "Any";
4
+ TouchMouseButton[TouchMouseButton["Left"] = 0] = "Left";
5
+ TouchMouseButton[TouchMouseButton["Right"] = 1] = "Right";
6
+ })(TouchMouseButton || (TouchMouseButton = {}));
@@ -0,0 +1,31 @@
1
+ import { Scene } from '@babylonjs/core/scene';
2
+ import { Vector4 } from '@babylonjs/core/Maths/math.vector';
3
+ import { CustomShaderMaterial, CustomShaderMaterialPlugin } from './scenemanager';
4
+ import { ShaderLanguage } from '@babylonjs/core/Materials';
5
+ import { MaterialDefines } from '@babylonjs/core/Materials/materialDefines';
6
+ import { UniformBuffer } from '@babylonjs/core/Materials/uniformBuffer';
7
+ import { SubMesh } from '@babylonjs/core/Meshes/subMesh';
8
+ import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
9
+ import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
10
+ import { AbstractEngine } from '@babylonjs/core/Engines/abstractEngine';
11
+ export declare class TreeBranchMaterial extends CustomShaderMaterial {
12
+ private _windTimeAccum;
13
+ constructor(name: string, scene: Scene);
14
+ awake(): void;
15
+ update(): void;
16
+ getShaderName(): string;
17
+ setWindDirection(x: number, y: number, z: number): void;
18
+ getWindDirection(): Vector4;
19
+ }
20
+ export declare class TreeBranchMaterialPlugin extends CustomShaderMaterialPlugin {
21
+ constructor(customMaterial: CustomShaderMaterial, shaderName: string);
22
+ isCompatible(shaderLanguage: ShaderLanguage): boolean;
23
+ getCustomCode(shaderType: string, shaderLanguage: ShaderLanguage): any;
24
+ getUniforms(shaderLanguage: ShaderLanguage): any;
25
+ getSamplers(samplers: string[]): void;
26
+ getAttributes(attributes: string[], scene: Scene, mesh: AbstractMesh): void;
27
+ prepareDefines(defines: MaterialDefines, scene: Scene, mesh: AbstractMesh): void;
28
+ bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: AbstractEngine, subMesh: SubMesh): void;
29
+ static ExtractWindZoneOverride(properties: any, terrainTransform: TransformNode, builderInstance?: any): any | null;
30
+ }
31
+ //# sourceMappingURL=treebranchmaterial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treebranchmaterial.d.ts","sourceRoot":"","sources":["../src/treebranchmaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAW,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAgB,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,qBAAa,kBAAmB,SAAQ,oBAAoB;IACpD,OAAO,CAAC,cAAc,CAAe;gBAElB,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;IAsBtC,KAAK,IAAI,IAAI;IAIb,MAAM,IAAI,IAAI;IAcd,aAAa,IAAI,MAAM;IAIvB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAUvD,gBAAgB,IAAI,OAAO;CAGrC;AAEL,qBAAa,wBAAyB,SAAQ,0BAA0B;gBAC7C,cAAc,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM;IAIpE,YAAY,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO;IAIrD,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,GAAG;IAyOtE,WAAW,CAAC,cAAc,EAAE,cAAc,GAAG,GAAG;IAOhD,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;IAKrC,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI;IAS3E,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI;IAKhF,cAAc,CAAC,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;WAYnG,uBAAuB,CAAC,UAAU,EAAE,GAAG,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI;CA+C7H"}