@tarsis/toolkit 0.4.8 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/fonts/GT-Flexa-VF-Trial.woff2 +0 -0
  2. package/dist/fonts/GT-Maru-Light-Oblique-Trial.woff2 +0 -0
  3. package/dist/fonts/GT-Maru-Light-Trial.woff2 +0 -0
  4. package/dist/fonts/GT-Maru-Medium-Oblique-Trial.woff2 +0 -0
  5. package/dist/fonts/GT-Maru-Medium-Trial.woff2 +0 -0
  6. package/dist/fonts/GT-Maru-Mono-Black-Oblique-Trial.woff2 +0 -0
  7. package/dist/fonts/GT-Maru-Mono-Black-Trial.woff2 +0 -0
  8. package/dist/fonts/GT-Maru-Mono-Bold-Oblique-Trial.woff2 +0 -0
  9. package/dist/fonts/GT-Maru-Mono-Bold-Trial.woff2 +0 -0
  10. package/dist/fonts/GT-Maru-Mono-Light-Oblique-Trial.woff2 +0 -0
  11. package/dist/fonts/GT-Maru-Mono-Light-Trial.woff2 +0 -0
  12. package/dist/fonts/GT-Maru-Mono-Medium-Oblique-Trial.woff2 +0 -0
  13. package/dist/fonts/GT-Maru-Mono-Medium-Trial.woff2 +0 -0
  14. package/dist/fonts/gt/maru/GT-Maru-Light-Oblique-Trial.woff2 +0 -0
  15. package/dist/fonts/gt/maru/GT-Maru-Light-Trial.woff2 +0 -0
  16. package/dist/fonts/gt/maru/GT-Maru-Medium-Oblique-Trial.woff2 +0 -0
  17. package/dist/fonts/gt/maru/GT-Maru-Medium-Trial.woff2 +0 -0
  18. package/dist/fonts/gt/maru/GT-Maru-Mono-Black-Oblique-Trial.woff2 +0 -0
  19. package/dist/fonts/gt/maru/GT-Maru-Mono-Black-Trial.woff2 +0 -0
  20. package/dist/fonts/gt/maru/GT-Maru-Mono-Bold-Oblique-Trial.woff2 +0 -0
  21. package/dist/fonts/gt/maru/GT-Maru-Mono-Bold-Trial.woff2 +0 -0
  22. package/dist/fonts/gt/maru/GT-Maru-Mono-Light-Oblique-Trial.woff2 +0 -0
  23. package/dist/fonts/gt/maru/GT-Maru-Mono-Light-Trial.woff2 +0 -0
  24. package/dist/fonts/gt/maru/GT-Maru-Mono-Medium-Oblique-Trial.woff2 +0 -0
  25. package/dist/fonts/gt/maru/GT-Maru-Mono-Medium-Trial.woff2 +0 -0
  26. package/dist/fonts/gt/maru/gt-maru-black-oblique.woff2 +0 -0
  27. package/dist/fonts/gt/maru/gt-maru-black.woff2 +0 -0
  28. package/dist/fonts/gt/maru/gt-maru-bold-oblique.woff2 +0 -0
  29. package/dist/fonts/gt/maru/gt-maru-bold.woff2 +0 -0
  30. package/dist/fonts/gt/maru/gt-maru-mega-l.woff2 +0 -0
  31. package/dist/fonts/gt/maru/gt-maru-mega-m.woff2 +0 -0
  32. package/dist/fonts/gt/maru/gt-maru-mega-s.woff2 +0 -0
  33. package/dist/fonts/gt/maru/gt-maru-mono-regular-oblique.woff2 +0 -0
  34. package/dist/fonts/gt/maru/gt-maru-mono-regular.woff2 +0 -0
  35. package/dist/fonts/gt/maru/gt-maru-regular-oblique.woff2 +0 -0
  36. package/dist/fonts/gt/maru/gt-maru-regular.woff2 +0 -0
  37. package/dist/fonts/gt-flexa/GT-Flexa-VF-Trial.woff2 +0 -0
  38. package/dist/fonts/gt-maru-black-oblique.woff2 +0 -0
  39. package/dist/fonts/gt-maru-black.woff2 +0 -0
  40. package/dist/fonts/gt-maru-bold-oblique.woff2 +0 -0
  41. package/dist/fonts/gt-maru-bold.woff2 +0 -0
  42. package/dist/fonts/gt-maru-mega-l.woff2 +0 -0
  43. package/dist/fonts/gt-maru-mega-m.woff2 +0 -0
  44. package/dist/fonts/gt-maru-mega-s.woff2 +0 -0
  45. package/dist/fonts/gt-maru-mono-regular-oblique.woff2 +0 -0
  46. package/dist/fonts/gt-maru-mono-regular.woff2 +0 -0
  47. package/dist/fonts/gt-maru-regular-oblique.woff2 +0 -0
  48. package/dist/fonts/gt-maru-regular.woff2 +0 -0
  49. package/dist/fonts/maru/GT-Maru-Light-Oblique-Trial.woff2 +0 -0
  50. package/dist/fonts/maru/GT-Maru-Light-Trial.woff2 +0 -0
  51. package/dist/fonts/maru/GT-Maru-Medium-Oblique-Trial.woff2 +0 -0
  52. package/dist/fonts/maru/GT-Maru-Medium-Trial.woff2 +0 -0
  53. package/dist/fonts/maru/GT-Maru-Mono-Black-Oblique-Trial.woff2 +0 -0
  54. package/dist/fonts/maru/GT-Maru-Mono-Black-Trial.woff2 +0 -0
  55. package/dist/fonts/maru/GT-Maru-Mono-Bold-Oblique-Trial.woff2 +0 -0
  56. package/dist/fonts/maru/GT-Maru-Mono-Bold-Trial.woff2 +0 -0
  57. package/dist/fonts/maru/GT-Maru-Mono-Light-Oblique-Trial.woff2 +0 -0
  58. package/dist/fonts/maru/GT-Maru-Mono-Light-Trial.woff2 +0 -0
  59. package/dist/fonts/maru/GT-Maru-Mono-Medium-Oblique-Trial.woff2 +0 -0
  60. package/dist/fonts/maru/GT-Maru-Mono-Medium-Trial.woff2 +0 -0
  61. package/dist/fonts/maru/gt-maru-black-oblique.woff2 +0 -0
  62. package/dist/fonts/maru/gt-maru-black.woff2 +0 -0
  63. package/dist/fonts/maru/gt-maru-bold-oblique.woff2 +0 -0
  64. package/dist/fonts/maru/gt-maru-bold.woff2 +0 -0
  65. package/dist/fonts/maru/gt-maru-mega-l.woff2 +0 -0
  66. package/dist/fonts/maru/gt-maru-mega-m.woff2 +0 -0
  67. package/dist/fonts/maru/gt-maru-mega-s.woff2 +0 -0
  68. package/dist/fonts/maru/gt-maru-mono-regular-oblique.woff2 +0 -0
  69. package/dist/fonts/maru/gt-maru-mono-regular.woff2 +0 -0
  70. package/dist/fonts/maru/gt-maru-regular-oblique.woff2 +0 -0
  71. package/dist/fonts/maru/gt-maru-regular.woff2 +0 -0
  72. package/dist/gl-BlKJDzVL.cjs +3262 -0
  73. package/dist/gl-DA94DTyS.js +3258 -0
  74. package/dist/hooks.cjs +24 -0
  75. package/dist/hooks.d.ts +190 -0
  76. package/dist/hooks.js +1 -0
  77. package/dist/index-B9O5nl2I.js +113847 -0
  78. package/dist/index-B_kRoqUz.cjs +3912 -0
  79. package/dist/index-BlpASwt4.js +3910 -0
  80. package/dist/index-DrShaNFt.cjs +114199 -0
  81. package/dist/index.cjs +343 -41240
  82. package/dist/index.d.ts +470 -354
  83. package/dist/index.js +4 -40894
  84. package/dist/server.cjs +0 -3
  85. package/dist/server.d.ts +0 -2
  86. package/dist/server.js +1 -3
  87. package/dist/styles.css +961 -647
  88. package/dist/svg-6fNe-PW5.cjs +68 -0
  89. package/dist/svg-C0Ykxk94.js +60 -0
  90. package/dist/useWindowReady-CESjx5iD.cjs +9275 -0
  91. package/dist/useWindowReady-CIGrizO6.js +9185 -0
  92. package/dist/utils.cjs +39 -0
  93. package/dist/utils.d.ts +90 -0
  94. package/dist/utils.js +2 -0
  95. package/package.json +71 -70
  96. package/dist/gl-BytuN41l.cjs +0 -380
  97. package/dist/gl-D_Ly48gx.js +0 -357
@@ -0,0 +1,3258 @@
1
+ import { c as commonjsGlobal, a as getAugmentedNamespace, g as getDefaultExportFromCjs, W as WebGLRenderer, P as PerspectiveCamera, S as Scene, T as THREE$1, C as Clock, b as TextureLoader, R as RawShaderMaterial, D as DoubleSide, d as WebGLRenderTarget, e as Color, M as Mesh, f as TorusKnotGeometry, h as ShaderMaterial } from './index-B9O5nl2I.js';
2
+
3
+ /*
4
+ object-assign
5
+ (c) Sindre Sorhus
6
+ @license MIT
7
+ */
8
+
9
+ var objectAssign;
10
+ var hasRequiredObjectAssign;
11
+
12
+ function requireObjectAssign () {
13
+ if (hasRequiredObjectAssign) return objectAssign;
14
+ hasRequiredObjectAssign = 1;
15
+ /* eslint-disable no-unused-vars */
16
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
17
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
18
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
19
+
20
+ function toObject(val) {
21
+ if (val === null || val === undefined) {
22
+ throw new TypeError('Object.assign cannot be called with null or undefined');
23
+ }
24
+
25
+ return Object(val);
26
+ }
27
+
28
+ function shouldUseNative() {
29
+ try {
30
+ if (!Object.assign) {
31
+ return false;
32
+ }
33
+
34
+ // Detect buggy property enumeration order in older V8 versions.
35
+
36
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4118
37
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
38
+ test1[5] = 'de';
39
+ if (Object.getOwnPropertyNames(test1)[0] === '5') {
40
+ return false;
41
+ }
42
+
43
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
44
+ var test2 = {};
45
+ for (var i = 0; i < 10; i++) {
46
+ test2['_' + String.fromCharCode(i)] = i;
47
+ }
48
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
49
+ return test2[n];
50
+ });
51
+ if (order2.join('') !== '0123456789') {
52
+ return false;
53
+ }
54
+
55
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
56
+ var test3 = {};
57
+ 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
58
+ test3[letter] = letter;
59
+ });
60
+ if (Object.keys(Object.assign({}, test3)).join('') !==
61
+ 'abcdefghijklmnopqrst') {
62
+ return false;
63
+ }
64
+
65
+ return true;
66
+ } catch (err) {
67
+ // We don't expect any of the above to throw, but better to be safe.
68
+ return false;
69
+ }
70
+ }
71
+
72
+ objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
73
+ var from;
74
+ var to = toObject(target);
75
+ var symbols;
76
+
77
+ for (var s = 1; s < arguments.length; s++) {
78
+ from = Object(arguments[s]);
79
+
80
+ for (var key in from) {
81
+ if (hasOwnProperty.call(from, key)) {
82
+ to[key] = from[key];
83
+ }
84
+ }
85
+
86
+ if (getOwnPropertySymbols) {
87
+ symbols = getOwnPropertySymbols(from);
88
+ for (var i = 0; i < symbols.length; i++) {
89
+ if (propIsEnumerable.call(from, symbols[i])) {
90
+ to[symbols[i]] = from[symbols[i]];
91
+ }
92
+ }
93
+ }
94
+ }
95
+
96
+ return to;
97
+ };
98
+ return objectAssign;
99
+ }
100
+
101
+ var xhr = {exports: {}};
102
+
103
+ var window_1;
104
+ var hasRequiredWindow;
105
+
106
+ function requireWindow () {
107
+ if (hasRequiredWindow) return window_1;
108
+ hasRequiredWindow = 1;
109
+ var win;
110
+
111
+ if (typeof window !== "undefined") {
112
+ win = window;
113
+ } else if (typeof commonjsGlobal !== "undefined") {
114
+ win = commonjsGlobal;
115
+ } else if (typeof self !== "undefined"){
116
+ win = self;
117
+ } else {
118
+ win = {};
119
+ }
120
+
121
+ window_1 = win;
122
+ return window_1;
123
+ }
124
+
125
+ var isFunction_1;
126
+ var hasRequiredIsFunction;
127
+
128
+ function requireIsFunction () {
129
+ if (hasRequiredIsFunction) return isFunction_1;
130
+ hasRequiredIsFunction = 1;
131
+ isFunction_1 = isFunction;
132
+
133
+ var toString = Object.prototype.toString;
134
+
135
+ function isFunction (fn) {
136
+ if (!fn) {
137
+ return false
138
+ }
139
+ var string = toString.call(fn);
140
+ return string === '[object Function]' ||
141
+ (typeof fn === 'function' && string !== '[object RegExp]') ||
142
+ (typeof window !== 'undefined' &&
143
+ // IE8 and below
144
+ (fn === window.setTimeout ||
145
+ fn === window.alert ||
146
+ fn === window.confirm ||
147
+ fn === window.prompt))
148
+ } return isFunction_1;
149
+ }
150
+
151
+ var parseHeaders;
152
+ var hasRequiredParseHeaders;
153
+
154
+ function requireParseHeaders () {
155
+ if (hasRequiredParseHeaders) return parseHeaders;
156
+ hasRequiredParseHeaders = 1;
157
+ var trim = function(string) {
158
+ return string.replace(/^\s+|\s+$/g, '');
159
+ }
160
+ , isArray = function(arg) {
161
+ return Object.prototype.toString.call(arg) === '[object Array]';
162
+ };
163
+
164
+ parseHeaders = function (headers) {
165
+ if (!headers)
166
+ return {}
167
+
168
+ var result = Object.create(null);
169
+
170
+ var headersArr = trim(headers).split('\n');
171
+
172
+ for (var i = 0; i < headersArr.length; i++) {
173
+ var row = headersArr[i];
174
+ var index = row.indexOf(':')
175
+ , key = trim(row.slice(0, index)).toLowerCase()
176
+ , value = trim(row.slice(index + 1));
177
+
178
+ if (typeof(result[key]) === 'undefined') {
179
+ result[key] = value;
180
+ } else if (isArray(result[key])) {
181
+ result[key].push(value);
182
+ } else {
183
+ result[key] = [ result[key], value ];
184
+ }
185
+ }
186
+
187
+ return result
188
+ };
189
+ return parseHeaders;
190
+ }
191
+
192
+ var immutable;
193
+ var hasRequiredImmutable;
194
+
195
+ function requireImmutable () {
196
+ if (hasRequiredImmutable) return immutable;
197
+ hasRequiredImmutable = 1;
198
+ immutable = extend;
199
+
200
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
201
+
202
+ function extend() {
203
+ var target = {};
204
+
205
+ for (var i = 0; i < arguments.length; i++) {
206
+ var source = arguments[i];
207
+
208
+ for (var key in source) {
209
+ if (hasOwnProperty.call(source, key)) {
210
+ target[key] = source[key];
211
+ }
212
+ }
213
+ }
214
+
215
+ return target
216
+ }
217
+ return immutable;
218
+ }
219
+
220
+ var hasRequiredXhr;
221
+
222
+ function requireXhr () {
223
+ if (hasRequiredXhr) return xhr.exports;
224
+ hasRequiredXhr = 1;
225
+ var window = requireWindow();
226
+ var isFunction = requireIsFunction();
227
+ var parseHeaders = requireParseHeaders();
228
+ var xtend = requireImmutable();
229
+
230
+ xhr.exports = createXHR;
231
+ // Allow use of default import syntax in TypeScript
232
+ xhr.exports.default = createXHR;
233
+ createXHR.XMLHttpRequest = window.XMLHttpRequest || noop;
234
+ createXHR.XDomainRequest = "withCredentials" in (new createXHR.XMLHttpRequest()) ? createXHR.XMLHttpRequest : window.XDomainRequest;
235
+
236
+ forEachArray(["get", "put", "post", "patch", "head", "delete"], function(method) {
237
+ createXHR[method === "delete" ? "del" : method] = function(uri, options, callback) {
238
+ options = initParams(uri, options, callback);
239
+ options.method = method.toUpperCase();
240
+ return _createXHR(options)
241
+ };
242
+ });
243
+
244
+ function forEachArray(array, iterator) {
245
+ for (var i = 0; i < array.length; i++) {
246
+ iterator(array[i]);
247
+ }
248
+ }
249
+
250
+ function isEmpty(obj){
251
+ for(var i in obj){
252
+ if(obj.hasOwnProperty(i)) return false
253
+ }
254
+ return true
255
+ }
256
+
257
+ function initParams(uri, options, callback) {
258
+ var params = uri;
259
+
260
+ if (isFunction(options)) {
261
+ callback = options;
262
+ if (typeof uri === "string") {
263
+ params = {uri:uri};
264
+ }
265
+ } else {
266
+ params = xtend(options, {uri: uri});
267
+ }
268
+
269
+ params.callback = callback;
270
+ return params
271
+ }
272
+
273
+ function createXHR(uri, options, callback) {
274
+ options = initParams(uri, options, callback);
275
+ return _createXHR(options)
276
+ }
277
+
278
+ function _createXHR(options) {
279
+ if(typeof options.callback === "undefined"){
280
+ throw new Error("callback argument missing")
281
+ }
282
+
283
+ var called = false;
284
+ var callback = function cbOnce(err, response, body){
285
+ if(!called){
286
+ called = true;
287
+ options.callback(err, response, body);
288
+ }
289
+ };
290
+
291
+ function readystatechange() {
292
+ if (xhr.readyState === 4) {
293
+ setTimeout(loadFunc, 0);
294
+ }
295
+ }
296
+
297
+ function getBody() {
298
+ // Chrome with requestType=blob throws errors arround when even testing access to responseText
299
+ var body = undefined;
300
+
301
+ if (xhr.response) {
302
+ body = xhr.response;
303
+ } else {
304
+ body = xhr.responseText || getXml(xhr);
305
+ }
306
+
307
+ if (isJson) {
308
+ try {
309
+ body = JSON.parse(body);
310
+ } catch (e) {}
311
+ }
312
+
313
+ return body
314
+ }
315
+
316
+ function errorFunc(evt) {
317
+ clearTimeout(timeoutTimer);
318
+ if(!(evt instanceof Error)){
319
+ evt = new Error("" + (evt || "Unknown XMLHttpRequest Error") );
320
+ }
321
+ evt.statusCode = 0;
322
+ return callback(evt, failureResponse)
323
+ }
324
+
325
+ // will load the data & process the response in a special response object
326
+ function loadFunc() {
327
+ if (aborted) return
328
+ var status;
329
+ clearTimeout(timeoutTimer);
330
+ if(options.useXDR && xhr.status===undefined) {
331
+ //IE8 CORS GET successful response doesn't have a status field, but body is fine
332
+ status = 200;
333
+ } else {
334
+ status = (xhr.status === 1223 ? 204 : xhr.status);
335
+ }
336
+ var response = failureResponse;
337
+ var err = null;
338
+
339
+ if (status !== 0){
340
+ response = {
341
+ body: getBody(),
342
+ statusCode: status,
343
+ method: method,
344
+ headers: {},
345
+ url: uri,
346
+ rawRequest: xhr
347
+ };
348
+ if(xhr.getAllResponseHeaders){ //remember xhr can in fact be XDR for CORS in IE
349
+ response.headers = parseHeaders(xhr.getAllResponseHeaders());
350
+ }
351
+ } else {
352
+ err = new Error("Internal XMLHttpRequest Error");
353
+ }
354
+ return callback(err, response, response.body)
355
+ }
356
+
357
+ var xhr = options.xhr || null;
358
+
359
+ if (!xhr) {
360
+ if (options.cors || options.useXDR) {
361
+ xhr = new createXHR.XDomainRequest();
362
+ }else {
363
+ xhr = new createXHR.XMLHttpRequest();
364
+ }
365
+ }
366
+
367
+ var key;
368
+ var aborted;
369
+ var uri = xhr.url = options.uri || options.url;
370
+ var method = xhr.method = options.method || "GET";
371
+ var body = options.body || options.data;
372
+ var headers = xhr.headers = options.headers || {};
373
+ var sync = !!options.sync;
374
+ var isJson = false;
375
+ var timeoutTimer;
376
+ var failureResponse = {
377
+ body: undefined,
378
+ headers: {},
379
+ statusCode: 0,
380
+ method: method,
381
+ url: uri,
382
+ rawRequest: xhr
383
+ };
384
+
385
+ if ("json" in options && options.json !== false) {
386
+ isJson = true;
387
+ headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json"); //Don't override existing accept header declared by user
388
+ if (method !== "GET" && method !== "HEAD") {
389
+ headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json"); //Don't override existing accept header declared by user
390
+ body = JSON.stringify(options.json === true ? body : options.json);
391
+ }
392
+ }
393
+
394
+ xhr.onreadystatechange = readystatechange;
395
+ xhr.onload = loadFunc;
396
+ xhr.onerror = errorFunc;
397
+ // IE9 must have onprogress be set to a unique function.
398
+ xhr.onprogress = function () {
399
+ // IE must die
400
+ };
401
+ xhr.onabort = function(){
402
+ aborted = true;
403
+ };
404
+ xhr.ontimeout = errorFunc;
405
+ xhr.open(method, uri, !sync, options.username, options.password);
406
+ //has to be after open
407
+ if(!sync) {
408
+ xhr.withCredentials = !!options.withCredentials;
409
+ }
410
+ // Cannot set timeout with sync request
411
+ // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly
412
+ // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent
413
+ if (!sync && options.timeout > 0 ) {
414
+ timeoutTimer = setTimeout(function(){
415
+ if (aborted) return
416
+ aborted = true;//IE9 may still call readystatechange
417
+ xhr.abort("timeout");
418
+ var e = new Error("XMLHttpRequest timeout");
419
+ e.code = "ETIMEDOUT";
420
+ errorFunc(e);
421
+ }, options.timeout );
422
+ }
423
+
424
+ if (xhr.setRequestHeader) {
425
+ for(key in headers){
426
+ if(headers.hasOwnProperty(key)){
427
+ xhr.setRequestHeader(key, headers[key]);
428
+ }
429
+ }
430
+ } else if (options.headers && !isEmpty(options.headers)) {
431
+ throw new Error("Headers cannot be set on an XDomainRequest object")
432
+ }
433
+
434
+ if ("responseType" in options) {
435
+ xhr.responseType = options.responseType;
436
+ }
437
+
438
+ if ("beforeSend" in options &&
439
+ typeof options.beforeSend === "function"
440
+ ) {
441
+ options.beforeSend(xhr);
442
+ }
443
+
444
+ // Microsoft Edge browser sends "undefined" when send is called with undefined value.
445
+ // XMLHttpRequest spec says to pass null as body to indicate no body
446
+ // See https://github.com/naugtur/xhr/issues/100.
447
+ xhr.send(body || null);
448
+
449
+ return xhr
450
+
451
+
452
+ }
453
+
454
+ function getXml(xhr) {
455
+ // xhr.responseXML will throw Exception "InvalidStateError" or "DOMException"
456
+ // See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML.
457
+ try {
458
+ if (xhr.responseType === "document") {
459
+ return xhr.responseXML
460
+ }
461
+ var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName === "parsererror";
462
+ if (xhr.responseType === "" && !firefoxBugTakenEffect) {
463
+ return xhr.responseXML
464
+ }
465
+ } catch (e) {}
466
+
467
+ return null
468
+ }
469
+
470
+ function noop() {}
471
+ return xhr.exports;
472
+ }
473
+
474
+ var parseBmfontAscii;
475
+ var hasRequiredParseBmfontAscii;
476
+
477
+ function requireParseBmfontAscii () {
478
+ if (hasRequiredParseBmfontAscii) return parseBmfontAscii;
479
+ hasRequiredParseBmfontAscii = 1;
480
+ parseBmfontAscii = function parseBMFontAscii(data) {
481
+ if (!data)
482
+ throw new Error('no data provided')
483
+ data = data.toString().trim();
484
+
485
+ var output = {
486
+ pages: [],
487
+ chars: [],
488
+ kernings: []
489
+ };
490
+
491
+ var lines = data.split(/\r\n?|\n/g);
492
+
493
+ if (lines.length === 0)
494
+ throw new Error('no data in BMFont file')
495
+
496
+ for (var i = 0; i < lines.length; i++) {
497
+ var lineData = splitLine(lines[i], i);
498
+ if (!lineData) //skip empty lines
499
+ continue
500
+
501
+ if (lineData.key === 'page') {
502
+ if (typeof lineData.data.id !== 'number')
503
+ throw new Error('malformed file at line ' + i + ' -- needs page id=N')
504
+ if (typeof lineData.data.file !== 'string')
505
+ throw new Error('malformed file at line ' + i + ' -- needs page file="path"')
506
+ output.pages[lineData.data.id] = lineData.data.file;
507
+ } else if (lineData.key === 'chars' || lineData.key === 'kernings') ; else if (lineData.key === 'char') {
508
+ output.chars.push(lineData.data);
509
+ } else if (lineData.key === 'kerning') {
510
+ output.kernings.push(lineData.data);
511
+ } else {
512
+ output[lineData.key] = lineData.data;
513
+ }
514
+ }
515
+
516
+ return output
517
+ };
518
+
519
+ function splitLine(line, idx) {
520
+ line = line.replace(/\t+/g, ' ').trim();
521
+ if (!line)
522
+ return null
523
+
524
+ var space = line.indexOf(' ');
525
+ if (space === -1)
526
+ throw new Error("no named row at line " + idx)
527
+
528
+ var key = line.substring(0, space);
529
+
530
+ line = line.substring(space + 1);
531
+ //clear "letter" field as it is non-standard and
532
+ //requires additional complexity to parse " / = symbols
533
+ line = line.replace(/letter=[\'\"]\S+[\'\"]/gi, '');
534
+ line = line.split("=");
535
+ line = line.map(function(str) {
536
+ return str.trim().match((/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g))
537
+ });
538
+
539
+ var data = [];
540
+ for (var i = 0; i < line.length; i++) {
541
+ var dt = line[i];
542
+ if (i === 0) {
543
+ data.push({
544
+ key: dt[0],
545
+ data: ""
546
+ });
547
+ } else if (i === line.length - 1) {
548
+ data[data.length - 1].data = parseData(dt[0]);
549
+ } else {
550
+ data[data.length - 1].data = parseData(dt[0]);
551
+ data.push({
552
+ key: dt[1],
553
+ data: ""
554
+ });
555
+ }
556
+ }
557
+
558
+ var out = {
559
+ key: key,
560
+ data: {}
561
+ };
562
+
563
+ data.forEach(function(v) {
564
+ out.data[v.key] = v.data;
565
+ });
566
+
567
+ return out
568
+ }
569
+
570
+ function parseData(data) {
571
+ if (!data || data.length === 0)
572
+ return ""
573
+
574
+ if (data.indexOf('"') === 0 || data.indexOf("'") === 0)
575
+ return data.substring(1, data.length - 1)
576
+ if (data.indexOf(',') !== -1)
577
+ return parseIntList(data)
578
+ return parseInt(data, 10)
579
+ }
580
+
581
+ function parseIntList(data) {
582
+ return data.split(',').map(function(val) {
583
+ return parseInt(val, 10)
584
+ })
585
+ }
586
+ return parseBmfontAscii;
587
+ }
588
+
589
+ var parseAttribs;
590
+ var hasRequiredParseAttribs;
591
+
592
+ function requireParseAttribs () {
593
+ if (hasRequiredParseAttribs) return parseAttribs;
594
+ hasRequiredParseAttribs = 1;
595
+ //Some versions of GlyphDesigner have a typo
596
+ //that causes some bugs with parsing.
597
+ //Need to confirm with recent version of the software
598
+ //to see whether this is still an issue or not.
599
+ var GLYPH_DESIGNER_ERROR = 'chasrset';
600
+
601
+ parseAttribs = function parseAttributes(obj) {
602
+ obj = Object.assign({}, obj);
603
+ if (GLYPH_DESIGNER_ERROR in obj) {
604
+ obj['charset'] = obj[GLYPH_DESIGNER_ERROR];
605
+ delete obj[GLYPH_DESIGNER_ERROR];
606
+ }
607
+
608
+ for (var k in obj) {
609
+ if (k === 'face' || k === 'charset')
610
+ continue
611
+ else if (k === 'padding' || k === 'spacing')
612
+ obj[k] = parseIntList(obj[k]);
613
+ else
614
+ obj[k] = parseInt(obj[k], 10);
615
+ }
616
+ return obj
617
+ };
618
+
619
+ function parseIntList(data) {
620
+ return data.split(',').map(function(val) {
621
+ return parseInt(val, 10)
622
+ })
623
+ }
624
+ return parseAttribs;
625
+ }
626
+
627
+ var xmlParseFromString;
628
+ var hasRequiredXmlParseFromString;
629
+
630
+ function requireXmlParseFromString () {
631
+ if (hasRequiredXmlParseFromString) return xmlParseFromString;
632
+ hasRequiredXmlParseFromString = 1;
633
+ xmlParseFromString = (function xmlparser() {
634
+ //common browsers
635
+ if (typeof self.DOMParser !== 'undefined') {
636
+ return function(str) {
637
+ var parser = new self.DOMParser();
638
+ return parser.parseFromString(str, 'application/xml')
639
+ }
640
+ }
641
+
642
+ //IE8 fallback
643
+ if (typeof self.ActiveXObject !== 'undefined'
644
+ && new self.ActiveXObject('Microsoft.XMLDOM')) {
645
+ return function(str) {
646
+ var xmlDoc = new self.ActiveXObject("Microsoft.XMLDOM");
647
+ xmlDoc.async = "false";
648
+ xmlDoc.loadXML(str);
649
+ return xmlDoc
650
+ }
651
+ }
652
+
653
+ //last resort fallback
654
+ return function(str) {
655
+ var div = document.createElement('div');
656
+ div.innerHTML = str;
657
+ return div
658
+ }
659
+ })();
660
+ return xmlParseFromString;
661
+ }
662
+
663
+ var browser$1;
664
+ var hasRequiredBrowser$1;
665
+
666
+ function requireBrowser$1 () {
667
+ if (hasRequiredBrowser$1) return browser$1;
668
+ hasRequiredBrowser$1 = 1;
669
+ var parseAttributes = requireParseAttribs();
670
+ var parseFromString = requireXmlParseFromString();
671
+
672
+ //In some cases element.attribute.nodeName can return
673
+ //all lowercase values.. so we need to map them to the correct
674
+ //case
675
+ var NAME_MAP = {
676
+ scaleh: 'scaleH',
677
+ scalew: 'scaleW',
678
+ stretchh: 'stretchH',
679
+ lineheight: 'lineHeight',
680
+ alphachnl: 'alphaChnl',
681
+ redchnl: 'redChnl',
682
+ greenchnl: 'greenChnl',
683
+ bluechnl: 'blueChnl'
684
+ };
685
+
686
+ browser$1 = function parse(data) {
687
+ data = data.toString();
688
+
689
+ var xmlRoot = parseFromString(data);
690
+ var output = {
691
+ pages: [],
692
+ chars: [],
693
+ kernings: []
694
+ }
695
+
696
+ //get config settings
697
+ ;['info', 'common'].forEach(function(key) {
698
+ var element = xmlRoot.getElementsByTagName(key)[0];
699
+ if (element)
700
+ output[key] = parseAttributes(getAttribs(element));
701
+ });
702
+
703
+ //get page info
704
+ var pageRoot = xmlRoot.getElementsByTagName('pages')[0];
705
+ if (!pageRoot)
706
+ throw new Error('malformed file -- no <pages> element')
707
+ var pages = pageRoot.getElementsByTagName('page');
708
+ for (var i=0; i<pages.length; i++) {
709
+ var p = pages[i];
710
+ var id = parseInt(p.getAttribute('id'), 10);
711
+ var file = p.getAttribute('file');
712
+ if (isNaN(id))
713
+ throw new Error('malformed file -- page "id" attribute is NaN')
714
+ if (!file)
715
+ throw new Error('malformed file -- needs page "file" attribute')
716
+ output.pages[parseInt(id, 10)] = file;
717
+ }
718
+ ['chars', 'kernings'].forEach(function(key) {
719
+ var element = xmlRoot.getElementsByTagName(key)[0];
720
+ if (!element)
721
+ return
722
+ var childTag = key.substring(0, key.length-1);
723
+ var children = element.getElementsByTagName(childTag);
724
+ for (var i=0; i<children.length; i++) {
725
+ var child = children[i];
726
+ output[key].push(parseAttributes(getAttribs(child)));
727
+ }
728
+ });
729
+ return output
730
+ };
731
+
732
+ function getAttribs(element) {
733
+ var attribs = getAttribList(element);
734
+ return attribs.reduce(function(dict, attrib) {
735
+ var key = mapName(attrib.nodeName);
736
+ dict[key] = attrib.nodeValue;
737
+ return dict
738
+ }, {})
739
+ }
740
+
741
+ function getAttribList(element) {
742
+ //IE8+ and modern browsers
743
+ var attribs = [];
744
+ for (var i=0; i<element.attributes.length; i++)
745
+ attribs.push(element.attributes[i]);
746
+ return attribs
747
+ }
748
+
749
+ function mapName(nodeName) {
750
+ return NAME_MAP[nodeName.toLowerCase()] || nodeName
751
+ }
752
+ return browser$1;
753
+ }
754
+
755
+ var parseBmfontBinary;
756
+ var hasRequiredParseBmfontBinary;
757
+
758
+ function requireParseBmfontBinary () {
759
+ if (hasRequiredParseBmfontBinary) return parseBmfontBinary;
760
+ hasRequiredParseBmfontBinary = 1;
761
+ var HEADER = [66, 77, 70];
762
+
763
+ parseBmfontBinary = function readBMFontBinary(buf) {
764
+ if (buf.length < 6)
765
+ throw new Error('invalid buffer length for BMFont')
766
+
767
+ var header = HEADER.every(function(byte, i) {
768
+ return buf.readUInt8(i) === byte
769
+ });
770
+
771
+ if (!header)
772
+ throw new Error('BMFont missing BMF byte header')
773
+
774
+ var i = 3;
775
+ var vers = buf.readUInt8(i++);
776
+ if (vers > 3)
777
+ throw new Error('Only supports BMFont Binary v3 (BMFont App v1.10)')
778
+
779
+ var target = { kernings: [], chars: [] };
780
+ for (var b=0; b<5; b++)
781
+ i += readBlock(target, buf, i);
782
+ return target
783
+ };
784
+
785
+ function readBlock(target, buf, i) {
786
+ if (i > buf.length-1)
787
+ return 0
788
+
789
+ var blockID = buf.readUInt8(i++);
790
+ var blockSize = buf.readInt32LE(i);
791
+ i += 4;
792
+
793
+ switch(blockID) {
794
+ case 1:
795
+ target.info = readInfo(buf, i);
796
+ break
797
+ case 2:
798
+ target.common = readCommon(buf, i);
799
+ break
800
+ case 3:
801
+ target.pages = readPages(buf, i, blockSize);
802
+ break
803
+ case 4:
804
+ target.chars = readChars(buf, i, blockSize);
805
+ break
806
+ case 5:
807
+ target.kernings = readKernings(buf, i, blockSize);
808
+ break
809
+ }
810
+ return 5 + blockSize
811
+ }
812
+
813
+ function readInfo(buf, i) {
814
+ var info = {};
815
+ info.size = buf.readInt16LE(i);
816
+
817
+ var bitField = buf.readUInt8(i+2);
818
+ info.smooth = (bitField >> 7) & 1;
819
+ info.unicode = (bitField >> 6) & 1;
820
+ info.italic = (bitField >> 5) & 1;
821
+ info.bold = (bitField >> 4) & 1;
822
+
823
+ //fixedHeight is only mentioned in binary spec
824
+ if ((bitField >> 3) & 1)
825
+ info.fixedHeight = 1;
826
+
827
+ info.charset = buf.readUInt8(i+3) || '';
828
+ info.stretchH = buf.readUInt16LE(i+4);
829
+ info.aa = buf.readUInt8(i+6);
830
+ info.padding = [
831
+ buf.readInt8(i+7),
832
+ buf.readInt8(i+8),
833
+ buf.readInt8(i+9),
834
+ buf.readInt8(i+10)
835
+ ];
836
+ info.spacing = [
837
+ buf.readInt8(i+11),
838
+ buf.readInt8(i+12)
839
+ ];
840
+ info.outline = buf.readUInt8(i+13);
841
+ info.face = readStringNT(buf, i+14);
842
+ return info
843
+ }
844
+
845
+ function readCommon(buf, i) {
846
+ var common = {};
847
+ common.lineHeight = buf.readUInt16LE(i);
848
+ common.base = buf.readUInt16LE(i+2);
849
+ common.scaleW = buf.readUInt16LE(i+4);
850
+ common.scaleH = buf.readUInt16LE(i+6);
851
+ common.pages = buf.readUInt16LE(i+8);
852
+ buf.readUInt8(i+10);
853
+ common.packed = 0;
854
+ common.alphaChnl = buf.readUInt8(i+11);
855
+ common.redChnl = buf.readUInt8(i+12);
856
+ common.greenChnl = buf.readUInt8(i+13);
857
+ common.blueChnl = buf.readUInt8(i+14);
858
+ return common
859
+ }
860
+
861
+ function readPages(buf, i, size) {
862
+ var pages = [];
863
+ var text = readNameNT(buf, i);
864
+ var len = text.length+1;
865
+ var count = size / len;
866
+ for (var c=0; c<count; c++) {
867
+ pages[c] = buf.slice(i, i+text.length).toString('utf8');
868
+ i += len;
869
+ }
870
+ return pages
871
+ }
872
+
873
+ function readChars(buf, i, blockSize) {
874
+ var chars = [];
875
+
876
+ var count = blockSize / 20;
877
+ for (var c=0; c<count; c++) {
878
+ var char = {};
879
+ var off = c*20;
880
+ char.id = buf.readUInt32LE(i + 0 + off);
881
+ char.x = buf.readUInt16LE(i + 4 + off);
882
+ char.y = buf.readUInt16LE(i + 6 + off);
883
+ char.width = buf.readUInt16LE(i + 8 + off);
884
+ char.height = buf.readUInt16LE(i + 10 + off);
885
+ char.xoffset = buf.readInt16LE(i + 12 + off);
886
+ char.yoffset = buf.readInt16LE(i + 14 + off);
887
+ char.xadvance = buf.readInt16LE(i + 16 + off);
888
+ char.page = buf.readUInt8(i + 18 + off);
889
+ char.chnl = buf.readUInt8(i + 19 + off);
890
+ chars[c] = char;
891
+ }
892
+ return chars
893
+ }
894
+
895
+ function readKernings(buf, i, blockSize) {
896
+ var kernings = [];
897
+ var count = blockSize / 10;
898
+ for (var c=0; c<count; c++) {
899
+ var kern = {};
900
+ var off = c*10;
901
+ kern.first = buf.readUInt32LE(i + 0 + off);
902
+ kern.second = buf.readUInt32LE(i + 4 + off);
903
+ kern.amount = buf.readInt16LE(i + 8 + off);
904
+ kernings[c] = kern;
905
+ }
906
+ return kernings
907
+ }
908
+
909
+ function readNameNT(buf, offset) {
910
+ var pos=offset;
911
+ for (; pos<buf.length; pos++) {
912
+ if (buf[pos] === 0x00)
913
+ break
914
+ }
915
+ return buf.slice(offset, pos)
916
+ }
917
+
918
+ function readStringNT(buf, offset) {
919
+ return readNameNT(buf, offset).toString('utf8')
920
+ }
921
+ return parseBmfontBinary;
922
+ }
923
+
924
+ const __viteBrowserExternal = {};
925
+
926
+ const __viteBrowserExternal$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
927
+ __proto__: null,
928
+ default: __viteBrowserExternal
929
+ }, Symbol.toStringTag, { value: 'Module' }));
930
+
931
+ const require$$0 = /*@__PURE__*/getAugmentedNamespace(__viteBrowserExternal$1);
932
+
933
+ var bufferEqual;
934
+ var hasRequiredBufferEqual;
935
+
936
+ function requireBufferEqual () {
937
+ if (hasRequiredBufferEqual) return bufferEqual;
938
+ hasRequiredBufferEqual = 1;
939
+ var Buffer = require$$0.Buffer; // for use with browserify
940
+
941
+ bufferEqual = function (a, b) {
942
+ if (!Buffer.isBuffer(a)) return undefined;
943
+ if (!Buffer.isBuffer(b)) return undefined;
944
+ if (typeof a.equals === 'function') return a.equals(b);
945
+ if (a.length !== b.length) return false;
946
+
947
+ for (var i = 0; i < a.length; i++) {
948
+ if (a[i] !== b[i]) return false;
949
+ }
950
+
951
+ return true;
952
+ };
953
+ return bufferEqual;
954
+ }
955
+
956
+ var isBinary;
957
+ var hasRequiredIsBinary;
958
+
959
+ function requireIsBinary () {
960
+ if (hasRequiredIsBinary) return isBinary;
961
+ hasRequiredIsBinary = 1;
962
+ var equal = requireBufferEqual();
963
+ var HEADER = Buffer.from([66, 77, 70, 3]);
964
+
965
+ isBinary = function(buf) {
966
+ if (typeof buf === 'string')
967
+ return buf.substring(0, 3) === 'BMF'
968
+ return buf.length > 4 && equal(buf.slice(0, 4), HEADER)
969
+ };
970
+ return isBinary;
971
+ }
972
+
973
+ var browser;
974
+ var hasRequiredBrowser;
975
+
976
+ function requireBrowser () {
977
+ if (hasRequiredBrowser) return browser;
978
+ hasRequiredBrowser = 1;
979
+ var xhr = requireXhr();
980
+ var noop = function(){};
981
+ var parseASCII = requireParseBmfontAscii();
982
+ var parseXML = requireBrowser$1();
983
+ var readBinary = requireParseBmfontBinary();
984
+ var isBinaryFormat = requireIsBinary();
985
+ var xtend = requireImmutable();
986
+
987
+ var xml2 = (function hasXML2() {
988
+ return self.XMLHttpRequest && "withCredentials" in new XMLHttpRequest
989
+ })();
990
+
991
+ browser = function(opt, cb) {
992
+ cb = typeof cb === 'function' ? cb : noop;
993
+
994
+ if (typeof opt === 'string')
995
+ opt = { uri: opt };
996
+ else if (!opt)
997
+ opt = {};
998
+
999
+ var expectBinary = opt.binary;
1000
+ if (expectBinary)
1001
+ opt = getBinaryOpts(opt);
1002
+
1003
+ xhr(opt, function(err, res, body) {
1004
+ if (err)
1005
+ return cb(err)
1006
+ if (!/^2/.test(res.statusCode))
1007
+ return cb(new Error('http status code: '+res.statusCode))
1008
+ if (!body)
1009
+ return cb(new Error('no body result'))
1010
+
1011
+ var binary = false;
1012
+
1013
+ //if the response type is an array buffer,
1014
+ //we need to convert it into a regular Buffer object
1015
+ if (isArrayBuffer(body)) {
1016
+ var array = new Uint8Array(body);
1017
+ body = Buffer.from(array, 'binary');
1018
+ }
1019
+
1020
+ //now check the string/Buffer response
1021
+ //and see if it has a binary BMF header
1022
+ if (isBinaryFormat(body)) {
1023
+ binary = true;
1024
+ //if we have a string, turn it into a Buffer
1025
+ if (typeof body === 'string')
1026
+ body = Buffer.from(body, 'binary');
1027
+ }
1028
+
1029
+ //we are not parsing a binary format, just ASCII/XML/etc
1030
+ if (!binary) {
1031
+ //might still be a buffer if responseType is 'arraybuffer'
1032
+ if (Buffer.isBuffer(body))
1033
+ body = body.toString(opt.encoding);
1034
+ body = body.trim();
1035
+ }
1036
+
1037
+ var result;
1038
+ try {
1039
+ var type = res.headers['content-type'];
1040
+ if (binary)
1041
+ result = readBinary(body);
1042
+ else if (/json/.test(type) || body.charAt(0) === '{')
1043
+ result = JSON.parse(body);
1044
+ else if (/xml/.test(type) || body.charAt(0) === '<')
1045
+ result = parseXML(body);
1046
+ else
1047
+ result = parseASCII(body);
1048
+ } catch (e) {
1049
+ cb(new Error('error parsing font '+e.message));
1050
+ cb = noop;
1051
+ }
1052
+ cb(null, result);
1053
+ });
1054
+ };
1055
+
1056
+ function isArrayBuffer(arr) {
1057
+ var str = Object.prototype.toString;
1058
+ return str.call(arr) === '[object ArrayBuffer]'
1059
+ }
1060
+
1061
+ function getBinaryOpts(opt) {
1062
+ //IE10+ and other modern browsers support array buffers
1063
+ if (xml2)
1064
+ return xtend(opt, { responseType: 'arraybuffer' })
1065
+
1066
+ if (typeof self.XMLHttpRequest === 'undefined')
1067
+ throw new Error('your browser does not support XHR loading')
1068
+
1069
+ //IE9 and XML1 browsers could still use an override
1070
+ var req = new self.XMLHttpRequest();
1071
+ req.overrideMimeType('text/plain; charset=x-user-defined');
1072
+ return xtend({
1073
+ xhr: req
1074
+ }, opt)
1075
+ }
1076
+ return browser;
1077
+ }
1078
+
1079
+ var browserExports = requireBrowser();
1080
+ const loadFont = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
1081
+
1082
+ var wordWrapper = {exports: {}};
1083
+
1084
+ var hasRequiredWordWrapper;
1085
+
1086
+ function requireWordWrapper () {
1087
+ if (hasRequiredWordWrapper) return wordWrapper.exports;
1088
+ hasRequiredWordWrapper = 1;
1089
+ (function (module) {
1090
+ var newline = /\n/;
1091
+ var newlineChar = '\n';
1092
+ var whitespace = /\s/;
1093
+
1094
+ module.exports = function(text, opt) {
1095
+ var lines = module.exports.lines(text, opt);
1096
+ return lines.map(function(line) {
1097
+ return text.substring(line.start, line.end)
1098
+ }).join('\n')
1099
+ };
1100
+
1101
+ module.exports.lines = function wordwrap(text, opt) {
1102
+ opt = opt||{};
1103
+
1104
+ //zero width results in nothing visible
1105
+ if (opt.width === 0 && opt.mode !== 'nowrap')
1106
+ return []
1107
+
1108
+ text = text||'';
1109
+ var width = typeof opt.width === 'number' ? opt.width : Number.MAX_VALUE;
1110
+ var start = Math.max(0, opt.start||0);
1111
+ var end = typeof opt.end === 'number' ? opt.end : text.length;
1112
+ var mode = opt.mode;
1113
+
1114
+ var measure = opt.measure || monospace;
1115
+ if (mode === 'pre')
1116
+ return pre(measure, text, start, end, width)
1117
+ else
1118
+ return greedy(measure, text, start, end, width, mode)
1119
+ };
1120
+
1121
+ function idxOf(text, chr, start, end) {
1122
+ var idx = text.indexOf(chr, start);
1123
+ if (idx === -1 || idx > end)
1124
+ return end
1125
+ return idx
1126
+ }
1127
+
1128
+ function isWhitespace(chr) {
1129
+ return whitespace.test(chr)
1130
+ }
1131
+
1132
+ function pre(measure, text, start, end, width) {
1133
+ var lines = [];
1134
+ var lineStart = start;
1135
+ for (var i=start; i<end && i<text.length; i++) {
1136
+ var chr = text.charAt(i);
1137
+ var isNewline = newline.test(chr);
1138
+
1139
+ //If we've reached a newline, then step down a line
1140
+ //Or if we've reached the EOF
1141
+ if (isNewline || i===end-1) {
1142
+ var lineEnd = isNewline ? i : i+1;
1143
+ var measured = measure(text, lineStart, lineEnd, width);
1144
+ lines.push(measured);
1145
+
1146
+ lineStart = i+1;
1147
+ }
1148
+ }
1149
+ return lines
1150
+ }
1151
+
1152
+ function greedy(measure, text, start, end, width, mode) {
1153
+ //A greedy word wrapper based on LibGDX algorithm
1154
+ //https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/BitmapFontCache.java
1155
+ var lines = [];
1156
+
1157
+ var testWidth = width;
1158
+ //if 'nowrap' is specified, we only wrap on newline chars
1159
+ if (mode === 'nowrap')
1160
+ testWidth = Number.MAX_VALUE;
1161
+
1162
+ while (start < end && start < text.length) {
1163
+ //get next newline position
1164
+ var newLine = idxOf(text, newlineChar, start, end);
1165
+
1166
+ //eat whitespace at start of line
1167
+ while (start < newLine) {
1168
+ if (!isWhitespace( text.charAt(start) ))
1169
+ break
1170
+ start++;
1171
+ }
1172
+
1173
+ //determine visible # of glyphs for the available width
1174
+ var measured = measure(text, start, newLine, testWidth);
1175
+
1176
+ var lineEnd = start + (measured.end-measured.start);
1177
+ var nextStart = lineEnd + newlineChar.length;
1178
+
1179
+ //if we had to cut the line before the next newline...
1180
+ if (lineEnd < newLine) {
1181
+ //find char to break on
1182
+ while (lineEnd > start) {
1183
+ if (isWhitespace(text.charAt(lineEnd)))
1184
+ break
1185
+ lineEnd--;
1186
+ }
1187
+ if (lineEnd === start) {
1188
+ if (nextStart > start + newlineChar.length) nextStart--;
1189
+ lineEnd = nextStart; // If no characters to break, show all.
1190
+ } else {
1191
+ nextStart = lineEnd;
1192
+ //eat whitespace at end of line
1193
+ while (lineEnd > start) {
1194
+ if (!isWhitespace(text.charAt(lineEnd - newlineChar.length)))
1195
+ break
1196
+ lineEnd--;
1197
+ }
1198
+ }
1199
+ }
1200
+ if (lineEnd >= start) {
1201
+ var result = measure(text, start, lineEnd, testWidth);
1202
+ lines.push(result);
1203
+ }
1204
+ start = nextStart;
1205
+ }
1206
+ return lines
1207
+ }
1208
+
1209
+ //determines the visible number of glyphs within a given width
1210
+ function monospace(text, start, end, width) {
1211
+ var glyphs = Math.min(width, end-start);
1212
+ return {
1213
+ start: start,
1214
+ end: start+glyphs
1215
+ }
1216
+ }
1217
+ } (wordWrapper));
1218
+ return wordWrapper.exports;
1219
+ }
1220
+
1221
+ var asNumber;
1222
+ var hasRequiredAsNumber;
1223
+
1224
+ function requireAsNumber () {
1225
+ if (hasRequiredAsNumber) return asNumber;
1226
+ hasRequiredAsNumber = 1;
1227
+ asNumber = function numtype(num, def) {
1228
+ return typeof num === 'number'
1229
+ ? num
1230
+ : (typeof def === 'number' ? def : 0)
1231
+ };
1232
+ return asNumber;
1233
+ }
1234
+
1235
+ var layoutBmfontText;
1236
+ var hasRequiredLayoutBmfontText;
1237
+
1238
+ function requireLayoutBmfontText () {
1239
+ if (hasRequiredLayoutBmfontText) return layoutBmfontText;
1240
+ hasRequiredLayoutBmfontText = 1;
1241
+ var wordWrap = requireWordWrapper();
1242
+ var xtend = requireImmutable();
1243
+ var number = requireAsNumber();
1244
+
1245
+ var X_HEIGHTS = ['x', 'e', 'a', 'o', 'n', 's', 'r', 'c', 'u', 'm', 'v', 'w', 'z'];
1246
+ var M_WIDTHS = ['m', 'w'];
1247
+ var CAP_HEIGHTS = ['H', 'I', 'N', 'E', 'F', 'K', 'L', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
1248
+
1249
+
1250
+ var TAB_ID = '\t'.charCodeAt(0);
1251
+ var SPACE_ID = ' '.charCodeAt(0);
1252
+ var ALIGN_LEFT = 0,
1253
+ ALIGN_CENTER = 1,
1254
+ ALIGN_RIGHT = 2;
1255
+
1256
+ layoutBmfontText = function createLayout(opt) {
1257
+ return new TextLayout(opt)
1258
+ };
1259
+
1260
+ function TextLayout(opt) {
1261
+ this.glyphs = [];
1262
+ this._measure = this.computeMetrics.bind(this);
1263
+ this.update(opt);
1264
+ }
1265
+
1266
+ TextLayout.prototype.update = function(opt) {
1267
+ opt = xtend({
1268
+ measure: this._measure
1269
+ }, opt);
1270
+ this._opt = opt;
1271
+ this._opt.tabSize = number(this._opt.tabSize, 4);
1272
+
1273
+ if (!opt.font)
1274
+ throw new Error('must provide a valid bitmap font')
1275
+
1276
+ var glyphs = this.glyphs;
1277
+ var text = opt.text||'';
1278
+ var font = opt.font;
1279
+ this._setupSpaceGlyphs(font);
1280
+
1281
+ var lines = wordWrap.lines(text, opt);
1282
+ var minWidth = opt.width || 0;
1283
+
1284
+ //clear glyphs
1285
+ glyphs.length = 0;
1286
+
1287
+ //get max line width
1288
+ var maxLineWidth = lines.reduce(function(prev, line) {
1289
+ return Math.max(prev, line.width, minWidth)
1290
+ }, 0);
1291
+
1292
+ //the pen position
1293
+ var x = 0;
1294
+ var y = 0;
1295
+ var lineHeight = number(opt.lineHeight, font.common.lineHeight);
1296
+ var baseline = font.common.base;
1297
+ var descender = lineHeight-baseline;
1298
+ var letterSpacing = opt.letterSpacing || 0;
1299
+ var height = lineHeight * lines.length - descender;
1300
+ var align = getAlignType(this._opt.align);
1301
+
1302
+ //draw text along baseline
1303
+ y -= height;
1304
+
1305
+ //the metrics for this text layout
1306
+ this._width = maxLineWidth;
1307
+ this._height = height;
1308
+ this._descender = lineHeight - baseline;
1309
+ this._baseline = baseline;
1310
+ this._xHeight = getXHeight(font);
1311
+ this._capHeight = getCapHeight(font);
1312
+ this._lineHeight = lineHeight;
1313
+ this._ascender = lineHeight - descender - this._xHeight;
1314
+
1315
+ //layout each glyph
1316
+ var self = this;
1317
+ lines.forEach(function(line, lineIndex) {
1318
+ var start = line.start;
1319
+ var end = line.end;
1320
+ var lineWidth = line.width;
1321
+ var lastGlyph;
1322
+
1323
+ //for each glyph in that line...
1324
+ for (var i=start; i<end; i++) {
1325
+ var id = text.charCodeAt(i);
1326
+ var glyph = self.getGlyph(font, id);
1327
+ if (glyph) {
1328
+ if (lastGlyph)
1329
+ x += getKerning(font, lastGlyph.id, glyph.id);
1330
+
1331
+ var tx = x;
1332
+ if (align === ALIGN_CENTER)
1333
+ tx += (maxLineWidth-lineWidth)/2;
1334
+ else if (align === ALIGN_RIGHT)
1335
+ tx += (maxLineWidth-lineWidth);
1336
+
1337
+ glyphs.push({
1338
+ position: [tx, y],
1339
+ data: glyph,
1340
+ index: i,
1341
+ line: lineIndex
1342
+ });
1343
+
1344
+ //move pen forward
1345
+ x += glyph.xadvance + letterSpacing;
1346
+ lastGlyph = glyph;
1347
+ }
1348
+ }
1349
+
1350
+ //next line down
1351
+ y += lineHeight;
1352
+ x = 0;
1353
+ });
1354
+ this._linesTotal = lines.length;
1355
+ };
1356
+
1357
+ TextLayout.prototype._setupSpaceGlyphs = function(font) {
1358
+ //These are fallbacks, when the font doesn't include
1359
+ //' ' or '\t' glyphs
1360
+ this._fallbackSpaceGlyph = null;
1361
+ this._fallbackTabGlyph = null;
1362
+
1363
+ if (!font.chars || font.chars.length === 0)
1364
+ return
1365
+
1366
+ //try to get space glyph
1367
+ //then fall back to the 'm' or 'w' glyphs
1368
+ //then fall back to the first glyph available
1369
+ var space = getGlyphById(font, SPACE_ID)
1370
+ || getMGlyph(font)
1371
+ || font.chars[0];
1372
+
1373
+ //and create a fallback for tab
1374
+ var tabWidth = this._opt.tabSize * space.xadvance;
1375
+ this._fallbackSpaceGlyph = space;
1376
+ this._fallbackTabGlyph = xtend(space, {
1377
+ x: 0, y: 0, xadvance: tabWidth, id: TAB_ID,
1378
+ xoffset: 0, yoffset: 0, width: 0, height: 0
1379
+ });
1380
+ };
1381
+
1382
+ TextLayout.prototype.getGlyph = function(font, id) {
1383
+ var glyph = getGlyphById(font, id);
1384
+ if (glyph)
1385
+ return glyph
1386
+ else if (id === TAB_ID)
1387
+ return this._fallbackTabGlyph
1388
+ else if (id === SPACE_ID)
1389
+ return this._fallbackSpaceGlyph
1390
+ return null
1391
+ };
1392
+
1393
+ TextLayout.prototype.computeMetrics = function(text, start, end, width) {
1394
+ var letterSpacing = this._opt.letterSpacing || 0;
1395
+ var font = this._opt.font;
1396
+ var curPen = 0;
1397
+ var curWidth = 0;
1398
+ var count = 0;
1399
+ var glyph;
1400
+ var lastGlyph;
1401
+
1402
+ if (!font.chars || font.chars.length === 0) {
1403
+ return {
1404
+ start: start,
1405
+ end: start,
1406
+ width: 0
1407
+ }
1408
+ }
1409
+
1410
+ end = Math.min(text.length, end);
1411
+ for (var i=start; i < end; i++) {
1412
+ var id = text.charCodeAt(i);
1413
+ var glyph = this.getGlyph(font, id);
1414
+
1415
+ if (glyph) {
1416
+ //move pen forward
1417
+ glyph.xoffset;
1418
+ var kern = lastGlyph ? getKerning(font, lastGlyph.id, glyph.id) : 0;
1419
+ curPen += kern;
1420
+
1421
+ var nextPen = curPen + glyph.xadvance + letterSpacing;
1422
+ var nextWidth = curPen + glyph.width;
1423
+
1424
+ //we've hit our limit; we can't move onto the next glyph
1425
+ if (nextWidth >= width || nextPen >= width)
1426
+ break
1427
+
1428
+ //otherwise continue along our line
1429
+ curPen = nextPen;
1430
+ curWidth = nextWidth;
1431
+ lastGlyph = glyph;
1432
+ }
1433
+ count++;
1434
+ }
1435
+
1436
+ //make sure rightmost edge lines up with rendered glyphs
1437
+ if (lastGlyph)
1438
+ curWidth += lastGlyph.xoffset;
1439
+
1440
+ return {
1441
+ start: start,
1442
+ end: start + count,
1443
+ width: curWidth
1444
+ }
1445
+ }
1446
+
1447
+ //getters for the private vars
1448
+ ;['width', 'height',
1449
+ 'descender', 'ascender',
1450
+ 'xHeight', 'baseline',
1451
+ 'capHeight',
1452
+ 'lineHeight' ].forEach(addGetter);
1453
+
1454
+ function addGetter(name) {
1455
+ Object.defineProperty(TextLayout.prototype, name, {
1456
+ get: wrapper(name),
1457
+ configurable: true
1458
+ });
1459
+ }
1460
+
1461
+ //create lookups for private vars
1462
+ function wrapper(name) {
1463
+ return (new Function([
1464
+ 'return function '+name+'() {',
1465
+ ' return this._'+name,
1466
+ '}'
1467
+ ].join('\n')))()
1468
+ }
1469
+
1470
+ function getGlyphById(font, id) {
1471
+ if (!font.chars || font.chars.length === 0)
1472
+ return null
1473
+
1474
+ var glyphIdx = findChar(font.chars, id);
1475
+ if (glyphIdx >= 0)
1476
+ return font.chars[glyphIdx]
1477
+ return null
1478
+ }
1479
+
1480
+ function getXHeight(font) {
1481
+ for (var i=0; i<X_HEIGHTS.length; i++) {
1482
+ var id = X_HEIGHTS[i].charCodeAt(0);
1483
+ var idx = findChar(font.chars, id);
1484
+ if (idx >= 0)
1485
+ return font.chars[idx].height
1486
+ }
1487
+ return 0
1488
+ }
1489
+
1490
+ function getMGlyph(font) {
1491
+ for (var i=0; i<M_WIDTHS.length; i++) {
1492
+ var id = M_WIDTHS[i].charCodeAt(0);
1493
+ var idx = findChar(font.chars, id);
1494
+ if (idx >= 0)
1495
+ return font.chars[idx]
1496
+ }
1497
+ return 0
1498
+ }
1499
+
1500
+ function getCapHeight(font) {
1501
+ for (var i=0; i<CAP_HEIGHTS.length; i++) {
1502
+ var id = CAP_HEIGHTS[i].charCodeAt(0);
1503
+ var idx = findChar(font.chars, id);
1504
+ if (idx >= 0)
1505
+ return font.chars[idx].height
1506
+ }
1507
+ return 0
1508
+ }
1509
+
1510
+ function getKerning(font, left, right) {
1511
+ if (!font.kernings || font.kernings.length === 0)
1512
+ return 0
1513
+
1514
+ var table = font.kernings;
1515
+ for (var i=0; i<table.length; i++) {
1516
+ var kern = table[i];
1517
+ if (kern.first === left && kern.second === right)
1518
+ return kern.amount
1519
+ }
1520
+ return 0
1521
+ }
1522
+
1523
+ function getAlignType(align) {
1524
+ if (align === 'center')
1525
+ return ALIGN_CENTER
1526
+ else if (align === 'right')
1527
+ return ALIGN_RIGHT
1528
+ return ALIGN_LEFT
1529
+ }
1530
+
1531
+ function findChar (array, value, start) {
1532
+ start = start || 0;
1533
+ for (var i = start; i < array.length; i++) {
1534
+ if (array[i].id === value) {
1535
+ return i
1536
+ }
1537
+ }
1538
+ return -1
1539
+ }
1540
+ return layoutBmfontText;
1541
+ }
1542
+
1543
+ var inherits_browser = {exports: {}};
1544
+
1545
+ var hasRequiredInherits_browser;
1546
+
1547
+ function requireInherits_browser () {
1548
+ if (hasRequiredInherits_browser) return inherits_browser.exports;
1549
+ hasRequiredInherits_browser = 1;
1550
+ if (typeof Object.create === 'function') {
1551
+ // implementation from standard node.js 'util' module
1552
+ inherits_browser.exports = function inherits(ctor, superCtor) {
1553
+ if (superCtor) {
1554
+ ctor.super_ = superCtor;
1555
+ ctor.prototype = Object.create(superCtor.prototype, {
1556
+ constructor: {
1557
+ value: ctor,
1558
+ enumerable: false,
1559
+ writable: true,
1560
+ configurable: true
1561
+ }
1562
+ });
1563
+ }
1564
+ };
1565
+ } else {
1566
+ // old school shim for old browsers
1567
+ inherits_browser.exports = function inherits(ctor, superCtor) {
1568
+ if (superCtor) {
1569
+ ctor.super_ = superCtor;
1570
+ var TempCtor = function () {};
1571
+ TempCtor.prototype = superCtor.prototype;
1572
+ ctor.prototype = new TempCtor();
1573
+ ctor.prototype.constructor = ctor;
1574
+ }
1575
+ };
1576
+ }
1577
+ return inherits_browser.exports;
1578
+ }
1579
+
1580
+ var dtype;
1581
+ var hasRequiredDtype;
1582
+
1583
+ function requireDtype () {
1584
+ if (hasRequiredDtype) return dtype;
1585
+ hasRequiredDtype = 1;
1586
+ dtype = function(dtype) {
1587
+ switch (dtype) {
1588
+ case 'int8':
1589
+ return Int8Array
1590
+ case 'int16':
1591
+ return Int16Array
1592
+ case 'int32':
1593
+ return Int32Array
1594
+ case 'uint8':
1595
+ return Uint8Array
1596
+ case 'uint16':
1597
+ return Uint16Array
1598
+ case 'uint32':
1599
+ return Uint32Array
1600
+ case 'float32':
1601
+ return Float32Array
1602
+ case 'float64':
1603
+ return Float64Array
1604
+ case 'array':
1605
+ return Array
1606
+ case 'uint8_clamped':
1607
+ return Uint8ClampedArray
1608
+ }
1609
+ };
1610
+ return dtype;
1611
+ }
1612
+
1613
+ var anArray_1;
1614
+ var hasRequiredAnArray;
1615
+
1616
+ function requireAnArray () {
1617
+ if (hasRequiredAnArray) return anArray_1;
1618
+ hasRequiredAnArray = 1;
1619
+ var str = Object.prototype.toString;
1620
+
1621
+ anArray_1 = anArray;
1622
+
1623
+ function anArray(arr) {
1624
+ return (
1625
+ arr.BYTES_PER_ELEMENT
1626
+ && str.call(arr.buffer) === '[object ArrayBuffer]'
1627
+ || Array.isArray(arr)
1628
+ )
1629
+ }
1630
+ return anArray_1;
1631
+ }
1632
+
1633
+ /*!
1634
+ * Determine if an object is a Buffer
1635
+ *
1636
+ * @author Feross Aboukhadijeh <https://feross.org>
1637
+ * @license MIT
1638
+ */
1639
+
1640
+ var isBuffer_1;
1641
+ var hasRequiredIsBuffer;
1642
+
1643
+ function requireIsBuffer () {
1644
+ if (hasRequiredIsBuffer) return isBuffer_1;
1645
+ hasRequiredIsBuffer = 1;
1646
+ // The _isBuffer check is for Safari 5-7 support, because it's missing
1647
+ // Object.prototype.constructor. Remove this eventually
1648
+ isBuffer_1 = function (obj) {
1649
+ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
1650
+ };
1651
+
1652
+ function isBuffer (obj) {
1653
+ return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
1654
+ }
1655
+
1656
+ // For Node v0.10 support. Remove this eventually.
1657
+ function isSlowBuffer (obj) {
1658
+ return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
1659
+ }
1660
+ return isBuffer_1;
1661
+ }
1662
+
1663
+ var quadIndices;
1664
+ var hasRequiredQuadIndices;
1665
+
1666
+ function requireQuadIndices () {
1667
+ if (hasRequiredQuadIndices) return quadIndices;
1668
+ hasRequiredQuadIndices = 1;
1669
+ var dtype = requireDtype();
1670
+ var anArray = requireAnArray();
1671
+ var isBuffer = requireIsBuffer();
1672
+
1673
+ var CW = [0, 2, 3];
1674
+ var CCW = [2, 1, 3];
1675
+
1676
+ quadIndices = function createQuadElements(array, opt) {
1677
+ //if user didn't specify an output array
1678
+ if (!array || !(anArray(array) || isBuffer(array))) {
1679
+ opt = array || {};
1680
+ array = null;
1681
+ }
1682
+
1683
+ if (typeof opt === 'number') //backwards-compatible
1684
+ opt = { count: opt };
1685
+ else
1686
+ opt = opt || {};
1687
+
1688
+ var type = typeof opt.type === 'string' ? opt.type : 'uint16';
1689
+ var count = typeof opt.count === 'number' ? opt.count : 1;
1690
+ var start = (opt.start || 0);
1691
+
1692
+ var dir = opt.clockwise !== false ? CW : CCW,
1693
+ a = dir[0],
1694
+ b = dir[1],
1695
+ c = dir[2];
1696
+
1697
+ var numIndices = count * 6;
1698
+
1699
+ var indices = array || new (dtype(type))(numIndices);
1700
+ for (var i = 0, j = 0; i < numIndices; i += 6, j += 4) {
1701
+ var x = i + start;
1702
+ indices[x + 0] = j + 0;
1703
+ indices[x + 1] = j + 1;
1704
+ indices[x + 2] = j + 2;
1705
+ indices[x + 3] = j + a;
1706
+ indices[x + 4] = j + b;
1707
+ indices[x + 5] = j + c;
1708
+ }
1709
+ return indices
1710
+ };
1711
+ return quadIndices;
1712
+ }
1713
+
1714
+ var vertices = {};
1715
+
1716
+ var hasRequiredVertices;
1717
+
1718
+ function requireVertices () {
1719
+ if (hasRequiredVertices) return vertices;
1720
+ hasRequiredVertices = 1;
1721
+ vertices.pages = function pages (glyphs) {
1722
+ var pages = new Float32Array(glyphs.length * 4 * 1);
1723
+ var i = 0;
1724
+ glyphs.forEach(function (glyph) {
1725
+ var id = glyph.data.page || 0;
1726
+ pages[i++] = id;
1727
+ pages[i++] = id;
1728
+ pages[i++] = id;
1729
+ pages[i++] = id;
1730
+ });
1731
+ return pages
1732
+ };
1733
+
1734
+ vertices.uvs = function uvs (glyphs, texWidth, texHeight, flipY) {
1735
+ var uvs = new Float32Array(glyphs.length * 4 * 2);
1736
+ var i = 0;
1737
+ glyphs.forEach(function (glyph) {
1738
+ var bitmap = glyph.data;
1739
+ var bw = (bitmap.x + bitmap.width);
1740
+ var bh = (bitmap.y + bitmap.height);
1741
+
1742
+ // top left position
1743
+ var u0 = bitmap.x / texWidth;
1744
+ var v1 = bitmap.y / texHeight;
1745
+ var u1 = bw / texWidth;
1746
+ var v0 = bh / texHeight;
1747
+
1748
+ if (flipY) {
1749
+ v1 = (texHeight - bitmap.y) / texHeight;
1750
+ v0 = (texHeight - bh) / texHeight;
1751
+ }
1752
+
1753
+ // BL
1754
+ uvs[i++] = u0;
1755
+ uvs[i++] = v1;
1756
+ // TL
1757
+ uvs[i++] = u0;
1758
+ uvs[i++] = v0;
1759
+ // TR
1760
+ uvs[i++] = u1;
1761
+ uvs[i++] = v0;
1762
+ // BR
1763
+ uvs[i++] = u1;
1764
+ uvs[i++] = v1;
1765
+ });
1766
+ return uvs
1767
+ };
1768
+
1769
+ vertices.positions = function positions (glyphs) {
1770
+ var positions = new Float32Array(glyphs.length * 4 * 2);
1771
+ var i = 0;
1772
+ glyphs.forEach(function (glyph) {
1773
+ var bitmap = glyph.data;
1774
+
1775
+ // bottom left position
1776
+ var x = glyph.position[0] + bitmap.xoffset;
1777
+ var y = glyph.position[1] + bitmap.yoffset;
1778
+
1779
+ // quad size
1780
+ var w = bitmap.width;
1781
+ var h = bitmap.height;
1782
+
1783
+ // BL
1784
+ positions[i++] = x;
1785
+ positions[i++] = y;
1786
+ // TL
1787
+ positions[i++] = x;
1788
+ positions[i++] = y + h;
1789
+ // TR
1790
+ positions[i++] = x + w;
1791
+ positions[i++] = y + h;
1792
+ // BR
1793
+ positions[i++] = x + w;
1794
+ positions[i++] = y;
1795
+ });
1796
+ return positions
1797
+ };
1798
+ return vertices;
1799
+ }
1800
+
1801
+ var utils = {};
1802
+
1803
+ var hasRequiredUtils;
1804
+
1805
+ function requireUtils () {
1806
+ if (hasRequiredUtils) return utils;
1807
+ hasRequiredUtils = 1;
1808
+ var itemSize = 2;
1809
+ var box = { min: [0, 0], max: [0, 0] };
1810
+
1811
+ function bounds (positions) {
1812
+ var count = positions.length / itemSize;
1813
+ box.min[0] = positions[0];
1814
+ box.min[1] = positions[1];
1815
+ box.max[0] = positions[0];
1816
+ box.max[1] = positions[1];
1817
+
1818
+ for (var i = 0; i < count; i++) {
1819
+ var x = positions[i * itemSize + 0];
1820
+ var y = positions[i * itemSize + 1];
1821
+ box.min[0] = Math.min(x, box.min[0]);
1822
+ box.min[1] = Math.min(y, box.min[1]);
1823
+ box.max[0] = Math.max(x, box.max[0]);
1824
+ box.max[1] = Math.max(y, box.max[1]);
1825
+ }
1826
+ }
1827
+
1828
+ utils.computeBox = function (positions, output) {
1829
+ bounds(positions);
1830
+ output.min.set(box.min[0], box.min[1], 0);
1831
+ output.max.set(box.max[0], box.max[1], 0);
1832
+ };
1833
+
1834
+ utils.computeSphere = function (positions, output) {
1835
+ bounds(positions);
1836
+ var minX = box.min[0];
1837
+ var minY = box.min[1];
1838
+ var maxX = box.max[0];
1839
+ var maxY = box.max[1];
1840
+ var width = maxX - minX;
1841
+ var height = maxY - minY;
1842
+ var length = Math.sqrt(width * width + height * height);
1843
+ output.center.set(minX + width / 2, minY + height / 2, 0);
1844
+ output.radius = length / 2;
1845
+ };
1846
+ return utils;
1847
+ }
1848
+
1849
+ var threeBmfontText;
1850
+ var hasRequiredThreeBmfontText;
1851
+
1852
+ function requireThreeBmfontText () {
1853
+ if (hasRequiredThreeBmfontText) return threeBmfontText;
1854
+ hasRequiredThreeBmfontText = 1;
1855
+ var createLayout = requireLayoutBmfontText();
1856
+ var inherits = requireInherits_browser();
1857
+ var createIndices = requireQuadIndices();
1858
+
1859
+ var vertices = requireVertices();
1860
+ var utils = requireUtils();
1861
+
1862
+ var Base = THREE.BufferGeometry;
1863
+
1864
+ threeBmfontText = function createTextGeometry (opt) {
1865
+ return new TextGeometry(opt)
1866
+ };
1867
+
1868
+ function TextGeometry (opt) {
1869
+ Base.call(this);
1870
+
1871
+ if (typeof opt === 'string') {
1872
+ opt = { text: opt };
1873
+ }
1874
+
1875
+ // use these as default values for any subsequent
1876
+ // calls to update()
1877
+ this._opt = Object.assign({}, opt);
1878
+
1879
+ // also do an initial setup...
1880
+ if (opt) this.update(opt);
1881
+ }
1882
+
1883
+ inherits(TextGeometry, Base);
1884
+
1885
+ TextGeometry.prototype.update = function (opt) {
1886
+ if (typeof opt === 'string') {
1887
+ opt = { text: opt };
1888
+ }
1889
+
1890
+ // use constructor defaults
1891
+ opt = Object.assign({}, this._opt, opt);
1892
+
1893
+ if (!opt.font) {
1894
+ throw new TypeError('must specify a { font } in options')
1895
+ }
1896
+
1897
+ this.layout = createLayout(opt);
1898
+
1899
+ // get vec2 texcoords
1900
+ var flipY = opt.flipY !== false;
1901
+
1902
+ // the desired BMFont data
1903
+ var font = opt.font;
1904
+
1905
+ // determine texture size from font file
1906
+ var texWidth = font.common.scaleW;
1907
+ var texHeight = font.common.scaleH;
1908
+
1909
+ // get visible glyphs
1910
+ var glyphs = this.layout.glyphs.filter(function (glyph) {
1911
+ var bitmap = glyph.data;
1912
+ return bitmap.width * bitmap.height > 0
1913
+ });
1914
+
1915
+ // provide visible glyphs for convenience
1916
+ this.visibleGlyphs = glyphs;
1917
+
1918
+ // get common vertex data
1919
+ var positions = vertices.positions(glyphs);
1920
+ var uvs = vertices.uvs(glyphs, texWidth, texHeight, flipY);
1921
+ var indices = createIndices([], {
1922
+ clockwise: true,
1923
+ type: 'uint16',
1924
+ count: glyphs.length
1925
+ });
1926
+
1927
+ // update vertex data
1928
+ this.setIndex(indices);
1929
+ this.setAttribute('position', new THREE.BufferAttribute(positions, 2));
1930
+ this.setAttribute('uv', new THREE.BufferAttribute(uvs, 2));
1931
+
1932
+ // update multipage data
1933
+ if (!opt.multipage && 'page' in this.attributes) {
1934
+ // disable multipage rendering
1935
+ this.removeAttribute('page');
1936
+ } else if (opt.multipage) {
1937
+ // enable multipage rendering
1938
+ var pages = vertices.pages(glyphs);
1939
+ this.setAttribute('page', new THREE.BufferAttribute(pages, 1));
1940
+ }
1941
+ };
1942
+
1943
+ TextGeometry.prototype.computeBoundingSphere = function () {
1944
+ if (this.boundingSphere === null) {
1945
+ this.boundingSphere = new THREE.Sphere();
1946
+ }
1947
+
1948
+ var positions = this.attributes.position.array;
1949
+ var itemSize = this.attributes.position.itemSize;
1950
+ if (!positions || !itemSize || positions.length < 2) {
1951
+ this.boundingSphere.radius = 0;
1952
+ this.boundingSphere.center.set(0, 0, 0);
1953
+ return
1954
+ }
1955
+ utils.computeSphere(positions, this.boundingSphere);
1956
+ if (isNaN(this.boundingSphere.radius)) {
1957
+ console.error('THREE.BufferGeometry.computeBoundingSphere(): ' +
1958
+ 'Computed radius is NaN. The ' +
1959
+ '"position" attribute is likely to have NaN values.');
1960
+ }
1961
+ };
1962
+
1963
+ TextGeometry.prototype.computeBoundingBox = function () {
1964
+ if (this.boundingBox === null) {
1965
+ this.boundingBox = new THREE.Box3();
1966
+ }
1967
+
1968
+ var bbox = this.boundingBox;
1969
+ var positions = this.attributes.position.array;
1970
+ var itemSize = this.attributes.position.itemSize;
1971
+ if (!positions || !itemSize || positions.length < 2) {
1972
+ bbox.makeEmpty();
1973
+ return
1974
+ }
1975
+ utils.computeBox(positions, bbox);
1976
+ };
1977
+ return threeBmfontText;
1978
+ }
1979
+
1980
+ var threeBmfontTextExports = requireThreeBmfontText();
1981
+ const createGeometry = /*@__PURE__*/getDefaultExportFromCjs(threeBmfontTextExports);
1982
+
1983
+ var msdf;
1984
+ var hasRequiredMsdf;
1985
+
1986
+ function requireMsdf () {
1987
+ if (hasRequiredMsdf) return msdf;
1988
+ hasRequiredMsdf = 1;
1989
+ var assign = requireObjectAssign();
1990
+
1991
+ msdf = function createMSDFShader (opt) {
1992
+ opt = opt || {};
1993
+ var opacity = typeof opt.opacity === 'number' ? opt.opacity : 1;
1994
+ var alphaTest = typeof opt.alphaTest === 'number' ? opt.alphaTest : 0.0001;
1995
+ var precision = opt.precision || 'highp';
1996
+ var color = opt.color;
1997
+ var map = opt.map;
1998
+ var negate = typeof opt.negate === 'boolean' ? opt.negate : true;
1999
+
2000
+ // remove to satisfy r73
2001
+ delete opt.map;
2002
+ delete opt.color;
2003
+ delete opt.precision;
2004
+ delete opt.opacity;
2005
+ delete opt.negate;
2006
+
2007
+ return assign({
2008
+ uniforms: {
2009
+ opacity: { type: 'f', value: opacity },
2010
+ map: { type: 't', value: map || new THREE.Texture() },
2011
+ color: { type: 'c', value: new THREE.Color(color) }
2012
+ },
2013
+ vertexShader: [
2014
+ 'attribute vec2 uv;',
2015
+ 'attribute vec4 position;',
2016
+ 'uniform mat4 projectionMatrix;',
2017
+ 'uniform mat4 modelViewMatrix;',
2018
+ 'varying vec2 vUv;',
2019
+ 'void main() {',
2020
+ 'vUv = uv;',
2021
+ 'gl_Position = projectionMatrix * modelViewMatrix * position;',
2022
+ '}'
2023
+ ].join('\n'),
2024
+ fragmentShader: [
2025
+ '#ifdef GL_OES_standard_derivatives',
2026
+ '#extension GL_OES_standard_derivatives : enable',
2027
+ '#endif',
2028
+ 'precision ' + precision + ' float;',
2029
+ 'uniform float opacity;',
2030
+ 'uniform vec3 color;',
2031
+ 'uniform sampler2D map;',
2032
+ 'varying vec2 vUv;',
2033
+
2034
+ 'float median(float r, float g, float b) {',
2035
+ ' return max(min(r, g), min(max(r, g), b));',
2036
+ '}',
2037
+
2038
+ 'void main() {',
2039
+ ' vec3 sample = ' + (negate ? '1.0 - ' : '') + 'texture2D(map, vUv).rgb;',
2040
+ ' float sigDist = median(sample.r, sample.g, sample.b) - 0.5;',
2041
+ ' float alpha = clamp(sigDist/fwidth(sigDist) + 0.5, 0.0, 1.0);',
2042
+ ' gl_FragColor = vec4(color.xyz, alpha * opacity);',
2043
+ alphaTest === 0
2044
+ ? ''
2045
+ : ' if (gl_FragColor.a < ' + alphaTest + ') discard;',
2046
+ '}'
2047
+ ].join('\n')
2048
+ }, opt);
2049
+ };
2050
+ return msdf;
2051
+ }
2052
+
2053
+ var msdfExports = requireMsdf();
2054
+ const MSDFShader = /*@__PURE__*/getDefaultExportFromCjs(msdfExports);
2055
+
2056
+ var threeOrbitControls;
2057
+ var hasRequiredThreeOrbitControls;
2058
+
2059
+ function requireThreeOrbitControls () {
2060
+ if (hasRequiredThreeOrbitControls) return threeOrbitControls;
2061
+ hasRequiredThreeOrbitControls = 1;
2062
+ threeOrbitControls = function( THREE ) {
2063
+ /**
2064
+ * @author qiao / https://github.com/qiao
2065
+ * @author mrdoob / http://mrdoob.com
2066
+ * @author alteredq / http://alteredqualia.com/
2067
+ * @author WestLangley / http://github.com/WestLangley
2068
+ * @author erich666 / http://erichaines.com
2069
+ */
2070
+
2071
+ // This set of controls performs orbiting, dollying (zooming), and panning.
2072
+ // Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
2073
+ //
2074
+ // Orbit - left mouse / touch: one finger move
2075
+ // Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
2076
+ // Pan - right mouse, or arrow keys / touch: three finter swipe
2077
+
2078
+ function OrbitControls( object, domElement ) {
2079
+
2080
+ this.object = object;
2081
+
2082
+ this.domElement = ( domElement !== undefined ) ? domElement : document;
2083
+
2084
+ // Set to false to disable this control
2085
+ this.enabled = true;
2086
+
2087
+ // "target" sets the location of focus, where the object orbits around
2088
+ this.target = new THREE.Vector3();
2089
+
2090
+ // How far you can dolly in and out ( PerspectiveCamera only )
2091
+ this.minDistance = 0;
2092
+ this.maxDistance = Infinity;
2093
+
2094
+ // How far you can zoom in and out ( OrthographicCamera only )
2095
+ this.minZoom = 0;
2096
+ this.maxZoom = Infinity;
2097
+
2098
+ // How far you can orbit vertically, upper and lower limits.
2099
+ // Range is 0 to Math.PI radians.
2100
+ this.minPolarAngle = 0; // radians
2101
+ this.maxPolarAngle = Math.PI; // radians
2102
+
2103
+ // How far you can orbit horizontally, upper and lower limits.
2104
+ // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
2105
+ this.minAzimuthAngle = - Infinity; // radians
2106
+ this.maxAzimuthAngle = Infinity; // radians
2107
+
2108
+ // Set to true to enable damping (inertia)
2109
+ // If damping is enabled, you must call controls.update() in your animation loop
2110
+ this.enableDamping = false;
2111
+ this.dampingFactor = 0.25;
2112
+
2113
+ // This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
2114
+ // Set to false to disable zooming
2115
+ this.enableZoom = true;
2116
+ this.zoomSpeed = 1.0;
2117
+
2118
+ // Set to false to disable rotating
2119
+ this.enableRotate = true;
2120
+ this.rotateSpeed = 1.0;
2121
+
2122
+ // Set to false to disable panning
2123
+ this.enablePan = true;
2124
+ this.keyPanSpeed = 7.0; // pixels moved per arrow key push
2125
+
2126
+ // Set to true to automatically rotate around the target
2127
+ // If auto-rotate is enabled, you must call controls.update() in your animation loop
2128
+ this.autoRotate = false;
2129
+ this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
2130
+
2131
+ // Set to false to disable use of the keys
2132
+ this.enableKeys = true;
2133
+
2134
+ // The four arrow keys
2135
+ this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
2136
+
2137
+ // Mouse buttons
2138
+ this.mouseButtons = { ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT };
2139
+
2140
+ // for reset
2141
+ this.target0 = this.target.clone();
2142
+ this.position0 = this.object.position.clone();
2143
+ this.zoom0 = this.object.zoom;
2144
+
2145
+ //
2146
+ // public methods
2147
+ //
2148
+
2149
+ this.getPolarAngle = function () {
2150
+
2151
+ return spherical.phi;
2152
+
2153
+ };
2154
+
2155
+ this.getAzimuthalAngle = function () {
2156
+
2157
+ return spherical.theta;
2158
+
2159
+ };
2160
+
2161
+ this.reset = function () {
2162
+
2163
+ scope.target.copy( scope.target0 );
2164
+ scope.object.position.copy( scope.position0 );
2165
+ scope.object.zoom = scope.zoom0;
2166
+
2167
+ scope.object.updateProjectionMatrix();
2168
+ scope.dispatchEvent( changeEvent );
2169
+
2170
+ scope.update();
2171
+
2172
+ state = STATE.NONE;
2173
+
2174
+ };
2175
+
2176
+ // this method is exposed, but perhaps it would be better if we can make it private...
2177
+ this.update = function() {
2178
+
2179
+ var offset = new THREE.Vector3();
2180
+
2181
+ // so camera.up is the orbit axis
2182
+ var quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) );
2183
+ var quatInverse = quat.clone().inverse();
2184
+
2185
+ var lastPosition = new THREE.Vector3();
2186
+ var lastQuaternion = new THREE.Quaternion();
2187
+
2188
+ return function update () {
2189
+
2190
+ var position = scope.object.position;
2191
+
2192
+ offset.copy( position ).sub( scope.target );
2193
+
2194
+ // rotate offset to "y-axis-is-up" space
2195
+ offset.applyQuaternion( quat );
2196
+
2197
+ // angle from z-axis around y-axis
2198
+ spherical.setFromVector3( offset );
2199
+
2200
+ if ( scope.autoRotate && state === STATE.NONE ) {
2201
+
2202
+ rotateLeft( getAutoRotationAngle() );
2203
+
2204
+ }
2205
+
2206
+ spherical.theta += sphericalDelta.theta;
2207
+ spherical.phi += sphericalDelta.phi;
2208
+
2209
+ // restrict theta to be between desired limits
2210
+ spherical.theta = Math.max( scope.minAzimuthAngle, Math.min( scope.maxAzimuthAngle, spherical.theta ) );
2211
+
2212
+ // restrict phi to be between desired limits
2213
+ spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) );
2214
+
2215
+ spherical.makeSafe();
2216
+
2217
+
2218
+ spherical.radius *= scale;
2219
+
2220
+ // restrict radius to be between desired limits
2221
+ spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) );
2222
+
2223
+ // move target to panned location
2224
+ scope.target.add( panOffset );
2225
+
2226
+ offset.setFromSpherical( spherical );
2227
+
2228
+ // rotate offset back to "camera-up-vector-is-up" space
2229
+ offset.applyQuaternion( quatInverse );
2230
+
2231
+ position.copy( scope.target ).add( offset );
2232
+
2233
+ scope.object.lookAt( scope.target );
2234
+
2235
+ if ( scope.enableDamping === true ) {
2236
+
2237
+ sphericalDelta.theta *= ( 1 - scope.dampingFactor );
2238
+ sphericalDelta.phi *= ( 1 - scope.dampingFactor );
2239
+
2240
+ } else {
2241
+
2242
+ sphericalDelta.set( 0, 0, 0 );
2243
+
2244
+ }
2245
+
2246
+ scale = 1;
2247
+ panOffset.set( 0, 0, 0 );
2248
+
2249
+ // update condition is:
2250
+ // min(camera displacement, camera rotation in radians)^2 > EPS
2251
+ // using small-angle approximation cos(x/2) = 1 - x^2 / 8
2252
+
2253
+ if ( zoomChanged ||
2254
+ lastPosition.distanceToSquared( scope.object.position ) > EPS ||
2255
+ 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
2256
+
2257
+ scope.dispatchEvent( changeEvent );
2258
+
2259
+ lastPosition.copy( scope.object.position );
2260
+ lastQuaternion.copy( scope.object.quaternion );
2261
+ zoomChanged = false;
2262
+
2263
+ return true;
2264
+
2265
+ }
2266
+
2267
+ return false;
2268
+
2269
+ };
2270
+
2271
+ }();
2272
+
2273
+ this.dispose = function() {
2274
+
2275
+ scope.domElement.removeEventListener( 'contextmenu', onContextMenu, false );
2276
+ scope.domElement.removeEventListener( 'mousedown', onMouseDown, false );
2277
+ scope.domElement.removeEventListener( 'wheel', onMouseWheel, false );
2278
+
2279
+ scope.domElement.removeEventListener( 'touchstart', onTouchStart, false );
2280
+ scope.domElement.removeEventListener( 'touchend', onTouchEnd, false );
2281
+ scope.domElement.removeEventListener( 'touchmove', onTouchMove, false );
2282
+
2283
+ document.removeEventListener( 'mousemove', onMouseMove, false );
2284
+ document.removeEventListener( 'mouseup', onMouseUp, false );
2285
+
2286
+ window.removeEventListener( 'keydown', onKeyDown, false );
2287
+
2288
+ //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here?
2289
+
2290
+ };
2291
+
2292
+ //
2293
+ // internals
2294
+ //
2295
+
2296
+ var scope = this;
2297
+
2298
+ var changeEvent = { type: 'change' };
2299
+ var startEvent = { type: 'start' };
2300
+ var endEvent = { type: 'end' };
2301
+
2302
+ var STATE = { NONE : -1, ROTATE : 0, DOLLY : 1, PAN : 2, TOUCH_ROTATE : 3, TOUCH_DOLLY : 4, TOUCH_PAN : 5 };
2303
+
2304
+ var state = STATE.NONE;
2305
+
2306
+ var EPS = 0.000001;
2307
+
2308
+ // current position in spherical coordinates
2309
+ var spherical = new THREE.Spherical();
2310
+ var sphericalDelta = new THREE.Spherical();
2311
+
2312
+ var scale = 1;
2313
+ var panOffset = new THREE.Vector3();
2314
+ var zoomChanged = false;
2315
+
2316
+ var rotateStart = new THREE.Vector2();
2317
+ var rotateEnd = new THREE.Vector2();
2318
+ var rotateDelta = new THREE.Vector2();
2319
+
2320
+ var panStart = new THREE.Vector2();
2321
+ var panEnd = new THREE.Vector2();
2322
+ var panDelta = new THREE.Vector2();
2323
+
2324
+ var dollyStart = new THREE.Vector2();
2325
+ var dollyEnd = new THREE.Vector2();
2326
+ var dollyDelta = new THREE.Vector2();
2327
+
2328
+ function getAutoRotationAngle() {
2329
+
2330
+ return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
2331
+
2332
+ }
2333
+
2334
+ function getZoomScale() {
2335
+
2336
+ return Math.pow( 0.95, scope.zoomSpeed );
2337
+
2338
+ }
2339
+
2340
+ function rotateLeft( angle ) {
2341
+
2342
+ sphericalDelta.theta -= angle;
2343
+
2344
+ }
2345
+
2346
+ function rotateUp( angle ) {
2347
+
2348
+ sphericalDelta.phi -= angle;
2349
+
2350
+ }
2351
+
2352
+ var panLeft = function() {
2353
+
2354
+ var v = new THREE.Vector3();
2355
+
2356
+ return function panLeft( distance, objectMatrix ) {
2357
+
2358
+ v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix
2359
+ v.multiplyScalar( - distance );
2360
+
2361
+ panOffset.add( v );
2362
+
2363
+ };
2364
+
2365
+ }();
2366
+
2367
+ var panUp = function() {
2368
+
2369
+ var v = new THREE.Vector3();
2370
+
2371
+ return function panUp( distance, objectMatrix ) {
2372
+
2373
+ v.setFromMatrixColumn( objectMatrix, 1 ); // get Y column of objectMatrix
2374
+ v.multiplyScalar( distance );
2375
+
2376
+ panOffset.add( v );
2377
+
2378
+ };
2379
+
2380
+ }();
2381
+
2382
+ // deltaX and deltaY are in pixels; right and down are positive
2383
+ var pan = function() {
2384
+
2385
+ var offset = new THREE.Vector3();
2386
+
2387
+ return function pan ( deltaX, deltaY ) {
2388
+
2389
+ var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
2390
+
2391
+ if ( scope.object instanceof THREE.PerspectiveCamera ) {
2392
+
2393
+ // perspective
2394
+ var position = scope.object.position;
2395
+ offset.copy( position ).sub( scope.target );
2396
+ var targetDistance = offset.length();
2397
+
2398
+ // half of the fov is center to top of screen
2399
+ targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 );
2400
+
2401
+ // we actually don't use screenWidth, since perspective camera is fixed to screen height
2402
+ panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix );
2403
+ panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix );
2404
+
2405
+ } else if ( scope.object instanceof THREE.OrthographicCamera ) {
2406
+
2407
+ // orthographic
2408
+ panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix );
2409
+ panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix );
2410
+
2411
+ } else {
2412
+
2413
+ // camera neither orthographic nor perspective
2414
+ console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
2415
+ scope.enablePan = false;
2416
+
2417
+ }
2418
+
2419
+ };
2420
+
2421
+ }();
2422
+
2423
+ function dollyIn( dollyScale ) {
2424
+
2425
+ if ( scope.object instanceof THREE.PerspectiveCamera ) {
2426
+
2427
+ scale /= dollyScale;
2428
+
2429
+ } else if ( scope.object instanceof THREE.OrthographicCamera ) {
2430
+
2431
+ scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) );
2432
+ scope.object.updateProjectionMatrix();
2433
+ zoomChanged = true;
2434
+
2435
+ } else {
2436
+
2437
+ console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
2438
+ scope.enableZoom = false;
2439
+
2440
+ }
2441
+
2442
+ }
2443
+
2444
+ function dollyOut( dollyScale ) {
2445
+
2446
+ if ( scope.object instanceof THREE.PerspectiveCamera ) {
2447
+
2448
+ scale *= dollyScale;
2449
+
2450
+ } else if ( scope.object instanceof THREE.OrthographicCamera ) {
2451
+
2452
+ scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) );
2453
+ scope.object.updateProjectionMatrix();
2454
+ zoomChanged = true;
2455
+
2456
+ } else {
2457
+
2458
+ console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
2459
+ scope.enableZoom = false;
2460
+
2461
+ }
2462
+
2463
+ }
2464
+
2465
+ //
2466
+ // event callbacks - update the object state
2467
+ //
2468
+
2469
+ function handleMouseDownRotate( event ) {
2470
+
2471
+ //console.log( 'handleMouseDownRotate' );
2472
+
2473
+ rotateStart.set( event.clientX, event.clientY );
2474
+
2475
+ }
2476
+
2477
+ function handleMouseDownDolly( event ) {
2478
+
2479
+ //console.log( 'handleMouseDownDolly' );
2480
+
2481
+ dollyStart.set( event.clientX, event.clientY );
2482
+
2483
+ }
2484
+
2485
+ function handleMouseDownPan( event ) {
2486
+
2487
+ //console.log( 'handleMouseDownPan' );
2488
+
2489
+ panStart.set( event.clientX, event.clientY );
2490
+
2491
+ }
2492
+
2493
+ function handleMouseMoveRotate( event ) {
2494
+
2495
+ //console.log( 'handleMouseMoveRotate' );
2496
+
2497
+ rotateEnd.set( event.clientX, event.clientY );
2498
+ rotateDelta.subVectors( rotateEnd, rotateStart );
2499
+
2500
+ var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
2501
+
2502
+ // rotating across whole screen goes 360 degrees around
2503
+ rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
2504
+
2505
+ // rotating up and down along whole screen attempts to go 360, but limited to 180
2506
+ rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
2507
+
2508
+ rotateStart.copy( rotateEnd );
2509
+
2510
+ scope.update();
2511
+
2512
+ }
2513
+
2514
+ function handleMouseMoveDolly( event ) {
2515
+
2516
+ //console.log( 'handleMouseMoveDolly' );
2517
+
2518
+ dollyEnd.set( event.clientX, event.clientY );
2519
+
2520
+ dollyDelta.subVectors( dollyEnd, dollyStart );
2521
+
2522
+ if ( dollyDelta.y > 0 ) {
2523
+
2524
+ dollyIn( getZoomScale() );
2525
+
2526
+ } else if ( dollyDelta.y < 0 ) {
2527
+
2528
+ dollyOut( getZoomScale() );
2529
+
2530
+ }
2531
+
2532
+ dollyStart.copy( dollyEnd );
2533
+
2534
+ scope.update();
2535
+
2536
+ }
2537
+
2538
+ function handleMouseMovePan( event ) {
2539
+
2540
+ //console.log( 'handleMouseMovePan' );
2541
+
2542
+ panEnd.set( event.clientX, event.clientY );
2543
+
2544
+ panDelta.subVectors( panEnd, panStart );
2545
+
2546
+ pan( panDelta.x, panDelta.y );
2547
+
2548
+ panStart.copy( panEnd );
2549
+
2550
+ scope.update();
2551
+
2552
+ }
2553
+
2554
+ function handleMouseWheel( event ) {
2555
+
2556
+ //console.log( 'handleMouseWheel' );
2557
+
2558
+ if ( event.deltaY < 0 ) {
2559
+
2560
+ dollyOut( getZoomScale() );
2561
+
2562
+ } else if ( event.deltaY > 0 ) {
2563
+
2564
+ dollyIn( getZoomScale() );
2565
+
2566
+ }
2567
+
2568
+ scope.update();
2569
+
2570
+ }
2571
+
2572
+ function handleKeyDown( event ) {
2573
+
2574
+ //console.log( 'handleKeyDown' );
2575
+
2576
+ switch ( event.keyCode ) {
2577
+
2578
+ case scope.keys.UP:
2579
+ pan( 0, scope.keyPanSpeed );
2580
+ scope.update();
2581
+ break;
2582
+
2583
+ case scope.keys.BOTTOM:
2584
+ pan( 0, - scope.keyPanSpeed );
2585
+ scope.update();
2586
+ break;
2587
+
2588
+ case scope.keys.LEFT:
2589
+ pan( scope.keyPanSpeed, 0 );
2590
+ scope.update();
2591
+ break;
2592
+
2593
+ case scope.keys.RIGHT:
2594
+ pan( - scope.keyPanSpeed, 0 );
2595
+ scope.update();
2596
+ break;
2597
+
2598
+ }
2599
+
2600
+ }
2601
+
2602
+ function handleTouchStartRotate( event ) {
2603
+
2604
+ //console.log( 'handleTouchStartRotate' );
2605
+
2606
+ rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
2607
+
2608
+ }
2609
+
2610
+ function handleTouchStartDolly( event ) {
2611
+
2612
+ //console.log( 'handleTouchStartDolly' );
2613
+
2614
+ var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
2615
+ var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
2616
+
2617
+ var distance = Math.sqrt( dx * dx + dy * dy );
2618
+
2619
+ dollyStart.set( 0, distance );
2620
+
2621
+ }
2622
+
2623
+ function handleTouchStartPan( event ) {
2624
+
2625
+ //console.log( 'handleTouchStartPan' );
2626
+
2627
+ panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
2628
+
2629
+ }
2630
+
2631
+ function handleTouchMoveRotate( event ) {
2632
+
2633
+ //console.log( 'handleTouchMoveRotate' );
2634
+
2635
+ rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
2636
+ rotateDelta.subVectors( rotateEnd, rotateStart );
2637
+
2638
+ var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
2639
+
2640
+ // rotating across whole screen goes 360 degrees around
2641
+ rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
2642
+
2643
+ // rotating up and down along whole screen attempts to go 360, but limited to 180
2644
+ rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
2645
+
2646
+ rotateStart.copy( rotateEnd );
2647
+
2648
+ scope.update();
2649
+
2650
+ }
2651
+
2652
+ function handleTouchMoveDolly( event ) {
2653
+
2654
+ //console.log( 'handleTouchMoveDolly' );
2655
+
2656
+ var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
2657
+ var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
2658
+
2659
+ var distance = Math.sqrt( dx * dx + dy * dy );
2660
+
2661
+ dollyEnd.set( 0, distance );
2662
+
2663
+ dollyDelta.subVectors( dollyEnd, dollyStart );
2664
+
2665
+ if ( dollyDelta.y > 0 ) {
2666
+
2667
+ dollyOut( getZoomScale() );
2668
+
2669
+ } else if ( dollyDelta.y < 0 ) {
2670
+
2671
+ dollyIn( getZoomScale() );
2672
+
2673
+ }
2674
+
2675
+ dollyStart.copy( dollyEnd );
2676
+
2677
+ scope.update();
2678
+
2679
+ }
2680
+
2681
+ function handleTouchMovePan( event ) {
2682
+
2683
+ //console.log( 'handleTouchMovePan' );
2684
+
2685
+ panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
2686
+
2687
+ panDelta.subVectors( panEnd, panStart );
2688
+
2689
+ pan( panDelta.x, panDelta.y );
2690
+
2691
+ panStart.copy( panEnd );
2692
+
2693
+ scope.update();
2694
+
2695
+ }
2696
+
2697
+ //
2698
+ // event handlers - FSM: listen for events and reset state
2699
+ //
2700
+
2701
+ function onMouseDown( event ) {
2702
+
2703
+ if ( scope.enabled === false ) return;
2704
+
2705
+ event.preventDefault();
2706
+
2707
+ if ( event.button === scope.mouseButtons.ORBIT ) {
2708
+
2709
+ if ( scope.enableRotate === false ) return;
2710
+
2711
+ handleMouseDownRotate( event );
2712
+
2713
+ state = STATE.ROTATE;
2714
+
2715
+ } else if ( event.button === scope.mouseButtons.ZOOM ) {
2716
+
2717
+ if ( scope.enableZoom === false ) return;
2718
+
2719
+ handleMouseDownDolly( event );
2720
+
2721
+ state = STATE.DOLLY;
2722
+
2723
+ } else if ( event.button === scope.mouseButtons.PAN ) {
2724
+
2725
+ if ( scope.enablePan === false ) return;
2726
+
2727
+ handleMouseDownPan( event );
2728
+
2729
+ state = STATE.PAN;
2730
+
2731
+ }
2732
+
2733
+ if ( state !== STATE.NONE ) {
2734
+
2735
+ document.addEventListener( 'mousemove', onMouseMove, false );
2736
+ document.addEventListener( 'mouseup', onMouseUp, false );
2737
+
2738
+ scope.dispatchEvent( startEvent );
2739
+
2740
+ }
2741
+
2742
+ }
2743
+
2744
+ function onMouseMove( event ) {
2745
+
2746
+ if ( scope.enabled === false ) return;
2747
+
2748
+ event.preventDefault();
2749
+
2750
+ if ( state === STATE.ROTATE ) {
2751
+
2752
+ if ( scope.enableRotate === false ) return;
2753
+
2754
+ handleMouseMoveRotate( event );
2755
+
2756
+ } else if ( state === STATE.DOLLY ) {
2757
+
2758
+ if ( scope.enableZoom === false ) return;
2759
+
2760
+ handleMouseMoveDolly( event );
2761
+
2762
+ } else if ( state === STATE.PAN ) {
2763
+
2764
+ if ( scope.enablePan === false ) return;
2765
+
2766
+ handleMouseMovePan( event );
2767
+
2768
+ }
2769
+
2770
+ }
2771
+
2772
+ function onMouseUp( event ) {
2773
+
2774
+ if ( scope.enabled === false ) return;
2775
+
2776
+ document.removeEventListener( 'mousemove', onMouseMove, false );
2777
+ document.removeEventListener( 'mouseup', onMouseUp, false );
2778
+
2779
+ scope.dispatchEvent( endEvent );
2780
+
2781
+ state = STATE.NONE;
2782
+
2783
+ }
2784
+
2785
+ function onMouseWheel( event ) {
2786
+
2787
+ if ( scope.enabled === false || scope.enableZoom === false || ( state !== STATE.NONE && state !== STATE.ROTATE ) ) return;
2788
+
2789
+ event.preventDefault();
2790
+ event.stopPropagation();
2791
+
2792
+ handleMouseWheel( event );
2793
+
2794
+ scope.dispatchEvent( startEvent ); // not sure why these are here...
2795
+ scope.dispatchEvent( endEvent );
2796
+
2797
+ }
2798
+
2799
+ function onKeyDown( event ) {
2800
+
2801
+ if ( scope.enabled === false || scope.enableKeys === false || scope.enablePan === false ) return;
2802
+
2803
+ handleKeyDown( event );
2804
+
2805
+ }
2806
+
2807
+ function onTouchStart( event ) {
2808
+
2809
+ if ( scope.enabled === false ) return;
2810
+
2811
+ switch ( event.touches.length ) {
2812
+
2813
+ case 1: // one-fingered touch: rotate
2814
+
2815
+ if ( scope.enableRotate === false ) return;
2816
+
2817
+ handleTouchStartRotate( event );
2818
+
2819
+ state = STATE.TOUCH_ROTATE;
2820
+
2821
+ break;
2822
+
2823
+ case 2: // two-fingered touch: dolly
2824
+
2825
+ if ( scope.enableZoom === false ) return;
2826
+
2827
+ handleTouchStartDolly( event );
2828
+
2829
+ state = STATE.TOUCH_DOLLY;
2830
+
2831
+ break;
2832
+
2833
+ case 3: // three-fingered touch: pan
2834
+
2835
+ if ( scope.enablePan === false ) return;
2836
+
2837
+ handleTouchStartPan( event );
2838
+
2839
+ state = STATE.TOUCH_PAN;
2840
+
2841
+ break;
2842
+
2843
+ default:
2844
+
2845
+ state = STATE.NONE;
2846
+
2847
+ }
2848
+
2849
+ if ( state !== STATE.NONE ) {
2850
+
2851
+ scope.dispatchEvent( startEvent );
2852
+
2853
+ }
2854
+
2855
+ }
2856
+
2857
+ function onTouchMove( event ) {
2858
+
2859
+ if ( scope.enabled === false ) return;
2860
+
2861
+ event.preventDefault();
2862
+ event.stopPropagation();
2863
+
2864
+ switch ( event.touches.length ) {
2865
+
2866
+ case 1: // one-fingered touch: rotate
2867
+
2868
+ if ( scope.enableRotate === false ) return;
2869
+ if ( state !== STATE.TOUCH_ROTATE ) return; // is this needed?...
2870
+
2871
+ handleTouchMoveRotate( event );
2872
+
2873
+ break;
2874
+
2875
+ case 2: // two-fingered touch: dolly
2876
+
2877
+ if ( scope.enableZoom === false ) return;
2878
+ if ( state !== STATE.TOUCH_DOLLY ) return; // is this needed?...
2879
+
2880
+ handleTouchMoveDolly( event );
2881
+
2882
+ break;
2883
+
2884
+ case 3: // three-fingered touch: pan
2885
+
2886
+ if ( scope.enablePan === false ) return;
2887
+ if ( state !== STATE.TOUCH_PAN ) return; // is this needed?...
2888
+
2889
+ handleTouchMovePan( event );
2890
+
2891
+ break;
2892
+
2893
+ default:
2894
+
2895
+ state = STATE.NONE;
2896
+
2897
+ }
2898
+
2899
+ }
2900
+
2901
+ function onTouchEnd( event ) {
2902
+
2903
+ if ( scope.enabled === false ) return;
2904
+
2905
+ scope.dispatchEvent( endEvent );
2906
+
2907
+ state = STATE.NONE;
2908
+
2909
+ }
2910
+
2911
+ function onContextMenu( event ) {
2912
+
2913
+ event.preventDefault();
2914
+
2915
+ }
2916
+
2917
+ //
2918
+
2919
+ scope.domElement.addEventListener( 'contextmenu', onContextMenu, false );
2920
+
2921
+ scope.domElement.addEventListener( 'mousedown', onMouseDown, false );
2922
+ scope.domElement.addEventListener( 'wheel', onMouseWheel, false );
2923
+
2924
+ scope.domElement.addEventListener( 'touchstart', onTouchStart, false );
2925
+ scope.domElement.addEventListener( 'touchend', onTouchEnd, false );
2926
+ scope.domElement.addEventListener( 'touchmove', onTouchMove, false );
2927
+
2928
+ window.addEventListener( 'keydown', onKeyDown, false );
2929
+
2930
+ // force an update at start
2931
+
2932
+ this.update();
2933
+
2934
+ }
2935
+ OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );
2936
+ OrbitControls.prototype.constructor = OrbitControls;
2937
+
2938
+ Object.defineProperties( OrbitControls.prototype, {
2939
+
2940
+ center: {
2941
+
2942
+ get: function () {
2943
+
2944
+ console.warn( 'THREE.OrbitControls: .center has been renamed to .target' );
2945
+ return this.target;
2946
+
2947
+ }
2948
+
2949
+ },
2950
+
2951
+ // backward compatibility
2952
+
2953
+ noZoom: {
2954
+
2955
+ get: function () {
2956
+
2957
+ console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' );
2958
+ return ! this.enableZoom;
2959
+
2960
+ },
2961
+
2962
+ set: function ( value ) {
2963
+
2964
+ console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' );
2965
+ this.enableZoom = ! value;
2966
+
2967
+ }
2968
+
2969
+ },
2970
+
2971
+ noRotate: {
2972
+
2973
+ get: function () {
2974
+
2975
+ console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' );
2976
+ return ! this.enableRotate;
2977
+
2978
+ },
2979
+
2980
+ set: function ( value ) {
2981
+
2982
+ console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' );
2983
+ this.enableRotate = ! value;
2984
+
2985
+ }
2986
+
2987
+ },
2988
+
2989
+ noPan: {
2990
+
2991
+ get: function () {
2992
+
2993
+ console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' );
2994
+ return ! this.enablePan;
2995
+
2996
+ },
2997
+
2998
+ set: function ( value ) {
2999
+
3000
+ console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' );
3001
+ this.enablePan = ! value;
3002
+
3003
+ }
3004
+
3005
+ },
3006
+
3007
+ noKeys: {
3008
+
3009
+ get: function () {
3010
+
3011
+ console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' );
3012
+ return ! this.enableKeys;
3013
+
3014
+ },
3015
+
3016
+ set: function ( value ) {
3017
+
3018
+ console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' );
3019
+ this.enableKeys = ! value;
3020
+
3021
+ }
3022
+
3023
+ },
3024
+
3025
+ staticMoving : {
3026
+
3027
+ get: function () {
3028
+
3029
+ console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' );
3030
+ return ! this.enableDamping;
3031
+
3032
+ },
3033
+
3034
+ set: function ( value ) {
3035
+
3036
+ console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' );
3037
+ this.enableDamping = ! value;
3038
+
3039
+ }
3040
+
3041
+ },
3042
+
3043
+ dynamicDampingFactor : {
3044
+
3045
+ get: function () {
3046
+
3047
+ console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' );
3048
+ return this.dampingFactor;
3049
+
3050
+ },
3051
+
3052
+ set: function ( value ) {
3053
+
3054
+ console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' );
3055
+ this.dampingFactor = value;
3056
+
3057
+ }
3058
+
3059
+ }
3060
+
3061
+ } );
3062
+
3063
+ return OrbitControls;
3064
+ };
3065
+ return threeOrbitControls;
3066
+ }
3067
+
3068
+ var threeOrbitControlsExports = requireThreeOrbitControls();
3069
+ const OrbitControls = /*@__PURE__*/getDefaultExportFromCjs(threeOrbitControlsExports);
3070
+
3071
+ const vertexShader = `
3072
+ varying vec2 vUv;
3073
+ varying vec3 vPos;
3074
+
3075
+ void main() {
3076
+ vUv = uv;
3077
+ vPos = position;
3078
+
3079
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.);
3080
+ }
3081
+ `;
3082
+ const fragmentShader = `
3083
+ varying vec2 vUv;
3084
+ varying vec3 vPos;
3085
+
3086
+ uniform sampler2D uTexture;
3087
+ uniform float uTime;
3088
+
3089
+ void main() {
3090
+ float time = uTime * 0.5;
3091
+ vec2 repeat = -vec2(12., 3.);
3092
+ // To repeat the uvs we need to multiply them by a scalar
3093
+ // and then get the fractional part of it so they from 0 to 1
3094
+ // To move them continuously we have to add time
3095
+ // to the x or y component, to change the direction
3096
+ vec2 uv = fract(vUv * repeat - vec2(time, 0.)); // The sign of time change direction of movement
3097
+
3098
+ // Fake shadow
3099
+ float shadow = clamp(vPos.z / 5., 0., 1.);
3100
+
3101
+ vec3 texture = texture2D(uTexture, uv).rgb;
3102
+ // texture *= vec3(uv.x, uv.y, 1.); // To help visualize the repeated uvs
3103
+
3104
+ gl_FragColor = vec4(texture * shadow, 1.);
3105
+ }
3106
+ `;
3107
+
3108
+ class GL {
3109
+ renderer;
3110
+ camera;
3111
+ scene;
3112
+ controls;
3113
+ clock;
3114
+ rt;
3115
+ rtCamera;
3116
+ rtScene;
3117
+ text;
3118
+ mesh;
3119
+ geometry;
3120
+ material;
3121
+ fontGeometry;
3122
+ fontMaterial;
3123
+ loader;
3124
+ rafId;
3125
+ isDestroyed = false;
3126
+ boundResize = null;
3127
+ constructor(container) {
3128
+ this.renderer = new WebGLRenderer({
3129
+ alpha: true
3130
+ });
3131
+ this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.5));
3132
+ this.renderer.setSize(window.innerWidth, window.innerHeight);
3133
+ this.renderer.setClearColor(0, 1);
3134
+ const targetContainer = container || document.body;
3135
+ targetContainer.appendChild(this.renderer.domElement);
3136
+ this.camera = new PerspectiveCamera(
3137
+ 45,
3138
+ window.innerWidth / window.innerHeight,
3139
+ 1,
3140
+ 1e3
3141
+ );
3142
+ this.camera.position.z = 60;
3143
+ this.scene = new Scene();
3144
+ this.controls = new (OrbitControls(THREE$1))(
3145
+ this.camera,
3146
+ this.renderer.domElement
3147
+ );
3148
+ this.clock = new Clock();
3149
+ }
3150
+ init() {
3151
+ loadFont("/fonts/orbitron/orbitron-black.fnt", (_, font) => {
3152
+ this.fontGeometry = createGeometry({
3153
+ font,
3154
+ text: "ENDLESS"
3155
+ });
3156
+ this.loader = new TextureLoader();
3157
+ this.loader.load("/fonts/orbitron/orbitron-black.png", (texture) => {
3158
+ this.fontMaterial = new RawShaderMaterial(
3159
+ MSDFShader({
3160
+ map: texture,
3161
+ side: DoubleSide,
3162
+ transparent: true,
3163
+ negate: false,
3164
+ color: 16777215
3165
+ })
3166
+ );
3167
+ this.createRenderTarget();
3168
+ this.createMesh();
3169
+ this.animate();
3170
+ this.addEvents();
3171
+ });
3172
+ });
3173
+ }
3174
+ createRenderTarget() {
3175
+ this.rt = new WebGLRenderTarget(window.innerWidth, window.innerHeight);
3176
+ this.rtCamera = new PerspectiveCamera(45, 1, 0.1, 1e3);
3177
+ this.rtCamera.position.z = 2.5;
3178
+ this.rtScene = new Scene();
3179
+ this.rtScene.background = new Color("#000000");
3180
+ this.text = new Mesh(this.fontGeometry, this.fontMaterial);
3181
+ this.text.position.set(-0.965, -0.525, 0);
3182
+ this.text.rotation.set(Math.PI, 0, 0);
3183
+ this.text.scale.set(8e-3, 0.04, 1);
3184
+ this.rtScene.add(this.text);
3185
+ }
3186
+ createMesh() {
3187
+ if (!this.rt) return;
3188
+ this.geometry = new TorusKnotGeometry(9, 3, 768, 3, 4, 3);
3189
+ this.material = new ShaderMaterial({
3190
+ vertexShader,
3191
+ fragmentShader,
3192
+ uniforms: {
3193
+ uTime: { value: 0 },
3194
+ uTexture: { value: this.rt.texture }
3195
+ }
3196
+ });
3197
+ this.mesh = new Mesh(this.geometry, this.material);
3198
+ this.scene.add(this.mesh);
3199
+ }
3200
+ animate() {
3201
+ if (this.isDestroyed) return;
3202
+ this.rafId = requestAnimationFrame(this.animate.bind(this));
3203
+ this.render();
3204
+ }
3205
+ render() {
3206
+ if (!this.material || !this.rt || !this.rtScene || !this.rtCamera) return;
3207
+ this.controls.update();
3208
+ this.material.uniforms.uTime.value = this.clock.getElapsedTime();
3209
+ this.renderer.setRenderTarget(this.rt);
3210
+ this.renderer.render(this.rtScene, this.rtCamera);
3211
+ this.renderer.setRenderTarget(null);
3212
+ this.renderer.render(this.scene, this.camera);
3213
+ }
3214
+ addEvents() {
3215
+ this.boundResize = this.resize.bind(this);
3216
+ window.addEventListener("resize", this.boundResize);
3217
+ }
3218
+ resize() {
3219
+ const width = window.innerWidth;
3220
+ const height = window.innerHeight;
3221
+ this.camera.aspect = width / height;
3222
+ this.camera.updateProjectionMatrix();
3223
+ this.renderer.setSize(width, height);
3224
+ }
3225
+ destroy() {
3226
+ this.isDestroyed = true;
3227
+ if (this.rafId) {
3228
+ cancelAnimationFrame(this.rafId);
3229
+ this.rafId = void 0;
3230
+ }
3231
+ if (this.boundResize) {
3232
+ window.removeEventListener("resize", this.boundResize);
3233
+ this.boundResize = null;
3234
+ }
3235
+ if (this.geometry) {
3236
+ this.geometry.dispose();
3237
+ }
3238
+ if (this.material) {
3239
+ this.material.dispose();
3240
+ }
3241
+ if (this.fontMaterial) {
3242
+ this.fontMaterial.dispose();
3243
+ }
3244
+ if (this.rt) {
3245
+ this.rt.dispose();
3246
+ }
3247
+ if (this.renderer) {
3248
+ this.renderer.dispose();
3249
+ if (this.renderer.domElement.parentNode) {
3250
+ this.renderer.domElement.parentNode.removeChild(
3251
+ this.renderer.domElement
3252
+ );
3253
+ }
3254
+ }
3255
+ }
3256
+ }
3257
+
3258
+ export { GL };