xl-public-utils 1.0.11 → 1.0.13
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/index.d.ts +52 -0
- package/index.js +2 -1
- package/package.json +4 -2
- package/src/drcUtils.js +1 -0
- package/src/threeFont/Curve/Curve.js +349 -0
- package/src/threeFont/Curve/CurvePath.js +202 -0
- package/src/threeFont/Curve/Interpolations.js +57 -0
- package/src/threeFont/Curve/Shape.js +77 -0
- package/src/threeFont/Math/MathUtils.js +526 -0
- package/src/threeFont/Math/Matrix4.js +863 -0
- package/src/threeFont/Math/Quaternion.js +584 -0
- package/src/threeFont/Math/Vector2.js +373 -0
- package/src/threeFont/Math/Vector3.js +617 -0
- package/src/threeFont/TextGeometry/Earcut.js +634 -0
- package/src/threeFont/TextGeometry/ExtrudeGeometry.js +647 -0
- package/src/threeFont/TextGeometry/FontLoader.js +114 -0
- package/src/threeFont/TextGeometry/Path.js +146 -0
- package/src/threeFont/TextGeometry/ShapePath.js +222 -0
- package/src/threeFont/TextGeometry/ShapeUtils.js +70 -0
- package/src/threeFont/curves/CubicBezierCurve.js +66 -0
- package/src/threeFont/curves/Curves.js +10 -0
- package/src/threeFont/curves/EllipseCurve.js +130 -0
- package/src/threeFont/curves/LineCurve.js +70 -0
- package/src/threeFont/curves/QuadraticBezierCurve.js +61 -0
- package/src/threeFont/curves/SplineCurve.js +76 -0
- package/src/threeFont/index.js +166 -0
- package/src/vtkUtils.js +55 -28
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Path } from '../TextGeometry/Path.js';
|
|
2
|
+
import * as MathUtils from '../Math/MathUtils.js';
|
|
3
|
+
|
|
4
|
+
class Shape extends Path {
|
|
5
|
+
constructor(points) {
|
|
6
|
+
super(points);
|
|
7
|
+
|
|
8
|
+
this.uuid = MathUtils.generateUUID();
|
|
9
|
+
|
|
10
|
+
this.type = 'Shape';
|
|
11
|
+
|
|
12
|
+
this.holes = [];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getPointsHoles(divisions) {
|
|
16
|
+
const holesPts = [];
|
|
17
|
+
|
|
18
|
+
for (let i = 0, l = this.holes.length; i < l; i++) {
|
|
19
|
+
holesPts[i] = this.holes[i].getPoints(divisions);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return holesPts;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// get points of shape and holes (keypoints based on segments parameter)
|
|
26
|
+
|
|
27
|
+
extractPoints(divisions) {
|
|
28
|
+
return {
|
|
29
|
+
shape: this.getPoints(divisions),
|
|
30
|
+
holes: this.getPointsHoles(divisions),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
copy(source) {
|
|
35
|
+
super.copy(source);
|
|
36
|
+
|
|
37
|
+
this.holes = [];
|
|
38
|
+
|
|
39
|
+
for (let i = 0, l = source.holes.length; i < l; i++) {
|
|
40
|
+
const hole = source.holes[i];
|
|
41
|
+
|
|
42
|
+
this.holes.push(hole.clone());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
toJSON() {
|
|
49
|
+
const data = super.toJSON();
|
|
50
|
+
|
|
51
|
+
data.uuid = this.uuid;
|
|
52
|
+
data.holes = [];
|
|
53
|
+
|
|
54
|
+
for (let i = 0, l = this.holes.length; i < l; i++) {
|
|
55
|
+
const hole = this.holes[i];
|
|
56
|
+
data.holes.push(hole.toJSON());
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return data;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fromJSON(json) {
|
|
63
|
+
super.fromJSON(json);
|
|
64
|
+
|
|
65
|
+
this.uuid = json.uuid;
|
|
66
|
+
this.holes = [];
|
|
67
|
+
|
|
68
|
+
for (let i = 0, l = json.holes.length; i < l; i++) {
|
|
69
|
+
const hole = json.holes[i];
|
|
70
|
+
this.holes.push(new Path().fromJSON(hole));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { Shape };
|
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
const _lut = [
|
|
2
|
+
'00',
|
|
3
|
+
'01',
|
|
4
|
+
'02',
|
|
5
|
+
'03',
|
|
6
|
+
'04',
|
|
7
|
+
'05',
|
|
8
|
+
'06',
|
|
9
|
+
'07',
|
|
10
|
+
'08',
|
|
11
|
+
'09',
|
|
12
|
+
'0a',
|
|
13
|
+
'0b',
|
|
14
|
+
'0c',
|
|
15
|
+
'0d',
|
|
16
|
+
'0e',
|
|
17
|
+
'0f',
|
|
18
|
+
'10',
|
|
19
|
+
'11',
|
|
20
|
+
'12',
|
|
21
|
+
'13',
|
|
22
|
+
'14',
|
|
23
|
+
'15',
|
|
24
|
+
'16',
|
|
25
|
+
'17',
|
|
26
|
+
'18',
|
|
27
|
+
'19',
|
|
28
|
+
'1a',
|
|
29
|
+
'1b',
|
|
30
|
+
'1c',
|
|
31
|
+
'1d',
|
|
32
|
+
'1e',
|
|
33
|
+
'1f',
|
|
34
|
+
'20',
|
|
35
|
+
'21',
|
|
36
|
+
'22',
|
|
37
|
+
'23',
|
|
38
|
+
'24',
|
|
39
|
+
'25',
|
|
40
|
+
'26',
|
|
41
|
+
'27',
|
|
42
|
+
'28',
|
|
43
|
+
'29',
|
|
44
|
+
'2a',
|
|
45
|
+
'2b',
|
|
46
|
+
'2c',
|
|
47
|
+
'2d',
|
|
48
|
+
'2e',
|
|
49
|
+
'2f',
|
|
50
|
+
'30',
|
|
51
|
+
'31',
|
|
52
|
+
'32',
|
|
53
|
+
'33',
|
|
54
|
+
'34',
|
|
55
|
+
'35',
|
|
56
|
+
'36',
|
|
57
|
+
'37',
|
|
58
|
+
'38',
|
|
59
|
+
'39',
|
|
60
|
+
'3a',
|
|
61
|
+
'3b',
|
|
62
|
+
'3c',
|
|
63
|
+
'3d',
|
|
64
|
+
'3e',
|
|
65
|
+
'3f',
|
|
66
|
+
'40',
|
|
67
|
+
'41',
|
|
68
|
+
'42',
|
|
69
|
+
'43',
|
|
70
|
+
'44',
|
|
71
|
+
'45',
|
|
72
|
+
'46',
|
|
73
|
+
'47',
|
|
74
|
+
'48',
|
|
75
|
+
'49',
|
|
76
|
+
'4a',
|
|
77
|
+
'4b',
|
|
78
|
+
'4c',
|
|
79
|
+
'4d',
|
|
80
|
+
'4e',
|
|
81
|
+
'4f',
|
|
82
|
+
'50',
|
|
83
|
+
'51',
|
|
84
|
+
'52',
|
|
85
|
+
'53',
|
|
86
|
+
'54',
|
|
87
|
+
'55',
|
|
88
|
+
'56',
|
|
89
|
+
'57',
|
|
90
|
+
'58',
|
|
91
|
+
'59',
|
|
92
|
+
'5a',
|
|
93
|
+
'5b',
|
|
94
|
+
'5c',
|
|
95
|
+
'5d',
|
|
96
|
+
'5e',
|
|
97
|
+
'5f',
|
|
98
|
+
'60',
|
|
99
|
+
'61',
|
|
100
|
+
'62',
|
|
101
|
+
'63',
|
|
102
|
+
'64',
|
|
103
|
+
'65',
|
|
104
|
+
'66',
|
|
105
|
+
'67',
|
|
106
|
+
'68',
|
|
107
|
+
'69',
|
|
108
|
+
'6a',
|
|
109
|
+
'6b',
|
|
110
|
+
'6c',
|
|
111
|
+
'6d',
|
|
112
|
+
'6e',
|
|
113
|
+
'6f',
|
|
114
|
+
'70',
|
|
115
|
+
'71',
|
|
116
|
+
'72',
|
|
117
|
+
'73',
|
|
118
|
+
'74',
|
|
119
|
+
'75',
|
|
120
|
+
'76',
|
|
121
|
+
'77',
|
|
122
|
+
'78',
|
|
123
|
+
'79',
|
|
124
|
+
'7a',
|
|
125
|
+
'7b',
|
|
126
|
+
'7c',
|
|
127
|
+
'7d',
|
|
128
|
+
'7e',
|
|
129
|
+
'7f',
|
|
130
|
+
'80',
|
|
131
|
+
'81',
|
|
132
|
+
'82',
|
|
133
|
+
'83',
|
|
134
|
+
'84',
|
|
135
|
+
'85',
|
|
136
|
+
'86',
|
|
137
|
+
'87',
|
|
138
|
+
'88',
|
|
139
|
+
'89',
|
|
140
|
+
'8a',
|
|
141
|
+
'8b',
|
|
142
|
+
'8c',
|
|
143
|
+
'8d',
|
|
144
|
+
'8e',
|
|
145
|
+
'8f',
|
|
146
|
+
'90',
|
|
147
|
+
'91',
|
|
148
|
+
'92',
|
|
149
|
+
'93',
|
|
150
|
+
'94',
|
|
151
|
+
'95',
|
|
152
|
+
'96',
|
|
153
|
+
'97',
|
|
154
|
+
'98',
|
|
155
|
+
'99',
|
|
156
|
+
'9a',
|
|
157
|
+
'9b',
|
|
158
|
+
'9c',
|
|
159
|
+
'9d',
|
|
160
|
+
'9e',
|
|
161
|
+
'9f',
|
|
162
|
+
'a0',
|
|
163
|
+
'a1',
|
|
164
|
+
'a2',
|
|
165
|
+
'a3',
|
|
166
|
+
'a4',
|
|
167
|
+
'a5',
|
|
168
|
+
'a6',
|
|
169
|
+
'a7',
|
|
170
|
+
'a8',
|
|
171
|
+
'a9',
|
|
172
|
+
'aa',
|
|
173
|
+
'ab',
|
|
174
|
+
'ac',
|
|
175
|
+
'ad',
|
|
176
|
+
'ae',
|
|
177
|
+
'af',
|
|
178
|
+
'b0',
|
|
179
|
+
'b1',
|
|
180
|
+
'b2',
|
|
181
|
+
'b3',
|
|
182
|
+
'b4',
|
|
183
|
+
'b5',
|
|
184
|
+
'b6',
|
|
185
|
+
'b7',
|
|
186
|
+
'b8',
|
|
187
|
+
'b9',
|
|
188
|
+
'ba',
|
|
189
|
+
'bb',
|
|
190
|
+
'bc',
|
|
191
|
+
'bd',
|
|
192
|
+
'be',
|
|
193
|
+
'bf',
|
|
194
|
+
'c0',
|
|
195
|
+
'c1',
|
|
196
|
+
'c2',
|
|
197
|
+
'c3',
|
|
198
|
+
'c4',
|
|
199
|
+
'c5',
|
|
200
|
+
'c6',
|
|
201
|
+
'c7',
|
|
202
|
+
'c8',
|
|
203
|
+
'c9',
|
|
204
|
+
'ca',
|
|
205
|
+
'cb',
|
|
206
|
+
'cc',
|
|
207
|
+
'cd',
|
|
208
|
+
'ce',
|
|
209
|
+
'cf',
|
|
210
|
+
'd0',
|
|
211
|
+
'd1',
|
|
212
|
+
'd2',
|
|
213
|
+
'd3',
|
|
214
|
+
'd4',
|
|
215
|
+
'd5',
|
|
216
|
+
'd6',
|
|
217
|
+
'd7',
|
|
218
|
+
'd8',
|
|
219
|
+
'd9',
|
|
220
|
+
'da',
|
|
221
|
+
'db',
|
|
222
|
+
'dc',
|
|
223
|
+
'dd',
|
|
224
|
+
'de',
|
|
225
|
+
'df',
|
|
226
|
+
'e0',
|
|
227
|
+
'e1',
|
|
228
|
+
'e2',
|
|
229
|
+
'e3',
|
|
230
|
+
'e4',
|
|
231
|
+
'e5',
|
|
232
|
+
'e6',
|
|
233
|
+
'e7',
|
|
234
|
+
'e8',
|
|
235
|
+
'e9',
|
|
236
|
+
'ea',
|
|
237
|
+
'eb',
|
|
238
|
+
'ec',
|
|
239
|
+
'ed',
|
|
240
|
+
'ee',
|
|
241
|
+
'ef',
|
|
242
|
+
'f0',
|
|
243
|
+
'f1',
|
|
244
|
+
'f2',
|
|
245
|
+
'f3',
|
|
246
|
+
'f4',
|
|
247
|
+
'f5',
|
|
248
|
+
'f6',
|
|
249
|
+
'f7',
|
|
250
|
+
'f8',
|
|
251
|
+
'f9',
|
|
252
|
+
'fa',
|
|
253
|
+
'fb',
|
|
254
|
+
'fc',
|
|
255
|
+
'fd',
|
|
256
|
+
'fe',
|
|
257
|
+
'ff',
|
|
258
|
+
];
|
|
259
|
+
|
|
260
|
+
let _seed = 1234567;
|
|
261
|
+
|
|
262
|
+
const DEG2RAD = Math.PI / 180;
|
|
263
|
+
const RAD2DEG = 180 / Math.PI;
|
|
264
|
+
|
|
265
|
+
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
|
|
266
|
+
function generateUUID() {
|
|
267
|
+
const d0 = (Math.random() * 0xffffffff) | 0;
|
|
268
|
+
const d1 = (Math.random() * 0xffffffff) | 0;
|
|
269
|
+
const d2 = (Math.random() * 0xffffffff) | 0;
|
|
270
|
+
const d3 = (Math.random() * 0xffffffff) | 0;
|
|
271
|
+
const uuid =
|
|
272
|
+
_lut[d0 & 0xff] +
|
|
273
|
+
_lut[(d0 >> 8) & 0xff] +
|
|
274
|
+
_lut[(d0 >> 16) & 0xff] +
|
|
275
|
+
_lut[(d0 >> 24) & 0xff] +
|
|
276
|
+
'-' +
|
|
277
|
+
_lut[d1 & 0xff] +
|
|
278
|
+
_lut[(d1 >> 8) & 0xff] +
|
|
279
|
+
'-' +
|
|
280
|
+
_lut[((d1 >> 16) & 0x0f) | 0x40] +
|
|
281
|
+
_lut[(d1 >> 24) & 0xff] +
|
|
282
|
+
'-' +
|
|
283
|
+
_lut[(d2 & 0x3f) | 0x80] +
|
|
284
|
+
_lut[(d2 >> 8) & 0xff] +
|
|
285
|
+
'-' +
|
|
286
|
+
_lut[(d2 >> 16) & 0xff] +
|
|
287
|
+
_lut[(d2 >> 24) & 0xff] +
|
|
288
|
+
_lut[d3 & 0xff] +
|
|
289
|
+
_lut[(d3 >> 8) & 0xff] +
|
|
290
|
+
_lut[(d3 >> 16) & 0xff] +
|
|
291
|
+
_lut[(d3 >> 24) & 0xff];
|
|
292
|
+
|
|
293
|
+
// .toLowerCase() here flattens concatenated strings to save heap memory space.
|
|
294
|
+
return uuid.toLowerCase();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function clamp(value, min, max) {
|
|
298
|
+
return Math.max(min, Math.min(max, value));
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// compute euclidean modulo of m % n
|
|
302
|
+
// https://en.wikipedia.org/wiki/Modulo_operation
|
|
303
|
+
function euclideanModulo(n, m) {
|
|
304
|
+
return ((n % m) + m) % m;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Linear mapping from range <a1, a2> to range <b1, b2>
|
|
308
|
+
function mapLinear(x, a1, a2, b1, b2) {
|
|
309
|
+
return b1 + ((x - a1) * (b2 - b1)) / (a2 - a1);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/inverse-lerp-a-super-useful-yet-often-overlooked-function-r5230/
|
|
313
|
+
function inverseLerp(x, y, value) {
|
|
314
|
+
if (x !== y) {
|
|
315
|
+
return (value - x) / (y - x);
|
|
316
|
+
} else {
|
|
317
|
+
return 0;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// https://en.wikipedia.org/wiki/Linear_interpolation
|
|
322
|
+
function lerp(x, y, t) {
|
|
323
|
+
return (1 - t) * x + t * y;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/
|
|
327
|
+
function damp(x, y, lambda, dt) {
|
|
328
|
+
return lerp(x, y, 1 - Math.exp(-lambda * dt));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// https://www.desmos.com/calculator/vcsjnyz7x4
|
|
332
|
+
function pingpong(x, length = 1) {
|
|
333
|
+
return length - Math.abs(euclideanModulo(x, length * 2) - length);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// http://en.wikipedia.org/wiki/Smoothstep
|
|
337
|
+
function smoothstep(x, min, max) {
|
|
338
|
+
if (x <= min) return 0;
|
|
339
|
+
if (x >= max) return 1;
|
|
340
|
+
|
|
341
|
+
x = (x - min) / (max - min);
|
|
342
|
+
|
|
343
|
+
return x * x * (3 - 2 * x);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function smootherstep(x, min, max) {
|
|
347
|
+
if (x <= min) return 0;
|
|
348
|
+
if (x >= max) return 1;
|
|
349
|
+
|
|
350
|
+
x = (x - min) / (max - min);
|
|
351
|
+
|
|
352
|
+
return x * x * x * (x * (x * 6 - 15) + 10);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// Random integer from <low, high> interval
|
|
356
|
+
function randInt(low, high) {
|
|
357
|
+
return low + Math.floor(Math.random() * (high - low + 1));
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Random float from <low, high> interval
|
|
361
|
+
function randFloat(low, high) {
|
|
362
|
+
return low + Math.random() * (high - low);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Random float from <-range/2, range/2> interval
|
|
366
|
+
function randFloatSpread(range) {
|
|
367
|
+
return range * (0.5 - Math.random());
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Deterministic pseudo-random float in the interval [ 0, 1 ]
|
|
371
|
+
function seededRandom(s) {
|
|
372
|
+
if (s !== undefined) _seed = s;
|
|
373
|
+
|
|
374
|
+
// Mulberry32 generator
|
|
375
|
+
|
|
376
|
+
let t = (_seed += 0x6d2b79f5);
|
|
377
|
+
|
|
378
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
379
|
+
|
|
380
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
381
|
+
|
|
382
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function degToRad(degrees) {
|
|
386
|
+
return degrees * DEG2RAD;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function radToDeg(radians) {
|
|
390
|
+
return radians * RAD2DEG;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function isPowerOfTwo(value) {
|
|
394
|
+
return (value & (value - 1)) === 0 && value !== 0;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function ceilPowerOfTwo(value) {
|
|
398
|
+
return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function floorPowerOfTwo(value) {
|
|
402
|
+
return Math.pow(2, Math.floor(Math.log(value) / Math.LN2));
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function setQuaternionFromProperEuler(q, a, b, c, order) {
|
|
406
|
+
// Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles
|
|
407
|
+
|
|
408
|
+
// rotations are applied to the axes in the order specified by 'order'
|
|
409
|
+
// rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c'
|
|
410
|
+
// angles are in radians
|
|
411
|
+
|
|
412
|
+
const cos = Math.cos;
|
|
413
|
+
const sin = Math.sin;
|
|
414
|
+
|
|
415
|
+
const c2 = cos(b / 2);
|
|
416
|
+
const s2 = sin(b / 2);
|
|
417
|
+
|
|
418
|
+
const c13 = cos((a + c) / 2);
|
|
419
|
+
const s13 = sin((a + c) / 2);
|
|
420
|
+
|
|
421
|
+
const c1_3 = cos((a - c) / 2);
|
|
422
|
+
const s1_3 = sin((a - c) / 2);
|
|
423
|
+
|
|
424
|
+
const c3_1 = cos((c - a) / 2);
|
|
425
|
+
const s3_1 = sin((c - a) / 2);
|
|
426
|
+
|
|
427
|
+
switch (order) {
|
|
428
|
+
case 'XYX':
|
|
429
|
+
q.set(c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13);
|
|
430
|
+
break;
|
|
431
|
+
|
|
432
|
+
case 'YZY':
|
|
433
|
+
q.set(s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13);
|
|
434
|
+
break;
|
|
435
|
+
|
|
436
|
+
case 'ZXZ':
|
|
437
|
+
q.set(s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13);
|
|
438
|
+
break;
|
|
439
|
+
|
|
440
|
+
case 'XZX':
|
|
441
|
+
q.set(c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13);
|
|
442
|
+
break;
|
|
443
|
+
|
|
444
|
+
case 'YXY':
|
|
445
|
+
q.set(s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13);
|
|
446
|
+
break;
|
|
447
|
+
|
|
448
|
+
case 'ZYZ':
|
|
449
|
+
q.set(s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13);
|
|
450
|
+
break;
|
|
451
|
+
|
|
452
|
+
default:
|
|
453
|
+
console.warn('THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function denormalize(value, array) {
|
|
458
|
+
switch (array.constructor) {
|
|
459
|
+
case Float32Array:
|
|
460
|
+
return value;
|
|
461
|
+
|
|
462
|
+
case Uint16Array:
|
|
463
|
+
return value / 65535.0;
|
|
464
|
+
|
|
465
|
+
case Uint8Array:
|
|
466
|
+
return value / 255.0;
|
|
467
|
+
|
|
468
|
+
case Int16Array:
|
|
469
|
+
return Math.max(value / 32767.0, -1.0);
|
|
470
|
+
|
|
471
|
+
case Int8Array:
|
|
472
|
+
return Math.max(value / 127.0, -1.0);
|
|
473
|
+
|
|
474
|
+
default:
|
|
475
|
+
throw new Error('Invalid component type.');
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function normalize(value, array) {
|
|
480
|
+
switch (array.constructor) {
|
|
481
|
+
case Float32Array:
|
|
482
|
+
return value;
|
|
483
|
+
|
|
484
|
+
case Uint16Array:
|
|
485
|
+
return Math.round(value * 65535.0);
|
|
486
|
+
|
|
487
|
+
case Uint8Array:
|
|
488
|
+
return Math.round(value * 255.0);
|
|
489
|
+
|
|
490
|
+
case Int16Array:
|
|
491
|
+
return Math.round(value * 32767.0);
|
|
492
|
+
|
|
493
|
+
case Int8Array:
|
|
494
|
+
return Math.round(value * 127.0);
|
|
495
|
+
|
|
496
|
+
default:
|
|
497
|
+
throw new Error('Invalid component type.');
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
export {
|
|
502
|
+
DEG2RAD,
|
|
503
|
+
RAD2DEG,
|
|
504
|
+
generateUUID,
|
|
505
|
+
clamp,
|
|
506
|
+
euclideanModulo,
|
|
507
|
+
mapLinear,
|
|
508
|
+
inverseLerp,
|
|
509
|
+
lerp,
|
|
510
|
+
damp,
|
|
511
|
+
pingpong,
|
|
512
|
+
smoothstep,
|
|
513
|
+
smootherstep,
|
|
514
|
+
randInt,
|
|
515
|
+
randFloat,
|
|
516
|
+
randFloatSpread,
|
|
517
|
+
seededRandom,
|
|
518
|
+
degToRad,
|
|
519
|
+
radToDeg,
|
|
520
|
+
isPowerOfTwo,
|
|
521
|
+
ceilPowerOfTwo,
|
|
522
|
+
floorPowerOfTwo,
|
|
523
|
+
setQuaternionFromProperEuler,
|
|
524
|
+
normalize,
|
|
525
|
+
denormalize,
|
|
526
|
+
};
|