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,80 +1,52 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
- exports.ThreeBase = exports.onProgress = void 0;
9
-
6
+ exports.onProgress = exports.ThreeBase = void 0;
10
7
  var _three = require("three");
11
-
12
8
  var _tween = _interopRequireDefault(require("@tweenjs/tween.js"));
13
-
14
9
  var _pointerEvent = require("../CommonUtils/pointerEvent");
15
-
16
10
  var _VisualizationInterface = require("../VisualizationInterface");
17
-
18
11
  var _Constants = require("../Constants");
19
-
20
12
  var _removeObject = require("../Utils/removeObject");
21
-
22
13
  var _disposeMaterial = require("../Utils/disposeMaterial");
23
-
24
14
  var _createCanvas = require("../Utils/createCanvas");
25
-
26
15
  var _Deferred = _interopRequireDefault(require("../CommonUtils/Deferred"));
27
-
28
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
29
-
17
+ 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); }
30
18
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
31
-
32
19
  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."); }
33
-
34
- 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; }
35
-
20
+ 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; } }
36
21
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
37
-
38
- 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(_e2) { throw _e2; }, 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(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
39
-
22
+ 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; } } }; }
40
23
  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); }
41
-
42
- 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; }
43
-
24
+ 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; }
25
+ 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; }
44
26
  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); } }
45
-
46
27
  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); }); }; }
47
-
48
28
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
49
-
50
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
51
-
52
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
53
-
54
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
55
-
56
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
57
-
29
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
30
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
31
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
32
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
58
33
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
59
-
60
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
61
-
34
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
62
35
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
63
-
64
36
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
65
-
66
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
67
-
68
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
69
-
37
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
38
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
39
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
40
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
70
41
  // default progress handler
71
- var onProgress = function onProgress(xhr) {
42
+ var onProgress = exports.onProgress = function onProgress(xhr) {
72
43
  if (xhr.lengthComputable) {
73
- var percentComplete = xhr.loaded / xhr.total * 100; // eslint-disable-next-line no-console
74
-
44
+ var percentComplete = xhr.loaded / xhr.total * 100;
45
+ // eslint-disable-next-line no-console
75
46
  console.log(percentComplete.toFixed(2) + "% downloaded");
76
47
  }
77
48
  };
49
+
78
50
  /**
79
51
  * This object is an additional layer between the Three.js library and this app.
80
52
  * Responsibilities:
@@ -82,174 +54,134 @@ var onProgress = function onProgress(xhr) {
82
54
  * - customizes and simplifies the usage of Three.js in this app
83
55
  * - provides functionality for the common 3D tasks (like drawing on a texture)
84
56
  */
85
-
86
-
87
- exports.onProgress = onProgress;
88
-
89
- var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
57
+ var ThreeBase = exports.ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
90
58
  _inherits(ThreeBase, _VisualizationInterfa);
91
-
92
59
  var _super = _createSuper(ThreeBase);
93
-
94
60
  function ThreeBase() {
95
61
  var _this2;
96
-
97
62
  _classCallCheck(this, ThreeBase);
98
-
99
63
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
100
64
  args[_key] = arguments[_key];
101
65
  }
102
-
103
66
  _this2 = _super.call.apply(_super, [this].concat(args));
104
-
105
67
  _defineProperty(_assertThisInitialized(_this2), "_container", null);
106
-
107
68
  _defineProperty(_assertThisInitialized(_this2), "_customizableMaterialKeys", []);
108
-
109
69
  _defineProperty(_assertThisInitialized(_this2), "_customizableMaterials", []);
110
-
111
70
  _defineProperty(_assertThisInitialized(_this2), "_animationFrame", null);
112
-
113
71
  _defineProperty(_assertThisInitialized(_this2), "_cameraMovementLocked", false);
114
-
115
72
  _defineProperty(_assertThisInitialized(_this2), "_hitTestEnabled", true);
116
-
117
73
  _defineProperty(_assertThisInitialized(_this2), "_isAnimating", false);
118
-
119
74
  _defineProperty(_assertThisInitialized(_this2), "_animationGroups", []);
120
-
121
75
  _defineProperty(_assertThisInitialized(_this2), "_loadingManager", Object.assign(new _three.LoadingManager(), {
122
76
  onError: function onError(url) {
123
77
  return _this2.onLoadError(url);
124
78
  }
125
79
  }));
126
-
127
80
  _defineProperty(_assertThisInitialized(_this2), "camera", null);
128
-
129
81
  _defineProperty(_assertThisInitialized(_this2), "scene", null);
130
-
131
82
  _defineProperty(_assertThisInitialized(_this2), "cameraTweenGroup", new _tween["default"].Group());
132
-
133
83
  _defineProperty(_assertThisInitialized(_this2), "cameraViews", {});
134
-
84
+ /**
85
+ * Starts the continuous animation in the animation frame
86
+ * It also updates the related tween group.
87
+ * @param {number} time The timestamp value from the requestAnimationFrame callback (DOMHighResTimeStamp)
88
+ */
135
89
  _defineProperty(_assertThisInitialized(_this2), "animate", function () {
136
90
  var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
137
-
138
91
  if (!_this2._isAnimating) {
139
92
  window.cancelAnimationFrame(_this2._animationFrame);
140
93
  _this2._animationFrame = null;
141
94
  return;
142
95
  }
143
-
144
96
  _this2._animationFrame = window.requestAnimationFrame(_this2.animate);
145
-
146
97
  if (time) {
147
98
  _this2.cameraTweenGroup.update(time);
148
-
149
99
  if (_this2.controls) {
150
100
  _this2.controls.update();
151
101
  }
152
-
153
102
  _this2.render();
154
103
  }
155
104
  });
156
-
157
105
  _defineProperty(_assertThisInitialized(_this2), "startAnimation", function (name) {
158
106
  if (_this2._animationGroups.indexOf(name) === -1) {
159
107
  _this2._animationGroups.push(name);
160
108
  }
161
-
162
109
  if (!_this2._isAnimating) {
163
110
  _this2._animationDeferred = new _Deferred["default"]("animation");
164
111
  _this2._isAnimating = true;
165
-
166
112
  _this2.animate();
167
113
  }
168
114
  });
169
-
115
+ /**
116
+ * Stops the currently running animation
117
+ */
170
118
  _defineProperty(_assertThisInitialized(_this2), "stopAnimation", function (name) {
171
119
  var animGroupIdx = _this2._animationGroups.indexOf(name);
172
-
173
120
  if (!name) {
174
121
  _this2._animationGroups.length = 0;
175
122
  } else if (animGroupIdx !== -1) {
176
123
  _this2._animationGroups.splice(animGroupIdx, 1);
177
124
  }
178
-
179
125
  if (_this2._animationGroups.length) {
180
126
  // there are still running animations in the list
181
127
  return;
182
128
  }
183
-
184
129
  window.cancelAnimationFrame(_this2._animationFrame);
185
130
  _this2._isAnimating = false;
186
-
187
131
  if (_this2._animationDeferred) {
188
132
  _this2._animationDeferred.resolve();
189
-
190
133
  delete _this2._animationDeferred;
191
134
  }
192
135
  });
193
-
194
- _defineProperty(_assertThisInitialized(_this2), "animationRunning", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
195
- return regeneratorRuntime.wrap(function _callee$(_context) {
196
- while (1) {
197
- switch (_context.prev = _context.next) {
198
- case 0:
199
- _context.t0 = _this2._animationDeferred;
200
-
201
- if (!_context.t0) {
202
- _context.next = 5;
203
- break;
204
- }
205
-
206
- _context.next = 4;
207
- return _this2._animationDeferred.promise;
208
-
209
- case 4:
210
- _context.t0 = _context.sent;
211
-
212
- case 5:
213
- return _context.abrupt("return", _context.t0);
214
-
215
- case 6:
216
- case "end":
217
- return _context.stop();
218
- }
136
+ _defineProperty(_assertThisInitialized(_this2), "animationRunning", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
137
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
138
+ while (1) switch (_context.prev = _context.next) {
139
+ case 0:
140
+ _context.t0 = _this2._animationDeferred;
141
+ if (!_context.t0) {
142
+ _context.next = 5;
143
+ break;
144
+ }
145
+ _context.next = 4;
146
+ return _this2._animationDeferred.promise;
147
+ case 4:
148
+ _context.t0 = _context.sent;
149
+ case 5:
150
+ return _context.abrupt("return", _context.t0);
151
+ case 6:
152
+ case "end":
153
+ return _context.stop();
219
154
  }
220
155
  }, _callee);
221
156
  })));
222
-
223
157
  _defineProperty(_assertThisInitialized(_this2), "endAnimation", function () {
224
158
  return _this2.cameraTweenGroup.getAll().forEach(function (item) {
225
159
  return item.end();
226
160
  });
227
161
  });
228
-
162
+ /**
163
+ * Checks if the pointer intersects with the model
164
+ * @param {MouseEvent|TouchEvent} pointerEvent
165
+ * @returns {{target: { distance, point, face, faceIndex, object }, getTextureHit: (function())}|null}
166
+ */
229
167
  _defineProperty(_assertThisInitialized(_this2), "getIntersection", function (pointerEvent) {
230
168
  var _this2$_intersectionR;
231
-
232
169
  var raycaster = new _three.Raycaster();
233
-
234
170
  var _this2$renderer$domEl = _this2.renderer.domElement.getBoundingClientRect(),
235
- elementWidth = _this2$renderer$domEl.width,
236
- elementHeight = _this2$renderer$domEl.height,
237
- offsetX = _this2$renderer$domEl.left,
238
- offsetY = _this2$renderer$domEl.top;
239
-
171
+ elementWidth = _this2$renderer$domEl.width,
172
+ elementHeight = _this2$renderer$domEl.height,
173
+ offsetX = _this2$renderer$domEl.left,
174
+ offsetY = _this2$renderer$domEl.top;
240
175
  var point = (0, _pointerEvent.getPointFromPointerEvent)(pointerEvent);
241
176
  var mouse = new _three.Vector2((point.x - offsetX) / elementWidth * 2 - 1, -((point.y - offsetY) / elementHeight) * 2 + 1);
242
177
  raycaster.setFromCamera(mouse, _this2.camera);
243
178
  var intersects = raycaster.intersectObjects(((_this2$_intersectionR = _this2._intersectionRoot) === null || _this2$_intersectionR === void 0 ? void 0 : _this2$_intersectionR.children) || _this2.scene.children, true);
244
-
245
179
  if (intersects.length > 0) {
246
180
  var intersect = intersects[0]; // closest object
247
-
248
181
  return {
249
182
  target: intersect,
250
183
  getTextureHit: function getTextureHit() {
251
184
  var material = intersect.object.material;
252
-
253
185
  if (material && _this2._customizableMaterialKeys.indexOf(material.name) !== -1) {
254
186
  // note: the texture Y is flipped by default in the webgl context
255
187
  // see (https://github.com/mrdoob/three.js/issues/5644)
@@ -257,8 +189,8 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
257
189
  var texture = material.map;
258
190
  var flipY = texture.flipY;
259
191
  var _texture$image = texture.image,
260
- width = _texture$image.width,
261
- height = _texture$image.height;
192
+ width = _texture$image.width,
193
+ height = _texture$image.height;
262
194
  var x = Math.round(intersect.uv.x * width);
263
195
  var y = Math.round((flipY ? 1 - intersect.uv.y : intersect.uv.y) * height);
264
196
  return _this2.textureHitFormatter(intersect, {
@@ -271,13 +203,10 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
271
203
  }
272
204
  };
273
205
  }
274
-
275
206
  return null;
276
207
  });
277
-
278
208
  return _this2;
279
209
  }
280
-
281
210
  _createClass(ThreeBase, [{
282
211
  key: "init",
283
212
  value:
@@ -297,13 +226,11 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
297
226
  this.renderer = this.createRenderer();
298
227
  this.addToContainer(container);
299
228
  this.setupContextLostHandling();
300
-
301
229
  if (useDefaultSetup) {
302
230
  this.setupDefaultLightning();
303
231
  this.setupDefaultControls();
304
232
  this.setupDefaultHitTest();
305
233
  }
306
-
307
234
  this.observable.dispatch(_Constants.EventTypes.Initialized);
308
235
  }
309
236
  }, {
@@ -311,29 +238,29 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
311
238
  value: function createScene() {
312
239
  return new _three.Scene();
313
240
  }
241
+
314
242
  /**
315
243
  * Create and return a customized three.js renderer object
316
244
  * @return {WebGLRenderer}
317
245
  */
318
-
319
246
  }, {
320
247
  key: "createRenderer",
321
248
  value: function createRenderer() {}
249
+
322
250
  /**
323
251
  * Create and return a customized three.js camera object
324
252
  * @return {Camera}
325
253
  */
326
-
327
254
  }, {
328
255
  key: "createCamera",
329
256
  value: function createCamera() {}
257
+
330
258
  /**
331
259
  * Updates the camera size (different setup for different camera types)
332
260
  * @param {number} width
333
261
  * @param {number} height
334
262
  */
335
263
  // eslint-disable-next-line no-unused-vars
336
-
337
264
  }, {
338
265
  key: "updateCamera",
339
266
  value: function updateCamera(width, height) {}
@@ -345,17 +272,22 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
345
272
  var size = container.getBoundingClientRect();
346
273
  this.setSize(size, false);
347
274
  }
275
+ }, {
276
+ key: "getContainer",
277
+ value: function getContainer() {
278
+ return this._container;
279
+ }
280
+
348
281
  /**
349
282
  * Creates the paths for loading a model (object + material)
350
283
  * @returns {{objPath: string, mtlPath: string}}
351
284
  */
352
-
353
285
  }, {
354
286
  key: "getModelPaths",
355
287
  value: function getModelPaths() {
356
288
  var _basePath = this._basePath,
357
- _itemPath = this._itemPath,
358
- _materialVariantPath = this._materialVariantPath;
289
+ _itemPath = this._itemPath,
290
+ _materialVariantPath = this._materialVariantPath;
359
291
  var objPath = _itemPath ? [_basePath, _itemPath].join("/") : "";
360
292
  var mtlPath = _materialVariantPath ? [objPath, "materials", _materialVariantPath].join("/") : "";
361
293
  return {
@@ -363,31 +295,32 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
363
295
  mtlPath: mtlPath
364
296
  };
365
297
  }
298
+
366
299
  /**
367
300
  * Sets the canvas size
368
301
  * @param {number} width
369
302
  * @param {number} height
370
303
  * @param {boolean} rerender
371
304
  */
372
-
373
305
  }, {
374
306
  key: "setSize",
375
307
  value: function setSize(_ref2) {
376
308
  var width = _ref2.width,
377
- height = _ref2.height;
309
+ height = _ref2.height;
378
310
  var rerender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
379
311
  this.renderer.setSize(width, height);
380
- this.updateCamera(width, height); // if not animating render should be called directly
312
+ this.updateCamera(width, height);
381
313
 
314
+ // if not animating render should be called directly
382
315
  if (rerender && !this.isAnimating()) {
383
316
  this.render();
384
317
  }
385
318
  }
319
+
386
320
  /**
387
321
  * Creates a simple cube for testing the scene setup
388
322
  * @returns {Mesh}
389
323
  */
390
-
391
324
  }, {
392
325
  key: "createSampleCube",
393
326
  value: function createSampleCube() {
@@ -398,19 +331,19 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
398
331
  var cube = new _three.Mesh(geometry, material);
399
332
  return cube;
400
333
  }
334
+
401
335
  /**
402
336
  * Implement this function to add default lights to the scene
403
337
  */
404
-
405
338
  }, {
406
339
  key: "setupDefaultLightning",
407
340
  value: function setupDefaultLightning() {}
341
+
408
342
  /**
409
343
  * @param {HTMLElement} targetElement
410
344
  * @param {{}} options Custom options for the controls (see the OrbitControls.js file for details)
411
345
  */
412
346
  // eslint-disable-next-line no-unused-vars
413
-
414
347
  }, {
415
348
  key: "setupDefaultControls",
416
349
  value: function setupDefaultControls(targetElement) {
@@ -422,33 +355,32 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
422
355
  var axesHelper = new _three.AxesHelper(50);
423
356
  this.scene.add(axesHelper);
424
357
  }
358
+
425
359
  /**
426
360
  * Enable or disable the controls
427
361
  * @param {boolean} [enabled=true]
428
362
  */
429
-
430
363
  }, {
431
364
  key: "setControlsEnabled",
432
365
  value: function setControlsEnabled() {
433
366
  var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
434
-
435
367
  if (!this.controls) {
436
368
  throw new Error("The controls should be available for the setControlsEnabled call!");
437
369
  }
438
-
439
370
  this.controls.enabled = enabled;
440
- } // eslint-disable-next-line no-unused-vars
371
+ }
441
372
 
373
+ // eslint-disable-next-line no-unused-vars
442
374
  }, {
443
375
  key: "updateMaterial",
444
376
  value: function updateMaterial() {
445
377
  var targetObject = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.scene;
446
378
  }
379
+
447
380
  /**
448
381
  * Getter function for the customizable materials
449
382
  * @returns {Array}
450
383
  */
451
-
452
384
  }, {
453
385
  key: "getCustomizableMaterials",
454
386
  value: function getCustomizableMaterials() {
@@ -459,22 +391,20 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
459
391
  value: function isCustomizableMaterialAvailable() {
460
392
  return this._customizableMaterials.length > 0;
461
393
  }
394
+
462
395
  /**
463
396
  * Returns the material for the given name, or false if not found.
464
397
  * @param {string} name
465
398
  * @returns {boolean|Material}
466
399
  */
467
-
468
400
  }, {
469
401
  key: "findMaterialByName",
470
402
  value: function findMaterialByName(name) {
471
403
  var _iterator = _createForOfIteratorHelper(this._customizableMaterials),
472
- _step;
473
-
404
+ _step;
474
405
  try {
475
406
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
476
407
  var mat = _step.value;
477
-
478
408
  if (mat.name === name) {
479
409
  return mat;
480
410
  }
@@ -484,9 +414,9 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
484
414
  } finally {
485
415
  _iterator.f();
486
416
  }
487
-
488
417
  return false;
489
418
  }
419
+
490
420
  /**
491
421
  * Calls the given drawing function for custom drawing implementations
492
422
  * It provides the drawing context and the original texture image to the callback function.
@@ -497,7 +427,6 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
497
427
  * @param {boolean} clearTexture
498
428
  * @param {string|undefined} materialName If not provided it uses the first customizable material
499
429
  */
500
-
501
430
  }, {
502
431
  key: "getDrawingContext",
503
432
  value: function getDrawingContext(drawingFn) {
@@ -505,20 +434,17 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
505
434
  var clearTexture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
506
435
  var materialName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
507
436
  }
508
- /**
509
- * Starts the continuous animation in the animation frame
510
- * It also updates the related tween group.
511
- * @param {number} time The timestamp value from the requestAnimationFrame callback (DOMHighResTimeStamp)
512
- */
513
-
514
437
  }, {
515
438
  key: "render",
516
439
  value: function render() {
517
- if (this._disableRender) {
440
+ if (this._disableRender || !this._isInitialized) {
518
441
  return;
519
442
  }
520
-
521
- this.renderer && this.renderer.render(this.scene, this.camera);
443
+ try {
444
+ this.renderer && this.renderer.render(this.scene, this.camera);
445
+ } catch (e) {
446
+ console.error("Rendering failed with the following error:", e);
447
+ }
522
448
  }
523
449
  }, {
524
450
  key: "isAnimating",
@@ -534,6 +460,7 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
534
460
  });
535
461
  this.cameraTweenGroup.removeAll();
536
462
  }
463
+
537
464
  /**
538
465
  * Ads a click event listener to the targetElement
539
466
  * The hit test will be performed only if the controls are enabled.
@@ -543,31 +470,36 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
543
470
  * @see createPointerHitListener
544
471
  * @param targetElement
545
472
  */
546
-
547
473
  }, {
548
474
  key: "setupDefaultHitTest",
549
475
  value: function setupDefaultHitTest(targetElement) {
550
476
  var _this3 = this;
551
-
552
477
  var element = targetElement || this.renderer.domElement;
553
478
  (0, _pointerEvent.createPointerHitListener)(element, function (evt) {
554
479
  if (!_this3._hitTestEnabled) {
555
480
  return;
556
481
  }
557
-
558
482
  if (!_this3.controls || _this3.controls.enabled || _this3._cameraMovementLocked) {
559
483
  var is = _this3.getIntersection(evt);
560
-
561
484
  _this3.observable.dispatch(is ? _Constants.EventTypes.Intersection : _Constants.EventTypes.ClickAway, is);
562
485
  }
563
486
  });
487
+ (0, _pointerEvent.createMouseMoveListener)(element, {
488
+ onMove: function onMove(evt) {
489
+ if (!_this3._hitTestEnabled) {
490
+ return;
491
+ }
492
+ var is = _this3.getIntersection(evt);
493
+ _this3.observable.dispatch(is ? _Constants.EventTypes.HoverIn : _Constants.EventTypes.HoverOut, is);
494
+ },
495
+ onLeave: function onLeave() {
496
+ if (!_this3._hitTestEnabled) {
497
+ return;
498
+ }
499
+ _this3.observable.dispatch(_Constants.EventTypes.HoverOut);
500
+ }
501
+ });
564
502
  }
565
- /**
566
- * Checks if the pointer intersects with the model
567
- * @param {MouseEvent|TouchEvent} pointerEvent
568
- * @returns {{target: { distance, point, face, faceIndex, object }, getTextureHit: (function())}|null}
569
- */
570
-
571
503
  }, {
572
504
  key: "textureHitFormatter",
573
505
  value: function textureHitFormatter(intersect, position) {
@@ -577,20 +509,18 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
577
509
  key: "setupContextLostHandling",
578
510
  value: function setupContextLostHandling() {
579
511
  var _this = this;
580
-
581
512
  this.renderer.getContext().canvas.addEventListener("webglcontextlost", function (event) {
582
513
  event.preventDefault();
583
- window.cancelAnimationFrame(_this._animationFrame); // eslint-disable-next-line no-console
584
-
514
+ window.cancelAnimationFrame(_this._animationFrame);
515
+ // eslint-disable-next-line no-console
585
516
  console.warn("WEBGL CONTEXT LOST");
586
517
  }, false);
587
518
  this.renderer.getContext().canvas.addEventListener("webglcontextrestored", function () {
588
519
  // if it was animating before start it again
589
520
  if (_this._animationFrame) {
590
521
  _this.animate();
591
- } // eslint-disable-next-line no-console
592
-
593
-
522
+ }
523
+ // eslint-disable-next-line no-console
594
524
  console.warn("WEGL CONTEXT RESTORED");
595
525
  }, false);
596
526
  }
@@ -598,7 +528,6 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
598
528
  key: "toggleCameraLock",
599
529
  value: function toggleCameraLock(locked) {
600
530
  this._cameraMovementLocked = locked;
601
-
602
531
  if (this.controls) {
603
532
  this.controls.enabled = !locked;
604
533
  }
@@ -614,8 +543,9 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
614
543
  // remove all Group objects
615
544
  this.scene.children.filter(function (obj) {
616
545
  return obj.type === "Group";
617
- }).forEach(_removeObject.removeObject); // clear customizable materials and camera views
546
+ }).forEach(_removeObject.removeObject);
618
547
 
548
+ // clear customizable materials and camera views
619
549
  this._customizableMaterials = [];
620
550
  this.cameraViews = {};
621
551
  }
@@ -625,36 +555,31 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
625
555
  this.stopAnimation();
626
556
  this.cleanUpCameraAnimations();
627
557
  this.observable.dispose();
628
-
629
558
  if (this._container && this.renderer) {
630
559
  this._container.removeChild(this.renderer.domElement);
631
560
  }
632
-
633
561
  if (this.scene) {
634
562
  this.scene.traverse(function (obj) {
635
563
  if (obj.geometry) {
636
564
  obj.geometry.dispose();
637
565
  }
638
-
639
566
  if (obj.material) {
640
567
  (0, _disposeMaterial.disposeMaterial)(obj.material);
641
568
  }
642
569
  });
643
570
  }
644
-
645
571
  this.scene = null;
646
-
647
572
  if (this.renderer) {
648
573
  this.renderer.dispose();
649
574
  }
650
-
651
575
  this.renderer = null;
652
576
  this.camera = null;
653
577
  this.cameraViews = null;
654
578
  this.controls = null;
655
579
  this._customizableMaterials = [];
656
- this._isInitialized = false; // eslint-disable-next-line no-console
580
+ this._isInitialized = false;
657
581
 
582
+ // eslint-disable-next-line no-console
658
583
  console.info("Three instance has been successfully disposed.");
659
584
  }
660
585
  }, {
@@ -671,58 +596,48 @@ var ThreeBase = /*#__PURE__*/function (_VisualizationInterfa) {
671
596
  }, {
672
597
  key: "createTempOverlay",
673
598
  value: function () {
674
- var _createTempOverlay = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
599
+ var _createTempOverlay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
675
600
  var canvas, _createWorkingCanvas, _createWorkingCanvas2, tmpCanvas, scale, container;
676
-
677
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
678
- while (1) {
679
- switch (_context2.prev = _context2.next) {
680
- case 0:
681
- canvas = this.renderer.domElement;
682
- this.render();
683
- _createWorkingCanvas = (0, _createCanvas.createWorkingCanvas)(canvas, true), _createWorkingCanvas2 = _slicedToArray(_createWorkingCanvas, 1), tmpCanvas = _createWorkingCanvas2[0];
684
- scale = 1 / this.renderer.getPixelRatio();
685
- container = this._container;
686
- Object.assign(tmpCanvas.style, {
687
- position: "absolute",
688
- top: "50%",
689
- left: "50%",
690
- transform: "translate(-50%, -50%) scale(".concat(scale, ", ").concat(scale, ")"),
691
- opacity: 0
692
- });
693
- container.insertBefore(tmpCanvas, canvas);
694
- _context2.next = 9;
695
- return new Promise(function (resolve) {
696
- window.requestAnimationFrame(function () {
697
- tmpCanvas.style.opacity = 1;
698
- canvas.style.visibility = "hidden";
699
- resolve();
700
- });
701
- });
702
-
703
- case 9:
704
- return _context2.abrupt("return", function () {
705
- canvas.style.visibility = "visible";
706
- container.removeChild(tmpCanvas);
601
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
602
+ while (1) switch (_context2.prev = _context2.next) {
603
+ case 0:
604
+ canvas = this.renderer.domElement;
605
+ this.render();
606
+ _createWorkingCanvas = (0, _createCanvas.createWorkingCanvas)(canvas, true), _createWorkingCanvas2 = _slicedToArray(_createWorkingCanvas, 1), tmpCanvas = _createWorkingCanvas2[0];
607
+ scale = 1 / this.renderer.getPixelRatio();
608
+ container = this._container;
609
+ Object.assign(tmpCanvas.style, {
610
+ position: "absolute",
611
+ top: "50%",
612
+ left: "50%",
613
+ transform: "translate(-50%, -50%) scale(".concat(scale, ", ").concat(scale, ")"),
614
+ opacity: 0
615
+ });
616
+ container.insertBefore(tmpCanvas, canvas);
617
+ _context2.next = 9;
618
+ return new Promise(function (resolve) {
619
+ window.requestAnimationFrame(function () {
620
+ tmpCanvas.style.opacity = 1;
621
+ canvas.style.visibility = "hidden";
622
+ resolve();
707
623
  });
708
-
709
- case 10:
710
- case "end":
711
- return _context2.stop();
712
- }
624
+ });
625
+ case 9:
626
+ return _context2.abrupt("return", function () {
627
+ canvas.style.visibility = "visible";
628
+ container.removeChild(tmpCanvas);
629
+ });
630
+ case 10:
631
+ case "end":
632
+ return _context2.stop();
713
633
  }
714
634
  }, _callee2, this);
715
635
  }));
716
-
717
636
  function createTempOverlay() {
718
637
  return _createTempOverlay.apply(this, arguments);
719
638
  }
720
-
721
639
  return createTempOverlay;
722
640
  }()
723
641
  }]);
724
-
725
642
  return ThreeBase;
726
- }(_VisualizationInterface.VisualizationInterface);
727
-
728
- exports.ThreeBase = ThreeBase;
643
+ }(_VisualizationInterface.VisualizationInterface);