@luma.gl/core 9.0.0-alpha.16 → 9.0.0-alpha.19

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.
@@ -0,0 +1,1315 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if (typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if (typeof define === 'function' && define.amd) define([], factory);
5
+ else if (typeof exports === 'object') exports['luma'] = factory();
6
+ else root['luma'] = factory();})(globalThis, function () {
7
+ var __exports__ = (() => {
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __export = (target, all) => {
14
+ for (var name in all)
15
+ __defProp(target, name, { get: all[name], enumerable: true });
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
+ var __publicField = (obj, key, value) => {
27
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
28
+ return value;
29
+ };
30
+
31
+ // src/index.ts
32
+ var src_exports = {};
33
+ __export(src_exports, {
34
+ Device: () => Device,
35
+ Timeline: () => Timeline,
36
+ assert: () => assert2,
37
+ log: () => log,
38
+ luma: () => luma,
39
+ uid: () => uid
40
+ });
41
+
42
+ // ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
43
+ function isElectron(mockUserAgent) {
44
+ if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
45
+ return true;
46
+ }
47
+ if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
48
+ return true;
49
+ }
50
+ const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
51
+ const userAgent = mockUserAgent || realUserAgent;
52
+ if (userAgent && userAgent.indexOf("Electron") >= 0) {
53
+ return true;
54
+ }
55
+ return false;
56
+ }
57
+
58
+ // ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
59
+ function isBrowser() {
60
+ const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
61
+ return !isNode || isElectron();
62
+ }
63
+
64
+ // ../../node_modules/@probe.gl/env/dist/lib/globals.js
65
+ var self_ = globalThis.self || globalThis.window || globalThis.global;
66
+ var window_ = globalThis.window || globalThis.self || globalThis.global;
67
+ var document_ = globalThis.document || {};
68
+ var process_ = globalThis.process || {};
69
+ var console_ = globalThis.console;
70
+ var navigator_ = globalThis.navigator || {};
71
+
72
+ // ../../node_modules/@probe.gl/env/dist/utils/globals.js
73
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
74
+ var isBrowser2 = isBrowser();
75
+
76
+ // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
77
+ function _typeof(obj) {
78
+ "@babel/helpers - typeof";
79
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
80
+ return typeof obj2;
81
+ } : function(obj2) {
82
+ return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
83
+ }, _typeof(obj);
84
+ }
85
+
86
+ // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
87
+ function _toPrimitive(input, hint) {
88
+ if (_typeof(input) !== "object" || input === null)
89
+ return input;
90
+ var prim = input[Symbol.toPrimitive];
91
+ if (prim !== void 0) {
92
+ var res = prim.call(input, hint || "default");
93
+ if (_typeof(res) !== "object")
94
+ return res;
95
+ throw new TypeError("@@toPrimitive must return a primitive value.");
96
+ }
97
+ return (hint === "string" ? String : Number)(input);
98
+ }
99
+
100
+ // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
101
+ function _toPropertyKey(arg) {
102
+ var key = _toPrimitive(arg, "string");
103
+ return _typeof(key) === "symbol" ? key : String(key);
104
+ }
105
+
106
+ // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
107
+ function _defineProperty(obj, key, value) {
108
+ key = _toPropertyKey(key);
109
+ if (key in obj) {
110
+ Object.defineProperty(obj, key, {
111
+ value,
112
+ enumerable: true,
113
+ configurable: true,
114
+ writable: true
115
+ });
116
+ } else {
117
+ obj[key] = value;
118
+ }
119
+ return obj;
120
+ }
121
+
122
+ // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
123
+ function getStorage(type) {
124
+ try {
125
+ const storage = window[type];
126
+ const x = "__storage_test__";
127
+ storage.setItem(x, x);
128
+ storage.removeItem(x);
129
+ return storage;
130
+ } catch (e) {
131
+ return null;
132
+ }
133
+ }
134
+ var LocalStorage = class {
135
+ constructor(id, defaultConfig) {
136
+ let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
137
+ _defineProperty(this, "storage", void 0);
138
+ _defineProperty(this, "id", void 0);
139
+ _defineProperty(this, "config", void 0);
140
+ this.storage = getStorage(type);
141
+ this.id = id;
142
+ this.config = defaultConfig;
143
+ this._loadConfiguration();
144
+ }
145
+ getConfiguration() {
146
+ return this.config;
147
+ }
148
+ setConfiguration(configuration) {
149
+ Object.assign(this.config, configuration);
150
+ if (this.storage) {
151
+ const serialized = JSON.stringify(this.config);
152
+ this.storage.setItem(this.id, serialized);
153
+ }
154
+ }
155
+ _loadConfiguration() {
156
+ let configuration = {};
157
+ if (this.storage) {
158
+ const serializedConfiguration = this.storage.getItem(this.id);
159
+ configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
160
+ }
161
+ Object.assign(this.config, configuration);
162
+ return this;
163
+ }
164
+ };
165
+
166
+ // ../../node_modules/@probe.gl/log/dist/utils/formatters.js
167
+ function formatTime(ms) {
168
+ let formatted;
169
+ if (ms < 10) {
170
+ formatted = "".concat(ms.toFixed(2), "ms");
171
+ } else if (ms < 100) {
172
+ formatted = "".concat(ms.toFixed(1), "ms");
173
+ } else if (ms < 1e3) {
174
+ formatted = "".concat(ms.toFixed(0), "ms");
175
+ } else {
176
+ formatted = "".concat((ms / 1e3).toFixed(2), "s");
177
+ }
178
+ return formatted;
179
+ }
180
+ function leftPad(string) {
181
+ let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
182
+ const padLength = Math.max(length - string.length, 0);
183
+ return "".concat(" ".repeat(padLength)).concat(string);
184
+ }
185
+ function formatImage(image, message, scale) {
186
+ let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
187
+ const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
188
+ if (image.width > maxWidth) {
189
+ scale = Math.min(scale, maxWidth / image.width);
190
+ }
191
+ const width = image.width * scale;
192
+ const height = image.height * scale;
193
+ const style = ["font-size:1px;", "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), "color:transparent;"].join("");
194
+ return ["".concat(message, " %c+"), style];
195
+ }
196
+
197
+ // ../../node_modules/@probe.gl/log/dist/utils/color.js
198
+ var COLOR;
199
+ (function(COLOR2) {
200
+ COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
201
+ COLOR2[COLOR2["RED"] = 31] = "RED";
202
+ COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
203
+ COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
204
+ COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
205
+ COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
206
+ COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
207
+ COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
208
+ COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
209
+ COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
210
+ COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
211
+ COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
212
+ COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
213
+ COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
214
+ COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
215
+ COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
216
+ })(COLOR || (COLOR = {}));
217
+ var BACKGROUND_INCREMENT = 10;
218
+ function getColor(color) {
219
+ if (typeof color !== "string") {
220
+ return color;
221
+ }
222
+ color = color.toUpperCase();
223
+ return COLOR[color] || COLOR.WHITE;
224
+ }
225
+ function addColor(string, color, background) {
226
+ if (!isBrowser && typeof string === "string") {
227
+ if (color) {
228
+ const colorCode = getColor(color);
229
+ string = "\x1B[".concat(colorCode, "m").concat(string, "\x1B[39m");
230
+ }
231
+ if (background) {
232
+ const colorCode = getColor(background);
233
+ string = "\x1B[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "\x1B[49m");
234
+ }
235
+ }
236
+ return string;
237
+ }
238
+
239
+ // ../../node_modules/@probe.gl/log/dist/utils/autobind.js
240
+ function autobind(obj) {
241
+ let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
242
+ const proto = Object.getPrototypeOf(obj);
243
+ const propNames = Object.getOwnPropertyNames(proto);
244
+ const object = obj;
245
+ for (const key of propNames) {
246
+ const value = object[key];
247
+ if (typeof value === "function") {
248
+ if (!predefined.find((name) => key === name)) {
249
+ object[key] = value.bind(obj);
250
+ }
251
+ }
252
+ }
253
+ }
254
+
255
+ // ../../node_modules/@probe.gl/log/dist/utils/assert.js
256
+ function assert(condition, message) {
257
+ if (!condition) {
258
+ throw new Error(message || "Assertion failed");
259
+ }
260
+ }
261
+
262
+ // ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
263
+ function getHiResTimestamp() {
264
+ let timestamp;
265
+ if (isBrowser() && window_.performance) {
266
+ var _window$performance, _window$performance$n;
267
+ timestamp = window_ === null || window_ === void 0 ? void 0 : (_window$performance = window_.performance) === null || _window$performance === void 0 ? void 0 : (_window$performance$n = _window$performance.now) === null || _window$performance$n === void 0 ? void 0 : _window$performance$n.call(_window$performance);
268
+ } else if ("hrtime" in process_) {
269
+ var _process$hrtime;
270
+ const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
271
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
272
+ } else {
273
+ timestamp = Date.now();
274
+ }
275
+ return timestamp;
276
+ }
277
+
278
+ // ../../node_modules/@probe.gl/log/dist/log.js
279
+ var originalConsole = {
280
+ debug: isBrowser() ? console.debug || console.log : console.log,
281
+ log: console.log,
282
+ info: console.info,
283
+ warn: console.warn,
284
+ error: console.error
285
+ };
286
+ var DEFAULT_LOG_CONFIGURATION = {
287
+ enabled: true,
288
+ level: 0
289
+ };
290
+ function noop() {
291
+ }
292
+ var cache = {};
293
+ var ONCE = {
294
+ once: true
295
+ };
296
+ var Log = class {
297
+ constructor() {
298
+ let {
299
+ id
300
+ } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
301
+ id: ""
302
+ };
303
+ _defineProperty(this, "id", void 0);
304
+ _defineProperty(this, "VERSION", VERSION);
305
+ _defineProperty(this, "_startTs", getHiResTimestamp());
306
+ _defineProperty(this, "_deltaTs", getHiResTimestamp());
307
+ _defineProperty(this, "_storage", void 0);
308
+ _defineProperty(this, "userData", {});
309
+ _defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
310
+ this.id = id;
311
+ this.userData = {};
312
+ this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
313
+ this.timeStamp("".concat(this.id, " started"));
314
+ autobind(this);
315
+ Object.seal(this);
316
+ }
317
+ set level(newLevel) {
318
+ this.setLevel(newLevel);
319
+ }
320
+ get level() {
321
+ return this.getLevel();
322
+ }
323
+ isEnabled() {
324
+ return this._storage.config.enabled;
325
+ }
326
+ getLevel() {
327
+ return this._storage.config.level;
328
+ }
329
+ getTotal() {
330
+ return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
331
+ }
332
+ getDelta() {
333
+ return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
334
+ }
335
+ set priority(newPriority) {
336
+ this.level = newPriority;
337
+ }
338
+ get priority() {
339
+ return this.level;
340
+ }
341
+ getPriority() {
342
+ return this.level;
343
+ }
344
+ enable() {
345
+ let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
346
+ this._storage.setConfiguration({
347
+ enabled
348
+ });
349
+ return this;
350
+ }
351
+ setLevel(level) {
352
+ this._storage.setConfiguration({
353
+ level
354
+ });
355
+ return this;
356
+ }
357
+ get(setting) {
358
+ return this._storage.config[setting];
359
+ }
360
+ set(setting, value) {
361
+ this._storage.setConfiguration({
362
+ [setting]: value
363
+ });
364
+ }
365
+ settings() {
366
+ if (console.table) {
367
+ console.table(this._storage.config);
368
+ } else {
369
+ console.log(this._storage.config);
370
+ }
371
+ }
372
+ assert(condition, message) {
373
+ assert(condition, message);
374
+ }
375
+ warn(message) {
376
+ return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
377
+ }
378
+ error(message) {
379
+ return this._getLogFunction(0, message, originalConsole.error, arguments);
380
+ }
381
+ deprecated(oldUsage, newUsage) {
382
+ return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
383
+ }
384
+ removed(oldUsage, newUsage) {
385
+ return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
386
+ }
387
+ probe(logLevel, message) {
388
+ return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
389
+ time: true,
390
+ once: true
391
+ });
392
+ }
393
+ log(logLevel, message) {
394
+ return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
395
+ }
396
+ info(logLevel, message) {
397
+ return this._getLogFunction(logLevel, message, console.info, arguments);
398
+ }
399
+ once(logLevel, message) {
400
+ return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
401
+ }
402
+ table(logLevel, table, columns) {
403
+ if (table) {
404
+ return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
405
+ tag: getTableHeader(table)
406
+ });
407
+ }
408
+ return noop;
409
+ }
410
+ image(_ref) {
411
+ let {
412
+ logLevel,
413
+ priority,
414
+ image,
415
+ message = "",
416
+ scale = 1
417
+ } = _ref;
418
+ if (!this._shouldLog(logLevel || priority)) {
419
+ return noop;
420
+ }
421
+ return isBrowser() ? logImageInBrowser({
422
+ image,
423
+ message,
424
+ scale
425
+ }) : logImageInNode({
426
+ image,
427
+ message,
428
+ scale
429
+ });
430
+ }
431
+ time(logLevel, message) {
432
+ return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
433
+ }
434
+ timeEnd(logLevel, message) {
435
+ return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
436
+ }
437
+ timeStamp(logLevel, message) {
438
+ return this._getLogFunction(logLevel, message, console.timeStamp || noop);
439
+ }
440
+ group(logLevel, message) {
441
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
442
+ collapsed: false
443
+ };
444
+ const options = normalizeArguments({
445
+ logLevel,
446
+ message,
447
+ opts
448
+ });
449
+ const {
450
+ collapsed
451
+ } = opts;
452
+ options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
453
+ return this._getLogFunction(options);
454
+ }
455
+ groupCollapsed(logLevel, message) {
456
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
457
+ return this.group(logLevel, message, Object.assign({}, opts, {
458
+ collapsed: true
459
+ }));
460
+ }
461
+ groupEnd(logLevel) {
462
+ return this._getLogFunction(logLevel, "", console.groupEnd || noop);
463
+ }
464
+ withGroup(logLevel, message, func) {
465
+ this.group(logLevel, message)();
466
+ try {
467
+ func();
468
+ } finally {
469
+ this.groupEnd(logLevel)();
470
+ }
471
+ }
472
+ trace() {
473
+ if (console.trace) {
474
+ console.trace();
475
+ }
476
+ }
477
+ _shouldLog(logLevel) {
478
+ return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
479
+ }
480
+ _getLogFunction(logLevel, message, method, args, opts) {
481
+ if (this._shouldLog(logLevel)) {
482
+ opts = normalizeArguments({
483
+ logLevel,
484
+ message,
485
+ args,
486
+ opts
487
+ });
488
+ method = method || opts.method;
489
+ assert(method);
490
+ opts.total = this.getTotal();
491
+ opts.delta = this.getDelta();
492
+ this._deltaTs = getHiResTimestamp();
493
+ const tag = opts.tag || opts.message;
494
+ if (opts.once && tag) {
495
+ if (!cache[tag]) {
496
+ cache[tag] = getHiResTimestamp();
497
+ } else {
498
+ return noop;
499
+ }
500
+ }
501
+ message = decorateMessage(this.id, opts.message, opts);
502
+ return method.bind(console, message, ...opts.args);
503
+ }
504
+ return noop;
505
+ }
506
+ };
507
+ _defineProperty(Log, "VERSION", VERSION);
508
+ function normalizeLogLevel(logLevel) {
509
+ if (!logLevel) {
510
+ return 0;
511
+ }
512
+ let resolvedLevel;
513
+ switch (typeof logLevel) {
514
+ case "number":
515
+ resolvedLevel = logLevel;
516
+ break;
517
+ case "object":
518
+ resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
519
+ break;
520
+ default:
521
+ return 0;
522
+ }
523
+ assert(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
524
+ return resolvedLevel;
525
+ }
526
+ function normalizeArguments(opts) {
527
+ const {
528
+ logLevel,
529
+ message
530
+ } = opts;
531
+ opts.logLevel = normalizeLogLevel(logLevel);
532
+ const args = opts.args ? Array.from(opts.args) : [];
533
+ while (args.length && args.shift() !== message) {
534
+ }
535
+ switch (typeof logLevel) {
536
+ case "string":
537
+ case "function":
538
+ if (message !== void 0) {
539
+ args.unshift(message);
540
+ }
541
+ opts.message = logLevel;
542
+ break;
543
+ case "object":
544
+ Object.assign(opts, logLevel);
545
+ break;
546
+ default:
547
+ }
548
+ if (typeof opts.message === "function") {
549
+ opts.message = opts.message();
550
+ }
551
+ const messageType = typeof opts.message;
552
+ assert(messageType === "string" || messageType === "object");
553
+ return Object.assign(opts, {
554
+ args
555
+ }, opts.opts);
556
+ }
557
+ function decorateMessage(id, message, opts) {
558
+ if (typeof message === "string") {
559
+ const time = opts.time ? leftPad(formatTime(opts.total)) : "";
560
+ message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
561
+ message = addColor(message, opts.color, opts.background);
562
+ }
563
+ return message;
564
+ }
565
+ function logImageInNode(_ref2) {
566
+ let {
567
+ image,
568
+ message = "",
569
+ scale = 1
570
+ } = _ref2;
571
+ console.warn("removed");
572
+ return noop;
573
+ }
574
+ function logImageInBrowser(_ref3) {
575
+ let {
576
+ image,
577
+ message = "",
578
+ scale = 1
579
+ } = _ref3;
580
+ if (typeof image === "string") {
581
+ const img = new Image();
582
+ img.onload = () => {
583
+ const args = formatImage(img, message, scale);
584
+ console.log(...args);
585
+ };
586
+ img.src = image;
587
+ return noop;
588
+ }
589
+ const element = image.nodeName || "";
590
+ if (element.toLowerCase() === "img") {
591
+ console.log(...formatImage(image, message, scale));
592
+ return noop;
593
+ }
594
+ if (element.toLowerCase() === "canvas") {
595
+ const img = new Image();
596
+ img.onload = () => console.log(...formatImage(img, message, scale));
597
+ img.src = image.toDataURL();
598
+ return noop;
599
+ }
600
+ return noop;
601
+ }
602
+ function getTableHeader(table) {
603
+ for (const key in table) {
604
+ for (const title in table[key]) {
605
+ return title || "untitled";
606
+ }
607
+ }
608
+ return "empty";
609
+ }
610
+
611
+ // ../../node_modules/@probe.gl/log/dist/index.js
612
+ var dist_default = new Log({
613
+ id: "@probe.gl/log"
614
+ });
615
+
616
+ // ../api/src/lib/utils/log.ts
617
+ var log = new Log({
618
+ id: "luma.gl"
619
+ });
620
+
621
+ // ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
622
+ function getHiResTimestamp2() {
623
+ let timestamp;
624
+ if (typeof window !== "undefined" && window.performance) {
625
+ timestamp = window.performance.now();
626
+ } else if (typeof process !== "undefined" && process.hrtime) {
627
+ const timeParts = process.hrtime();
628
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
629
+ } else {
630
+ timestamp = Date.now();
631
+ }
632
+ return timestamp;
633
+ }
634
+
635
+ // ../../node_modules/@probe.gl/stats/dist/lib/stat.js
636
+ var Stat = class {
637
+ constructor(name, type) {
638
+ _defineProperty(this, "name", void 0);
639
+ _defineProperty(this, "type", void 0);
640
+ _defineProperty(this, "sampleSize", 1);
641
+ _defineProperty(this, "time", 0);
642
+ _defineProperty(this, "count", 0);
643
+ _defineProperty(this, "samples", 0);
644
+ _defineProperty(this, "lastTiming", 0);
645
+ _defineProperty(this, "lastSampleTime", 0);
646
+ _defineProperty(this, "lastSampleCount", 0);
647
+ _defineProperty(this, "_count", 0);
648
+ _defineProperty(this, "_time", 0);
649
+ _defineProperty(this, "_samples", 0);
650
+ _defineProperty(this, "_startTime", 0);
651
+ _defineProperty(this, "_timerPending", false);
652
+ this.name = name;
653
+ this.type = type;
654
+ this.reset();
655
+ }
656
+ reset() {
657
+ this.time = 0;
658
+ this.count = 0;
659
+ this.samples = 0;
660
+ this.lastTiming = 0;
661
+ this.lastSampleTime = 0;
662
+ this.lastSampleCount = 0;
663
+ this._count = 0;
664
+ this._time = 0;
665
+ this._samples = 0;
666
+ this._startTime = 0;
667
+ this._timerPending = false;
668
+ return this;
669
+ }
670
+ setSampleSize(samples) {
671
+ this.sampleSize = samples;
672
+ return this;
673
+ }
674
+ incrementCount() {
675
+ this.addCount(1);
676
+ return this;
677
+ }
678
+ decrementCount() {
679
+ this.subtractCount(1);
680
+ return this;
681
+ }
682
+ addCount(value) {
683
+ this._count += value;
684
+ this._samples++;
685
+ this._checkSampling();
686
+ return this;
687
+ }
688
+ subtractCount(value) {
689
+ this._count -= value;
690
+ this._samples++;
691
+ this._checkSampling();
692
+ return this;
693
+ }
694
+ addTime(time) {
695
+ this._time += time;
696
+ this.lastTiming = time;
697
+ this._samples++;
698
+ this._checkSampling();
699
+ return this;
700
+ }
701
+ timeStart() {
702
+ this._startTime = getHiResTimestamp2();
703
+ this._timerPending = true;
704
+ return this;
705
+ }
706
+ timeEnd() {
707
+ if (!this._timerPending) {
708
+ return this;
709
+ }
710
+ this.addTime(getHiResTimestamp2() - this._startTime);
711
+ this._timerPending = false;
712
+ this._checkSampling();
713
+ return this;
714
+ }
715
+ getSampleAverageCount() {
716
+ return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
717
+ }
718
+ getSampleAverageTime() {
719
+ return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
720
+ }
721
+ getSampleHz() {
722
+ return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
723
+ }
724
+ getAverageCount() {
725
+ return this.samples > 0 ? this.count / this.samples : 0;
726
+ }
727
+ getAverageTime() {
728
+ return this.samples > 0 ? this.time / this.samples : 0;
729
+ }
730
+ getHz() {
731
+ return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
732
+ }
733
+ _checkSampling() {
734
+ if (this._samples === this.sampleSize) {
735
+ this.lastSampleTime = this._time;
736
+ this.lastSampleCount = this._count;
737
+ this.count += this._count;
738
+ this.time += this._time;
739
+ this.samples += this._samples;
740
+ this._time = 0;
741
+ this._count = 0;
742
+ this._samples = 0;
743
+ }
744
+ }
745
+ };
746
+
747
+ // ../../node_modules/@probe.gl/stats/dist/lib/stats.js
748
+ var Stats = class {
749
+ constructor(options) {
750
+ _defineProperty(this, "id", void 0);
751
+ _defineProperty(this, "stats", {});
752
+ this.id = options.id;
753
+ this.stats = {};
754
+ this._initializeStats(options.stats);
755
+ Object.seal(this);
756
+ }
757
+ get(name) {
758
+ let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
759
+ return this._getOrCreate({
760
+ name,
761
+ type
762
+ });
763
+ }
764
+ get size() {
765
+ return Object.keys(this.stats).length;
766
+ }
767
+ reset() {
768
+ for (const stat of Object.values(this.stats)) {
769
+ stat.reset();
770
+ }
771
+ return this;
772
+ }
773
+ forEach(fn) {
774
+ for (const stat of Object.values(this.stats)) {
775
+ fn(stat);
776
+ }
777
+ }
778
+ getTable() {
779
+ const table = {};
780
+ this.forEach((stat) => {
781
+ table[stat.name] = {
782
+ time: stat.time || 0,
783
+ count: stat.count || 0,
784
+ average: stat.getAverageTime() || 0,
785
+ hz: stat.getHz() || 0
786
+ };
787
+ });
788
+ return table;
789
+ }
790
+ _initializeStats() {
791
+ let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
792
+ stats.forEach((stat) => this._getOrCreate(stat));
793
+ }
794
+ _getOrCreate(stat) {
795
+ const {
796
+ name,
797
+ type
798
+ } = stat;
799
+ let result = this.stats[name];
800
+ if (!result) {
801
+ if (stat instanceof Stat) {
802
+ result = stat;
803
+ } else {
804
+ result = new Stat(name, type);
805
+ }
806
+ this.stats[name] = result;
807
+ }
808
+ return result;
809
+ }
810
+ };
811
+
812
+ // ../api/src/lib/utils/stats-manager.ts
813
+ var StatsManager = class {
814
+ stats = /* @__PURE__ */ new Map();
815
+ getStats(name) {
816
+ return this.get(name);
817
+ }
818
+ get(name) {
819
+ if (!this.stats.has(name)) {
820
+ this.stats.set(name, new Stats({
821
+ id: name
822
+ }));
823
+ }
824
+ return this.stats.get(name);
825
+ }
826
+ };
827
+ var lumaStats = new StatsManager();
828
+
829
+ // ../api/src/init.ts
830
+ function init() {
831
+ const VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
832
+ const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
833
+ if (globalThis.luma && globalThis.luma.VERSION !== VERSION3) {
834
+ throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION3}`);
835
+ }
836
+ if (!globalThis.luma) {
837
+ if (isBrowser()) {
838
+ log.log(1, `luma.gl ${VERSION3} - ${STARTUP_MESSAGE}`)();
839
+ }
840
+ globalThis.luma = globalThis.luma || {
841
+ VERSION: VERSION3,
842
+ version: VERSION3,
843
+ log,
844
+ // A global stats object that various components can add information to
845
+ // E.g. see webgl/resource.js
846
+ stats: lumaStats
847
+ };
848
+ }
849
+ return VERSION3;
850
+ }
851
+ var VERSION2 = init();
852
+ var init_default = globalThis.luma;
853
+
854
+ // ../api/src/lib/utils/utils.ts
855
+ var uidCounters = {};
856
+ function uid(id = "id") {
857
+ uidCounters[id] = uidCounters[id] || 1;
858
+ const count = uidCounters[id]++;
859
+ return `${id}-${count}`;
860
+ }
861
+
862
+ // ../api/src/adapter/resources/resource.ts
863
+ var DEFAULT_RESOURCE_PROPS = {
864
+ id: "undefined",
865
+ handle: void 0,
866
+ userData: {}
867
+ };
868
+ var Resource = class {
869
+ /** props.id, for debugging. */
870
+ userData = {};
871
+ destroyed = false;
872
+ /** For resources that allocate GPU memory */
873
+ allocatedBytes = 0;
874
+ /**
875
+ * Create a new Resource. Called from Subclass
876
+ */
877
+ constructor(device, props, defaultProps) {
878
+ if (!device) {
879
+ throw new Error("no device");
880
+ }
881
+ this._device = device;
882
+ this.props = selectivelyMerge(props, defaultProps);
883
+ const id = this.props.id !== "undefined" ? this.props.id : uid(this[Symbol.toStringTag]);
884
+ this.props.id = id;
885
+ this.id = id;
886
+ this.userData = this.props.userData || {};
887
+ this.addStats();
888
+ }
889
+ /**
890
+ * destroy can be called on any resource to release it before it is garbage collected.
891
+ */
892
+ destroy() {
893
+ this.removeStats();
894
+ }
895
+ /** @deprecated Use destroy() */
896
+ delete() {
897
+ this.destroy();
898
+ return this;
899
+ }
900
+ toString() {
901
+ return `${this[Symbol.toStringTag] || this.constructor.name}(${this.id})`;
902
+ }
903
+ /**
904
+ * Combines a map of user props and default props, only including props from defaultProps
905
+ * @returns returns a map of overridden default props
906
+ */
907
+ getProps() {
908
+ return this.props;
909
+ }
910
+ // PROTECTED METHODS
911
+ /** Called by resource constructor to track object creation */
912
+ addStats() {
913
+ const stats = this._device.statsManager.getStats("Resource Counts");
914
+ const name = this[Symbol.toStringTag];
915
+ stats.get("Resources Created").incrementCount();
916
+ stats.get(`${name}s Created`).incrementCount();
917
+ stats.get(`${name}s Active`).incrementCount();
918
+ }
919
+ /** Called by .destroy() to track object destruction. Subclass must call if overriding destroy() */
920
+ removeStats() {
921
+ const stats = this._device.statsManager.getStats("Resource Counts");
922
+ const name = this[Symbol.toStringTag];
923
+ stats.get(`${name}s Active`).decrementCount();
924
+ }
925
+ /** Called by subclass to track memory allocations */
926
+ trackAllocatedMemory(bytes, name = this[Symbol.toStringTag]) {
927
+ const stats = this._device.statsManager.getStats("Resource Counts");
928
+ stats.get("GPU Memory").addCount(bytes);
929
+ stats.get(`${name} Memory`).addCount(bytes);
930
+ this.allocatedBytes = bytes;
931
+ }
932
+ /** Called by subclass to track memory deallocations */
933
+ trackDeallocatedMemory(name = this[Symbol.toStringTag]) {
934
+ const stats = this._device.statsManager.getStats("Resource Counts");
935
+ stats.get("GPU Memory").subtractCount(this.allocatedBytes);
936
+ stats.get(`${name} Memory`).subtractCount(this.allocatedBytes);
937
+ this.allocatedBytes = 0;
938
+ }
939
+ };
940
+ function selectivelyMerge(props, defaultProps) {
941
+ const mergedProps = {
942
+ ...defaultProps
943
+ };
944
+ for (const key in props) {
945
+ if (props[key] !== void 0) {
946
+ mergedProps[key] = props[key];
947
+ }
948
+ }
949
+ return mergedProps;
950
+ }
951
+
952
+ // ../api/src/adapter/resources/buffer.ts
953
+ var DEFAULT_BUFFER_PROPS = {
954
+ ...DEFAULT_RESOURCE_PROPS,
955
+ usage: 0,
956
+ // Buffer.COPY_DST | Buffer.COPY_SRC
957
+ byteLength: 0,
958
+ byteOffset: 0,
959
+ data: null,
960
+ indexType: "uint16",
961
+ mappedAtCreation: false
962
+ };
963
+ var _Buffer = class extends Resource {
964
+ get [Symbol.toStringTag]() {
965
+ return "Buffer";
966
+ }
967
+ constructor(device, props) {
968
+ const deducedProps = {
969
+ ...props
970
+ };
971
+ if ((props.usage || 0) & _Buffer.INDEX && !props.indexType) {
972
+ if (props.data instanceof Uint32Array) {
973
+ deducedProps.indexType = "uint32";
974
+ } else if (props.data instanceof Uint16Array) {
975
+ deducedProps.indexType = "uint16";
976
+ }
977
+ }
978
+ super(device, deducedProps, DEFAULT_BUFFER_PROPS);
979
+ }
980
+ write(data, byteOffset) {
981
+ throw new Error("not implemented");
982
+ }
983
+ readAsync(byteOffset, byteLength) {
984
+ throw new Error("not implemented");
985
+ }
986
+ // TODO - can sync read be supported in WebGPU?
987
+ getData() {
988
+ throw new Error("not implemented");
989
+ }
990
+ // Convenience API
991
+ /** Read data from the buffer *
992
+ async readAsync(options: {
993
+ byteOffset?: number,
994
+ byteLength?: number,
995
+ map?: boolean,
996
+ unmap?: boolean
997
+ }): Promise<ArrayBuffer> {
998
+ if (options.map ?? true) {
999
+ await this.mapAsync(Buffer.MAP_READ, options.byteOffset, options.byteLength);
1000
+ }
1001
+ const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);
1002
+ if (options.unmap ?? true) {
1003
+ this.unmap();
1004
+ }
1005
+ return arrayBuffer;
1006
+ }
1007
+ /** Write data to the buffer *
1008
+ async writeAsync(options: {
1009
+ data: ArrayBuffer,
1010
+ byteOffset?: number,
1011
+ byteLength?: number,
1012
+ map?: boolean,
1013
+ unmap?: boolean
1014
+ }): Promise<void> {
1015
+ if (options.map ?? true) {
1016
+ await this.mapAsync(Buffer.MAP_WRITE, options.byteOffset, options.byteLength);
1017
+ }
1018
+ const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);
1019
+ const destArray = new Uint8Array(arrayBuffer);
1020
+ const srcArray = new Uint8Array(options.data);
1021
+ destArray.set(srcArray);
1022
+ if (options.unmap ?? true) {
1023
+ this.unmap();
1024
+ }
1025
+ }
1026
+ */
1027
+ // Mapped API (WebGPU)
1028
+ /** Maps the memory so that it can be read */
1029
+ // abstract mapAsync(mode, byteOffset, byteLength): Promise<void>
1030
+ /** Get the mapped range of data for reading or writing */
1031
+ // abstract getMappedRange(byteOffset, byteLength): ArrayBuffer;
1032
+ /** unmap makes the contents of the buffer available to the GPU again */
1033
+ // abstract unmap(): void;
1034
+ };
1035
+ var Buffer2 = _Buffer;
1036
+ // Usage Flags
1037
+ __publicField(Buffer2, "MAP_READ", 1);
1038
+ __publicField(Buffer2, "MAP_WRITE", 2);
1039
+ __publicField(Buffer2, "COPY_SRC", 4);
1040
+ __publicField(Buffer2, "COPY_DST", 8);
1041
+ __publicField(Buffer2, "INDEX", 16);
1042
+ __publicField(Buffer2, "VERTEX", 32);
1043
+ __publicField(Buffer2, "UNIFORM", 64);
1044
+ __publicField(Buffer2, "STORAGE", 128);
1045
+ __publicField(Buffer2, "INDIRECT", 256);
1046
+ __publicField(Buffer2, "QUERY_RESOLVE", 512);
1047
+
1048
+ // ../api/src/adapter/device.ts
1049
+ var DEFAULT_DEVICE_PROPS = {
1050
+ id: null,
1051
+ type: "best-available",
1052
+ canvas: null,
1053
+ container: null,
1054
+ webgl2: true,
1055
+ // Attempt to create a WebGL2 context
1056
+ webgl1: true,
1057
+ // Attempt to create a WebGL1 context (false to fail if webgl2 not available)
1058
+ manageState: true,
1059
+ width: 800,
1060
+ // width are height are only used by headless gl
1061
+ height: 600,
1062
+ debug: Boolean(log.get("debug")),
1063
+ // Instrument context (at the expense of performance)
1064
+ break: [],
1065
+ // alpha: undefined,
1066
+ // depth: undefined,
1067
+ // stencil: undefined,
1068
+ // antialias: undefined,
1069
+ // premultipliedAlpha: undefined,
1070
+ // preserveDrawingBuffer: undefined,
1071
+ // failIfMajorPerformanceCaveat: undefined
1072
+ gl: null
1073
+ };
1074
+ var Device = class {
1075
+ get [Symbol.toStringTag]() {
1076
+ return "Device";
1077
+ }
1078
+ constructor(props) {
1079
+ this.props = {
1080
+ ...DEFAULT_DEVICE_PROPS,
1081
+ ...props
1082
+ };
1083
+ this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
1084
+ }
1085
+ statsManager = lumaStats;
1086
+ userData = {};
1087
+ /** Information about the device (vendor, versions etc) */
1088
+ /** Optional capability discovery */
1089
+ /** WebGPU style device limits */
1090
+ /** Check if device supports a specific texture format (creation and `nearest` sampling) */
1091
+ /** Check if linear filtering (sampler interpolation) is supported for a specific texture format */
1092
+ /** Check if device supports rendering to a specific texture format */
1093
+ /** True context is already lost */
1094
+ /** Promise that resolves when context is lost */
1095
+ /** default canvas context */
1096
+ /** Creates a new CanvasContext (WebGPU only) */
1097
+ /** Call after rendering a frame (necessary e.g. on WebGL OffscreenCanvas) */
1098
+ // Resource creation
1099
+ /** Create a buffer */
1100
+ createBuffer(props) {
1101
+ if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
1102
+ return this._createBuffer({
1103
+ data: props
1104
+ });
1105
+ }
1106
+ if ((props.usage || 0) & Buffer2.INDEX && !props.indexType) {
1107
+ if (props.data instanceof Uint32Array) {
1108
+ props.indexType = "uint32";
1109
+ } else if (props.data instanceof Uint16Array) {
1110
+ props.indexType = "uint16";
1111
+ }
1112
+ }
1113
+ return this._createBuffer(props);
1114
+ }
1115
+ /** Create a texture */
1116
+ createTexture(props) {
1117
+ if (props instanceof Promise || typeof props === "string") {
1118
+ props = {
1119
+ data: props
1120
+ };
1121
+ }
1122
+ return this._createTexture(props);
1123
+ }
1124
+ /** Create a temporary texture view of a video source */
1125
+ /** Create a sampler */
1126
+ /** Create a shader */
1127
+ /** Create a render pipeline (aka program) */
1128
+ /** Create a compute pipeline (aka program) */
1129
+ /** Create a RenderPass */
1130
+ /** Create a ComputePass */
1131
+ // Implementation
1132
+ };
1133
+ __publicField(Device, "VERSION", VERSION2);
1134
+
1135
+ // ../api/src/lib/luma.ts
1136
+ var deviceList = /* @__PURE__ */ new Map();
1137
+ var luma = class {
1138
+ static registerDevices(deviceClasses) {
1139
+ for (const deviceClass of deviceClasses) {
1140
+ assert2(deviceClass.type && deviceClass.isSupported && deviceClass.create);
1141
+ deviceList.set(deviceClass.type, deviceClass);
1142
+ }
1143
+ }
1144
+ static getAvailableDevices() {
1145
+ return Array.from(deviceList).map((Device2) => Device2.type);
1146
+ }
1147
+ static getSupportedDevices() {
1148
+ return Array.from(deviceList).filter((Device2) => Device2.isSupported()).map((Device2) => Device2.type);
1149
+ }
1150
+ static setDefaultDeviceProps(props) {
1151
+ Object.assign(DEFAULT_DEVICE_PROPS, props);
1152
+ }
1153
+ /** Creates a device. Asynchronously. */
1154
+ static async createDevice(props = {}) {
1155
+ props = {
1156
+ ...DEFAULT_DEVICE_PROPS,
1157
+ ...props
1158
+ };
1159
+ if (props.gl) {
1160
+ props.type = "webgl";
1161
+ }
1162
+ let Device2;
1163
+ switch (props.type) {
1164
+ case "webgpu":
1165
+ Device2 = deviceList.get("webgpu");
1166
+ if (Device2) {
1167
+ return await Device2.create(props);
1168
+ }
1169
+ break;
1170
+ case "webgl":
1171
+ case "webgl1":
1172
+ case "webgl2":
1173
+ Device2 = deviceList.get("webgl");
1174
+ if (Device2) {
1175
+ return await Device2.create(props);
1176
+ }
1177
+ break;
1178
+ case "best-available":
1179
+ Device2 = deviceList.get("webgl");
1180
+ if (Device2 && Device2.isSupported()) {
1181
+ return await Device2.create(props);
1182
+ }
1183
+ break;
1184
+ }
1185
+ throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.");
1186
+ }
1187
+ };
1188
+ /** Global stats for all devices */
1189
+ __publicField(luma, "stats", lumaStats);
1190
+ /** Global log */
1191
+ __publicField(luma, "log", log);
1192
+
1193
+ // ../api/src/lib/utils/assert.ts
1194
+ function assert2(condition, message) {
1195
+ if (!condition) {
1196
+ throw new Error(message || "luma.gl: assertion failed.");
1197
+ }
1198
+ }
1199
+
1200
+ // ../engine/src/animation/timeline.ts
1201
+ var channelHandles = 1;
1202
+ var animationHandles = 1;
1203
+ var Timeline = class {
1204
+ time = 0;
1205
+ channels = /* @__PURE__ */ new Map();
1206
+ animations = /* @__PURE__ */ new Map();
1207
+ playing = false;
1208
+ lastEngineTime = -1;
1209
+ constructor() {
1210
+ }
1211
+ addChannel(props) {
1212
+ const {
1213
+ delay = 0,
1214
+ duration = Number.POSITIVE_INFINITY,
1215
+ rate = 1,
1216
+ repeat = 1
1217
+ } = props;
1218
+ const handle = channelHandles++;
1219
+ const channel = {
1220
+ time: 0,
1221
+ delay,
1222
+ duration,
1223
+ rate,
1224
+ repeat
1225
+ };
1226
+ this._setChannelTime(channel, this.time);
1227
+ this.channels.set(handle, channel);
1228
+ return handle;
1229
+ }
1230
+ removeChannel(handle) {
1231
+ this.channels.delete(handle);
1232
+ for (const [animationHandle, animation] of this.animations) {
1233
+ if (animation.channel === handle) {
1234
+ this.detachAnimation(animationHandle);
1235
+ }
1236
+ }
1237
+ }
1238
+ isFinished(handle) {
1239
+ const channel = this.channels.get(handle);
1240
+ if (channel === void 0) {
1241
+ return false;
1242
+ }
1243
+ return this.time >= channel.delay + channel.duration * channel.repeat;
1244
+ }
1245
+ getTime(handle) {
1246
+ if (handle === void 0) {
1247
+ return this.time;
1248
+ }
1249
+ const channel = this.channels.get(handle);
1250
+ if (channel === void 0) {
1251
+ return -1;
1252
+ }
1253
+ return channel.time;
1254
+ }
1255
+ setTime(time) {
1256
+ this.time = Math.max(0, time);
1257
+ const channels = this.channels.values();
1258
+ for (const channel of channels) {
1259
+ this._setChannelTime(channel, this.time);
1260
+ }
1261
+ const animations = this.animations.values();
1262
+ for (const animationData of animations) {
1263
+ const {
1264
+ animation,
1265
+ channel
1266
+ } = animationData;
1267
+ animation.setTime(this.getTime(channel));
1268
+ }
1269
+ }
1270
+ play() {
1271
+ this.playing = true;
1272
+ }
1273
+ pause() {
1274
+ this.playing = false;
1275
+ this.lastEngineTime = -1;
1276
+ }
1277
+ reset() {
1278
+ this.setTime(0);
1279
+ }
1280
+ attachAnimation(animation, channelHandle) {
1281
+ const animationHandle = animationHandles++;
1282
+ this.animations.set(animationHandle, {
1283
+ animation,
1284
+ channel: channelHandle
1285
+ });
1286
+ animation.setTime(this.getTime(channelHandle));
1287
+ return animationHandle;
1288
+ }
1289
+ detachAnimation(handle) {
1290
+ this.animations.delete(handle);
1291
+ }
1292
+ update(engineTime) {
1293
+ if (this.playing) {
1294
+ if (this.lastEngineTime === -1) {
1295
+ this.lastEngineTime = engineTime;
1296
+ }
1297
+ this.setTime(this.time + (engineTime - this.lastEngineTime));
1298
+ this.lastEngineTime = engineTime;
1299
+ }
1300
+ }
1301
+ _setChannelTime(channel, time) {
1302
+ const offsetTime = time - channel.delay;
1303
+ const totalDuration = channel.duration * channel.repeat;
1304
+ if (offsetTime >= totalDuration) {
1305
+ channel.time = channel.duration * channel.rate;
1306
+ } else {
1307
+ channel.time = Math.max(0, offsetTime) % channel.duration;
1308
+ channel.time *= channel.rate;
1309
+ }
1310
+ }
1311
+ };
1312
+ return __toCommonJS(src_exports);
1313
+ })();
1314
+ return __exports__;
1315
+ });