viral-viewer-2 2.2.0 → 2.2.2

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.
@@ -105,6 +105,627 @@ function workerFunction() {
105
105
  break;
106
106
  }
107
107
  }, false);
108
+ //#region Threejs Types
109
+ const REVISION = '135';
110
+ const CullFaceNone = 0;
111
+ const CullFaceBack = 1;
112
+ const CullFaceFront = 2;
113
+ const PCFShadowMap = 1;
114
+ const PCFSoftShadowMap = 2;
115
+ const VSMShadowMap = 3;
116
+ const FrontSide = 0;
117
+ const BackSide = 1;
118
+ const DoubleSide = 2;
119
+ const FlatShading = 1;
120
+ const NoBlending = 0;
121
+ const NormalBlending = 1;
122
+ const AdditiveBlending = 2;
123
+ const SubtractiveBlending = 3;
124
+ const MultiplyBlending = 4;
125
+ const CustomBlending = 5;
126
+ const AddEquation = 100;
127
+ const SubtractEquation = 101;
128
+ const ReverseSubtractEquation = 102;
129
+ const MinEquation = 103;
130
+ const MaxEquation = 104;
131
+ const ZeroFactor = 200;
132
+ const OneFactor = 201;
133
+ const SrcColorFactor = 202;
134
+ const OneMinusSrcColorFactor = 203;
135
+ const SrcAlphaFactor = 204;
136
+ const OneMinusSrcAlphaFactor = 205;
137
+ const DstAlphaFactor = 206;
138
+ const OneMinusDstAlphaFactor = 207;
139
+ const DstColorFactor = 208;
140
+ const OneMinusDstColorFactor = 209;
141
+ const SrcAlphaSaturateFactor = 210;
142
+ const NeverDepth = 0;
143
+ const AlwaysDepth = 1;
144
+ const LessDepth = 2;
145
+ const LessEqualDepth = 3;
146
+ const EqualDepth = 4;
147
+ const GreaterEqualDepth = 5;
148
+ const GreaterDepth = 6;
149
+ const NotEqualDepth = 7;
150
+ const MultiplyOperation = 0;
151
+ const MixOperation = 1;
152
+ const AddOperation = 2;
153
+ const NoToneMapping = 0;
154
+ const LinearToneMapping = 1;
155
+ const ReinhardToneMapping = 2;
156
+ const CineonToneMapping = 3;
157
+ const ACESFilmicToneMapping = 4;
158
+ const CustomToneMapping = 5;
159
+ const UVMapping = 300;
160
+ const CubeReflectionMapping = 301;
161
+ const CubeRefractionMapping = 302;
162
+ const EquirectangularReflectionMapping = 303;
163
+ const EquirectangularRefractionMapping = 304;
164
+ const CubeUVReflectionMapping = 306;
165
+ const CubeUVRefractionMapping = 307;
166
+ const RepeatWrapping = 1000;
167
+ const ClampToEdgeWrapping = 1001;
168
+ const MirroredRepeatWrapping = 1002;
169
+ const NearestFilter = 1003;
170
+ const NearestMipmapNearestFilter = 1004;
171
+ const NearestMipmapLinearFilter = 1005;
172
+ const LinearFilter = 1006;
173
+ const LinearMipmapNearestFilter = 1007;
174
+ const LinearMipmapLinearFilter = 1008;
175
+ const UnsignedByteType = 1009;
176
+ const ByteType = 1010;
177
+ const ShortType = 1011;
178
+ const UnsignedShortType = 1012;
179
+ const IntType = 1013;
180
+ const UnsignedIntType = 1014;
181
+ const FloatType = 1015;
182
+ const HalfFloatType = 1016;
183
+ const UnsignedShort4444Type = 1017;
184
+ const UnsignedShort5551Type = 1018;
185
+ const UnsignedShort565Type = 1019;
186
+ const UnsignedInt248Type = 1020;
187
+ const AlphaFormat = 1021;
188
+ const RGBFormat = 1022;
189
+ const RGBAFormat = 1023;
190
+ const LuminanceFormat = 1024;
191
+ const LuminanceAlphaFormat = 1025;
192
+ const RGBEFormat = RGBAFormat;
193
+ const DepthFormat = 1026;
194
+ const DepthStencilFormat = 1027;
195
+ const RedFormat = 1028;
196
+ const RedIntegerFormat = 1029;
197
+ const RGFormat = 1030;
198
+ const RGIntegerFormat = 1031;
199
+ const RGBIntegerFormat = 1032;
200
+ const RGBAIntegerFormat = 1033;
201
+ const RGB_S3TC_DXT1_Format = 33776;
202
+ const RGBA_S3TC_DXT1_Format = 33777;
203
+ const RGBA_S3TC_DXT3_Format = 33778;
204
+ const RGBA_S3TC_DXT5_Format = 33779;
205
+ const RGB_PVRTC_4BPPV1_Format = 35840;
206
+ const RGB_PVRTC_2BPPV1_Format = 35841;
207
+ const RGBA_PVRTC_4BPPV1_Format = 35842;
208
+ const RGBA_PVRTC_2BPPV1_Format = 35843;
209
+ const RGB_ETC1_Format = 36196;
210
+ const RGB_ETC2_Format = 37492;
211
+ const RGBA_ETC2_EAC_Format = 37496;
212
+ const RGBA_ASTC_4x4_Format = 37808;
213
+ const RGBA_ASTC_5x4_Format = 37809;
214
+ const RGBA_ASTC_5x5_Format = 37810;
215
+ const RGBA_ASTC_6x5_Format = 37811;
216
+ const RGBA_ASTC_6x6_Format = 37812;
217
+ const RGBA_ASTC_8x5_Format = 37813;
218
+ const RGBA_ASTC_8x6_Format = 37814;
219
+ const RGBA_ASTC_8x8_Format = 37815;
220
+ const RGBA_ASTC_10x5_Format = 37816;
221
+ const RGBA_ASTC_10x6_Format = 37817;
222
+ const RGBA_ASTC_10x8_Format = 37818;
223
+ const RGBA_ASTC_10x10_Format = 37819;
224
+ const RGBA_ASTC_12x10_Format = 37820;
225
+ const RGBA_ASTC_12x12_Format = 37821;
226
+ const RGBA_BPTC_Format = 36492;
227
+ const SRGB8_ALPHA8_ASTC_4x4_Format = 37840;
228
+ const SRGB8_ALPHA8_ASTC_5x4_Format = 37841;
229
+ const SRGB8_ALPHA8_ASTC_5x5_Format = 37842;
230
+ const SRGB8_ALPHA8_ASTC_6x5_Format = 37843;
231
+ const SRGB8_ALPHA8_ASTC_6x6_Format = 37844;
232
+ const SRGB8_ALPHA8_ASTC_8x5_Format = 37845;
233
+ const SRGB8_ALPHA8_ASTC_8x6_Format = 37846;
234
+ const SRGB8_ALPHA8_ASTC_8x8_Format = 37847;
235
+ const SRGB8_ALPHA8_ASTC_10x5_Format = 37848;
236
+ const SRGB8_ALPHA8_ASTC_10x6_Format = 37849;
237
+ const SRGB8_ALPHA8_ASTC_10x8_Format = 37850;
238
+ const SRGB8_ALPHA8_ASTC_10x10_Format = 37851;
239
+ const SRGB8_ALPHA8_ASTC_12x10_Format = 37852;
240
+ const SRGB8_ALPHA8_ASTC_12x12_Format = 37853;
241
+ const LoopOnce = 2200;
242
+ const LoopRepeat = 2201;
243
+ const LoopPingPong = 2202;
244
+ const InterpolateDiscrete = 2300;
245
+ const InterpolateLinear = 2301;
246
+ const InterpolateSmooth = 2302;
247
+ const ZeroCurvatureEnding = 2400;
248
+ const ZeroSlopeEnding = 2401;
249
+ const WrapAroundEnding = 2402;
250
+ const NormalAnimationBlendMode = 2500;
251
+ const AdditiveAnimationBlendMode = 2501;
252
+ const TrianglesDrawMode = 0;
253
+ const LinearEncoding = 3000;
254
+ const sRGBEncoding = 3001;
255
+ const GammaEncoding = 3007;
256
+ const RGBEEncoding = 3002;
257
+ const RGBM7Encoding = 3004;
258
+ const RGBM16Encoding = 3005;
259
+ const RGBDEncoding = 3006;
260
+ const BasicDepthPacking = 3200;
261
+ const RGBADepthPacking = 3201;
262
+ const TangentSpaceNormalMap = 0;
263
+ const ObjectSpaceNormalMap = 1;
264
+ const KeepStencilOp = 7680;
265
+ const AlwaysStencilFunc = 519;
266
+ const StaticDrawUsage = 35044;
267
+ const DynamicDrawUsage = 35048;
268
+ const GLSL3 = '300 es';
269
+ class EventDispatcher {
270
+ constructor() {
271
+ this._listeners = {};
272
+ }
273
+ addEventListener(type, listener) {
274
+ if (this._listeners[type] === undefined)
275
+ this._listeners[type] = [];
276
+ const listeners = this._listeners[type];
277
+ if (listeners.indexOf(listener) === -1) {
278
+ listeners.push(listener);
279
+ }
280
+ }
281
+ hasEventListener(type, listener) {
282
+ if (this._listeners[type] === undefined)
283
+ return false;
284
+ const listeners = this._listeners[type];
285
+ return listeners !== undefined && listeners.indexOf(listener) !== -1;
286
+ }
287
+ removeEventListener(type, listener) {
288
+ if (this._listeners[type] === undefined)
289
+ return;
290
+ const listeners = this._listeners[type];
291
+ if (listeners !== undefined) {
292
+ const index = listeners.indexOf(listener);
293
+ if (index !== -1) {
294
+ listeners.splice(index, 1);
295
+ }
296
+ }
297
+ }
298
+ dispatchEvent(event) {
299
+ if (this._listeners[event.type] === undefined)
300
+ return;
301
+ const listeners = this._listeners[event.type];
302
+ if (listeners !== undefined) {
303
+ event.target = this;
304
+ // Make a copy, in case listeners are removed while iterating.
305
+ const array = listeners.slice(0);
306
+ for (let i = 0, l = array.length; i < l; i++) {
307
+ array[i].call(this, event);
308
+ }
309
+ event.target = undefined;
310
+ }
311
+ }
312
+ }
313
+ const _lut = [];
314
+ for (let i = 0; i < 256; i++) {
315
+ _lut[i] = (i < 16 ? '0' : '') + (i).toString(16);
316
+ }
317
+ const DEG2RAD = Math.PI / 180;
318
+ const RAD2DEG = 180 / Math.PI;
319
+ const generateUUID = () => {
320
+ const d0 = Math.random() * 0xffffffff | 0;
321
+ const d1 = Math.random() * 0xffffffff | 0;
322
+ const d2 = Math.random() * 0xffffffff | 0;
323
+ const d3 = Math.random() * 0xffffffff | 0;
324
+ const uuid = _lut[d0 & 0xff] + _lut[d0 >> 8 & 0xff] + _lut[d0 >> 16 & 0xff] + _lut[d0 >> 24 & 0xff] + '-' +
325
+ _lut[d1 & 0xff] + _lut[d1 >> 8 & 0xff] + '-' + _lut[d1 >> 16 & 0x0f | 0x40] + _lut[d1 >> 24 & 0xff] + '-' +
326
+ _lut[d2 & 0x3f | 0x80] + _lut[d2 >> 8 & 0xff] + '-' + _lut[d2 >> 16 & 0xff] + _lut[d2 >> 24 & 0xff] +
327
+ _lut[d3 & 0xff] + _lut[d3 >> 8 & 0xff] + _lut[d3 >> 16 & 0xff] + _lut[d3 >> 24 & 0xff];
328
+ // .toUpperCase() here flattens concatenated strings to save heap memory space.
329
+ return uuid.toUpperCase();
330
+ };
331
+ function clamp(value, min, max) {
332
+ return Math.max(min, Math.min(max, value));
333
+ }
334
+ // Compute euclidean modulo of n % m
335
+ // https://en.wikipedia.org/wiki/Modulo_operation
336
+ function euclideanModulo(n, m) {
337
+ return ((n % m) + m) % m;
338
+ }
339
+ // https://en.wikipedia.org/wiki/Linear_interpolation
340
+ function lerp(x, y, t) {
341
+ return (1 - t) * x + t * y;
342
+ }
343
+ function isPowerOfTwo(value) {
344
+ return (value & (value - 1)) === 0 && value !== 0;
345
+ }
346
+ function floorPowerOfTwo(value) {
347
+ return Math.pow(2, Math.floor(Math.log(value) / Math.LN2));
348
+ }
349
+ //#region Color
350
+ const _colorKeywords = {
351
+ 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
352
+ 'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
353
+ 'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,
354
+ 'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,
355
+ 'darkgoldenrod': 0xB8860B, 'darkgray': 0xA9A9A9, 'darkgreen': 0x006400, 'darkgrey': 0xA9A9A9, 'darkkhaki': 0xBDB76B, 'darkmagenta': 0x8B008B,
356
+ 'darkolivegreen': 0x556B2F, 'darkorange': 0xFF8C00, 'darkorchid': 0x9932CC, 'darkred': 0x8B0000, 'darksalmon': 0xE9967A, 'darkseagreen': 0x8FBC8F,
357
+ 'darkslateblue': 0x483D8B, 'darkslategray': 0x2F4F4F, 'darkslategrey': 0x2F4F4F, 'darkturquoise': 0x00CED1, 'darkviolet': 0x9400D3,
358
+ 'deeppink': 0xFF1493, 'deepskyblue': 0x00BFFF, 'dimgray': 0x696969, 'dimgrey': 0x696969, 'dodgerblue': 0x1E90FF, 'firebrick': 0xB22222,
359
+ 'floralwhite': 0xFFFAF0, 'forestgreen': 0x228B22, 'fuchsia': 0xFF00FF, 'gainsboro': 0xDCDCDC, 'ghostwhite': 0xF8F8FF, 'gold': 0xFFD700,
360
+ 'goldenrod': 0xDAA520, 'gray': 0x808080, 'green': 0x008000, 'greenyellow': 0xADFF2F, 'grey': 0x808080, 'honeydew': 0xF0FFF0, 'hotpink': 0xFF69B4,
361
+ 'indianred': 0xCD5C5C, 'indigo': 0x4B0082, 'ivory': 0xFFFFF0, 'khaki': 0xF0E68C, 'lavender': 0xE6E6FA, 'lavenderblush': 0xFFF0F5, 'lawngreen': 0x7CFC00,
362
+ 'lemonchiffon': 0xFFFACD, 'lightblue': 0xADD8E6, 'lightcoral': 0xF08080, 'lightcyan': 0xE0FFFF, 'lightgoldenrodyellow': 0xFAFAD2, 'lightgray': 0xD3D3D3,
363
+ 'lightgreen': 0x90EE90, 'lightgrey': 0xD3D3D3, 'lightpink': 0xFFB6C1, 'lightsalmon': 0xFFA07A, 'lightseagreen': 0x20B2AA, 'lightskyblue': 0x87CEFA,
364
+ 'lightslategray': 0x778899, 'lightslategrey': 0x778899, 'lightsteelblue': 0xB0C4DE, 'lightyellow': 0xFFFFE0, 'lime': 0x00FF00, 'limegreen': 0x32CD32,
365
+ 'linen': 0xFAF0E6, 'magenta': 0xFF00FF, 'maroon': 0x800000, 'mediumaquamarine': 0x66CDAA, 'mediumblue': 0x0000CD, 'mediumorchid': 0xBA55D3,
366
+ 'mediumpurple': 0x9370DB, 'mediumseagreen': 0x3CB371, 'mediumslateblue': 0x7B68EE, 'mediumspringgreen': 0x00FA9A, 'mediumturquoise': 0x48D1CC,
367
+ 'mediumvioletred': 0xC71585, 'midnightblue': 0x191970, 'mintcream': 0xF5FFFA, 'mistyrose': 0xFFE4E1, 'moccasin': 0xFFE4B5, 'navajowhite': 0xFFDEAD,
368
+ 'navy': 0x000080, 'oldlace': 0xFDF5E6, 'olive': 0x808000, 'olivedrab': 0x6B8E23, 'orange': 0xFFA500, 'orangered': 0xFF4500, 'orchid': 0xDA70D6,
369
+ 'palegoldenrod': 0xEEE8AA, 'palegreen': 0x98FB98, 'paleturquoise': 0xAFEEEE, 'palevioletred': 0xDB7093, 'papayawhip': 0xFFEFD5, 'peachpuff': 0xFFDAB9,
370
+ 'peru': 0xCD853F, 'pink': 0xFFC0CB, 'plum': 0xDDA0DD, 'powderblue': 0xB0E0E6, 'purple': 0x800080, 'rebeccapurple': 0x663399, 'red': 0xFF0000, 'rosybrown': 0xBC8F8F,
371
+ 'royalblue': 0x4169E1, 'saddlebrown': 0x8B4513, 'salmon': 0xFA8072, 'sandybrown': 0xF4A460, 'seagreen': 0x2E8B57, 'seashell': 0xFFF5EE,
372
+ 'sienna': 0xA0522D, 'silver': 0xC0C0C0, 'skyblue': 0x87CEEB, 'slateblue': 0x6A5ACD, 'slategray': 0x708090, 'slategrey': 0x708090, 'snow': 0xFFFAFA,
373
+ 'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,
374
+ 'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32
375
+ };
376
+ const _hslA = { h: 0, s: 0, l: 0 };
377
+ const _hslB = { h: 0, s: 0, l: 0 };
378
+ function hue2rgb(p, q, t) {
379
+ if (t < 0)
380
+ t += 1;
381
+ if (t > 1)
382
+ t -= 1;
383
+ if (t < 1 / 6)
384
+ return p + (q - p) * 6 * t;
385
+ if (t < 1 / 2)
386
+ return q;
387
+ if (t < 2 / 3)
388
+ return p + (q - p) * 6 * (2 / 3 - t);
389
+ return p;
390
+ }
391
+ function SRGBToLinear(c) {
392
+ return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
393
+ }
394
+ function LinearToSRGB(c) {
395
+ return c < 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 0.41666) - 0.055;
396
+ }
397
+ class Color {
398
+ constructor(r, g, b) {
399
+ this.r = 0;
400
+ this.g = 0;
401
+ this.b = 0;
402
+ if (g === undefined && b === undefined) {
403
+ // r is THREE.Color, hex, or string
404
+ return this.set(r);
405
+ }
406
+ return this.setRGB(r, g, b);
407
+ }
408
+ set(value) {
409
+ if (value && value.isColor) {
410
+ this.copy(value);
411
+ }
412
+ else if (typeof value === 'number') {
413
+ this.setHex(value);
414
+ }
415
+ else if (typeof value === 'string') {
416
+ this.setStyle(value);
417
+ }
418
+ return this;
419
+ }
420
+ setScalar(scalar) {
421
+ this.r = scalar;
422
+ this.g = scalar;
423
+ this.b = scalar;
424
+ return this;
425
+ }
426
+ setHex(hex) {
427
+ hex = Math.floor(hex);
428
+ this.r = ((hex >> 16) & 255) / 255;
429
+ this.g = ((hex >> 8) & 255) / 255;
430
+ this.b = (hex & 255) / 255;
431
+ return this;
432
+ }
433
+ setRGB(r, g, b) {
434
+ this.r = r;
435
+ this.g = g;
436
+ this.b = b;
437
+ return this;
438
+ }
439
+ setHSL(h, s, l) {
440
+ // h, s, l ranges are in 0.0 - 1.0
441
+ h = euclideanModulo(h, 1);
442
+ s = clamp(s, 0, 1);
443
+ l = clamp(l, 0, 1);
444
+ if (s === 0) {
445
+ this.r = this.g = this.b = l;
446
+ }
447
+ else {
448
+ const p = l <= 0.5 ? l * (1 + s) : l + s - (l * s);
449
+ const q = 2 * l - p;
450
+ this.r = hue2rgb(q, p, h + 1 / 3);
451
+ this.g = hue2rgb(q, p, h);
452
+ this.b = hue2rgb(q, p, h - 1 / 3);
453
+ }
454
+ return this;
455
+ }
456
+ setStyle(style) {
457
+ function handleAlpha(string) {
458
+ if (string === undefined)
459
+ return;
460
+ if (parseFloat(string) < 1) {
461
+ console.warn('THREE.Color: Alpha component of ' + style + ' will be ignored.');
462
+ }
463
+ }
464
+ let m;
465
+ if ((m = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(style))) {
466
+ // rgb / hsl
467
+ let color;
468
+ const name = m[1];
469
+ const components = m[2];
470
+ switch (name) {
471
+ case 'rgb':
472
+ case 'rgba':
473
+ if ((color = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(components))) {
474
+ // rgb(255,0,0) rgba(255,0,0,0.5)
475
+ this.r = Math.min(255, parseInt(color[1], 10)) / 255;
476
+ this.g = Math.min(255, parseInt(color[2], 10)) / 255;
477
+ this.b = Math.min(255, parseInt(color[3], 10)) / 255;
478
+ handleAlpha(color[4]);
479
+ return this;
480
+ }
481
+ if ((color = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(components))) {
482
+ // rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)
483
+ this.r = Math.min(100, parseInt(color[1], 10)) / 100;
484
+ this.g = Math.min(100, parseInt(color[2], 10)) / 100;
485
+ this.b = Math.min(100, parseInt(color[3], 10)) / 100;
486
+ handleAlpha(color[4]);
487
+ return this;
488
+ }
489
+ break;
490
+ case 'hsl':
491
+ case 'hsla':
492
+ if ((color = /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(components))) {
493
+ // hsl(120,50%,50%) hsla(120,50%,50%,0.5)
494
+ const h = parseFloat(color[1]) / 360;
495
+ const s = parseInt(color[2], 10) / 100;
496
+ const l = parseInt(color[3], 10) / 100;
497
+ handleAlpha(color[4]);
498
+ return this.setHSL(h, s, l);
499
+ }
500
+ break;
501
+ }
502
+ }
503
+ else if ((m = /^\#([A-Fa-f\d]+)$/.exec(style))) {
504
+ // hex color
505
+ const hex = m[1];
506
+ const size = hex.length;
507
+ if (size === 3) {
508
+ // #ff0
509
+ this.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255;
510
+ this.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255;
511
+ this.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255;
512
+ return this;
513
+ }
514
+ else if (size === 6) {
515
+ // #ff0000
516
+ this.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255;
517
+ this.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255;
518
+ this.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255;
519
+ return this;
520
+ }
521
+ }
522
+ if (style && style.length > 0) {
523
+ return this.setColorName(style);
524
+ }
525
+ return this;
526
+ }
527
+ setColorName(style) {
528
+ // color keywords
529
+ let key = style.toLowerCase();
530
+ const hex = _colorKeywords[key];
531
+ if (hex !== undefined) {
532
+ // red
533
+ this.setHex(hex);
534
+ }
535
+ else {
536
+ // unknown color
537
+ console.warn('THREE.Color: Unknown color ' + style);
538
+ }
539
+ return this;
540
+ }
541
+ clone() {
542
+ return new Color(this.r, this.g, this.b);
543
+ }
544
+ copy(color) {
545
+ this.r = color.r;
546
+ this.g = color.g;
547
+ this.b = color.b;
548
+ return this;
549
+ }
550
+ copyGammaToLinear(color, gammaFactor = 2.0) {
551
+ this.r = Math.pow(color.r, gammaFactor);
552
+ this.g = Math.pow(color.g, gammaFactor);
553
+ this.b = Math.pow(color.b, gammaFactor);
554
+ return this;
555
+ }
556
+ copyLinearToGamma(color, gammaFactor = 2.0) {
557
+ const safeInverse = gammaFactor > 0 ? 1.0 / gammaFactor : 1.0;
558
+ this.r = Math.pow(color.r, safeInverse);
559
+ this.g = Math.pow(color.g, safeInverse);
560
+ this.b = Math.pow(color.b, safeInverse);
561
+ return this;
562
+ }
563
+ convertGammaToLinear(gammaFactor) {
564
+ this.copyGammaToLinear(this, gammaFactor);
565
+ return this;
566
+ }
567
+ convertLinearToGamma(gammaFactor) {
568
+ this.copyLinearToGamma(this, gammaFactor);
569
+ return this;
570
+ }
571
+ copySRGBToLinear(color) {
572
+ this.r = SRGBToLinear(color.r);
573
+ this.g = SRGBToLinear(color.g);
574
+ this.b = SRGBToLinear(color.b);
575
+ return this;
576
+ }
577
+ copyLinearToSRGB(color) {
578
+ this.r = LinearToSRGB(color.r);
579
+ this.g = LinearToSRGB(color.g);
580
+ this.b = LinearToSRGB(color.b);
581
+ return this;
582
+ }
583
+ convertSRGBToLinear() {
584
+ this.copySRGBToLinear(this);
585
+ return this;
586
+ }
587
+ convertLinearToSRGB() {
588
+ this.copyLinearToSRGB(this);
589
+ return this;
590
+ }
591
+ getHex() {
592
+ return (this.r * 255) << 16 ^ (this.g * 255) << 8 ^ (this.b * 255) << 0;
593
+ }
594
+ getHexString() {
595
+ return ('000000' + this.getHex().toString(16)).slice(-6);
596
+ }
597
+ getHSL(target) {
598
+ const r = this.r, g = this.g, b = this.b;
599
+ const max = Math.max(r, g, b);
600
+ const min = Math.min(r, g, b);
601
+ let hue = 0, saturation = 0;
602
+ const lightness = (min + max) / 2.0;
603
+ if (min === max) {
604
+ hue = 0;
605
+ saturation = 0;
606
+ }
607
+ else {
608
+ const delta = max - min;
609
+ saturation = lightness <= 0.5 ? delta / (max + min) : delta / (2 - max - min);
610
+ switch (max) {
611
+ case r:
612
+ hue = (g - b) / delta + (g < b ? 6 : 0);
613
+ break;
614
+ case g:
615
+ hue = (b - r) / delta + 2;
616
+ break;
617
+ case b:
618
+ hue = (r - g) / delta + 4;
619
+ break;
620
+ }
621
+ hue /= 6;
622
+ }
623
+ target.h = hue;
624
+ target.s = saturation;
625
+ target.l = lightness;
626
+ return target;
627
+ }
628
+ getStyle() {
629
+ return 'rgb(' + (this.r * 255) + ',' + (this.g * 255) + ',' + (this.b * 255) + ')';
630
+ }
631
+ offsetHSL(h, s, l) {
632
+ this.getHSL(_hslA);
633
+ _hslA.h += h;
634
+ _hslA.s += s;
635
+ _hslA.l += l;
636
+ this.setHSL(_hslA.h, _hslA.s, _hslA.l);
637
+ return this;
638
+ }
639
+ add(color) {
640
+ this.r += color.r;
641
+ this.g += color.g;
642
+ this.b += color.b;
643
+ return this;
644
+ }
645
+ addColors(color1, color2) {
646
+ this.r = color1.r + color2.r;
647
+ this.g = color1.g + color2.g;
648
+ this.b = color1.b + color2.b;
649
+ return this;
650
+ }
651
+ addScalar(s) {
652
+ this.r += s;
653
+ this.g += s;
654
+ this.b += s;
655
+ return this;
656
+ }
657
+ sub(color) {
658
+ this.r = Math.max(0, this.r - color.r);
659
+ this.g = Math.max(0, this.g - color.g);
660
+ this.b = Math.max(0, this.b - color.b);
661
+ return this;
662
+ }
663
+ multiply(color) {
664
+ this.r *= color.r;
665
+ this.g *= color.g;
666
+ this.b *= color.b;
667
+ return this;
668
+ }
669
+ multiplyScalar(s) {
670
+ this.r *= s;
671
+ this.g *= s;
672
+ this.b *= s;
673
+ return this;
674
+ }
675
+ lerp(color, alpha) {
676
+ this.r += (color.r - this.r) * alpha;
677
+ this.g += (color.g - this.g) * alpha;
678
+ this.b += (color.b - this.b) * alpha;
679
+ return this;
680
+ }
681
+ lerpColors(color1, color2, alpha) {
682
+ this.r = color1.r + (color2.r - color1.r) * alpha;
683
+ this.g = color1.g + (color2.g - color1.g) * alpha;
684
+ this.b = color1.b + (color2.b - color1.b) * alpha;
685
+ return this;
686
+ }
687
+ lerpHSL(color, alpha) {
688
+ this.getHSL(_hslA);
689
+ color.getHSL(_hslB);
690
+ const h = lerp(_hslA.h, _hslB.h, alpha);
691
+ const s = lerp(_hslA.s, _hslB.s, alpha);
692
+ const l = lerp(_hslA.l, _hslB.l, alpha);
693
+ this.setHSL(h, s, l);
694
+ return this;
695
+ }
696
+ equals(c) {
697
+ return c.r === this.r && c.g === this.g && c.b === this.b;
698
+ }
699
+ fromArray(array, offset = 0) {
700
+ this.r = array[offset];
701
+ this.g = array[offset + 1];
702
+ this.b = array[offset + 2];
703
+ return this;
704
+ }
705
+ toArray(array = [], offset = 0) {
706
+ array[offset] = this.r;
707
+ array[offset + 1] = this.g;
708
+ array[offset + 2] = this.b;
709
+ return array;
710
+ }
711
+ fromBufferAttribute(attribute, index) {
712
+ this.r = attribute.getX(index);
713
+ this.g = attribute.getY(index);
714
+ this.b = attribute.getZ(index);
715
+ if (attribute.normalized === true) {
716
+ // assuming Uint8Array
717
+ this.r /= 255;
718
+ this.g /= 255;
719
+ this.b /= 255;
720
+ }
721
+ return this;
722
+ }
723
+ toJSON() {
724
+ return this.getHex();
725
+ }
726
+ }
727
+ //#endregion
728
+ //#region Base Unit
108
729
  class Matrix4 {
109
730
  constructor() {
110
731
  this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
@@ -116,17 +737,427 @@ function workerFunction() {
116
737
  return this;
117
738
  }
118
739
  }
740
+ class Vector2 {
741
+ constructor(x = 0, y = 0) {
742
+ this.x = x;
743
+ this.y = y;
744
+ }
745
+ get width() {
746
+ return this.x;
747
+ }
748
+ set width(value) {
749
+ this.x = value;
750
+ }
751
+ get height() {
752
+ return this.y;
753
+ }
754
+ set height(value) {
755
+ this.y = value;
756
+ }
757
+ set(x, y) {
758
+ this.x = x;
759
+ this.y = y;
760
+ return this;
761
+ }
762
+ setScalar(scalar) {
763
+ this.x = scalar;
764
+ this.y = scalar;
765
+ return this;
766
+ }
767
+ setX(x) {
768
+ this.x = x;
769
+ return this;
770
+ }
771
+ setY(y) {
772
+ this.y = y;
773
+ return this;
774
+ }
775
+ setComponent(index, value) {
776
+ switch (index) {
777
+ case 0:
778
+ this.x = value;
779
+ break;
780
+ case 1:
781
+ this.y = value;
782
+ break;
783
+ default:
784
+ throw new Error('index is out of range: ' + index);
785
+ }
786
+ return this;
787
+ }
788
+ getComponent(index) {
789
+ switch (index) {
790
+ case 0:
791
+ return this.x;
792
+ case 1:
793
+ return this.y;
794
+ default:
795
+ throw new Error('index is out of range: ' + index);
796
+ }
797
+ }
798
+ clone() {
799
+ return new this.constructor(this.x, this.y);
800
+ }
801
+ copy(v) {
802
+ this.x = v.x;
803
+ this.y = v.y;
804
+ return this;
805
+ }
806
+ add(v, w) {
807
+ if (w !== undefined) {
808
+ console.warn('THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.');
809
+ return this.addVectors(v, w);
810
+ }
811
+ this.x += v.x;
812
+ this.y += v.y;
813
+ return this;
814
+ }
815
+ addScalar(s) {
816
+ this.x += s;
817
+ this.y += s;
818
+ return this;
819
+ }
820
+ addVectors(a, b) {
821
+ this.x = a.x + b.x;
822
+ this.y = a.y + b.y;
823
+ return this;
824
+ }
825
+ addScaledVector(v, s) {
826
+ this.x += v.x * s;
827
+ this.y += v.y * s;
828
+ return this;
829
+ }
830
+ sub(v, w) {
831
+ if (w !== undefined) {
832
+ console.warn('THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.');
833
+ return this.subVectors(v, w);
834
+ }
835
+ this.x -= v.x;
836
+ this.y -= v.y;
837
+ return this;
838
+ }
839
+ subScalar(s) {
840
+ this.x -= s;
841
+ this.y -= s;
842
+ return this;
843
+ }
844
+ subVectors(a, b) {
845
+ this.x = a.x - b.x;
846
+ this.y = a.y - b.y;
847
+ return this;
848
+ }
849
+ multiply(v) {
850
+ this.x *= v.x;
851
+ this.y *= v.y;
852
+ return this;
853
+ }
854
+ multiplyScalar(scalar) {
855
+ this.x *= scalar;
856
+ this.y *= scalar;
857
+ return this;
858
+ }
859
+ divide(v) {
860
+ this.x /= v.x;
861
+ this.y /= v.y;
862
+ return this;
863
+ }
864
+ divideScalar(scalar) {
865
+ return this.multiplyScalar(1 / scalar);
866
+ }
867
+ applyMatrix3(m) {
868
+ const x = this.x, y = this.y;
869
+ const e = m.elements;
870
+ this.x = e[0] * x + e[3] * y + e[6];
871
+ this.y = e[1] * x + e[4] * y + e[7];
872
+ return this;
873
+ }
874
+ min(v) {
875
+ this.x = Math.min(this.x, v.x);
876
+ this.y = Math.min(this.y, v.y);
877
+ return this;
878
+ }
879
+ max(v) {
880
+ this.x = Math.max(this.x, v.x);
881
+ this.y = Math.max(this.y, v.y);
882
+ return this;
883
+ }
884
+ clamp(min, max) {
885
+ // assumes min < max, componentwise
886
+ this.x = Math.max(min.x, Math.min(max.x, this.x));
887
+ this.y = Math.max(min.y, Math.min(max.y, this.y));
888
+ return this;
889
+ }
890
+ clampScalar(minVal, maxVal) {
891
+ this.x = Math.max(minVal, Math.min(maxVal, this.x));
892
+ this.y = Math.max(minVal, Math.min(maxVal, this.y));
893
+ return this;
894
+ }
895
+ clampLength(min, max) {
896
+ const length = this.length();
897
+ return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
898
+ }
899
+ floor() {
900
+ this.x = Math.floor(this.x);
901
+ this.y = Math.floor(this.y);
902
+ return this;
903
+ }
904
+ ceil() {
905
+ this.x = Math.ceil(this.x);
906
+ this.y = Math.ceil(this.y);
907
+ return this;
908
+ }
909
+ round() {
910
+ this.x = Math.round(this.x);
911
+ this.y = Math.round(this.y);
912
+ return this;
913
+ }
914
+ roundToZero() {
915
+ this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
916
+ this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
917
+ return this;
918
+ }
919
+ negate() {
920
+ this.x = -this.x;
921
+ this.y = -this.y;
922
+ return this;
923
+ }
924
+ dot(v) {
925
+ return this.x * v.x + this.y * v.y;
926
+ }
927
+ cross(v) {
928
+ return this.x * v.y - this.y * v.x;
929
+ }
930
+ lengthSq() {
931
+ return this.x * this.x + this.y * this.y;
932
+ }
933
+ length() {
934
+ return Math.sqrt(this.x * this.x + this.y * this.y);
935
+ }
936
+ manhattanLength() {
937
+ return Math.abs(this.x) + Math.abs(this.y);
938
+ }
939
+ normalize() {
940
+ return this.divideScalar(this.length() || 1);
941
+ }
942
+ angle() {
943
+ // computes the angle in radians with respect to the positive x-axis
944
+ const angle = Math.atan2(-this.y, -this.x) + Math.PI;
945
+ return angle;
946
+ }
947
+ distanceTo(v) {
948
+ return Math.sqrt(this.distanceToSquared(v));
949
+ }
950
+ distanceToSquared(v) {
951
+ const dx = this.x - v.x, dy = this.y - v.y;
952
+ return dx * dx + dy * dy;
953
+ }
954
+ manhattanDistanceTo(v) {
955
+ return Math.abs(this.x - v.x) + Math.abs(this.y - v.y);
956
+ }
957
+ setLength(length) {
958
+ return this.normalize().multiplyScalar(length);
959
+ }
960
+ lerp(v, alpha) {
961
+ this.x += (v.x - this.x) * alpha;
962
+ this.y += (v.y - this.y) * alpha;
963
+ return this;
964
+ }
965
+ lerpVectors(v1, v2, alpha) {
966
+ this.x = v1.x + (v2.x - v1.x) * alpha;
967
+ this.y = v1.y + (v2.y - v1.y) * alpha;
968
+ return this;
969
+ }
970
+ equals(v) {
971
+ return v.x === this.x && v.y === this.y;
972
+ }
973
+ fromArray(array, offset = 0) {
974
+ this.x = array[offset];
975
+ this.y = array[offset + 1];
976
+ return this;
977
+ }
978
+ toArray(array = [], offset = 0) {
979
+ array[offset] = this.x;
980
+ array[offset + 1] = this.y;
981
+ return array;
982
+ }
983
+ fromBufferAttribute(attribute, index, offset) {
984
+ if (offset !== undefined) {
985
+ console.warn('THREE.Vector2: offset has been removed from .fromBufferAttribute().');
986
+ }
987
+ this.x = attribute.getX(index);
988
+ this.y = attribute.getY(index);
989
+ return this;
990
+ }
991
+ rotateAround(center, angle) {
992
+ const c = Math.cos(angle), s = Math.sin(angle);
993
+ const x = this.x - center.x;
994
+ const y = this.y - center.y;
995
+ this.x = x * c - y * s + center.x;
996
+ this.y = x * s + y * c + center.y;
997
+ return this;
998
+ }
999
+ random() {
1000
+ this.x = Math.random();
1001
+ this.y = Math.random();
1002
+ return this;
1003
+ }
1004
+ *[Symbol.iterator]() {
1005
+ yield this.x;
1006
+ yield this.y;
1007
+ }
1008
+ }
119
1009
  class Vector3 {
120
- constructor(x, y, z) {
121
- this.x = 0;
122
- this.y = 0;
123
- this.z = 0;
1010
+ constructor(x = 0, y = 0, z = 0) {
1011
+ this.x = x;
1012
+ this.y = y;
1013
+ this.z = z;
1014
+ }
1015
+ set(x, y, z) {
1016
+ if (z === undefined)
1017
+ z = this.z; // sprite.scale.set(x, y)
1018
+ this.x = x;
1019
+ this.y = y;
1020
+ this.z = z;
1021
+ return this;
1022
+ }
1023
+ setScalar(scalar) {
1024
+ this.x = scalar;
1025
+ this.y = scalar;
1026
+ this.z = scalar;
1027
+ return this;
1028
+ }
1029
+ setX(x) {
124
1030
  this.x = x;
1031
+ return this;
1032
+ }
1033
+ setY(y) {
125
1034
  this.y = y;
1035
+ return this;
1036
+ }
1037
+ setZ(z) {
126
1038
  this.z = z;
1039
+ return this;
1040
+ }
1041
+ setComponent(index, value) {
1042
+ switch (index) {
1043
+ case 0:
1044
+ this.x = value;
1045
+ break;
1046
+ case 1:
1047
+ this.y = value;
1048
+ break;
1049
+ case 2:
1050
+ this.z = value;
1051
+ break;
1052
+ default:
1053
+ throw new Error('index is out of range: ' + index);
1054
+ }
1055
+ return this;
1056
+ }
1057
+ getComponent(index) {
1058
+ switch (index) {
1059
+ case 0:
1060
+ return this.x;
1061
+ case 1:
1062
+ return this.y;
1063
+ case 2:
1064
+ return this.z;
1065
+ default:
1066
+ throw new Error('index is out of range: ' + index);
1067
+ }
1068
+ }
1069
+ clone() {
1070
+ return new Vector3(this.x, this.y, this.z);
1071
+ }
1072
+ copy(v) {
1073
+ this.x = v.x;
1074
+ this.y = v.y;
1075
+ this.z = v.z;
1076
+ return this;
1077
+ }
1078
+ add(v, w) {
1079
+ if (w !== undefined) {
1080
+ console.warn('THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.');
1081
+ return this.addVectors(v, w);
1082
+ }
1083
+ this.x += v.x;
1084
+ this.y += v.y;
1085
+ this.z += v.z;
1086
+ return this;
1087
+ }
1088
+ addScalar(s) {
1089
+ this.x += s;
1090
+ this.y += s;
1091
+ this.z += s;
1092
+ return this;
1093
+ }
1094
+ addVectors(a, b) {
1095
+ this.x = a.x + b.x;
1096
+ this.y = a.y + b.y;
1097
+ this.z = a.z + b.z;
1098
+ return this;
1099
+ }
1100
+ addScaledVector(v, s) {
1101
+ this.x += v.x * s;
1102
+ this.y += v.y * s;
1103
+ this.z += v.z * s;
1104
+ return this;
1105
+ }
1106
+ sub(v, w) {
1107
+ if (w !== undefined) {
1108
+ console.warn('THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.');
1109
+ return this.subVectors(v, w);
1110
+ }
1111
+ this.x -= v.x;
1112
+ this.y -= v.y;
1113
+ this.z -= v.z;
1114
+ return this;
1115
+ }
1116
+ subScalar(s) {
1117
+ this.x -= s;
1118
+ this.y -= s;
1119
+ this.z -= s;
1120
+ return this;
1121
+ }
1122
+ subVectors(a, b) {
1123
+ this.x = a.x - b.x;
1124
+ this.y = a.y - b.y;
1125
+ this.z = a.z - b.z;
1126
+ return this;
1127
+ }
1128
+ multiply(v, w) {
1129
+ if (w !== undefined) {
1130
+ console.warn('THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.');
1131
+ return this.multiplyVectors(v, w);
1132
+ }
1133
+ this.x *= v.x;
1134
+ this.y *= v.y;
1135
+ this.z *= v.z;
1136
+ return this;
1137
+ }
1138
+ multiplyScalar(scalar) {
1139
+ this.x *= scalar;
1140
+ this.y *= scalar;
1141
+ this.z *= scalar;
1142
+ return this;
1143
+ }
1144
+ multiplyVectors(a, b) {
1145
+ this.x = a.x * b.x;
1146
+ this.y = a.y * b.y;
1147
+ this.z = a.z * b.z;
1148
+ return this;
1149
+ }
1150
+ applyMatrix3(m) {
1151
+ const x = this.x, y = this.y;
1152
+ const e = m.elements;
1153
+ this.x = e[0] * x + e[3] * y + e[6];
1154
+ this.y = e[1] * x + e[4] * y + e[7];
1155
+ return this;
127
1156
  }
128
1157
  applyMatrix4(m) {
129
- const x = this.x, y = this.y, z = this.z;
1158
+ const x = this.x;
1159
+ const y = this.y;
1160
+ const z = this.z;
130
1161
  const e = m.elements;
131
1162
  const w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
132
1163
  this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
@@ -134,7 +1165,1299 @@ function workerFunction() {
134
1165
  this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
135
1166
  return this;
136
1167
  }
1168
+ setFromMatrix3Column(m, index) {
1169
+ return this.fromArray(m.elements, index * 3);
1170
+ }
1171
+ fromArray(array, offset = 0) {
1172
+ this.x = array[offset];
1173
+ this.y = array[offset + 1];
1174
+ this.z = array[offset + 2];
1175
+ return this;
1176
+ }
1177
+ toArray(array = [], offset = 0) {
1178
+ array[offset] = this.x;
1179
+ array[offset + 1] = this.y;
1180
+ array[offset + 2] = this.z;
1181
+ return array;
1182
+ }
1183
+ fromBufferAttribute(attribute, index, offset) {
1184
+ if (offset !== undefined) {
1185
+ console.warn('THREE.Vector3: offset has been removed from .fromBufferAttribute().');
1186
+ }
1187
+ this.x = attribute.getX(index);
1188
+ this.y = attribute.getY(index);
1189
+ this.z = attribute.getZ(index);
1190
+ return this;
1191
+ }
1192
+ applyNormalMatrix(m) {
1193
+ this.applyMatrix3(m);
1194
+ this.normalize();
1195
+ return this;
1196
+ }
1197
+ normalize() {
1198
+ const length = this.length() || 1;
1199
+ return this.divideScalar(length);
1200
+ }
1201
+ length() {
1202
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
1203
+ }
1204
+ divideScalar(scalar) {
1205
+ return this.multiplyScalar(1 / scalar);
1206
+ }
1207
+ transformDirection(m) {
1208
+ const x = this.x, y = this.y, z = this.z;
1209
+ const e = m.elements;
1210
+ this.x = e[0] * x + e[4] * y + e[8] * z;
1211
+ this.y = e[1] * x + e[5] * y + e[9] * z;
1212
+ this.z = e[2] * x + e[6] * y + e[10] * z;
1213
+ return this.normalize();
1214
+ }
1215
+ }
1216
+ class Vector4 {
1217
+ constructor(x = 0, y = 0, z = 0, w = 1) {
1218
+ this.x = x;
1219
+ this.y = y;
1220
+ this.z = z;
1221
+ this.w = w;
1222
+ }
1223
+ get width() {
1224
+ return this.z;
1225
+ }
1226
+ set width(value) {
1227
+ this.z = value;
1228
+ }
1229
+ get height() {
1230
+ return this.w;
1231
+ }
1232
+ set height(value) {
1233
+ this.w = value;
1234
+ }
1235
+ set(x, y, z, w) {
1236
+ this.x = x;
1237
+ this.y = y;
1238
+ this.z = z;
1239
+ this.w = w;
1240
+ return this;
1241
+ }
1242
+ setScalar(scalar) {
1243
+ this.x = scalar;
1244
+ this.y = scalar;
1245
+ this.z = scalar;
1246
+ this.w = scalar;
1247
+ return this;
1248
+ }
1249
+ setX(x) {
1250
+ this.x = x;
1251
+ return this;
1252
+ }
1253
+ setY(y) {
1254
+ this.y = y;
1255
+ return this;
1256
+ }
1257
+ setZ(z) {
1258
+ this.z = z;
1259
+ return this;
1260
+ }
1261
+ setW(w) {
1262
+ this.w = w;
1263
+ return this;
1264
+ }
1265
+ setComponent(index, value) {
1266
+ switch (index) {
1267
+ case 0:
1268
+ this.x = value;
1269
+ break;
1270
+ case 1:
1271
+ this.y = value;
1272
+ break;
1273
+ case 2:
1274
+ this.z = value;
1275
+ break;
1276
+ case 3:
1277
+ this.w = value;
1278
+ break;
1279
+ default:
1280
+ throw new Error('index is out of range: ' + index);
1281
+ }
1282
+ return this;
1283
+ }
1284
+ getComponent(index) {
1285
+ switch (index) {
1286
+ case 0:
1287
+ return this.x;
1288
+ case 1:
1289
+ return this.y;
1290
+ case 2:
1291
+ return this.z;
1292
+ case 3:
1293
+ return this.w;
1294
+ default:
1295
+ throw new Error('index is out of range: ' + index);
1296
+ }
1297
+ }
1298
+ clone() {
1299
+ return new this.constructor(this.x, this.y, this.z, this.w);
1300
+ }
1301
+ copy(v) {
1302
+ this.x = v.x;
1303
+ this.y = v.y;
1304
+ this.z = v.z;
1305
+ this.w = v.w !== undefined ? v.w : 1;
1306
+ return this;
1307
+ }
1308
+ add(v, w) {
1309
+ if (w !== undefined) {
1310
+ console.warn('THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.');
1311
+ return this.addVectors(v, w);
1312
+ }
1313
+ this.x += v.x;
1314
+ this.y += v.y;
1315
+ this.z += v.z;
1316
+ this.w += v.w;
1317
+ return this;
1318
+ }
1319
+ addScalar(s) {
1320
+ this.x += s;
1321
+ this.y += s;
1322
+ this.z += s;
1323
+ this.w += s;
1324
+ return this;
1325
+ }
1326
+ addVectors(a, b) {
1327
+ this.x = a.x + b.x;
1328
+ this.y = a.y + b.y;
1329
+ this.z = a.z + b.z;
1330
+ this.w = a.w + b.w;
1331
+ return this;
1332
+ }
1333
+ addScaledVector(v, s) {
1334
+ this.x += v.x * s;
1335
+ this.y += v.y * s;
1336
+ this.z += v.z * s;
1337
+ this.w += v.w * s;
1338
+ return this;
1339
+ }
1340
+ sub(v, w) {
1341
+ if (w !== undefined) {
1342
+ console.warn('THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.');
1343
+ return this.subVectors(v, w);
1344
+ }
1345
+ this.x -= v.x;
1346
+ this.y -= v.y;
1347
+ this.z -= v.z;
1348
+ this.w -= v.w;
1349
+ return this;
1350
+ }
1351
+ subScalar(s) {
1352
+ this.x -= s;
1353
+ this.y -= s;
1354
+ this.z -= s;
1355
+ this.w -= s;
1356
+ return this;
1357
+ }
1358
+ subVectors(a, b) {
1359
+ this.x = a.x - b.x;
1360
+ this.y = a.y - b.y;
1361
+ this.z = a.z - b.z;
1362
+ this.w = a.w - b.w;
1363
+ return this;
1364
+ }
1365
+ multiply(v) {
1366
+ this.x *= v.x;
1367
+ this.y *= v.y;
1368
+ this.z *= v.z;
1369
+ this.w *= v.w;
1370
+ return this;
1371
+ }
1372
+ multiplyScalar(scalar) {
1373
+ this.x *= scalar;
1374
+ this.y *= scalar;
1375
+ this.z *= scalar;
1376
+ this.w *= scalar;
1377
+ return this;
1378
+ }
1379
+ applyMatrix4(m) {
1380
+ const x = this.x, y = this.y, z = this.z, w = this.w;
1381
+ const e = m.elements;
1382
+ this.x = e[0] * x + e[4] * y + e[8] * z + e[12] * w;
1383
+ this.y = e[1] * x + e[5] * y + e[9] * z + e[13] * w;
1384
+ this.z = e[2] * x + e[6] * y + e[10] * z + e[14] * w;
1385
+ this.w = e[3] * x + e[7] * y + e[11] * z + e[15] * w;
1386
+ return this;
1387
+ }
1388
+ divideScalar(scalar) {
1389
+ return this.multiplyScalar(1 / scalar);
1390
+ }
1391
+ setAxisAngleFromQuaternion(q) {
1392
+ this.w = 2 * Math.acos(q.w);
1393
+ const s = Math.sqrt(1 - q.w * q.w);
1394
+ if (s < 0.0001) {
1395
+ this.x = 1;
1396
+ this.y = 0;
1397
+ this.z = 0;
1398
+ }
1399
+ else {
1400
+ this.x = q.x / s;
1401
+ this.y = q.y / s;
1402
+ this.z = q.z / s;
1403
+ }
1404
+ return this;
1405
+ }
1406
+ setAxisAngleFromRotationMatrix(m) {
1407
+ const epsilon = 0.01;
1408
+ const epsilon2 = 0.1;
1409
+ const te = m.elements;
1410
+ const m11 = te[0], m12 = te[4], m13 = te[8];
1411
+ const m21 = te[1], m22 = te[5], m23 = te[9];
1412
+ const m31 = te[2], m32 = te[6], m33 = te[10];
1413
+ if (Math.abs(m12 - m21) < epsilon &&
1414
+ Math.abs(m13 - m31) < epsilon &&
1415
+ Math.abs(m23 - m32) < epsilon) {
1416
+ if (Math.abs(m12 + m21) < epsilon2 &&
1417
+ Math.abs(m13 + m31) < epsilon2 &&
1418
+ Math.abs(m23 + m32) < epsilon2 &&
1419
+ Math.abs(m11 + m22 + m33 - 3) < epsilon2) {
1420
+ this.set(1, 0, 0, 0);
1421
+ return this;
1422
+ }
1423
+ this.set(0, 0.707106781, 0.707106781, Math.PI);
1424
+ return this;
1425
+ }
1426
+ let s = Math.sqrt((m32 - m23) * (m32 - m23) +
1427
+ (m13 - m31) * (m13 - m31) +
1428
+ (m21 - m12) * (m21 - m12));
1429
+ if (Math.abs(s) < 0.001)
1430
+ s = 1;
1431
+ this.x = (m32 - m23) / s;
1432
+ this.y = (m13 - m31) / s;
1433
+ this.z = (m21 - m12) / s;
1434
+ this.w = Math.acos((m11 + m22 + m33 - 1) / 2);
1435
+ return this;
1436
+ }
1437
+ min(v) {
1438
+ this.x = Math.min(this.x, v.x);
1439
+ this.y = Math.min(this.y, v.y);
1440
+ this.z = Math.min(this.z, v.z);
1441
+ this.w = Math.min(this.w, v.w);
1442
+ return this;
1443
+ }
1444
+ max(v) {
1445
+ this.x = Math.max(this.x, v.x);
1446
+ this.y = Math.max(this.y, v.y);
1447
+ this.z = Math.max(this.z, v.z);
1448
+ this.w = Math.max(this.w, v.w);
1449
+ return this;
1450
+ }
1451
+ clamp(min, max) {
1452
+ this.x = Math.max(min.x, Math.min(max.x, this.x));
1453
+ this.y = Math.max(min.y, Math.min(max.y, this.y));
1454
+ this.z = Math.max(min.z, Math.min(max.z, this.z));
1455
+ this.w = Math.max(min.w, Math.min(max.w, this.w));
1456
+ return this;
1457
+ }
1458
+ clampScalar(minVal, maxVal) {
1459
+ this.x = Math.max(minVal, Math.min(maxVal, this.x));
1460
+ this.y = Math.max(minVal, Math.min(maxVal, this.y));
1461
+ this.z = Math.max(minVal, Math.min(maxVal, this.z));
1462
+ this.w = Math.max(minVal, Math.min(maxVal, this.w));
1463
+ return this;
1464
+ }
1465
+ clampLength(min, max) {
1466
+ const length = this.length();
1467
+ return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
1468
+ }
1469
+ floor() {
1470
+ this.x = Math.floor(this.x);
1471
+ this.y = Math.floor(this.y);
1472
+ this.z = Math.floor(this.z);
1473
+ this.w = Math.floor(this.w);
1474
+ return this;
1475
+ }
1476
+ ceil() {
1477
+ this.x = Math.ceil(this.x);
1478
+ this.y = Math.ceil(this.y);
1479
+ this.z = Math.ceil(this.z);
1480
+ this.w = Math.ceil(this.w);
1481
+ return this;
1482
+ }
1483
+ round() {
1484
+ this.x = Math.round(this.x);
1485
+ this.y = Math.round(this.y);
1486
+ this.z = Math.round(this.z);
1487
+ this.w = Math.round(this.w);
1488
+ return this;
1489
+ }
1490
+ roundToZero() {
1491
+ this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
1492
+ this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
1493
+ this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);
1494
+ this.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(this.w);
1495
+ return this;
1496
+ }
1497
+ negate() {
1498
+ this.x = -this.x;
1499
+ this.y = -this.y;
1500
+ this.z = -this.z;
1501
+ this.w = -this.w;
1502
+ return this;
1503
+ }
1504
+ dot(v) {
1505
+ return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
1506
+ }
1507
+ lengthSq() {
1508
+ return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
1509
+ }
1510
+ length() {
1511
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
1512
+ }
1513
+ manhattanLength() {
1514
+ return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);
1515
+ }
1516
+ normalize() {
1517
+ return this.divideScalar(this.length() || 1);
1518
+ }
1519
+ setLength(length) {
1520
+ return this.normalize().multiplyScalar(length);
1521
+ }
1522
+ lerp(v, alpha) {
1523
+ this.x += (v.x - this.x) * alpha;
1524
+ this.y += (v.y - this.y) * alpha;
1525
+ this.z += (v.z - this.z) * alpha;
1526
+ this.w += (v.w - this.w) * alpha;
1527
+ return this;
1528
+ }
1529
+ lerpVectors(v1, v2, alpha) {
1530
+ this.x = v1.x + (v2.x - v1.x) * alpha;
1531
+ this.y = v1.y + (v2.y - v1.y) * alpha;
1532
+ this.z = v1.z + (v2.z - v1.z) * alpha;
1533
+ this.w = v1.w + (v2.w - v1.w) * alpha;
1534
+ return this;
1535
+ }
1536
+ equals(v) {
1537
+ return v.x === this.x && v.y === this.y && v.z === this.z && v.w === this.w;
1538
+ }
1539
+ fromArray(array, offset = 0) {
1540
+ this.x = array[offset];
1541
+ this.y = array[offset + 1];
1542
+ this.z = array[offset + 2];
1543
+ this.w = array[offset + 3];
1544
+ return this;
1545
+ }
1546
+ toArray(array = [], offset = 0) {
1547
+ array[offset] = this.x;
1548
+ array[offset + 1] = this.y;
1549
+ array[offset + 2] = this.z;
1550
+ array[offset + 3] = this.w;
1551
+ return array;
1552
+ }
1553
+ fromBufferAttribute(attribute, index, offset) {
1554
+ if (offset !== undefined) {
1555
+ console.warn('THREE.Vector4: offset has been removed from .fromBufferAttribute().');
1556
+ }
1557
+ this.x = attribute.getX(index);
1558
+ this.y = attribute.getY(index);
1559
+ this.z = attribute.getZ(index);
1560
+ this.w = attribute.getW(index);
1561
+ return this;
1562
+ }
1563
+ random() {
1564
+ this.x = Math.random();
1565
+ this.y = Math.random();
1566
+ this.z = Math.random();
1567
+ this.w = Math.random();
1568
+ return this;
1569
+ }
1570
+ *[Symbol.iterator]() {
1571
+ yield this.x;
1572
+ yield this.y;
1573
+ yield this.z;
1574
+ yield this.w;
1575
+ }
1576
+ }
1577
+ class Matrix3 {
1578
+ constructor() {
1579
+ this.elements = [
1580
+ 1, 0, 0,
1581
+ 0, 1, 0,
1582
+ 0, 0, 1
1583
+ ];
1584
+ if (arguments.length > 0) {
1585
+ console.error('THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.');
1586
+ }
1587
+ }
1588
+ set(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
1589
+ const te = this.elements;
1590
+ te[0] = n11;
1591
+ te[1] = n21;
1592
+ te[2] = n31;
1593
+ te[3] = n12;
1594
+ te[4] = n22;
1595
+ te[5] = n32;
1596
+ te[6] = n13;
1597
+ te[7] = n23;
1598
+ te[8] = n33;
1599
+ return this;
1600
+ }
1601
+ identity() {
1602
+ this.set(1, 0, 0, 0, 1, 0, 0, 0, 1);
1603
+ return this;
1604
+ }
1605
+ copy(m) {
1606
+ const te = this.elements;
1607
+ const me = m.elements;
1608
+ te[0] = me[0];
1609
+ te[1] = me[1];
1610
+ te[2] = me[2];
1611
+ te[3] = me[3];
1612
+ te[4] = me[4];
1613
+ te[5] = me[5];
1614
+ te[6] = me[6];
1615
+ te[7] = me[7];
1616
+ te[8] = me[8];
1617
+ return this;
1618
+ }
1619
+ extractBasis(xAxis, yAxis, zAxis) {
1620
+ xAxis.setFromMatrix3Column(this, 0);
1621
+ yAxis.setFromMatrix3Column(this, 1);
1622
+ zAxis.setFromMatrix3Column(this, 2);
1623
+ return this;
1624
+ }
1625
+ setFromMatrix4(m) {
1626
+ const me = m.elements;
1627
+ this.set(me[0], me[4], me[8], me[1], me[5], me[9], me[2], me[6], me[10]);
1628
+ return this;
1629
+ }
1630
+ multiply(m) {
1631
+ return this.multiplyMatrices(this, m);
1632
+ }
1633
+ premultiply(m) {
1634
+ return this.multiplyMatrices(m, this);
1635
+ }
1636
+ multiplyMatrices(a, b) {
1637
+ const ae = a.elements;
1638
+ const be = b.elements;
1639
+ const te = this.elements;
1640
+ const a11 = ae[0], a12 = ae[3], a13 = ae[6];
1641
+ const a21 = ae[1], a22 = ae[4], a23 = ae[7];
1642
+ const a31 = ae[2], a32 = ae[5], a33 = ae[8];
1643
+ const b11 = be[0], b12 = be[3], b13 = be[6];
1644
+ const b21 = be[1], b22 = be[4], b23 = be[7];
1645
+ const b31 = be[2], b32 = be[5], b33 = be[8];
1646
+ te[0] = a11 * b11 + a12 * b21 + a13 * b31;
1647
+ te[3] = a11 * b12 + a12 * b22 + a13 * b32;
1648
+ te[6] = a11 * b13 + a12 * b23 + a13 * b33;
1649
+ te[1] = a21 * b11 + a22 * b21 + a23 * b31;
1650
+ te[4] = a21 * b12 + a22 * b22 + a23 * b32;
1651
+ te[7] = a21 * b13 + a22 * b23 + a23 * b33;
1652
+ te[2] = a31 * b11 + a32 * b21 + a33 * b31;
1653
+ te[5] = a31 * b12 + a32 * b22 + a33 * b32;
1654
+ te[8] = a31 * b13 + a32 * b23 + a33 * b33;
1655
+ return this;
1656
+ }
1657
+ multiplyScalar(s) {
1658
+ const te = this.elements;
1659
+ te[0] *= s;
1660
+ te[3] *= s;
1661
+ te[6] *= s;
1662
+ te[1] *= s;
1663
+ te[4] *= s;
1664
+ te[7] *= s;
1665
+ te[2] *= s;
1666
+ te[5] *= s;
1667
+ te[8] *= s;
1668
+ return this;
1669
+ }
1670
+ determinant() {
1671
+ const te = this.elements;
1672
+ const a = te[0], b = te[1], c = te[2], d = te[3], e = te[4], f = te[5], g = te[6], h = te[7], i = te[8];
1673
+ return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;
1674
+ }
1675
+ invert() {
1676
+ const te = this.elements;
1677
+ const n11 = te[0], n21 = te[1], n31 = te[2], n12 = te[3], n22 = te[4], n32 = te[5], n13 = te[6], n23 = te[7], n33 = te[8], t11 = n33 * n22 - n32 * n23, t12 = n32 * n13 - n33 * n12, t13 = n23 * n12 - n22 * n13, det = n11 * t11 + n21 * t12 + n31 * t13;
1678
+ if (det === 0)
1679
+ return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
1680
+ const detInv = 1 / det;
1681
+ te[0] = t11 * detInv;
1682
+ te[1] = (n31 * n23 - n33 * n21) * detInv;
1683
+ te[2] = (n32 * n21 - n31 * n22) * detInv;
1684
+ te[3] = t12 * detInv;
1685
+ te[4] = (n33 * n11 - n31 * n13) * detInv;
1686
+ te[5] = (n31 * n12 - n32 * n11) * detInv;
1687
+ te[6] = t13 * detInv;
1688
+ te[7] = (n21 * n13 - n23 * n11) * detInv;
1689
+ te[8] = (n22 * n11 - n21 * n12) * detInv;
1690
+ return this;
1691
+ }
1692
+ transpose() {
1693
+ let tmp;
1694
+ const m = this.elements;
1695
+ tmp = m[1];
1696
+ m[1] = m[3];
1697
+ m[3] = tmp;
1698
+ tmp = m[2];
1699
+ m[2] = m[6];
1700
+ m[6] = tmp;
1701
+ tmp = m[5];
1702
+ m[5] = m[7];
1703
+ m[7] = tmp;
1704
+ return this;
1705
+ }
1706
+ getNormalMatrix(matrix4) {
1707
+ return this.setFromMatrix4(matrix4).invert().transpose();
1708
+ }
1709
+ transposeIntoArray(r) {
1710
+ const m = this.elements;
1711
+ r[0] = m[0];
1712
+ r[1] = m[3];
1713
+ r[2] = m[6];
1714
+ r[3] = m[1];
1715
+ r[4] = m[4];
1716
+ r[5] = m[7];
1717
+ r[6] = m[2];
1718
+ r[7] = m[5];
1719
+ r[8] = m[8];
1720
+ return this;
1721
+ }
1722
+ setUvTransform(tx, ty, sx, sy, rotation, cx, cy) {
1723
+ const c = Math.cos(rotation);
1724
+ const s = Math.sin(rotation);
1725
+ this.set(sx * c, sx * s, -sx * (c * cx + s * cy) + cx + tx, -sy * s, sy * c, -sy * (-s * cx + c * cy) + cy + ty, 0, 0, 1);
1726
+ return this;
1727
+ }
1728
+ scale(sx, sy) {
1729
+ const te = this.elements;
1730
+ te[0] *= sx;
1731
+ te[3] *= sx;
1732
+ te[6] *= sx;
1733
+ te[1] *= sy;
1734
+ te[4] *= sy;
1735
+ te[7] *= sy;
1736
+ return this;
1737
+ }
1738
+ rotate(theta) {
1739
+ const c = Math.cos(theta);
1740
+ const s = Math.sin(theta);
1741
+ const te = this.elements;
1742
+ const a11 = te[0], a12 = te[3], a13 = te[6];
1743
+ const a21 = te[1], a22 = te[4], a23 = te[7];
1744
+ te[0] = c * a11 + s * a21;
1745
+ te[3] = c * a12 + s * a22;
1746
+ te[6] = c * a13 + s * a23;
1747
+ te[1] = -s * a11 + c * a21;
1748
+ te[4] = -s * a12 + c * a22;
1749
+ te[7] = -s * a13 + c * a23;
1750
+ return this;
1751
+ }
1752
+ translate(tx, ty) {
1753
+ const te = this.elements;
1754
+ te[0] += tx * te[2];
1755
+ te[3] += tx * te[5];
1756
+ te[6] += tx * te[8];
1757
+ te[1] += ty * te[2];
1758
+ te[4] += ty * te[5];
1759
+ te[7] += ty * te[8];
1760
+ return this;
1761
+ }
1762
+ equals(matrix) {
1763
+ const te = this.elements;
1764
+ const me = matrix.elements;
1765
+ for (let i = 0; i < 9; i++) {
1766
+ if (te[i] !== me[i])
1767
+ return false;
1768
+ }
1769
+ return true;
1770
+ }
1771
+ fromArray(array, offset = 0) {
1772
+ for (let i = 0; i < 9; i++) {
1773
+ this.elements[i] = array[i + offset];
1774
+ }
1775
+ return this;
1776
+ }
1777
+ toArray(array = [], offset = 0) {
1778
+ const te = this.elements;
1779
+ array[offset] = te[0];
1780
+ array[offset + 1] = te[1];
1781
+ array[offset + 2] = te[2];
1782
+ array[offset + 3] = te[3];
1783
+ array[offset + 4] = te[4];
1784
+ array[offset + 5] = te[5];
1785
+ array[offset + 6] = te[6];
1786
+ array[offset + 7] = te[7];
1787
+ array[offset + 8] = te[8];
1788
+ return array;
1789
+ }
1790
+ clone() {
1791
+ return new Matrix3().fromArray(this.elements);
1792
+ }
1793
+ }
1794
+ //#endregion
1795
+ const _vector$9 = /*@__PURE__*/ new Vector3(0, 0, 0);
1796
+ const _vector2$1 = /*@__PURE__*/ new Vector2();
1797
+ class BufferAttribute {
1798
+ constructor(array, itemSize, normalized) {
1799
+ this.name = '';
1800
+ if (Array.isArray(array)) {
1801
+ throw new TypeError('THREE.BufferAttribute: array should be a Typed Array.');
1802
+ }
1803
+ this.array = array;
1804
+ this.itemSize = itemSize;
1805
+ this.count = array !== undefined ? array.length / itemSize : 0;
1806
+ this.normalized = normalized === true;
1807
+ this.usage = StaticDrawUsage;
1808
+ this.updateRange = { offset: 0, count: -1 };
1809
+ this.version = 0;
1810
+ }
1811
+ onUploadCallback() { }
1812
+ set needsUpdate(value) {
1813
+ if (value === true)
1814
+ this.version++;
1815
+ }
1816
+ setUsage(value) {
1817
+ this.usage = value;
1818
+ return this;
1819
+ }
1820
+ copy(source) {
1821
+ this.name = source.name;
1822
+ this.array = source.array;
1823
+ this.itemSize = source.itemSize;
1824
+ this.count = source.count;
1825
+ this.normalized = source.normalized;
1826
+ this.usage = source.usage;
1827
+ return this;
1828
+ }
1829
+ copyAt(index1, attribute, index2) {
1830
+ index1 *= this.itemSize;
1831
+ index2 *= attribute.itemSize;
1832
+ for (let i = 0, l = this.itemSize; i < l; i++) {
1833
+ this.array[index1 + i] = attribute.array[index2 + i];
1834
+ }
1835
+ return this;
1836
+ }
1837
+ copyArray(array) {
1838
+ this.array.set(array);
1839
+ return this;
1840
+ }
1841
+ copyColorsArray(colors) {
1842
+ const array = this.array;
1843
+ let offset = 0;
1844
+ for (let i = 0, l = colors.length; i < l; i++) {
1845
+ let color = colors[i];
1846
+ if (color === undefined) {
1847
+ console.warn('THREE.BufferAttribute.copyColorsArray(): color is undefined', i);
1848
+ color = new Color(255, 255, 255);
1849
+ }
1850
+ array[offset++] = color.r;
1851
+ array[offset++] = color.g;
1852
+ array[offset++] = color.b;
1853
+ }
1854
+ return this;
1855
+ }
1856
+ copyVector2sArray(vectors) {
1857
+ const array = this.array;
1858
+ let offset = 0;
1859
+ for (let i = 0, l = vectors.length; i < l; i++) {
1860
+ let vector = vectors[i];
1861
+ if (vector === undefined) {
1862
+ console.warn('THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i);
1863
+ vector = new Vector2();
1864
+ }
1865
+ array[offset++] = vector.x;
1866
+ array[offset++] = vector.y;
1867
+ }
1868
+ return this;
1869
+ }
1870
+ copyVector3sArray(vectors) {
1871
+ const array = this.array;
1872
+ let offset = 0;
1873
+ for (let i = 0, l = vectors.length; i < l; i++) {
1874
+ let vector = vectors[i];
1875
+ if (vector === undefined) {
1876
+ console.warn('THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i);
1877
+ vector = new Vector3(0, 0, 0);
1878
+ }
1879
+ array[offset++] = vector.x;
1880
+ array[offset++] = vector.y;
1881
+ array[offset++] = vector.z;
1882
+ }
1883
+ return this;
1884
+ }
1885
+ copyVector4sArray(vectors) {
1886
+ const array = this.array;
1887
+ let offset = 0;
1888
+ for (let i = 0, l = vectors.length; i < l; i++) {
1889
+ let vector = vectors[i];
1890
+ if (vector === undefined) {
1891
+ console.warn('THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i);
1892
+ vector = new Vector4();
1893
+ }
1894
+ array[offset++] = vector.x;
1895
+ array[offset++] = vector.y;
1896
+ array[offset++] = vector.z;
1897
+ array[offset++] = vector.w;
1898
+ }
1899
+ return this;
1900
+ }
1901
+ applyMatrix3(m) {
1902
+ if (this.itemSize === 2) {
1903
+ for (let i = 0, l = this.count; i < l; i++) {
1904
+ _vector2$1.fromBufferAttribute(this, i);
1905
+ _vector2$1.applyMatrix3(m);
1906
+ this.setXY(i, _vector2$1.x, _vector2$1.y);
1907
+ }
1908
+ }
1909
+ else if (this.itemSize === 3) {
1910
+ for (let i = 0, l = this.count; i < l; i++) {
1911
+ _vector$9.fromBufferAttribute(this, i);
1912
+ _vector$9.applyMatrix3(m);
1913
+ this.setXYZ(i, _vector$9.x, _vector$9.y, _vector$9.z);
1914
+ }
1915
+ }
1916
+ return this;
1917
+ }
1918
+ applyMatrix4(m) {
1919
+ for (let i = 0, l = this.count; i < l; i++) {
1920
+ _vector$9.x = this.getX(i);
1921
+ _vector$9.y = this.getY(i);
1922
+ _vector$9.z = this.getZ(i);
1923
+ _vector$9.applyMatrix4(m);
1924
+ this.setXYZ(i, _vector$9.x, _vector$9.y, _vector$9.z);
1925
+ }
1926
+ return this;
1927
+ }
1928
+ applyNormalMatrix(m) {
1929
+ for (let i = 0, l = this.count; i < l; i++) {
1930
+ _vector$9.x = this.getX(i);
1931
+ _vector$9.y = this.getY(i);
1932
+ _vector$9.z = this.getZ(i);
1933
+ _vector$9.applyNormalMatrix(m);
1934
+ this.setXYZ(i, _vector$9.x, _vector$9.y, _vector$9.z);
1935
+ }
1936
+ return this;
1937
+ }
1938
+ transformDirection(m) {
1939
+ for (let i = 0, l = this.count; i < l; i++) {
1940
+ _vector$9.x = this.getX(i);
1941
+ _vector$9.y = this.getY(i);
1942
+ _vector$9.z = this.getZ(i);
1943
+ _vector$9.transformDirection(m);
1944
+ this.setXYZ(i, _vector$9.x, _vector$9.y, _vector$9.z);
1945
+ }
1946
+ return this;
1947
+ }
1948
+ set(value, offset = 0) {
1949
+ this.array.set(value, offset);
1950
+ return this;
1951
+ }
1952
+ getX(index) {
1953
+ return this.array[index * this.itemSize];
1954
+ }
1955
+ setX(index, x) {
1956
+ this.array[index * this.itemSize] = x;
1957
+ return this;
1958
+ }
1959
+ getY(index) {
1960
+ return this.array[index * this.itemSize + 1];
1961
+ }
1962
+ setY(index, y) {
1963
+ this.array[index * this.itemSize + 1] = y;
1964
+ return this;
1965
+ }
1966
+ getZ(index) {
1967
+ return this.array[index * this.itemSize + 2];
1968
+ }
1969
+ setZ(index, z) {
1970
+ this.array[index * this.itemSize + 2] = z;
1971
+ return this;
1972
+ }
1973
+ getW(index) {
1974
+ return this.array[index * this.itemSize + 3];
1975
+ }
1976
+ setW(index, w) {
1977
+ this.array[index * this.itemSize + 3] = w;
1978
+ return this;
1979
+ }
1980
+ setXY(index, x, y) {
1981
+ index *= this.itemSize;
1982
+ this.array[index + 0] = x;
1983
+ this.array[index + 1] = y;
1984
+ return this;
1985
+ }
1986
+ setXYZ(index, x, y, z) {
1987
+ index *= this.itemSize;
1988
+ this.array[index + 0] = x;
1989
+ this.array[index + 1] = y;
1990
+ this.array[index + 2] = z;
1991
+ return this;
1992
+ }
1993
+ setXYZW(index, x, y, z, w) {
1994
+ index *= this.itemSize;
1995
+ this.array[index + 0] = x;
1996
+ this.array[index + 1] = y;
1997
+ this.array[index + 2] = z;
1998
+ this.array[index + 3] = w;
1999
+ return this;
2000
+ }
2001
+ onUpload(callback) {
2002
+ this.onUploadCallback = callback;
2003
+ return this;
2004
+ }
2005
+ clone() {
2006
+ return new this.constructor(this.array, this.itemSize).copy(this);
2007
+ }
2008
+ toJSON() {
2009
+ const data = {
2010
+ itemSize: this.itemSize,
2011
+ type: this.array.constructor.name,
2012
+ array: Array.prototype.slice.call(this.array),
2013
+ normalized: this.normalized,
2014
+ name: '',
2015
+ usage: 0,
2016
+ updateRange: {
2017
+ offset: 0,
2018
+ count: 0
2019
+ }
2020
+ };
2021
+ if (this.name !== '')
2022
+ data.name = this.name;
2023
+ if (this.usage !== StaticDrawUsage)
2024
+ data.usage = this.usage;
2025
+ if (this.updateRange.offset !== 0 || this.updateRange.count !== -1)
2026
+ data.updateRange = this.updateRange;
2027
+ return data;
2028
+ }
137
2029
  }
2030
+ // class BufferGeometry extends EventDispatcher {
2031
+ // uuid: string;
2032
+ // name: string;
2033
+ // type: string;
2034
+ // index: BufferAttribute | null;
2035
+ // attributes: { [name: string]: BufferAttribute };
2036
+ // morphAttributes: { [name: string]: BufferAttribute[] };
2037
+ // morphTargetsRelative: boolean;
2038
+ // groups: { start: number; count: number; materialIndex: number }[];
2039
+ // boundingBox: Box3 | null;
2040
+ // boundingSphere: Sphere | null;
2041
+ // drawRange: { start: number; count: number };
2042
+ // userData: { [key: string]: any };
2043
+ // constructor() {
2044
+ // super();
2045
+ // Object.defineProperty(this, 'id', { value: _id++ });
2046
+ // this.uuid = generateUUID();
2047
+ // this.name = '';
2048
+ // this.type = 'BufferGeometry';
2049
+ // this.index = null;
2050
+ // this.attributes = {};
2051
+ // this.morphAttributes = {};
2052
+ // this.morphTargetsRelative = false;
2053
+ // this.groups = [];
2054
+ // this.boundingBox = null;
2055
+ // this.boundingSphere = null;
2056
+ // this.drawRange = { start: 0, count: Infinity };
2057
+ // this.userData = {};
2058
+ // }
2059
+ // getIndex(): BufferAttribute | null {
2060
+ // return this.index;
2061
+ // }
2062
+ // setIndex(index: BufferAttribute | number[]): this {
2063
+ // if (Array.isArray(index)) {
2064
+ // this.index = new (arrayMax(index) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(
2065
+ // index,
2066
+ // 1
2067
+ // );
2068
+ // } else {
2069
+ // this.index = index;
2070
+ // }
2071
+ // return this;
2072
+ // }
2073
+ // getAttribute(name: string): BufferAttribute | undefined {
2074
+ // return this.attributes[name];
2075
+ // }
2076
+ // setAttribute(name: string, attribute: BufferAttribute): this {
2077
+ // this.attributes[name] = attribute;
2078
+ // return this;
2079
+ // }
2080
+ // deleteAttribute(name: string): this {
2081
+ // delete this.attributes[name];
2082
+ // return this;
2083
+ // }
2084
+ // hasAttribute(name: string): boolean {
2085
+ // return this.attributes[name] !== undefined;
2086
+ // }
2087
+ // addGroup(start: number, count: number, materialIndex: number = 0): void {
2088
+ // this.groups.push({
2089
+ // start,
2090
+ // count,
2091
+ // materialIndex,
2092
+ // });
2093
+ // }
2094
+ // clearGroups(): void {
2095
+ // this.groups = [];
2096
+ // }
2097
+ // setDrawRange(start: number, count: number): void {
2098
+ // this.drawRange.start = start;
2099
+ // this.drawRange.count = count;
2100
+ // }
2101
+ // applyMatrix4(matrix: Matrix4): this {
2102
+ // const position = this.attributes.position;
2103
+ // if (position !== undefined) {
2104
+ // position.applyMatrix4(matrix);
2105
+ // position.needsUpdate = true;
2106
+ // }
2107
+ // const normal = this.attributes.normal;
2108
+ // if (normal !== undefined) {
2109
+ // const normalMatrix = new Matrix3().getNormalMatrix(matrix);
2110
+ // normal.applyNormalMatrix(normalMatrix);
2111
+ // normal.needsUpdate = true;
2112
+ // }
2113
+ // const tangent = this.attributes.tangent;
2114
+ // if (tangent !== undefined) {
2115
+ // tangent.transformDirection(matrix);
2116
+ // tangent.needsUpdate = true;
2117
+ // }
2118
+ // if (this.boundingBox !== null) {
2119
+ // this.computeBoundingBox();
2120
+ // }
2121
+ // if (this.boundingSphere !== null) {
2122
+ // this.computeBoundingSphere();
2123
+ // }
2124
+ // return this;
2125
+ // }
2126
+ // applyQuaternion(q: Quaternion): this {
2127
+ // _m1.makeRotationFromQuaternion(q);
2128
+ // this.applyMatrix4(_m1);
2129
+ // return this;
2130
+ // }
2131
+ // rotateX(angle: number): this {
2132
+ // _m1.makeRotationX(angle);
2133
+ // this.applyMatrix4(_m1);
2134
+ // return this;
2135
+ // }
2136
+ // rotateY(angle: number): this {
2137
+ // _m1.makeRotationY(angle);
2138
+ // this.applyMatrix4(_m1);
2139
+ // return this;
2140
+ // }
2141
+ // rotateZ(angle: number): this {
2142
+ // _m1.makeRotationZ(angle);
2143
+ // this.applyMatrix4(_m1);
2144
+ // return this;
2145
+ // }
2146
+ // translate(x: number, y: number, z: number): this {
2147
+ // _m1.makeTranslation(x, y, z);
2148
+ // this.applyMatrix4(_m1);
2149
+ // return this;
2150
+ // }
2151
+ // scale(x: number, y: number, z: number): this {
2152
+ // _m1.makeScale(x, y, z);
2153
+ // this.applyMatrix4(_m1);
2154
+ // return this;
2155
+ // }
2156
+ // lookAt(vector: Vector3): this {
2157
+ // _obj.lookAt(vector);
2158
+ // _obj.updateMatrix();
2159
+ // this.applyMatrix4(_obj.matrix);
2160
+ // return this;
2161
+ // }
2162
+ // center(): this {
2163
+ // this.computeBoundingBox();
2164
+ // this.boundingBox.getCenter(_offset).negate();
2165
+ // this.translate(_offset.x, _offset.y, _offset.z);
2166
+ // return this;
2167
+ // }
2168
+ // setFromPoints(points: Vector3[]): this {
2169
+ // const position: number[] = [];
2170
+ // for (let i = 0, l = points.length; i < l; i++) {
2171
+ // const point = points[i];
2172
+ // position.push(point.x, point.y, point.z || 0);
2173
+ // }
2174
+ // this.setAttribute('position', new Float32BufferAttribute(position, 3));
2175
+ // return this;
2176
+ // }
2177
+ // computeBoundingBox(): void {
2178
+ // if (this.boundingBox === null) {
2179
+ // this.boundingBox = new Box3();
2180
+ // }
2181
+ // const position = this.attributes.position;
2182
+ // const morphAttributesPosition = this.morphAttributes.position;
2183
+ // if (position && position.isGLBufferAttribute) {
2184
+ // console.error(
2185
+ // 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',
2186
+ // this
2187
+ // );
2188
+ // this.boundingBox.set(
2189
+ // new Vector3(-Infinity, -Infinity, -Infinity),
2190
+ // new Vector3(+Infinity, +Infinity, +Infinity)
2191
+ // );
2192
+ // return;
2193
+ // }
2194
+ // if (position !== undefined) {
2195
+ // this.boundingBox.setFromBufferAttribute(position);
2196
+ // // process morph attributes if present
2197
+ // if (morphAttributesPosition) {
2198
+ // for (let i = 0, il = morphAttributesPosition.length; i < il; i++) {
2199
+ // const morphAttribute = morphAttributesPosition[i];
2200
+ // _box.fromBufferAttribute(morphAttribute);
2201
+ // _box.min.add(this.boundingBox.min);
2202
+ // _box.max.add(this.boundingBox.max);
2203
+ // this.boundingBox.union(_box);
2204
+ // }
2205
+ // }
2206
+ // }
2207
+ // }
2208
+ // computeBoundingSphere(): void {
2209
+ // if (this.boundingSphere === null) {
2210
+ // this.boundingSphere = new Sphere();
2211
+ // }
2212
+ // const position = this.attributes.position;
2213
+ // const morphAttributesPosition = this.morphAttributes.position;
2214
+ // if (position && position.isGLBufferAttribute) {
2215
+ // console.error(
2216
+ // 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',
2217
+ // this
2218
+ // );
2219
+ // this.boundingSphere.set(
2220
+ // new Vector3(),
2221
+ // Infinity
2222
+ // );
2223
+ // return;
2224
+ // }
2225
+ // if (position) {
2226
+ // const center = this.boundingSphere.center;
2227
+ // this.boundingSphere.radius = position.isInterleavedBufferAttribute
2228
+ // ? position.data.stride <= 0 ? 0 : position.data.stride / 4
2229
+ // : 0;
2230
+ // // process morph attributes if present
2231
+ // if (morphAttributesPosition) {
2232
+ // for (let i = 0, il = morphAttributesPosition.length; i < il; i++) {
2233
+ // const morphAttribute = morphAttributesPosition[i];
2234
+ // const morphRadius = 0;
2235
+ // if (morphAttribute.isInterleavedBufferAttribute) {
2236
+ // console.error(
2237
+ // 'THREE.BufferGeometry.computeBoundingSphere(): morphAttribute isInterleavedBufferAttribute is not supported. Please use regular BufferAttribute.'
2238
+ // );
2239
+ // continue;
2240
+ // }
2241
+ // for (let i = 0, il = morphAttribute.count; i < il; i++) {
2242
+ // _v1.x = morphAttribute.getX(i);
2243
+ // _v1.y = morphAttribute.getY(i);
2244
+ // _v1.z = morphAttribute.getZ(i);
2245
+ // morphRadius = Math.max(morphRadius, center.distanceToSquared(_v1));
2246
+ // }
2247
+ // this.boundingSphere.radius = Math.max(this.boundingSphere.radius, Math.sqrt(morphRadius));
2248
+ // }
2249
+ // }
2250
+ // // process regular attributes
2251
+ // for (let i = 0, il = position.count; i < il; i++) {
2252
+ // _v1.x = position.getX(i);
2253
+ // _v1.y = position.getY(i);
2254
+ // _v1.z = position.getZ(i);
2255
+ // this.boundingSphere.radius = Math.max(this.boundingSphere.radius, center.distanceToSquared(_v1));
2256
+ // }
2257
+ // this.boundingSphere.radius = Math.sqrt(this.boundingSphere.radius);
2258
+ // }
2259
+ // }
2260
+ // computeTangents(): this {
2261
+ // console.warn(
2262
+ // 'THREE.BufferGeometry: .computeTangents() has been removed. Please use the TangentSpaceNormalMap shader or THREE.TangentSpaceUtils.computeTangents() instead.'
2263
+ // );
2264
+ // return this;
2265
+ // }
2266
+ // computeVertexNormals(): this {
2267
+ // console.error(
2268
+ // 'THREE.BufferGeometry: .computeVertexNormals() has been removed. Use THREE.BufferGeometryUtils.computeNormals() instead.'
2269
+ // );
2270
+ // return this;
2271
+ // }
2272
+ // computeFaceNormals(): this {
2273
+ // const cb = new Vector3(), ab = new Vector3();
2274
+ // if (this.index !== null) {
2275
+ // // indexed BufferGeometry
2276
+ // const indices = this.index.array;
2277
+ // const positions = this.attributes.position.array;
2278
+ // const normals = this.attributes.normal !== undefined ? this.attributes.normal.array : null;
2279
+ // for (let i = 0, il = indices.length; i < il; i += 3) {
2280
+ // const a = indices[i + 0];
2281
+ // const b = indices[i + 1];
2282
+ // const c = indices[i + 2];
2283
+ // if (normals !== null) {
2284
+ // const x = normals[a * 3 + 0] + normals[b * 3 + 0] + normals[c * 3 + 0];
2285
+ // const y = normals[a * 3 + 1] + normals[b * 3 + 1] + normals[c * 3 + 1];
2286
+ // const z = normals[a * 3 + 2] + normals[b * 3 + 2] + normals[c * 3 + 2];
2287
+ // _cb.set(x, y, z).normalize();
2288
+ // } else {
2289
+ // // flat normals
2290
+ // const x = positions[a * 3 + 0] - positions[b * 3 + 0];
2291
+ // const y = positions[a * 3 + 1] - positions[b * 3 + 1];
2292
+ // const z = positions[a * 3 + 2] - positions[b * 3 + 2];
2293
+ // _cb.set(x, y, z).normalize();
2294
+ // }
2295
+ // _ab.set(positions[a * 3 + 0] - positions[c * 3 + 0], positions[a * 3 + 1] - positions[c * 3 + 1], positions[a * 3 + 2] - positions[c * 3 + 2]);
2296
+ // _cb.cross(_ab).normalize();
2297
+ // normals[a * 3 + 0] += _cb.x;
2298
+ // normals[a * 3 + 1] += _cb.y;
2299
+ // normals[a * 3 + 2] += _cb.z;
2300
+ // normals[b * 3 + 0] += _cb.x;
2301
+ // normals[b * 3 + 1] += _cb.y;
2302
+ // normals[b * 3 + 2] += _cb.z;
2303
+ // normals[c * 3 + 0] += _cb.x;
2304
+ // normals[c * 3 + 1] += _cb.y;
2305
+ // normals[c * 3 + 2] += _cb.z;
2306
+ // }
2307
+ // this.normalizeNormals();
2308
+ // this.attributes.normal.needsUpdate = true;
2309
+ // } else {
2310
+ // // non-indexed BufferGeometry
2311
+ // const positions = this.attributes.position.array;
2312
+ // const normals = this.attributes.normal !== undefined ? this.attributes.normal.array : null;
2313
+ // for (let i = 0, il = positions.length; i < il; i += 9) {
2314
+ // // flat normals
2315
+ // const x = positions[i + 0] - positions[i + 3];
2316
+ // const y = positions[i + 1] - positions[i + 4];
2317
+ // const z = positions[i + 2] - positions[i + 5];
2318
+ // _cb.set(x, y, z).normalize();
2319
+ // const a = x;
2320
+ // const b = y;
2321
+ // const c = z;
2322
+ // x = positions[i + 0] - positions[i + 6];
2323
+ // y = positions[i + 1] - positions[i + 7];
2324
+ // z = positions[i + 2] - positions[i + 8];
2325
+ // _ab.set(x, y, z).normalize();
2326
+ // x = positions[i + 3] - positions[i + 6];
2327
+ // y = positions[i + 4] - positions[i + 7];
2328
+ // z = positions[i + 5] - positions[i + 8];
2329
+ // _ab.set(x, y, z).normalize();
2330
+ // _cb.cross(_ab).normalize();
2331
+ // if (normals !== null) {
2332
+ // normals[i + 0] = normals[i + 3] = normals[i + 6] = _cb.x;
2333
+ // normals[i + 1] = normals[i + 4] = normals[i + 7] = _cb.y;
2334
+ // normals[i + 2] = normals[i + 5] = normals[i + 8] = _cb.z;
2335
+ // }
2336
+ // }
2337
+ // this.normalizeNormals();
2338
+ // if (normals !== null) this.attributes.normal.needsUpdate = true;
2339
+ // }
2340
+ // return this;
2341
+ // }
2342
+ // computeMorphNormals(): this {
2343
+ // const normal = new Vector3();
2344
+ // return function computeMorphNormals() {
2345
+ // const morphNormals = this.morphAttributes.normal;
2346
+ // const normalAttribute = this.attributes.normal;
2347
+ // if (morphNormals && normalAttribute) {
2348
+ // const numMorphTargets = morphNormals.length;
2349
+ // const numNormals = normalAttribute.count;
2350
+ // for (let i = 0; i < numNormals; i++) {
2351
+ // normal.set(0, 0, 0);
2352
+ // for (let j = 0; j < numMorphTargets; j++) {
2353
+ // const morphAttribute = morphNormals[j];
2354
+ // // computing the tangent space for true normals is expensive
2355
+ // // don't use for morphNormals if normal is null
2356
+ // if (normalAttribute) {
2357
+ // _normal.fromBufferAttribute(normalAttribute, i);
2358
+ // _morphedNormal.fromBufferAttribute(morphAttribute, i);
2359
+ // // compute normals
2360
+ // _normal.applyQuaternion(this._rotationMatrix);
2361
+ // _morphedNormal.applyQuaternion(this._rotationMatrix);
2362
+ // // compute morph normal
2363
+ // _morphedNormal.sub(_normal).multiplyScalar(this.morphTargetInfluences[j]);
2364
+ // normal.add(_morphedNormal);
2365
+ // }
2366
+ // }
2367
+ // normal.normalize();
2368
+ // normalAttribute.setXYZ(i, normal.x, normal.y, normal.z);
2369
+ // }
2370
+ // normalAttribute.needsUpdate = true;
2371
+ // }
2372
+ // };
2373
+ // }
2374
+ // computeMorphTangents(): this {
2375
+ // const normal = new Vector3();
2376
+ // return function computeMorphTangents() {
2377
+ // const morphNormals = this.morphAttributes.normal;
2378
+ // const morphTangents = this.morphAttributes.tangent;
2379
+ // const normalAttribute = this.attributes.normal;
2380
+ // const tangentAttribute = this.attributes.tangent;
2381
+ // if (morphTangents && morphNormals && normalAttribute && tangentAttribute) {
2382
+ // const numMorphTargets = morphNormals.length;
2383
+ // const numTangents = tangentAttribute.count;
2384
+ // for (let i = 0; i < numTangents; i++) {
2385
+ // normal.set(0, 0, 0);
2386
+ // for (let j = 0; j < numMorphTargets; j++) {
2387
+ // const morphAttribute = morphNormals[j];
2388
+ // const morphTangent = morphTangents[j];
2389
+ // // computing the tangent space for true normals is expensive
2390
+ // // don't use for morphNormals if normal is null
2391
+ // if (normalAttribute) {
2392
+ // _normal.fromBufferAttribute(normalAttribute, i);
2393
+ // _morphedNormal.fromBufferAttribute(morphAttribute, i);
2394
+ // // compute normals
2395
+ // _normal.applyQuaternion(this._rotationMatrix);
2396
+ // _morphedNormal.applyQuaternion(this._rotationMatrix);
2397
+ // // compute morph normal
2398
+ // _morphedNormal.sub(_normal).multiplyScalar(this.morphTargetInfluences[j]);
2399
+ // normal.add(_morphedNormal);
2400
+ // // compute morph tangent
2401
+ // if (morphTangent) {
2402
+ // _tangent.fromBufferAttribute(morphTangent, i);
2403
+ // _morphedTangent.fromBufferAttribute(morphTangent, i);
2404
+ // _tangent.applyQuaternion(this._rotationMatrix);
2405
+ // _morphedTangent.applyQuaternion(this._rotationMatrix);
2406
+ // _morphedTangent.sub(_tangent).multiplyScalar(this.morphTargetInfluences[j]);
2407
+ // normal.add(_morphedTangent);
2408
+ // }
2409
+ // }
2410
+ // }
2411
+ // normal.normalize();
2412
+ // tangentAttribute.setXYZ(i, normal.x, normal.y, normal.z);
2413
+ // }
2414
+ // tangentAttribute.needsUpdate = true;
2415
+ // }
2416
+ // };
2417
+ // }
2418
+ // clearGroups(): void {
2419
+ // this.groups.length = 0;
2420
+ // this.drawRange.start = 0;
2421
+ // this.drawRange.count = Infinity;
2422
+ // }
2423
+ // setDrawRange(start: number, count: number): void {
2424
+ // this.drawRange.start = start;
2425
+ // this.drawRange.count = count;
2426
+ // }
2427
+ // updateFromObject(object: Object3D): void {
2428
+ // if (object.geometry === this) {
2429
+ // console.error(
2430
+ // 'THREE.BufferGeometry.updateFromObject(): The object and its geometry are already linked.'
2431
+ // );
2432
+ // return;
2433
+ // }
2434
+ // const geometry2 = object.geometry;
2435
+ // if (object.isPoints || object.isLine) {
2436
+ // const attributes = this.attributes;
2437
+ // if (geometry2.isBufferGeometry) {
2438
+ // attributes.position.updateRange = { offset: 0, count: geometry2.attributes.position.count };
2439
+ // const array = geometry2.attributes.position.array;
2440
+ // for (let i = 0; i < array.length; i++) {
2441
+ // attributes.position.array[i] = array[i];
2442
+ // }
2443
+ // attributes.position.needsUpdate = true;
2444
+ // }
2445
+ // } else if (object.isMesh) {
2446
+ // const newGeometry = geometry2.clone();
2447
+ // this.fromGeometry(newGeometry);
2448
+ // }
2449
+ // }
2450
+ // /**
2451
+ // * @deprecated Use {@link BufferGeometry#toJSON .toJSON()} instead.
2452
+ // */
2453
+ // toJSON(): any {
2454
+ // return this.toBufferGeometry().toJSON();
2455
+ // }
2456
+ // dispose(): void {
2457
+ // this.dispatchEvent({ type: 'dispose' });
2458
+ // }
2459
+ // }
2460
+ //#endregion
138
2461
  }
139
2462
  exports.workerCode = workerFunction;
140
2463
  //# sourceMappingURL=load-model-worker-2.script.js.map