redhotmagma-visualization 1.41.0 → 1.42.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 (67) hide show
  1. package/AlignTargetProvider.js +50 -79
  2. package/CommonUtils/Deferred.js +11 -38
  3. package/CommonUtils/Observable.js +29 -48
  4. package/CommonUtils/PropertyObserver.js +10 -17
  5. package/CommonUtils/SyncCurrentFunction.js +33 -42
  6. package/CommonUtils/SyncObservableEvent.js +2 -6
  7. package/CommonUtils/pointerEvent.js +50 -98
  8. package/Constants.js +6 -6
  9. package/DevApp.js +187 -309
  10. package/ExposedModules.js +2 -9
  11. package/FallbackVisualization.js +4 -10
  12. package/PrintingEffects/ColorEmbossingEffect.js +15 -26
  13. package/PrintingEffects/DomingEffect.js +29 -52
  14. package/PrintingEffects/EmbossingEffect.js +17 -29
  15. package/PrintingEffects/EmbroideryEffect.js +251 -362
  16. package/PrintingEffects/EngravingEffect.js +17 -29
  17. package/PrintingEffects/PrintingEffects.js +44 -73
  18. package/PrintingEffects/PrintingEffectsUtils.js +1 -7
  19. package/React/ReactBase.js +15 -47
  20. package/Three/Controls/OrbitControls.js +105 -126
  21. package/Three/Exporters/glTFExporter.js +2 -6
  22. package/Three/Loaders/ColladaLoader.js +202 -550
  23. package/Three/Loaders/MTLLoader.js +33 -64
  24. package/Three/Loaders/OBJLoader.js +48 -80
  25. package/Three/Three2D.js +750 -1014
  26. package/Three/Three2DLayers.js +217 -341
  27. package/Three/Three3D.js +530 -800
  28. package/Three/Three3DScene.js +484 -780
  29. package/Three/ThreeBase.js +145 -230
  30. package/Utils/DesignArea/getDesignAreaCanvasSize.js +3 -11
  31. package/Utils/TextureBuilder/createTextureBuilder.js +133 -193
  32. package/Utils/TextureBuilder/textureBuilderFunctions.js +11 -27
  33. package/Utils/alignToElement.js +13 -24
  34. package/Utils/canvasBlur.js +27 -45
  35. package/Utils/createAlphaMapFromAlphaChannel.js +11 -21
  36. package/Utils/createBakedShadow.js +38 -42
  37. package/Utils/createCache.js +0 -4
  38. package/Utils/createCanvas.js +3 -9
  39. package/Utils/createImageRepository.js +63 -87
  40. package/Utils/disposeMaterial.js +4 -14
  41. package/Utils/getImageSize.js +1 -2
  42. package/Utils/imagePreloader.js +36 -48
  43. package/Utils/initTextureCanvas.js +6 -18
  44. package/Utils/isMobileDevice.js +3 -7
  45. package/Utils/optimizeTextureImage.js +13 -29
  46. package/Utils/rememberCameraViewOffset.js +8 -11
  47. package/Utils/removeObject.js +0 -4
  48. package/Utils/restrictCameraMovement.js +2 -12
  49. package/Utils/setLightShadow.js +3 -5
  50. package/Utils/setOrthographicCameraSize.js +0 -1
  51. package/Utils/updateFitSizeToElement.js +4 -9
  52. package/VisualizationContainer.js +37 -90
  53. package/VisualizationInterface.js +32 -67
  54. package/VisualizationProvider.js +5 -15
  55. package/index.js +2 -9
  56. package/package.json +6 -7
  57. package/scripts/cpPublicLocal.js +7 -2
  58. package/src/CommonUtils/Observable.js +1 -0
  59. package/src/CommonUtils/pointerEvent.js +17 -0
  60. package/src/Constants.js +2 -0
  61. package/src/DevApp.js +1 -2
  62. package/src/Three/Three2D.js +105 -1
  63. package/src/Three/ThreeBase.js +31 -3
  64. package/src/Utils/TextureBuilder/createTextureBuilder.js +12 -3
  65. package/src/VisualizationContainer.js +8 -2
  66. package/src/index.js +2 -3
  67. package/visualizationAdapterCreator.js +6 -23
@@ -1,121 +1,97 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.createImageRepository = createImageRepository;
7
-
8
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
8
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
-
10
10
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
-
12
11
  function createImageRepository(cache, loadFunction) {
13
12
  function loadImages(_x) {
14
13
  return _loadImages.apply(this, arguments);
15
14
  }
16
-
17
15
  function _loadImages() {
18
- _loadImages = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(imageURLs) {
19
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
20
- while (1) {
21
- switch (_context2.prev = _context2.next) {
22
- case 0:
23
- _context2.next = 2;
24
- return Promise.all(imageURLs.map( /*#__PURE__*/function () {
25
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(src) {
26
- var image, imageLoadingPromise;
27
- return regeneratorRuntime.wrap(function _callee$(_context) {
28
- while (1) {
29
- switch (_context.prev = _context.next) {
30
- case 0:
31
- _context.next = 2;
32
- return cache.get(src);
33
-
34
- case 2:
35
- image = _context.sent;
36
-
37
- if (image) {
38
- _context.next = 16;
39
- break;
40
- }
41
-
42
- imageLoadingPromise = loadFunction(src);
43
- cache.set(src, imageLoadingPromise);
44
- _context.prev = 6;
45
- _context.next = 9;
46
- return imageLoadingPromise;
47
-
48
- case 9:
49
- image = _context.sent;
50
- _context.next = 16;
51
- break;
52
-
53
- case 12:
54
- _context.prev = 12;
55
- _context.t0 = _context["catch"](6);
56
- // remove if the loading was not successful (do not store rejected promises)
57
- cache["delete"](src);
58
- throw _context.t0;
59
-
60
- case 16:
61
- return _context.abrupt("return", image);
62
-
63
- case 17:
64
- case "end":
65
- return _context.stop();
16
+ _loadImages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(imageURLs) {
17
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
18
+ while (1) switch (_context2.prev = _context2.next) {
19
+ case 0:
20
+ _context2.next = 2;
21
+ return Promise.all(imageURLs.map( /*#__PURE__*/function () {
22
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(src) {
23
+ var image, imageLoadingPromise;
24
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
25
+ while (1) switch (_context.prev = _context.next) {
26
+ case 0:
27
+ _context.next = 2;
28
+ return cache.get(src);
29
+ case 2:
30
+ image = _context.sent;
31
+ if (image) {
32
+ _context.next = 16;
33
+ break;
66
34
  }
67
- }
68
- }, _callee, null, [[6, 12]]);
69
- }));
70
-
71
- return function (_x3) {
72
- return _ref.apply(this, arguments);
73
- };
74
- }()));
75
-
76
- case 2:
77
- return _context2.abrupt("return", _context2.sent);
78
-
79
- case 3:
80
- case "end":
81
- return _context2.stop();
82
- }
35
+ imageLoadingPromise = loadFunction(src);
36
+ cache.set(src, imageLoadingPromise);
37
+ _context.prev = 6;
38
+ _context.next = 9;
39
+ return imageLoadingPromise;
40
+ case 9:
41
+ image = _context.sent;
42
+ _context.next = 16;
43
+ break;
44
+ case 12:
45
+ _context.prev = 12;
46
+ _context.t0 = _context["catch"](6);
47
+ // remove if the loading was not successful (do not store rejected promises)
48
+ cache["delete"](src);
49
+ throw _context.t0;
50
+ case 16:
51
+ return _context.abrupt("return", image);
52
+ case 17:
53
+ case "end":
54
+ return _context.stop();
55
+ }
56
+ }, _callee, null, [[6, 12]]);
57
+ }));
58
+ return function (_x3) {
59
+ return _ref.apply(this, arguments);
60
+ };
61
+ }()));
62
+ case 2:
63
+ return _context2.abrupt("return", _context2.sent);
64
+ case 3:
65
+ case "end":
66
+ return _context2.stop();
83
67
  }
84
68
  }, _callee2);
85
69
  }));
86
70
  return _loadImages.apply(this, arguments);
87
71
  }
88
-
89
72
  function loadImage(_x2) {
90
73
  return _loadImage.apply(this, arguments);
91
74
  }
92
-
93
75
  function _loadImage() {
94
- _loadImage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(imageURL) {
95
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
96
- while (1) {
97
- switch (_context3.prev = _context3.next) {
98
- case 0:
99
- _context3.next = 2;
100
- return loadImages([imageURL]);
101
-
102
- case 2:
103
- return _context3.abrupt("return", _context3.sent[0]);
104
-
105
- case 3:
106
- case "end":
107
- return _context3.stop();
108
- }
76
+ _loadImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(imageURL) {
77
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
78
+ while (1) switch (_context3.prev = _context3.next) {
79
+ case 0:
80
+ _context3.next = 2;
81
+ return loadImages([imageURL]);
82
+ case 2:
83
+ return _context3.abrupt("return", _context3.sent[0]);
84
+ case 3:
85
+ case "end":
86
+ return _context3.stop();
109
87
  }
110
88
  }, _callee3);
111
89
  }));
112
90
  return _loadImage.apply(this, arguments);
113
91
  }
114
-
115
92
  function dispose() {
116
93
  cache.clear();
117
94
  }
118
-
119
95
  return {
120
96
  loadImages: loadImages,
121
97
  loadImage: loadImage,
@@ -4,23 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.disposeMaterial = void 0;
7
-
8
7
  var _three = require("three");
9
-
10
8
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
11
-
12
9
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
-
14
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
15
-
16
- var disposeMaterial = function disposeMaterial(material) {
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } // helper function to remove materials that are not used any longer
11
+ var disposeMaterial = exports.disposeMaterial = function disposeMaterial(material) {
17
12
  var textures = Object.values(material).filter(function (propValue) {
18
13
  return propValue instanceof _three.Texture;
19
14
  });
20
-
21
15
  var _iterator = _createForOfIteratorHelper(textures),
22
- _step;
23
-
16
+ _step;
24
17
  try {
25
18
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
26
19
  var texture = _step.value;
@@ -33,9 +26,6 @@ var disposeMaterial = function disposeMaterial(material) {
33
26
  } finally {
34
27
  _iterator.f();
35
28
  }
36
-
37
29
  material.needsUpdate = true;
38
30
  material.dispose();
39
- };
40
-
41
- exports.disposeMaterial = disposeMaterial;
31
+ };
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getImageSize = getImageSize;
7
-
8
7
  function getImageSize(imageOrCanvasElement) {
9
8
  var width = imageOrCanvasElement.width,
10
- height = imageOrCanvasElement.height;
9
+ height = imageOrCanvasElement.height;
11
10
  return {
12
11
  width: width,
13
12
  height: height
@@ -1,60 +1,50 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.createImagePreloader = void 0;
7
-
8
8
  var _once = _interopRequireDefault(require("lodash/once"));
9
-
10
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
-
10
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
12
11
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13
-
14
12
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
15
-
16
- var createImagePreloader = function createImagePreloader(srcArr) {
13
+ var createImagePreloader = exports.createImagePreloader = function createImagePreloader(srcArr) {
17
14
  var ready = false;
18
15
  var images;
19
- var loadAll = (0, _once["default"])( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
20
- return regeneratorRuntime.wrap(function _callee$(_context) {
21
- while (1) {
22
- switch (_context.prev = _context.next) {
23
- case 0:
24
- _context.prev = 0;
25
- _context.next = 3;
26
- return Promise.all(srcArr.map(function (src) {
27
- return new Promise(function (resolve, reject) {
28
- var img = document.createElement("img");
29
-
30
- img.onload = function () {
31
- return resolve({
32
- src: src,
33
- img: img
34
- });
35
- };
36
-
37
- img.onerror = reject;
38
- img.src = src;
39
- });
40
- }));
41
-
42
- case 3:
43
- images = _context.sent;
44
- ready = true;
45
- _context.next = 10;
46
- break;
47
-
48
- case 7:
49
- _context.prev = 7;
50
- _context.t0 = _context["catch"](0);
51
- // eslint-disable-next-line no-console
52
- console.error("Error while loading resource!", _context.t0);
53
-
54
- case 10:
55
- case "end":
56
- return _context.stop();
57
- }
16
+ var loadAll = (0, _once["default"])( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
17
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
18
+ while (1) switch (_context.prev = _context.next) {
19
+ case 0:
20
+ _context.prev = 0;
21
+ _context.next = 3;
22
+ return Promise.all(srcArr.map(function (src) {
23
+ return new Promise(function (resolve, reject) {
24
+ var img = document.createElement("img");
25
+ img.onload = function () {
26
+ return resolve({
27
+ src: src,
28
+ img: img
29
+ });
30
+ };
31
+ img.onerror = reject;
32
+ img.src = src;
33
+ });
34
+ }));
35
+ case 3:
36
+ images = _context.sent;
37
+ ready = true;
38
+ _context.next = 10;
39
+ break;
40
+ case 7:
41
+ _context.prev = 7;
42
+ _context.t0 = _context["catch"](0);
43
+ // eslint-disable-next-line no-console
44
+ console.error("Error while loading resource!", _context.t0);
45
+ case 10:
46
+ case "end":
47
+ return _context.stop();
58
48
  }
59
49
  }, _callee, null, [[0, 7]]);
60
50
  })));
@@ -71,6 +61,4 @@ var createImagePreloader = function createImagePreloader(srcArr) {
71
61
  return item && item.img;
72
62
  }
73
63
  };
74
- };
75
-
76
- exports.createImagePreloader = createImagePreloader;
64
+ };
@@ -5,40 +5,28 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createCanvasFromImage = createCanvasFromImage;
7
7
  exports.initTextureCanvas = initTextureCanvas;
8
-
9
8
  var _createCanvas = require("./createCanvas");
10
-
11
9
  var _optimizeTextureImage = require("./optimizeTextureImage");
12
-
13
10
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
-
15
11
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
-
17
12
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
-
19
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
20
-
21
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
22
-
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
23
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
-
25
16
  function createCanvasFromImage(image) {
26
17
  var _createWorkingCanvas = (0, _createCanvas.createWorkingCanvas)(image, true),
27
- _createWorkingCanvas2 = _slicedToArray(_createWorkingCanvas, 1),
28
- canvas = _createWorkingCanvas2[0];
29
-
18
+ _createWorkingCanvas2 = _slicedToArray(_createWorkingCanvas, 1),
19
+ canvas = _createWorkingCanvas2[0];
30
20
  return canvas;
31
21
  }
32
-
33
22
  function initTextureCanvas(texture) {
34
23
  if (!texture.image) {
35
24
  // eslint-disable-next-line no-console
36
25
  console.warn("There is no image for the given texture.", texture);
37
26
  }
38
-
39
27
  if (!texture.originalImage || texture.image.nodeName !== "CANVAS") {
40
- var originalImage = (0, _optimizeTextureImage.optimizeTextureImage)(texture.image); // eslint-disable-next-line no-console
41
-
28
+ var originalImage = (0, _optimizeTextureImage.optimizeTextureImage)(texture.image);
29
+ // eslint-disable-next-line no-console
42
30
  console.log("Creating canvas from texture: ".concat(originalImage.src));
43
31
  texture.image = createCanvasFromImage(originalImage);
44
32
  texture.originalImage = originalImage;
@@ -4,16 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isMobileDevice = void 0;
7
-
8
7
  /* eslint-disable no-useless-escape */
9
- var isMobileDevice = function isMobileDevice() {
10
- var check = false;
11
8
 
9
+ var isMobileDevice = exports.isMobileDevice = function isMobileDevice() {
10
+ var check = false;
12
11
  (function (a) {
13
12
  if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true;
14
13
  })(navigator.userAgent || navigator.vendor || window.opera);
15
-
16
14
  return check;
17
- };
18
-
19
- exports.isMobileDevice = isMobileDevice;
15
+ };
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.optimizeTextureImage = void 0;
7
-
8
7
  var _createCanvas = require("./createCanvas");
9
-
10
8
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
-
12
9
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
-
14
10
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
-
16
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
17
-
18
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
19
-
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
20
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
-
22
14
  /**
23
15
  * Creates a new canvas with the given minimum size if the image size is smaller
24
16
  * This makes the mipmap quality better eg. when the image is close to the next power of two size
@@ -28,46 +20,38 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
20
  * @param {number} minTextureSize
29
21
  * @return {HTMLImageElement|HTMLCanvasElement}
30
22
  */
31
- var optimizeTextureImage = function optimizeTextureImage(image) {
23
+ var optimizeTextureImage = exports.optimizeTextureImage = function optimizeTextureImage(image) {
32
24
  var maxTextureSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2048;
33
25
  var minTextureSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2048;
34
26
  var textureSize = Math.max(image.width, image.height);
35
-
36
27
  if (textureSize <= maxTextureSize && textureSize >= minTextureSize) {
37
28
  return image;
38
29
  }
39
-
40
30
  if (textureSize > maxTextureSize) {
41
31
  textureSize = maxTextureSize;
42
32
  } else if (textureSize < minTextureSize) {
43
33
  textureSize = minTextureSize;
44
34
  }
45
-
46
35
  var width = image.width,
47
- height = image.height;
36
+ height = image.height;
48
37
  var ratio = width / height;
49
-
50
38
  if (ratio > 1) {
51
39
  width = textureSize;
52
40
  height = width / ratio;
53
41
  } else {
54
42
  height = textureSize;
55
43
  width = height * ratio;
56
- } // eslint-disable-next-line no-console
57
-
44
+ }
58
45
 
46
+ // eslint-disable-next-line no-console
59
47
  console.log("Optimizing texture image for better mipmaps:", "".concat(image.width, "x").concat(image.height, " -> ").concat(width, "x").concat(height));
60
-
61
48
  var _createWorkingCanvas = (0, _createCanvas.createWorkingCanvas)({
62
- width: width,
63
- height: height
64
- }),
65
- _createWorkingCanvas2 = _slicedToArray(_createWorkingCanvas, 2),
66
- canvas = _createWorkingCanvas2[0],
67
- ctx = _createWorkingCanvas2[1];
68
-
49
+ width: width,
50
+ height: height
51
+ }),
52
+ _createWorkingCanvas2 = _slicedToArray(_createWorkingCanvas, 2),
53
+ canvas = _createWorkingCanvas2[0],
54
+ ctx = _createWorkingCanvas2[1];
69
55
  ctx.drawImage(image, 0, 0, width, height);
70
56
  return canvas;
71
- };
72
-
73
- exports.optimizeTextureImage = optimizeTextureImage;
57
+ };
@@ -4,18 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.rememberCameraViewOffset = void 0;
7
-
8
- var rememberCameraViewOffset = function rememberCameraViewOffset(camera) {
7
+ var rememberCameraViewOffset = exports.rememberCameraViewOffset = function rememberCameraViewOffset(camera) {
9
8
  var _camera$view = camera.view,
10
- fullWidth = _camera$view.fullWidth,
11
- fullHeight = _camera$view.fullHeight,
12
- offsetX = _camera$view.offsetX,
13
- offsetY = _camera$view.offsetY,
14
- width = _camera$view.width,
15
- height = _camera$view.height;
9
+ fullWidth = _camera$view.fullWidth,
10
+ fullHeight = _camera$view.fullHeight,
11
+ offsetX = _camera$view.offsetX,
12
+ offsetY = _camera$view.offsetY,
13
+ width = _camera$view.width,
14
+ height = _camera$view.height;
16
15
  return function () {
17
16
  return camera.setViewOffset(fullWidth, fullHeight, offsetX, offsetY, width, height);
18
17
  };
19
- };
20
-
21
- exports.rememberCameraViewOffset = rememberCameraViewOffset;
18
+ };
@@ -4,19 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.removeObject = removeObject;
7
-
8
7
  var _disposeMaterial = require("./disposeMaterial");
9
-
10
8
  function removeObject(obj) {
11
9
  if (!obj) {
12
10
  return;
13
11
  }
14
-
15
12
  while (obj.children.length > 0) {
16
13
  removeObject(obj.children[0]);
17
14
  obj.remove(obj.children[0]);
18
15
  }
19
-
20
16
  if (obj.geometry) obj.geometry.dispose();
21
17
  if (obj.material) (0, _disposeMaterial.disposeMaterial)(obj.material);
22
18
  }
@@ -4,27 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.restrictOrbitControls = void 0;
7
-
8
7
  var _pick = _interopRequireDefault(require("lodash/pick"));
9
-
10
8
  var _OrbitControls = _interopRequireDefault(require("../Three/Controls/OrbitControls"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  var stateMemo = function stateMemo(obj, props) {
15
11
  var state = (0, _pick["default"])(obj, props);
16
12
  return function () {
17
13
  Object.assign(obj, state);
18
14
  };
19
15
  };
20
-
21
- var restrictOrbitControls = function restrictOrbitControls(orbitControls) {
16
+ var restrictOrbitControls = exports.restrictOrbitControls = function restrictOrbitControls(orbitControls) {
22
17
  if (!(orbitControls instanceof _OrbitControls["default"])) {
23
18
  throw new Error("restrictOrbitControls can handle only the OrbitControls object type");
24
19
  }
25
-
26
20
  var restoreInitialState = stateMemo(orbitControls, ["minPolarAngle", "maxPolarAngle", "minAzimuthAngle", "maxAzimuthAngle"]);
27
-
28
21
  var byAngle = function byAngle(angleRad) {
29
22
  var currentPolarAngle = orbitControls.getPolarAngle();
30
23
  var currentAzimuthAngle = orbitControls.getAzimuthalAngle();
@@ -36,10 +29,7 @@ var restrictOrbitControls = function restrictOrbitControls(orbitControls) {
36
29
  });
37
30
  return restoreInitialState;
38
31
  };
39
-
40
32
  return {
41
33
  byAngle: byAngle
42
34
  };
43
- };
44
-
45
- exports.restrictOrbitControls = restrictOrbitControls;
35
+ };