@yangyongtao/gaea 1.0.3 → 1.1.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.
Files changed (137) hide show
  1. package/README.md +158 -67
  2. package/package.json +28 -7
  3. package/public/Gaea.apple-touch-icon.png +0 -0
  4. package/public/Gaea.apple-touch-icon.png.import +35 -0
  5. package/public/Gaea.audio.worklet.js +211 -0
  6. package/public/Gaea.html +245 -0
  7. package/public/Gaea.icon.png +0 -0
  8. package/public/Gaea.icon.png.import +35 -0
  9. package/public/Gaea.js +782 -0
  10. package/public/Gaea.png +0 -0
  11. package/public/Gaea.png.import +35 -0
  12. package/public/Gaea.worker.js +1 -0
  13. package/public/GaeaApp.html +275 -0
  14. package/public/GaeaMethods.js +4342 -0
  15. package/public/GaeaModule.html +276 -0
  16. package/public/config.js +76 -0
  17. package/public/constants.js +185 -0
  18. package/public/favicon.ico +0 -0
  19. package/public/image/1.png +0 -0
  20. package/public/image/12-min-min.gif +0 -0
  21. package/public/image/3.png +0 -0
  22. package/public/image/labelImg//345/217/263/350/276/271.png +0 -0
  23. package/public/image/labelImg//345/267/246/350/276/271.png +0 -0
  24. package/public/image/labelImg//346/260/264/344/275/215.png +0 -0
  25. package/public/image/screenIcon//345/205/266/344/273/226.png +0 -0
  26. package/public/image/screenIcon//345/256/211/345/205/250/347/233/221/346/265/213/350/201/232/345/220/210-/347/272/242.png +0 -0
  27. package/public/image/screenIcon//345/256/211/345/205/250/347/233/221/346/265/213/350/201/232/345/220/210-/347/273/277.png +0 -0
  28. package/public/image/screenIcon//346/212/242/351/231/251/345/215/225/344/275/215.png +0 -0
  29. package/public/image/screenIcon//346/226/255/351/235/242.png +0 -0
  30. package/public/image/screenIcon//346/227/240/344/272/272/346/234/272.png +0 -0
  31. package/public/image/screenIcon//346/227/240/344/272/272/346/234/272/345/237/272/345/234/260.png +0 -0
  32. package/public/image/screenIcon//346/260/264/345/272/223/347/253/231.png +0 -0
  33. package/public/image/screenIcon//346/260/264/346/226/207/346/265/213/347/253/231.png +0 -0
  34. package/public/image/screenIcon//346/260/264/351/227/270.png +0 -0
  35. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/346/227/240/346/225/260/346/215/256.png +0 -0
  36. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/346/255/243/345/270/270.png +0 -0
  37. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/350/266/205/344/277/235.png +0 -0
  38. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/350/266/205/350/255/246.png +0 -0
  39. package/public/image/screenIcon//346/263/265/347/253/231-/347/201/260.png +0 -0
  40. package/public/image/screenIcon//346/263/265/347/253/231-/347/273/277.png +0 -0
  41. package/public/image/screenIcon//346/265/201/351/207/217/346/265/213/347/253/231.png +0 -0
  42. package/public/image/screenIcon//346/265/267/345/241/230-1/347/272/247.png +0 -0
  43. package/public/image/screenIcon//346/265/267/345/241/230-2/347/272/247.png +0 -0
  44. package/public/image/screenIcon//346/265/267/345/241/230-3/347/272/247.png +0 -0
  45. package/public/image/screenIcon//346/265/267/345/241/230-4/347/272/247.png +0 -0
  46. package/public/image/screenIcon//346/265/267/345/241/230-5/347/272/247.png +0 -0
  47. package/public/image/screenIcon//346/265/267/345/241/230-/346/251/231.png +0 -0
  48. package/public/image/screenIcon//346/265/267/345/241/230-/347/272/242.png +0 -0
  49. package/public/image/screenIcon//346/265/267/345/241/230-/347/273/277.png +0 -0
  50. package/public/image/screenIcon//346/265/267/345/241/230-/350/247/204/346/250/241/344/273/245/344/270/213.png +0 -0
  51. package/public/image/screenIcon//346/265/267/345/241/230-/351/273/204.png +0 -0
  52. package/public/image/screenIcon//346/265/267/345/241/230.png +0 -0
  53. package/public/image/screenIcon//346/275/256/344/275/215.png +0 -0
  54. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/346/227/240/346/225/260/346/215/256.png +0 -0
  55. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/346/255/243/345/270/270.png +0 -0
  56. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/350/266/205/344/277/235.png +0 -0
  57. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/350/266/205/350/255/246.png +0 -0
  58. package/public/image/screenIcon//347/211/251/350/265/204/344/273/223/345/272/223.png +0 -0
  59. package/public/image/screenIcon//347/220/203/346/234/272-/345/205/263.png +0 -0
  60. package/public/image/screenIcon//347/220/203/346/234/272-/345/274/200.png +0 -0
  61. package/public/image/screenIcon//347/220/203/346/234/272-/347/272/242.png +0 -0
  62. package/public/image/screenIcon//350/247/206/351/242/221/347/233/221/346/216/247.png +0 -0
  63. package/public/image/screenIcon//351/227/270/351/227/250-/347/201/260.png +0 -0
  64. package/public/image/screenIcon//351/227/270/351/227/250-/347/273/277.png +0 -0
  65. package/public/image/screenIcon//351/230/262/346/264/252/344/273/223/345/272/223.png +0 -0
  66. package/public/image/screenIcon//351/232/220/346/202/243.png +0 -0
  67. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/346/265/205/350/223/235.png +0 -0
  68. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/201/260.png +0 -0
  69. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/262/211.png +0 -0
  70. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/272/242.png +0 -0
  71. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/273/277.png +0 -0
  72. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/350/223/235.png +0 -0
  73. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/351/273/204.png +0 -0
  74. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/351/273/221.png +0 -0
  75. package/public/image/screenIcon//351/243/216/351/200/237.png +0 -0
  76. package/public/image/screenIcon//351/243/216/351/200/237/346/265/213/347/253/231.png +0 -0
  77. package/public/image//346/260/264/346/226/207.gif +0 -0
  78. package/public/image//350/211/262/345/270/246.png +0 -0
  79. package/public/index.html +22 -0
  80. package/public/index.js +185662 -0
  81. package/public/jsWebControl-1.0.0.min.js +31 -0
  82. package/public/jsencrypt.min.js +1 -0
  83. package/public/math/Box2.js +203 -0
  84. package/public/math/Box3.js +532 -0
  85. package/public/math/Color.js +605 -0
  86. package/public/math/ColorManagement.js +74 -0
  87. package/public/math/Cylindrical.js +61 -0
  88. package/public/math/EngineUtils.js +81 -0
  89. package/public/math/Euler.js +315 -0
  90. package/public/math/Frustum.js +162 -0
  91. package/public/math/Interpolant.js +241 -0
  92. package/public/math/Line3.js +115 -0
  93. package/public/math/MathUtils.js +345 -0
  94. package/public/math/Matrix3.js +365 -0
  95. package/public/math/Matrix4.js +858 -0
  96. package/public/math/Plane.js +205 -0
  97. package/public/math/Quaternion.js +724 -0
  98. package/public/math/Ray.js +493 -0
  99. package/public/math/Sphere.js +243 -0
  100. package/public/math/Spherical.js +86 -0
  101. package/public/math/SphericalHarmonics3.js +243 -0
  102. package/public/math/Triangle.js +299 -0
  103. package/public/math/Vector2.js +464 -0
  104. package/public/math/Vector3.js +715 -0
  105. package/public/math/Vector4.js +644 -0
  106. package/public/math/interpolants/CubicInterpolant.js +151 -0
  107. package/public/math/interpolants/DiscreteInterpolant.js +26 -0
  108. package/public/math/interpolants/LinearInterpolant.js +38 -0
  109. package/public/math/interpolants/QuaternionLinearInterpolant.js +39 -0
  110. package/public/static/Cloud.png +0 -0
  111. package/public/static/Global2.jpg +0 -0
  112. package/public/static/css/main.css +170 -0
  113. package/public/static/geojson//346/265/267/345/241/230.geojson +99 -0
  114. package/public/static/img/loading.gif +0 -0
  115. package/public/static/js/app.js +359 -0
  116. package/public/static/js/appcontroller.js +207 -0
  117. package/public/static/js/dist/game.dev.js +137 -0
  118. package/public/static/js/env.js +74 -0
  119. package/public/static/js/event/event.js +107 -0
  120. package/public/static/js/init.js +8 -0
  121. package/public/static/js/initcloudmorph.js +1 -0
  122. package/public/static/js/log.js +35 -0
  123. package/public/static/js/network/ajax.js +29 -0
  124. package/public/static/js/network/rtcp.js +172 -0
  125. package/public/static/js/network/socket.js +106 -0
  126. package/public/web-control.min.js +2 -0
  127. package/scripts/postinstall.mjs +127 -0
  128. package/src/GaeaMethods.js +68 -405
  129. package/src/components/FlyAlongRoute.vue +1 -0
  130. package/src/components/WeatherControl.vue +2 -0
  131. package/src/directives/vDrag.js +70 -0
  132. package/src/index.js +1 -8
  133. package/src/plugin.js +16 -0
  134. package/src/utils.js +10 -21
  135. package/src/vite-plugin.js +117 -0
  136. package/public/static/1111.res +0 -0
  137. package/src/config.js +0 -40
@@ -0,0 +1,241 @@
1
+ /**
2
+ * Abstract base class of interpolants over parametric samples.
3
+ *
4
+ * The parameter domain is one dimensional, typically the time or a path
5
+ * along a curve defined by the data.
6
+ *
7
+ * The sample values can have any dimensionality and derived classes may
8
+ * apply special interpretations to the data.
9
+ *
10
+ * This class provides the interval seek in a Template Method, deferring
11
+ * the actual interpolation to derived classes.
12
+ *
13
+ * Time complexity is O(1) for linear access crossing at most two points
14
+ * and O(log N) for random access, where N is the number of positions.
15
+ *
16
+ * References:
17
+ *
18
+ * http://www.oodesign.com/template-method-pattern.html
19
+ *
20
+ */
21
+
22
+ class Interpolant {
23
+
24
+ constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) {
25
+
26
+ this.parameterPositions = parameterPositions;
27
+ this._cachedIndex = 0;
28
+
29
+ this.resultBuffer = resultBuffer !== undefined ?
30
+ resultBuffer : new sampleValues.constructor( sampleSize );
31
+ this.sampleValues = sampleValues;
32
+ this.valueSize = sampleSize;
33
+
34
+ this.settings = null;
35
+ this.DefaultSettings_ = {};
36
+
37
+ }
38
+
39
+ evaluate( t ) {
40
+
41
+ const pp = this.parameterPositions;
42
+ let i1 = this._cachedIndex,
43
+ t1 = pp[ i1 ],
44
+ t0 = pp[ i1 - 1 ];
45
+
46
+ validate_interval: {
47
+
48
+ seek: {
49
+
50
+ let right;
51
+
52
+ linear_scan: {
53
+
54
+ //- See http://jsperf.com/comparison-to-undefined/3
55
+ //- slower code:
56
+ //-
57
+ //- if ( t >= t1 || t1 === undefined ) {
58
+ forward_scan: if ( ! ( t < t1 ) ) {
59
+
60
+ for ( let giveUpAt = i1 + 2; ; ) {
61
+
62
+ if ( t1 === undefined ) {
63
+
64
+ if ( t < t0 ) break forward_scan;
65
+
66
+ // after end
67
+
68
+ i1 = pp.length;
69
+ this._cachedIndex = i1;
70
+ return this.copySampleValue_( i1 - 1 );
71
+
72
+ }
73
+
74
+ if ( i1 === giveUpAt ) break; // this loop
75
+
76
+ t0 = t1;
77
+ t1 = pp[ ++ i1 ];
78
+
79
+ if ( t < t1 ) {
80
+
81
+ // we have arrived at the sought interval
82
+ break seek;
83
+
84
+ }
85
+
86
+ }
87
+
88
+ // prepare binary search on the right side of the index
89
+ right = pp.length;
90
+ break linear_scan;
91
+
92
+ }
93
+
94
+ //- slower code:
95
+ //- if ( t < t0 || t0 === undefined ) {
96
+ if ( ! ( t >= t0 ) ) {
97
+
98
+ // looping?
99
+
100
+ const t1global = pp[ 1 ];
101
+
102
+ if ( t < t1global ) {
103
+
104
+ i1 = 2; // + 1, using the scan for the details
105
+ t0 = t1global;
106
+
107
+ }
108
+
109
+ // linear reverse scan
110
+
111
+ for ( let giveUpAt = i1 - 2; ; ) {
112
+
113
+ if ( t0 === undefined ) {
114
+
115
+ // before start
116
+
117
+ this._cachedIndex = 0;
118
+ return this.copySampleValue_( 0 );
119
+
120
+ }
121
+
122
+ if ( i1 === giveUpAt ) break; // this loop
123
+
124
+ t1 = t0;
125
+ t0 = pp[ -- i1 - 1 ];
126
+
127
+ if ( t >= t0 ) {
128
+
129
+ // we have arrived at the sought interval
130
+ break seek;
131
+
132
+ }
133
+
134
+ }
135
+
136
+ // prepare binary search on the left side of the index
137
+ right = i1;
138
+ i1 = 0;
139
+ break linear_scan;
140
+
141
+ }
142
+
143
+ // the interval is valid
144
+
145
+ break validate_interval;
146
+
147
+ } // linear scan
148
+
149
+ // binary search
150
+
151
+ while ( i1 < right ) {
152
+
153
+ const mid = ( i1 + right ) >>> 1;
154
+
155
+ if ( t < pp[ mid ] ) {
156
+
157
+ right = mid;
158
+
159
+ } else {
160
+
161
+ i1 = mid + 1;
162
+
163
+ }
164
+
165
+ }
166
+
167
+ t1 = pp[ i1 ];
168
+ t0 = pp[ i1 - 1 ];
169
+
170
+ // check boundary cases, again
171
+
172
+ if ( t0 === undefined ) {
173
+
174
+ this._cachedIndex = 0;
175
+ return this.copySampleValue_( 0 );
176
+
177
+ }
178
+
179
+ if ( t1 === undefined ) {
180
+
181
+ i1 = pp.length;
182
+ this._cachedIndex = i1;
183
+ return this.copySampleValue_( i1 - 1 );
184
+
185
+ }
186
+
187
+ } // seek
188
+
189
+ this._cachedIndex = i1;
190
+
191
+ this.intervalChanged_( i1, t0, t1 );
192
+
193
+ } // validate_interval
194
+
195
+ return this.interpolate_( i1, t0, t, t1 );
196
+
197
+ }
198
+
199
+ getSettings_() {
200
+
201
+ return this.settings || this.DefaultSettings_;
202
+
203
+ }
204
+
205
+ copySampleValue_( index ) {
206
+
207
+ // copies a sample value to the result buffer
208
+
209
+ const result = this.resultBuffer,
210
+ values = this.sampleValues,
211
+ stride = this.valueSize,
212
+ offset = index * stride;
213
+
214
+ for ( let i = 0; i !== stride; ++ i ) {
215
+
216
+ result[ i ] = values[ offset + i ];
217
+
218
+ }
219
+
220
+ return result;
221
+
222
+ }
223
+
224
+ // Template methods for derived classes:
225
+
226
+ interpolate_( /* i1, t0, t, t1 */ ) {
227
+
228
+ throw new Error( 'call to abstract method' );
229
+ // implementations shall return this.resultBuffer
230
+
231
+ }
232
+
233
+ intervalChanged_( /* i1, t0, t1 */ ) {
234
+
235
+ // empty
236
+
237
+ }
238
+
239
+ }
240
+
241
+ export { Interpolant };
@@ -0,0 +1,115 @@
1
+ import { Vector3 } from './Vector3.js';
2
+ import * as MathUtils from './MathUtils.js';
3
+
4
+ const _startP = /*@__PURE__*/ new Vector3();
5
+ const _startEnd = /*@__PURE__*/ new Vector3();
6
+
7
+ class Line3 {
8
+
9
+ constructor( start = new Vector3(), end = new Vector3() ) {
10
+
11
+ this.start = start;
12
+ this.end = end;
13
+
14
+ }
15
+
16
+ set( start, end ) {
17
+
18
+ this.start.copy( start );
19
+ this.end.copy( end );
20
+
21
+ return this;
22
+
23
+ }
24
+
25
+ copy( line ) {
26
+
27
+ this.start.copy( line.start );
28
+ this.end.copy( line.end );
29
+
30
+ return this;
31
+
32
+ }
33
+
34
+ getCenter( target ) {
35
+
36
+ return target.addVectors( this.start, this.end ).multiplyScalar( 0.5 );
37
+
38
+ }
39
+
40
+ delta( target ) {
41
+
42
+ return target.subVectors( this.end, this.start );
43
+
44
+ }
45
+
46
+ distanceSq() {
47
+
48
+ return this.start.distanceToSquared( this.end );
49
+
50
+ }
51
+
52
+ distance() {
53
+
54
+ return this.start.distanceTo( this.end );
55
+
56
+ }
57
+
58
+ at( t, target ) {
59
+
60
+ return this.delta( target ).multiplyScalar( t ).add( this.start );
61
+
62
+ }
63
+
64
+ closestPointToPointParameter( point, clampToLine ) {
65
+
66
+ _startP.subVectors( point, this.start );
67
+ _startEnd.subVectors( this.end, this.start );
68
+
69
+ const startEnd2 = _startEnd.dot( _startEnd );
70
+ const startEnd_startP = _startEnd.dot( _startP );
71
+
72
+ let t = startEnd_startP / startEnd2;
73
+
74
+ if ( clampToLine ) {
75
+
76
+ t = MathUtils.clamp( t, 0, 1 );
77
+
78
+ }
79
+
80
+ return t;
81
+
82
+ }
83
+
84
+ closestPointToPoint( point, clampToLine, target ) {
85
+
86
+ const t = this.closestPointToPointParameter( point, clampToLine );
87
+
88
+ return this.delta( target ).multiplyScalar( t ).add( this.start );
89
+
90
+ }
91
+
92
+ applyMatrix4( matrix ) {
93
+
94
+ this.start.applyMatrix4( matrix );
95
+ this.end.applyMatrix4( matrix );
96
+
97
+ return this;
98
+
99
+ }
100
+
101
+ equals( line ) {
102
+
103
+ return line.start.equals( this.start ) && line.end.equals( this.end );
104
+
105
+ }
106
+
107
+ clone() {
108
+
109
+ return new this.constructor().copy( this );
110
+
111
+ }
112
+
113
+ }
114
+
115
+ export { Line3 };
@@ -0,0 +1,345 @@
1
+ const _lut = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c', '0d', '0e', '0f', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1a', '1b', '1c', '1d', '1e', '1f', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2a', '2b', '2c', '2d', '2e', '2f', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3a', '3b', '3c', '3d', '3e', '3f', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4a', '4b', '4c', '4d', '4e', '4f', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5a', '5b', '5c', '5d', '5e', '5f', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6a', '6b', '6c', '6d', '6e', '6f', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7a', '7b', '7c', '7d', '7e', '7f', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '8a', '8b', '8c', '8d', '8e', '8f', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '9a', '9b', '9c', '9d', '9e', '9f', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'ca', 'cb', 'cc', 'cd', 'ce', 'cf', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'da', 'db', 'dc', 'dd', 'de', 'df', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'ea', 'eb', 'ec', 'ed', 'ee', 'ef', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'fa', 'fb', 'fc', 'fd', 'fe', 'ff'];
2
+
3
+ let _seed = 1234567;
4
+
5
+
6
+ const DEG2RAD = Math.PI / 180;
7
+ const RAD2DEG = 180 / Math.PI;
8
+
9
+ // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
10
+ function generateUUID() {
11
+
12
+ const d0 = Math.random() * 0xffffffff | 0;
13
+ const d1 = Math.random() * 0xffffffff | 0;
14
+ const d2 = Math.random() * 0xffffffff | 0;
15
+ const d3 = Math.random() * 0xffffffff | 0;
16
+ const uuid = _lut[d0 & 0xff] + _lut[d0 >> 8 & 0xff] + _lut[d0 >> 16 & 0xff] + _lut[d0 >> 24 & 0xff] + '-' +
17
+ _lut[d1 & 0xff] + _lut[d1 >> 8 & 0xff] + '-' + _lut[d1 >> 16 & 0x0f | 0x40] + _lut[d1 >> 24 & 0xff] + '-' +
18
+ _lut[d2 & 0x3f | 0x80] + _lut[d2 >> 8 & 0xff] + '-' + _lut[d2 >> 16 & 0xff] + _lut[d2 >> 24 & 0xff] +
19
+ _lut[d3 & 0xff] + _lut[d3 >> 8 & 0xff] + _lut[d3 >> 16 & 0xff] + _lut[d3 >> 24 & 0xff];
20
+
21
+ // .toLowerCase() here flattens concatenated strings to save heap memory space.
22
+ return uuid.toLowerCase();
23
+
24
+ }
25
+
26
+ function clamp(value, min, max) {
27
+
28
+ return Math.max(min, Math.min(max, value));
29
+
30
+ }
31
+
32
+ // compute euclidean modulo of m % n
33
+ // https://en.wikipedia.org/wiki/Modulo_operation
34
+ function euclideanModulo(n, m) {
35
+
36
+ return ((n % m) + m) % m;
37
+
38
+ }
39
+
40
+ // Linear mapping from range <a1, a2> to range <b1, b2>
41
+ function mapLinear(x, a1, a2, b1, b2) {
42
+
43
+ return b1 + (x - a1) * (b2 - b1) / (a2 - a1);
44
+
45
+ }
46
+
47
+ // https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/inverse-lerp-a-super-useful-yet-often-overlooked-function-r5230/
48
+ function inverseLerp(x, y, value) {
49
+
50
+ if (x !== y) {
51
+
52
+ return (value - x) / (y - x);
53
+
54
+ } else {
55
+
56
+ return 0;
57
+
58
+ }
59
+
60
+ }
61
+
62
+ // https://en.wikipedia.org/wiki/Linear_interpolation
63
+ function lerp(x, y, t) {
64
+
65
+ return (1 - t) * x + t * y;
66
+
67
+ }
68
+
69
+ // http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/
70
+ function damp(x, y, lambda, dt) {
71
+
72
+ return lerp(x, y, 1 - Math.exp(- lambda * dt));
73
+
74
+ }
75
+
76
+ // https://www.desmos.com/calculator/vcsjnyz7x4
77
+ function pingpong(x, length = 1) {
78
+
79
+ return length - Math.abs(euclideanModulo(x, length * 2) - length);
80
+
81
+ }
82
+
83
+ // http://en.wikipedia.org/wiki/Smoothstep
84
+ function smoothstep(x, min, max) {
85
+
86
+ if (x <= min) return 0;
87
+ if (x >= max) return 1;
88
+
89
+ x = (x - min) / (max - min);
90
+
91
+ return x * x * (3 - 2 * x);
92
+
93
+ }
94
+
95
+ function smootherstep(x, min, max) {
96
+
97
+ if (x <= min) return 0;
98
+ if (x >= max) return 1;
99
+
100
+ x = (x - min) / (max - min);
101
+
102
+ return x * x * x * (x * (x * 6 - 15) + 10);
103
+
104
+ }
105
+
106
+ // Random integer from <low, high> interval
107
+ function randInt(low, high) {
108
+
109
+ return low + Math.floor(Math.random() * (high - low + 1));
110
+
111
+ }
112
+
113
+ // Random float from <low, high> interval
114
+ function randFloat(low, high) {
115
+
116
+ return low + Math.random() * (high - low);
117
+
118
+ }
119
+
120
+ // Random float from <-range/2, range/2> interval
121
+ function randFloatSpread(range) {
122
+
123
+ return range * (0.5 - Math.random());
124
+
125
+ }
126
+
127
+ // Deterministic pseudo-random float in the interval [ 0, 1 ]
128
+ function seededRandom(s) {
129
+
130
+ if (s !== undefined) _seed = s;
131
+
132
+ // Mulberry32 generator
133
+
134
+ let t = _seed += 0x6D2B79F5;
135
+
136
+ t = Math.imul(t ^ t >>> 15, t | 1);
137
+
138
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
139
+
140
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
141
+
142
+ }
143
+
144
+ function degToRad(degrees) {
145
+
146
+ return degrees * DEG2RAD;
147
+
148
+ }
149
+
150
+ function radToDeg(radians) {
151
+
152
+ return radians * RAD2DEG;
153
+
154
+ }
155
+
156
+ function isPowerOfTwo(value) {
157
+
158
+ return (value & (value - 1)) === 0 && value !== 0;
159
+
160
+ }
161
+
162
+ function ceilPowerOfTwo(value) {
163
+
164
+ return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));
165
+
166
+ }
167
+
168
+ function log(value){
169
+ return Math.log(value);
170
+ }
171
+ function sin(value){
172
+ return Math.sin(value);
173
+ }
174
+ function cos(value){
175
+ return Math.cos(value);
176
+ }
177
+ function abs(value){
178
+ return Math.abs(value);
179
+ }
180
+ function sqrt(value){
181
+ return Math.sqrt(value);
182
+ }
183
+ function pow(value1, value2){
184
+ return Math.pow(value1,value2);
185
+ }
186
+
187
+ function floorPowerOfTwo(value) {
188
+
189
+ return Math.pow(2, Math.floor(Math.log(value) / Math.LN2));
190
+
191
+ }
192
+
193
+ function setQuaternionFromProperEuler(q, a, b, c, order) {
194
+
195
+ // Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles
196
+
197
+ // rotations are applied to the axes in the order specified by 'order'
198
+ // rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c'
199
+ // angles are in radians
200
+
201
+ const cos = Math.cos;
202
+ const sin = Math.sin;
203
+
204
+ const c2 = cos(b / 2);
205
+ const s2 = sin(b / 2);
206
+
207
+ const c13 = cos((a + c) / 2);
208
+ const s13 = sin((a + c) / 2);
209
+
210
+ const c1_3 = cos((a - c) / 2);
211
+ const s1_3 = sin((a - c) / 2);
212
+
213
+ const c3_1 = cos((c - a) / 2);
214
+ const s3_1 = sin((c - a) / 2);
215
+
216
+ switch (order) {
217
+
218
+ case 'XYX':
219
+ q.set(c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13);
220
+ break;
221
+
222
+ case 'YZY':
223
+ q.set(s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13);
224
+ break;
225
+
226
+ case 'ZXZ':
227
+ q.set(s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13);
228
+ break;
229
+
230
+ case 'XZX':
231
+ q.set(c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13);
232
+ break;
233
+
234
+ case 'YXY':
235
+ q.set(s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13);
236
+ break;
237
+
238
+ case 'ZYZ':
239
+ q.set(s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13);
240
+ break;
241
+
242
+ default:
243
+ console.warn('THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order);
244
+
245
+ }
246
+
247
+ }
248
+
249
+ function denormalize(value, array) {
250
+
251
+ switch (array.constructor) {
252
+
253
+ case Float32Array:
254
+
255
+ return value;
256
+
257
+ case Uint16Array:
258
+
259
+ return value / 65535.0;
260
+
261
+ case Uint8Array:
262
+
263
+ return value / 255.0;
264
+
265
+ case Int16Array:
266
+
267
+ return Math.max(value / 32767.0, - 1.0);
268
+
269
+ case Int8Array:
270
+
271
+ return Math.max(value / 127.0, - 1.0);
272
+
273
+ default:
274
+
275
+ throw new Error('Invalid component type.');
276
+
277
+ }
278
+
279
+ }
280
+
281
+ function normalize(value, array) {
282
+
283
+ switch (array.constructor) {
284
+
285
+ case Float32Array:
286
+
287
+ return value;
288
+
289
+ case Uint16Array:
290
+
291
+ return Math.round(value * 65535.0);
292
+
293
+ case Uint8Array:
294
+
295
+ return Math.round(value * 255.0);
296
+
297
+ case Int16Array:
298
+
299
+ return Math.round(value * 32767.0);
300
+
301
+ case Int8Array:
302
+
303
+ return Math.round(value * 127.0);
304
+
305
+ default:
306
+
307
+ throw new Error('Invalid component type.');
308
+
309
+ }
310
+
311
+ }
312
+
313
+
314
+
315
+ export {
316
+ DEG2RAD,
317
+ RAD2DEG,
318
+ generateUUID,
319
+ clamp,
320
+ euclideanModulo,
321
+ mapLinear,
322
+ inverseLerp,
323
+ lerp,
324
+ damp,
325
+ pingpong,
326
+ smoothstep,
327
+ smootherstep,
328
+ randInt,
329
+ randFloat,
330
+ randFloatSpread,
331
+ seededRandom,
332
+ degToRad,
333
+ radToDeg,
334
+ isPowerOfTwo,
335
+ ceilPowerOfTwo,
336
+ floorPowerOfTwo,
337
+ setQuaternionFromProperEuler,
338
+ normalize,
339
+ sin,
340
+ cos,
341
+ log,
342
+ sqrt,
343
+ pow,
344
+ abs,
345
+ };