redhotmagma-visualization 1.51.0 → 1.51.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/AlignTargetProvider.js +21 -30
  2. package/CommonUtils/Deferred.js +11 -19
  3. package/CommonUtils/Observable.js +23 -30
  4. package/CommonUtils/PropertyObserver.js +4 -10
  5. package/CommonUtils/SyncCurrentFunction.js +25 -31
  6. package/CommonUtils/SyncObservableEvent.js +4 -10
  7. package/CommonUtils/pointerEvent.js +9 -15
  8. package/Constants.js +2 -8
  9. package/DevApp.js +224 -236
  10. package/ExposedModules.js +4 -19
  11. package/FallbackVisualization.js +5 -12
  12. package/PrintingEffects/ColorEmbossingEffect.js +13 -19
  13. package/PrintingEffects/DomingEffect.js +13 -19
  14. package/PrintingEffects/EmbossingEffect.js +14 -20
  15. package/PrintingEffects/EmbroideryEffect.js +113 -128
  16. package/PrintingEffects/EngravingEffect.js +14 -20
  17. package/PrintingEffects/PrintingEffects.js +40 -48
  18. package/PrintingEffects/PrintingEffectsUtils.js +4 -13
  19. package/React/ReactBase.js +29 -37
  20. package/Three/Exporters/glTFExporter.js +3 -10
  21. package/Three/Three2D.js +441 -470
  22. package/Three/Three2DLayers.js +136 -148
  23. package/Three/Three3D.js +285 -302
  24. package/Three/Three3DScene.js +326 -341
  25. package/Three/ThreeBase.js +92 -104
  26. package/Utils/DesignArea/getDesignAreaCanvasSize.js +3 -10
  27. package/Utils/TextureBuilder/createTextureBuilder.js +57 -69
  28. package/Utils/TextureBuilder/textureBuilderFunctions.js +4 -10
  29. package/Utils/canvasBlur.js +2 -8
  30. package/Utils/createAlphaMapFromAlphaChannel.js +8 -13
  31. package/Utils/createBakedShadow.js +18 -25
  32. package/Utils/createCache.js +1 -7
  33. package/Utils/createCanvas.js +1 -7
  34. package/Utils/createImageRepository.js +38 -53
  35. package/Utils/disposeMaterial.js +7 -12
  36. package/Utils/getImageSize.js +1 -7
  37. package/Utils/imagePreloader.js +22 -29
  38. package/Utils/initTextureCanvas.js +10 -17
  39. package/Utils/isMobileDevice.js +1 -7
  40. package/Utils/optimizeTextureImage.js +8 -13
  41. package/Utils/rememberCameraViewOffset.js +1 -7
  42. package/Utils/removeObject.js +3 -9
  43. package/Utils/restrictCameraMovement.js +5 -12
  44. package/Utils/setLightShadow.js +3 -9
  45. package/Utils/setOrthographicCameraSize.js +1 -7
  46. package/Utils/updateFitSizeToElement.js +5 -11
  47. package/VisualizationContainer.js +46 -55
  48. package/VisualizationInterface.js +42 -50
  49. package/VisualizationProvider.js +8 -15
  50. package/index.js +4 -7
  51. package/package.json +2 -2
  52. package/src/Three/Exporters/glTFExporter.js +1 -1
  53. package/src/Three/Three3D.js +4 -4
  54. package/src/Three/Three3DScene.js +13 -3
  55. package/src/Utils/restrictCameraMovement.js +1 -1
  56. package/visualizationAdapterCreator.js +18 -27
@@ -1,55 +1,50 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Three3DScene = void 0;
7
- var _three = require("three");
8
- var _Three3D2 = require("./Three3D");
9
- var _isMobileDevice = require("../Utils/isMobileDevice");
10
- var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
11
- var _DRACOLoader2 = require("three/examples/jsm/loaders/DRACOLoader");
12
- var _RGBELoader = require("three/examples/jsm/loaders/RGBELoader");
13
- var _get2 = _interopRequireDefault(require("lodash/get"));
14
- var _size = _interopRequireDefault(require("lodash/size"));
15
- var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
16
- var _glTFExporter = require("./Exporters/glTFExporter");
17
- var _findIndex = _interopRequireDefault(require("lodash/findIndex"));
18
- var _merge = _interopRequireDefault(require("lodash/merge"));
19
- var _createBakedShadow = _interopRequireDefault(require("../Utils/createBakedShadow"));
20
- var _setLightShadow2 = _interopRequireDefault(require("../Utils/setLightShadow"));
21
- var _Constants = require("../Constants");
22
- var _createImageRepository = require("../Utils/createImageRepository");
23
- var _createCache = require("../Utils/createCache");
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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; }
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); } }
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); }); }; }
28
- function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
29
- function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
30
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
31
- 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); } }
32
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
33
- 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); }
34
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
35
- 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); }; }
36
- 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); }
37
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
38
- 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; } }
39
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
1
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
2
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
3
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
+ function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
6
+ function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
7
+ function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
8
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
10
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
13
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
14
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
15
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
16
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
17
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
40
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
41
19
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
42
- 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; }
43
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
44
- 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); }
45
- 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; } } }; }
46
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
20
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
21
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
22
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
24
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
47
25
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
48
- 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); }
49
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
50
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
51
- 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; }
26
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
27
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
28
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
29
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
52
30
  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); }
31
+ import { ACESFilmicToneMapping, AnimationMixer, Box3, CameraHelper, Clock, Color, DirectionalLight, DoubleSide, Group, ImageLoader, LoadingManager, Mesh, MeshBasicMaterial, Object3D, PCFSoftShadowMap, PerspectiveCamera, PlaneGeometry, PMREMGenerator, Scene, ShadowMaterial, Sphere, SphereGeometry, Texture, Vector3, WebGLRenderer } from "three";
32
+ import { Three3D } from "./Three3D";
33
+ import { isMobileDevice } from "../Utils/isMobileDevice";
34
+ import { GLTFLoader } from "three/addons/loaders/GLTFLoader";
35
+ import { DRACOLoader } from "three/addons/loaders/DRACOLoader";
36
+ import { RGBELoader } from "three/addons/loaders/RGBELoader";
37
+ import get from "lodash/get";
38
+ import size from "lodash/size";
39
+ import isPlainObject from "lodash/isPlainObject";
40
+ import { exportGLTF as _exportGLTF } from "./Exporters/glTFExporter";
41
+ import findIndex from "lodash/findIndex";
42
+ import merge from "lodash/merge";
43
+ import createBakedShadow from "../Utils/createBakedShadow";
44
+ import _setLightShadow from "../Utils/setLightShadow";
45
+ import { EventTypes } from "../Constants";
46
+ import { createImageRepository } from "../Utils/createImageRepository";
47
+ import { createCache } from "../Utils/createCache";
53
48
  var UNSET = Symbol("unset");
54
49
  var allowedObjectProps = ["position", "rotation", "scale"];
55
50
  function getSrc(item) {
@@ -58,7 +53,7 @@ function getSrc(item) {
58
53
  function getPatch(oldObj, newObj) {
59
54
  var patch = {};
60
55
  newObj && Object.keys(newObj).forEach(function (prop) {
61
- if ((0, _isPlainObject["default"])(newObj[prop])) {
56
+ if (isPlainObject(newObj[prop])) {
62
57
  var objPatch = getPatch(oldObj && oldObj[prop], newObj[prop]);
63
58
  if (Object.keys(objPatch).length) {
64
59
  patch[prop] = objPatch;
@@ -69,7 +64,7 @@ function getPatch(oldObj, newObj) {
69
64
  });
70
65
  oldObj && Object.keys(oldObj).forEach(function (prop) {
71
66
  if (!newObj.hasOwnProperty(prop)) {
72
- if ((0, _isPlainObject["default"])(_typeof(newObj[prop]))) {
67
+ if (isPlainObject(_typeof(newObj[prop]))) {
73
68
  var objPatch = getPatch(oldObj[prop], newObj[prop]);
74
69
  if (Object.keys(objPatch).length) {
75
70
  patch[prop] = objPatch;
@@ -268,32 +263,30 @@ function setCameraAspectFromRendererSize(camera, renderer) {
268
263
  camera.aspect = width / height;
269
264
  camera.updateProjectionMatrix();
270
265
  }
271
- var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
272
- _inherits(Three3DScene, _Three3D);
273
- var _super = _createSuper(Three3DScene);
266
+ export var Three3DScene = /*#__PURE__*/function (_Three3D) {
274
267
  function Three3DScene() {
275
268
  var _this;
276
269
  var cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
277
270
  _classCallCheck(this, Three3DScene);
278
- _this = _super.call(this, cfg);
279
- _defineProperty(_assertThisInitialized(_this), "DefaultCustomizableMaterialKey", "CustomizableMaterial");
280
- _defineProperty(_assertThisInitialized(_this), "clock", new _three.Clock());
281
- _defineProperty(_assertThisInitialized(_this), "animations", []);
282
- _defineProperty(_assertThisInitialized(_this), "currentResourceList", []);
283
- _defineProperty(_assertThisInitialized(_this), "sceneContainer", function () {
284
- var g = new _three.Group();
271
+ _this = _callSuper(this, Three3DScene, [cfg]);
272
+ _defineProperty(_this, "DefaultCustomizableMaterialKey", "CustomizableMaterial");
273
+ _defineProperty(_this, "clock", new Clock());
274
+ _defineProperty(_this, "animations", []);
275
+ _defineProperty(_this, "currentResourceList", []);
276
+ _defineProperty(_this, "sceneContainer", function () {
277
+ var g = new Group();
285
278
  g.name = "sceneContainer";
286
279
  return g;
287
280
  }());
288
- _defineProperty(_assertThisInitialized(_this), "mixer", new _three.AnimationMixer(_this.sceneContainer));
289
- _defineProperty(_assertThisInitialized(_this), "defaultCamera", null);
290
- _defineProperty(_assertThisInitialized(_this), "dirLightPosition", new _three.Vector3(1, 1, 1).normalize());
291
- _defineProperty(_assertThisInitialized(_this), "defaultCameraPosition", new _three.Vector3(0, 1, 2).normalize());
292
- _defineProperty(_assertThisInitialized(_this), "defaultScreenshotPosition", new _three.Vector3(0, 1, 2).normalize());
293
- _defineProperty(_assertThisInitialized(_this), "relativeCameraViews", {});
294
- _defineProperty(_assertThisInitialized(_this), "relativeScreenshotViews", {});
295
- _defineProperty(_assertThisInitialized(_this), "groundObjectNames", [/ground/i]);
296
- _defineProperty(_assertThisInitialized(_this), "config", {
281
+ _defineProperty(_this, "mixer", new AnimationMixer(_this.sceneContainer));
282
+ _defineProperty(_this, "defaultCamera", null);
283
+ _defineProperty(_this, "dirLightPosition", new Vector3(1, 1, 1).normalize());
284
+ _defineProperty(_this, "defaultCameraPosition", new Vector3(0, 1, 2).normalize());
285
+ _defineProperty(_this, "defaultScreenshotPosition", new Vector3(0, 1, 2).normalize());
286
+ _defineProperty(_this, "relativeCameraViews", {});
287
+ _defineProperty(_this, "relativeScreenshotViews", {});
288
+ _defineProperty(_this, "groundObjectNames", [/ground/i]);
289
+ _defineProperty(_this, "config", {
297
290
  useShadowGround: true,
298
291
  shadowGroundShadowColor: 0x808080,
299
292
  removeGroundForScreenshot: true,
@@ -322,12 +315,12 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
322
315
  },
323
316
  textureImageCacheSize: 20
324
317
  });
325
- _defineProperty(_assertThisInitialized(_this), "onLoadError", function (url) {
318
+ _defineProperty(_this, "onLoadError", function (url) {
326
319
  var errorMessage = "Could not load file: ".concat(url);
327
320
  // eslint-disable-next-line no-console
328
321
  console.error(errorMessage);
329
322
  });
330
- _defineProperty(_assertThisInitialized(_this), "animate", function () {
323
+ _defineProperty(_this, "animate", function () {
331
324
  var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
332
325
  if (!_this._isAnimating) {
333
326
  window.cancelAnimationFrame(_this._animationFrame);
@@ -345,18 +338,18 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
345
338
  _this.render();
346
339
  }
347
340
  });
348
- _defineProperty(_assertThisInitialized(_this), "helpers", {
341
+ _defineProperty(_this, "helpers", {
349
342
  addDirectionalLightHelper: function addDirectionalLightHelper() {
350
- var _assertThisInitialize = _assertThisInitialized(_this),
351
- dirLight = _assertThisInitialize.dirLight;
352
- var cameraHelper = new _three.CameraHelper(dirLight.shadow.camera);
343
+ var _this2 = _this,
344
+ dirLight = _this2.dirLight;
345
+ var cameraHelper = new CameraHelper(dirLight.shadow.camera);
353
346
  _this.scene.add(cameraHelper);
354
347
  },
355
348
  addSceneSphereHelper: function addSceneSphereHelper() {
356
349
  var box = _this.getSceneContainerBox();
357
- var sphere = new _three.Sphere();
350
+ var sphere = new Sphere();
358
351
  box.getBoundingSphere(sphere);
359
- var sphereMesh = new _three.Mesh(new _three.SphereGeometry(sphere.radius, 32, 32), new _three.MeshBasicMaterial({
352
+ var sphereMesh = new Mesh(new SphereGeometry(sphere.radius, 32, 32), new MeshBasicMaterial({
360
353
  color: 0x66ff66,
361
354
  wireframe: true
362
355
  }));
@@ -367,10 +360,11 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
367
360
  cfg.modelBasePath ? _this._modelBasePath = cfg.modelBasePath : _this._modelBasePath = "";
368
361
  return _this;
369
362
  }
370
- _createClass(Three3DScene, [{
363
+ _inherits(Three3DScene, _Three3D);
364
+ return _createClass(Three3DScene, [{
371
365
  key: "setOptions3D",
372
366
  value: function setOptions3D(options) {
373
- (0, _merge["default"])(this.config, options);
367
+ merge(this.config, options);
374
368
  }
375
369
  }, {
376
370
  key: "createLoadingManager",
@@ -384,7 +378,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
384
378
  onLoad = _this$_loadingManager.onLoad,
385
379
  onProgress = _this$_loadingManager.onProgress,
386
380
  onError = _this$_loadingManager.onError;
387
- var loadingManager = new _three.LoadingManager(onLoad, onProgress, onError);
381
+ var loadingManager = new LoadingManager(onLoad, onProgress, onError);
388
382
  loadingManager.setURLModifier(function (url) {
389
383
  if (/^(data|blob):/.test(url)) {
390
384
  return url;
@@ -400,17 +394,16 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
400
394
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
401
395
  var loadingManager = this.createLoadingManager(options);
402
396
  if (!this.dracoLoader) {
403
- var dracoLoader = new ( /*#__PURE__*/function (_DRACOLoader) {
404
- _inherits(PatchedDRACOLoader, _DRACOLoader);
405
- var _super2 = _createSuper(PatchedDRACOLoader);
397
+ var dracoLoader = new (/*#__PURE__*/function (_DRACOLoader) {
406
398
  function PatchedDRACOLoader() {
407
399
  _classCallCheck(this, PatchedDRACOLoader);
408
- return _super2.apply(this, arguments);
400
+ return _callSuper(this, PatchedDRACOLoader, arguments);
409
401
  }
410
- _createClass(PatchedDRACOLoader, [{
402
+ _inherits(PatchedDRACOLoader, _DRACOLoader);
403
+ return _createClass(PatchedDRACOLoader, [{
411
404
  key: "decodeGeometry",
412
405
  value: function decodeGeometry(buffer, taskConfig) {
413
- return _get(_getPrototypeOf(PatchedDRACOLoader.prototype), "decodeGeometry", this).call(this, buffer, taskConfig)["catch"](function (e) {
406
+ return _superPropGet(PatchedDRACOLoader, "decodeGeometry", this, 3)([buffer, taskConfig])["catch"](function (e) {
414
407
  // eslint-disable-next-line no-console
415
408
  console.error(e.message || e.error);
416
409
  // make sure an empty geometry is returned to not break the app
@@ -420,12 +413,11 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
420
413
  });
421
414
  }
422
415
  }]);
423
- return PatchedDRACOLoader;
424
- }(_DRACOLoader2.DRACOLoader))();
416
+ }(DRACOLoader))();
425
417
  dracoLoader.setDecoderPath("libs/draco/gltf/");
426
418
  this.dracoLoader = dracoLoader;
427
419
  }
428
- var loader = new _GLTFLoader.GLTFLoader(loadingManager);
420
+ var loader = new GLTFLoader(loadingManager);
429
421
  loader.setDRACOLoader(this.dracoLoader);
430
422
  return loader;
431
423
  }
@@ -433,14 +425,14 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
433
425
  key: "getImageCache",
434
426
  value: function getImageCache() {
435
427
  if (!this._imageCache) {
436
- this._imageCache = (0, _createCache.createCache)(this.config.textureImageCacheSize);
428
+ this._imageCache = createCache(this.config.textureImageCacheSize);
437
429
  }
438
430
  return this._imageCache;
439
431
  }
440
432
  }, {
441
433
  key: "useImageRepository",
442
434
  value: function useImageRepository(imageLoader) {
443
- return (0, _createImageRepository.createImageRepository)(this.getImageCache(), function (src) {
435
+ return createImageRepository(this.getImageCache(), function (src) {
444
436
  return new Promise(function (resolve, reject) {
445
437
  return imageLoader.load(src, resolve, undefined, reject);
446
438
  });
@@ -451,22 +443,22 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
451
443
  value: function createImageLoader() {
452
444
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
453
445
  var loadingManager = this.createLoadingManager(options);
454
- var imageLoader = new _three.ImageLoader(loadingManager);
446
+ var imageLoader = new ImageLoader(loadingManager);
455
447
  return imageLoader;
456
448
  }
457
449
  }, {
458
450
  key: "createRenderer",
459
451
  value: function createRenderer() {
460
- var renderer = new _three.WebGLRenderer({
452
+ var renderer = new WebGLRenderer({
461
453
  alpha: true,
462
454
  antialias: true
463
455
  });
464
456
  renderer.shadowMap.enabled = true;
465
- renderer.shadowMap.type = _three.PCFSoftShadowMap;
466
- renderer.toneMapping = _three.ACESFilmicToneMapping;
457
+ renderer.shadowMap.type = PCFSoftShadowMap;
458
+ renderer.toneMapping = ACESFilmicToneMapping;
467
459
  renderer.toneMappingExposure = 1;
468
460
  var realWidth = window.innerWidth * window.devicePixelRatio;
469
- if ((0, _isMobileDevice.isMobileDevice)() && realWidth >= 1024) {
461
+ if (isMobileDevice() && realWidth >= 1024) {
470
462
  renderer.setPixelRatio(1);
471
463
  } else {
472
464
  renderer.setPixelRatio(window.devicePixelRatio);
@@ -482,18 +474,18 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
482
474
  }, {
483
475
  key: "loadEnvMap",
484
476
  value: function loadEnvMap(renderer) {
485
- var _this2 = this;
477
+ var _this3 = this;
486
478
  var envMapURL = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultEnvMapURL();
487
479
  if (this.config.useEnvironmentMap) {
488
- var pmremGenerator = new _three.PMREMGenerator(renderer);
480
+ var pmremGenerator = new PMREMGenerator(renderer);
489
481
  pmremGenerator.compileEquirectangularShader();
490
482
  this.envMapPromise = new Promise(function (resolve, reject) {
491
- new _RGBELoader.RGBELoader().load(envMapURL, function (texture) {
492
- _this2.envMap = pmremGenerator.fromEquirectangular(texture).texture;
493
- _this2.scene.environment = _this2.envMap;
483
+ new RGBELoader().load(envMapURL, function (texture) {
484
+ _this3.envMap = pmremGenerator.fromEquirectangular(texture).texture;
485
+ _this3.scene.environment = _this3.envMap;
494
486
  texture.dispose();
495
487
  pmremGenerator.dispose();
496
- resolve(_this2.envMap);
488
+ resolve(_this3.envMap);
497
489
  }, undefined, reject);
498
490
  });
499
491
  }
@@ -501,7 +493,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
501
493
  }, {
502
494
  key: "createCamera",
503
495
  value: function createCamera() {
504
- var camera = new _three.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.01);
496
+ var camera = new PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.01);
505
497
  camera.position.copy(this.defaultCameraPosition).multiplyScalar(1000);
506
498
  return camera;
507
499
  }
@@ -514,7 +506,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
514
506
  }, {
515
507
  key: "createScene",
516
508
  value: function createScene() {
517
- var scene = new _three.Scene();
509
+ var scene = new Scene();
518
510
  scene.add(this.sceneContainer);
519
511
  if (this.config.useEnvironmentMap && this.envMap) {
520
512
  scene.environment = this.envMap;
@@ -530,16 +522,16 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
530
522
  this.ground && this.scene.remove(this.ground);
531
523
  var shadowMaterial;
532
524
  if (this.config.useBakedShadows) {
533
- shadowMaterial = (0, _createBakedShadow["default"])(this.scene, {
525
+ shadowMaterial = createBakedShadow(this.scene, {
534
526
  withMaterial: true,
535
527
  config: this.config.bakedShadow
536
528
  });
537
529
  } else {
538
- shadowMaterial = new _three.ShadowMaterial({
530
+ shadowMaterial = new ShadowMaterial({
539
531
  color: this.config.shadowGroundShadowColor
540
532
  });
541
533
  }
542
- var mesh = new _three.Mesh(new _three.PlaneGeometry(1, 1), shadowMaterial);
534
+ var mesh = new Mesh(new PlaneGeometry(1, 1), shadowMaterial);
543
535
  mesh.name = "ground";
544
536
  mesh.rotation.x = -Math.PI / 2;
545
537
  mesh.receiveShadow = true;
@@ -552,17 +544,17 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
552
544
  var d = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 50;
553
545
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
554
546
  if (this.config.useSoftShadow) {
555
- (0, _setLightShadow2["default"])(light, d * 2, (0, _merge["default"])(this.calculateShadowProps(light), options));
547
+ _setLightShadow(light, d * 2, merge(this.calculateShadowProps(light), options));
556
548
  }
557
549
  }
558
550
  }, {
559
551
  key: "calculateShadowProps",
560
552
  value: function calculateShadowProps(dirLight) {
561
553
  var box = this.getSceneContainerBox();
562
- var sphere = box.getBoundingSphere(new _three.Sphere());
554
+ var sphere = box.getBoundingSphere(new Sphere());
563
555
  var radius = sphere.radius;
564
- var center = box.getCenter(new _three.Vector3());
565
- var lightDistance = dirLight.getWorldPosition(new _three.Vector3()).sub(center).length();
556
+ var center = box.getCenter(new Vector3());
557
+ var lightDistance = dirLight.getWorldPosition(new Vector3()).sub(center).length();
566
558
  var cameraProps = {
567
559
  near: lightDistance - radius,
568
560
  far: lightDistance * 2
@@ -577,7 +569,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
577
569
  this.sceneContainer.scale.set(1, 1, 1);
578
570
  this.sceneContainer.updateWorldMatrix(true, true);
579
571
  var box = this.getSceneContainerBox();
580
- var size = box.getSize(new _three.Vector3()).length();
572
+ var size = box.getSize(new Vector3()).length();
581
573
  var sizeLog = Math.log10(size);
582
574
  if (sizeLog >= 2) {
583
575
  var scaling = 1 / Math.pow(10, Math.ceil(sizeLog));
@@ -588,7 +580,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
588
580
  }, {
589
581
  key: "createDirLight",
590
582
  value: function createDirLight() {
591
- var dirLight = new _three.DirectionalLight(0xffffff, 1);
583
+ var dirLight = new DirectionalLight(0xffffff, 1);
592
584
  dirLight.name = "dirLight";
593
585
  dirLight.position.set(1, 1, 1).normalize();
594
586
  this.setLightShadow(dirLight);
@@ -610,110 +602,115 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
610
602
  }, {
611
603
  key: "fixImportedScene",
612
604
  value: function fixImportedScene(scene) {
613
- var _this3 = this;
605
+ var _this4 = this;
614
606
  scene.traverse(function (object) {
615
607
  if (object.isMesh) {
616
608
  object.castShadow = true;
617
- if (_this3.config.softShadow.selfShadow) {
609
+ if (_this4.config.softShadow.selfShadow) {
618
610
  object.receiveShadow = true;
619
611
  }
620
612
  }
621
- if (object.isLight && object.target && _this3.ground) {
622
- object.target = _this3.ground;
623
- _this3.setLightShadow(object);
613
+ if (object.isLight && object.target && _this4.ground) {
614
+ object.target = _this4.ground;
615
+ _this4.setLightShadow(object);
624
616
  }
625
617
  });
626
618
  }
627
619
  }, {
628
620
  key: "applyMaterialParams",
629
621
  value: function () {
630
- var _applyMaterialParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(model, materialOptions, imageLoader) {
631
- var _this4 = this;
632
- var imageRepository, params;
633
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
634
- while (1) switch (_context3.prev = _context3.next) {
622
+ var _applyMaterialParams = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(model, materialOptions, imageLoader) {
623
+ var _this5 = this;
624
+ var imageRepository, params, _t2;
625
+ return _regenerator().w(function (_context3) {
626
+ while (1) switch (_context3.n) {
635
627
  case 0:
636
628
  imageRepository = this.useImageRepository(imageLoader);
637
629
  if (!materialOptions) {
638
- _context3.next = 7;
630
+ _context3.n = 1;
639
631
  break;
640
632
  }
641
633
  params = materialOptions.params;
642
- _context3.t0 = params;
643
- if (!_context3.t0) {
644
- _context3.next = 7;
634
+ _t2 = params;
635
+ if (!_t2) {
636
+ _context3.n = 1;
645
637
  break;
646
638
  }
647
- _context3.next = 7;
648
- return Promise.all(getAllMaterials(model).map( /*#__PURE__*/function () {
649
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(material) {
639
+ _context3.n = 1;
640
+ return Promise.all(getAllMaterials(model).map(/*#__PURE__*/function () {
641
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(material) {
650
642
  var materialName, materialNames;
651
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
652
- while (1) switch (_context2.prev = _context2.next) {
643
+ return _regenerator().w(function (_context2) {
644
+ while (1) switch (_context2.n) {
653
645
  case 0:
654
646
  materialName = params.materialName, materialNames = params.materialNames; // check materialNames list if provided
655
647
  if (!(materialNames instanceof Array && materialNames.indexOf(material.name) === -1)) {
656
- _context2.next = 3;
648
+ _context2.n = 1;
657
649
  break;
658
650
  }
659
- return _context2.abrupt("return");
660
- case 3:
651
+ return _context2.a(2);
652
+ case 1:
661
653
  if (!(materialName && material.name !== materialName)) {
662
- _context2.next = 5;
654
+ _context2.n = 2;
663
655
  break;
664
656
  }
665
- return _context2.abrupt("return");
666
- case 5:
667
- _context2.next = 7;
668
- return Promise.all(Object.keys(params).map( /*#__PURE__*/function () {
669
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(p) {
670
- var _material$p, _material$map, texture, src, textureSource, value;
671
- return _regeneratorRuntime().wrap(function _callee$(_context) {
672
- while (1) switch (_context.prev = _context.next) {
657
+ return _context2.a(2);
658
+ case 2:
659
+ if (!(!materialName && size(params) === 1 && params.map && material.name !== "ColorMaterial")) {
660
+ _context2.n = 3;
661
+ break;
662
+ }
663
+ return _context2.a(2);
664
+ case 3:
665
+ _context2.n = 4;
666
+ return Promise.all(Object.keys(params).map(/*#__PURE__*/function () {
667
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(p) {
668
+ var _material$p, _material$map, texture, src, textureSource, value, _t;
669
+ return _regenerator().w(function (_context) {
670
+ while (1) switch (_context.n) {
673
671
  case 0:
674
672
  if (!(params[p] === UNSET)) {
675
- _context.next = 2;
673
+ _context.n = 1;
676
674
  break;
677
675
  }
678
- return _context.abrupt("return");
679
- case 2:
680
- _context.t0 = p;
681
- _context.next = _context.t0 === "alphaMap" ? 5 : _context.t0 === "aoMap" ? 5 : _context.t0 === "emissiveMap" ? 5 : _context.t0 === "lightMap" ? 5 : _context.t0 === "map" ? 5 : _context.t0 === "metalnessMap" ? 5 : _context.t0 === "normalMap" ? 5 : _context.t0 === "roughnessMap" ? 5 : _context.t0 === "clearcoatMap" ? 5 : _context.t0 === "clearcoatNormalMap" ? 5 : _context.t0 === "clearcoatRoughnessMap" ? 5 : _context.t0 === "sheenRoughnessMap" ? 5 : _context.t0 === "sheenColorMap" ? 5 : _context.t0 === "specularIntensityMap" ? 5 : _context.t0 === "specularColorMap" ? 5 : _context.t0 === "thicknessMap" ? 5 : _context.t0 === "transmissionMap" ? 5 : _context.t0 === "aoMapIntensity" ? 20 : _context.t0 === "emissiveIntensity" ? 20 : _context.t0 === "envMapIntensity" ? 20 : _context.t0 === "lightMapIntensity" ? 20 : _context.t0 === "metalness" ? 20 : _context.t0 === "opacity" ? 20 : _context.t0 === "refractionRatio" ? 20 : _context.t0 === "roughness" ? 20 : _context.t0 === "attenuationDistance" ? 20 : _context.t0 === "clearcoat" ? 20 : _context.t0 === "clearcoatRoughness" ? 20 : _context.t0 === "ior" ? 20 : _context.t0 === "reflectivity" ? 20 : _context.t0 === "sheen" ? 20 : _context.t0 === "sheenRoughness" ? 20 : _context.t0 === "specularIntensity" ? 20 : _context.t0 === "thickness" ? 20 : _context.t0 === "transmission" ? 20 : _context.t0 === "color" ? 23 : _context.t0 === "emissive" ? 23 : _context.t0 === "attenuationColor" ? 23 : _context.t0 === "sheenColor" ? 23 : _context.t0 === "specularColor" ? 23 : 25;
676
+ return _context.a(2);
677
+ case 1:
678
+ _t = p;
679
+ _context.n = _t === "alphaMap" ? 2 : _t === "aoMap" ? 2 : _t === "emissiveMap" ? 2 : _t === "lightMap" ? 2 : _t === "map" ? 2 : _t === "metalnessMap" ? 2 : _t === "normalMap" ? 2 : _t === "roughnessMap" ? 2 : _t === "clearcoatMap" ? 2 : _t === "clearcoatNormalMap" ? 2 : _t === "clearcoatRoughnessMap" ? 2 : _t === "sheenRoughnessMap" ? 2 : _t === "sheenColorMap" ? 2 : _t === "specularIntensityMap" ? 2 : _t === "specularColorMap" ? 2 : _t === "thicknessMap" ? 2 : _t === "transmissionMap" ? 2 : _t === "aoMapIntensity" ? 6 : _t === "emissiveIntensity" ? 6 : _t === "envMapIntensity" ? 6 : _t === "lightMapIntensity" ? 6 : _t === "metalness" ? 6 : _t === "opacity" ? 6 : _t === "refractionRatio" ? 6 : _t === "roughness" ? 6 : _t === "attenuationDistance" ? 6 : _t === "clearcoat" ? 6 : _t === "clearcoatRoughness" ? 6 : _t === "ior" ? 6 : _t === "reflectivity" ? 6 : _t === "sheen" ? 6 : _t === "sheenRoughness" ? 6 : _t === "specularIntensity" ? 6 : _t === "thickness" ? 6 : _t === "transmission" ? 6 : _t === "color" ? 7 : _t === "emissive" ? 7 : _t === "attenuationColor" ? 7 : _t === "sheenColor" ? 7 : _t === "specularColor" ? 7 : 8;
682
680
  break;
683
- case 5:
684
- texture = ((_material$p = material[p]) === null || _material$p === void 0 ? void 0 : _material$p.clone()) || new _three.Texture();
681
+ case 2:
682
+ texture = ((_material$p = material[p]) === null || _material$p === void 0 ? void 0 : _material$p.clone()) || new Texture();
685
683
  texture.flipY = ((_material$map = material.map) === null || _material$map === void 0 ? void 0 : _material$map.flipY) || false;
686
684
  src = imageLoader.manager.resolveURL(params[p]);
687
- textureSource = findImageBySrc(_this4.sceneContainer, src);
685
+ textureSource = findImageBySrc(_this5.sceneContainer, src);
688
686
  if (!textureSource) {
689
- _context.next = 13;
687
+ _context.n = 3;
690
688
  break;
691
689
  }
692
690
  texture.source = textureSource;
693
- _context.next = 16;
691
+ _context.n = 5;
694
692
  break;
695
- case 13:
696
- _context.next = 15;
693
+ case 3:
694
+ _context.n = 4;
697
695
  return imageRepository.loadImage(params[p]);
698
- case 15:
699
- texture.image = _context.sent;
700
- case 16:
696
+ case 4:
697
+ texture.image = _context.v;
698
+ case 5:
701
699
  texture.userData.src = src;
702
700
  texture.needsUpdate = true;
703
701
  material[p] = texture;
704
- return _context.abrupt("break", 25);
705
- case 20:
702
+ return _context.a(3, 8);
703
+ case 6:
706
704
  value = parseFloat(params[p]);
707
705
  if (!isNaN(value)) {
708
706
  material[p] = value;
709
707
  }
710
- return _context.abrupt("break", 25);
711
- case 23:
712
- material[p] = new _three.Color(params[p]);
713
- return _context.abrupt("break", 25);
714
- case 25:
715
- case "end":
716
- return _context.stop();
708
+ return _context.a(3, 8);
709
+ case 7:
710
+ material[p] = new Color(params[p]);
711
+ return _context.a(3, 8);
712
+ case 8:
713
+ return _context.a(2);
717
714
  }
718
715
  }, _callee);
719
716
  }));
@@ -721,15 +718,14 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
721
718
  return _ref7.apply(this, arguments);
722
719
  };
723
720
  }()));
724
- case 7:
721
+ case 4:
725
722
  if (material.alphaMap) {
726
723
  material.transparent = true;
727
- material.side = _three.DoubleSide;
724
+ material.side = DoubleSide;
728
725
  }
729
726
  material.needsUpdate = true;
730
- case 9:
731
- case "end":
732
- return _context2.stop();
727
+ case 5:
728
+ return _context2.a(2);
733
729
  }
734
730
  }, _callee2);
735
731
  }));
@@ -737,9 +733,8 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
737
733
  return _ref6.apply(this, arguments);
738
734
  };
739
735
  }()));
740
- case 7:
741
- case "end":
742
- return _context3.stop();
736
+ case 1:
737
+ return _context3.a(2);
743
738
  }
744
739
  }, _callee3, this);
745
740
  }));
@@ -751,8 +746,8 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
751
746
  }, {
752
747
  key: "applyCustomizations",
753
748
  value: function () {
754
- var _applyCustomizations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(model, item, imageLoader) {
755
- var _this5 = this;
749
+ var _applyCustomizations = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(model, item, imageLoader) {
750
+ var _this6 = this;
756
751
  var options,
757
752
  _options$saveAndResto,
758
753
  saveAndRestore,
@@ -760,9 +755,10 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
760
755
  materials,
761
756
  material,
762
757
  allMaterials,
763
- _args4 = arguments;
764
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
765
- while (1) switch (_context4.prev = _context4.next) {
758
+ _args4 = arguments,
759
+ _t3;
760
+ return _regenerator().w(function (_context4) {
761
+ while (1) switch (_context4.n) {
766
762
  case 0:
767
763
  options = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : {};
768
764
  _options$saveAndResto = options.saveAndRestore, saveAndRestore = _options$saveAndResto === void 0 ? true : _options$saveAndResto;
@@ -849,18 +845,17 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
849
845
  allMaterials = [].concat(_toConsumableArray(materials), [material]).filter(function (v) {
850
846
  return v;
851
847
  });
852
- _context4.t0 = allMaterials.length;
853
- if (!_context4.t0) {
854
- _context4.next = 12;
848
+ _t3 = allMaterials.length;
849
+ if (!_t3) {
850
+ _context4.n = 1;
855
851
  break;
856
852
  }
857
- _context4.next = 12;
853
+ _context4.n = 1;
858
854
  return Promise.all(allMaterials.map(function (material) {
859
- return _this5.applyMaterialParams(model, material, imageLoader);
855
+ return _this6.applyMaterialParams(model, material, imageLoader);
860
856
  }));
861
- case 12:
862
- case "end":
863
- return _context4.stop();
857
+ case 1:
858
+ return _context4.a(2);
864
859
  }
865
860
  }, _callee4);
866
861
  }));
@@ -872,7 +867,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
872
867
  }, {
873
868
  key: "loadSceneContainer",
874
869
  value: function loadSceneContainer(item) {
875
- var _this6 = this;
870
+ var _this7 = this;
876
871
  var path;
877
872
  var itemType = _typeof(item);
878
873
  if ("string" === itemType) {
@@ -891,32 +886,31 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
891
886
  var imageLoader = this.createImageLoader(loaderOptions);
892
887
  return new Promise(function (resolve, reject) {
893
888
  modelLoader.load(modelFileName, /*#__PURE__*/function () {
894
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(gltf) {
889
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(gltf) {
895
890
  var model;
896
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
897
- while (1) switch (_context5.prev = _context5.next) {
891
+ return _regenerator().w(function (_context5) {
892
+ while (1) switch (_context5.n) {
898
893
  case 0:
899
894
  model = gltf.scene;
900
895
  model.userData.path = path;
901
896
  if (undefined !== item.index) {
902
897
  model.userData.index = item.index;
903
898
  }
904
- _this6.fixImportedScene(model);
899
+ _this7.fixImportedScene(model);
905
900
  if (!("object" === itemType)) {
906
- _context5.next = 7;
901
+ _context5.n = 1;
907
902
  break;
908
903
  }
909
- _context5.next = 7;
910
- return _this6.applyCustomizations(model, item, imageLoader);
911
- case 7:
904
+ _context5.n = 1;
905
+ return _this7.applyCustomizations(model, item, imageLoader);
906
+ case 1:
912
907
  resolve(gltf);
913
- case 8:
914
- case "end":
915
- return _context5.stop();
908
+ case 2:
909
+ return _context5.a(2);
916
910
  }
917
911
  }, _callee5);
918
912
  }));
919
- return function (_x10) {
913
+ return function (_x0) {
920
914
  return _ref8.apply(this, arguments);
921
915
  };
922
916
  }(), undefined, reject);
@@ -933,7 +927,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
933
927
  var mat = materialsObj[key];
934
928
  if (mat) {
935
929
  this.prepareCustomCanvasForMaterial(mat);
936
- var index = (0, _findIndex["default"])(this._customizableMaterials, {
930
+ var index = findIndex(this._customizableMaterials, {
937
931
  name: key
938
932
  });
939
933
  if (index === -1) {
@@ -952,24 +946,23 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
952
946
  }, {
953
947
  key: "initCustomizableMaterialsIfNeeded",
954
948
  value: function () {
955
- var _initCustomizableMaterialsIfNeeded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
949
+ var _initCustomizableMaterialsIfNeeded = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
956
950
  var materials;
957
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
958
- while (1) switch (_context6.prev = _context6.next) {
951
+ return _regenerator().w(function (_context6) {
952
+ while (1) switch (_context6.n) {
959
953
  case 0:
960
954
  // reset customizable materials to always find the right one in the loaded scene
961
955
  this._customizableMaterialKeys.length = 0;
962
956
  this._customizableMaterials.length = 0;
963
957
  materials = getMaterials(this.sceneContainer);
964
- if ((0, _size["default"])(materials)) {
958
+ if (size(materials)) {
965
959
  this.guessCustomizableMaterialNameIfNotSet(materials);
966
960
  this.findCustomizableMaterials(materials);
967
961
  }
968
- _context6.next = 6;
962
+ _context6.n = 1;
969
963
  return this.dispatchMaterialUpdateEvent();
970
- case 6:
971
- case "end":
972
- return _context6.stop();
964
+ case 1:
965
+ return _context6.a(2);
973
966
  }
974
967
  }, _callee6, this);
975
968
  }));
@@ -996,62 +989,59 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
996
989
  key: "checkEmptyScene",
997
990
  value: function checkEmptyScene() {
998
991
  if (!this.sceneContainer.children.length) {
999
- this.observable.dispatch(_Constants.EventTypes.EmptySceneError);
992
+ this.observable.dispatch(EventTypes.EmptySceneError);
1000
993
  }
1001
994
  }
1002
995
  }, {
1003
996
  key: "loadSceneSync",
1004
997
  value: function () {
1005
- var _loadSceneSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(resourceList) {
1006
- var result;
1007
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1008
- while (1) switch (_context7.prev = _context7.next) {
998
+ var _loadSceneSync = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(resourceList) {
999
+ var result, _t4, _t5, _t6;
1000
+ return _regenerator().w(function (_context7) {
1001
+ while (1) switch (_context7.p = _context7.n) {
1009
1002
  case 0:
1010
- _context7.prev = 0;
1011
- _context7.next = 3;
1003
+ _context7.p = 0;
1004
+ _context7.n = 1;
1012
1005
  return this._loadScenePromise;
1013
- case 3:
1014
- _context7.next = 7;
1006
+ case 1:
1007
+ _context7.n = 3;
1015
1008
  break;
1016
- case 5:
1017
- _context7.prev = 5;
1018
- _context7.t0 = _context7["catch"](0);
1019
- case 7:
1020
- _context7.prev = 7;
1009
+ case 2:
1010
+ _context7.p = 2;
1011
+ _t4 = _context7.v;
1012
+ case 3:
1013
+ _context7.p = 3;
1021
1014
  this._loadScenePromise = this.loadScene(resourceList);
1022
- _context7.next = 11;
1015
+ _context7.n = 4;
1023
1016
  return this._loadScenePromise;
1024
- case 11:
1025
- result = _context7.sent;
1026
- _context7.next = 17;
1017
+ case 4:
1018
+ result = _context7.v;
1019
+ _context7.n = 6;
1027
1020
  break;
1028
- case 14:
1029
- _context7.prev = 14;
1030
- _context7.t1 = _context7["catch"](7);
1021
+ case 5:
1022
+ _context7.p = 5;
1023
+ _t5 = _context7.v;
1031
1024
  // remove promise if it is failed
1032
1025
  delete this._loadScenePromise;
1033
- case 17:
1034
- _context7.prev = 17;
1035
- _context7.next = 20;
1026
+ case 6:
1027
+ _context7.p = 6;
1028
+ _context7.n = 7;
1036
1029
  return this.envMapPromise;
1037
- case 20:
1038
- _context7.next = 24;
1030
+ case 7:
1031
+ _context7.n = 9;
1039
1032
  break;
1040
- case 22:
1041
- _context7.prev = 22;
1042
- _context7.t2 = _context7["catch"](17);
1043
- case 24:
1033
+ case 8:
1034
+ _context7.p = 8;
1035
+ _t6 = _context7.v;
1036
+ case 9:
1044
1037
  if (!this.isAnimating()) {
1045
1038
  this.render();
1046
1039
  }
1047
- return _context7.abrupt("return", result);
1048
- case 26:
1049
- case "end":
1050
- return _context7.stop();
1040
+ return _context7.a(2, result);
1051
1041
  }
1052
- }, _callee7, this, [[0, 5], [7, 14], [17, 22]]);
1042
+ }, _callee7, this, [[6, 8], [3, 5], [0, 2]]);
1053
1043
  }));
1054
- function loadSceneSync(_x11) {
1044
+ function loadSceneSync(_x1) {
1055
1045
  return _loadSceneSync.apply(this, arguments);
1056
1046
  }
1057
1047
  return loadSceneSync;
@@ -1059,11 +1049,11 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1059
1049
  }, {
1060
1050
  key: "loadScene",
1061
1051
  value: function () {
1062
- var _loadScene = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(resourceList) {
1063
- var _this7 = this;
1052
+ var _loadScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(resourceList) {
1053
+ var _this8 = this;
1064
1054
  var sceneContainer, _diffResourceLists, toBeRemoved, toBeAdded, toBeUpdated, toBeApplied, shouldResetScene, toBeDisposed, triggerLoadEvent, sceneParts, imageLoader, mixer, animations;
1065
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1066
- while (1) switch (_context8.prev = _context8.next) {
1055
+ return _regenerator().w(function (_context8) {
1056
+ while (1) switch (_context8.n) {
1067
1057
  case 0:
1068
1058
  sceneContainer = this.sceneContainer;
1069
1059
  this.stopAnimation();
@@ -1088,15 +1078,15 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1088
1078
  });
1089
1079
  triggerLoadEvent = !!(toBeAdded.length || toBeUpdated.length || toBeApplied.length);
1090
1080
  triggerLoadEvent && this.onLoadStart();
1091
- _context8.next = 13;
1081
+ _context8.n = 1;
1092
1082
  return Promise.allSettled(toBeAdded.map(function (item) {
1093
- return _this7.loadSceneContainer(item);
1083
+ return _this8.loadSceneContainer(item);
1094
1084
  }));
1095
- case 13:
1096
- sceneParts = _context8.sent;
1097
- sceneParts.forEach(function (_ref10, index) {
1098
- var value = _ref10.value,
1099
- reason = _ref10.reason;
1085
+ case 1:
1086
+ sceneParts = _context8.v;
1087
+ sceneParts.forEach(function (_ref0, index) {
1088
+ var value = _ref0.value,
1089
+ reason = _ref0.reason;
1100
1090
  if (reason) {
1101
1091
  // eslint-disable-next-line no-console
1102
1092
  console.error("Failed to load 3D model: ".concat(toBeAdded[index].model));
@@ -1108,11 +1098,11 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1108
1098
 
1109
1099
  // collect animations
1110
1100
  if (animations.length) {
1111
- var _this7$animations;
1112
- (_this7$animations = _this7.animations).push.apply(_this7$animations, _toConsumableArray(animations.filter(function (_ref11) {
1113
- var name = _ref11.name;
1114
- return !_this7.animations.find(function (_ref12) {
1115
- var existingName = _ref12.name;
1101
+ var _this8$animations;
1102
+ (_this8$animations = _this8.animations).push.apply(_this8$animations, _toConsumableArray(animations.filter(function (_ref1) {
1103
+ var name = _ref1.name;
1104
+ return !_this8.animations.find(function (_ref10) {
1105
+ var existingName = _ref10.name;
1116
1106
  return name !== existingName;
1117
1107
  });
1118
1108
  })));
@@ -1120,40 +1110,40 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1120
1110
  });
1121
1111
  this.checkEmptyScene();
1122
1112
  sceneContainer.updateWorldMatrix(true, true);
1123
- _context8.next = 19;
1113
+ _context8.n = 2;
1124
1114
  return Promise.all(toBeUpdated.map(function (item) {
1125
1115
  var itemSrc = getSrc(item);
1126
- var object = findObjectWith(sceneContainer, function (_ref13) {
1127
- var userData = _ref13.userData;
1116
+ var object = findObjectWith(sceneContainer, function (_ref11) {
1117
+ var userData = _ref11.userData;
1128
1118
  return userData.path === itemSrc && userData.index === item.index;
1129
1119
  });
1130
1120
  var path = getSrc(item);
1131
- var _this7$parseModelPath = _this7.parseModelPath(path),
1132
- resourcePath = _this7$parseModelPath.resourcePath;
1121
+ var _this8$parseModelPath = _this8.parseModelPath(path),
1122
+ resourcePath = _this8$parseModelPath.resourcePath;
1133
1123
  var loaderOptions = {
1134
- basePath: _this7._modelBasePath,
1124
+ basePath: _this8._modelBasePath,
1135
1125
  resourcePath: resourcePath
1136
1126
  };
1137
- var imageLoader = _this7.createImageLoader(loaderOptions);
1138
- return object && _this7.applyCustomizations(object, item, imageLoader);
1127
+ var imageLoader = _this8.createImageLoader(loaderOptions);
1128
+ return object && _this8.applyCustomizations(object, item, imageLoader);
1139
1129
  }));
1140
- case 19:
1130
+ case 2:
1141
1131
  // apply global or targeted param values
1142
1132
  imageLoader = this.createImageLoader({
1143
1133
  basePath: this._modelBasePath
1144
1134
  });
1145
- _context8.next = 22;
1146
- return Promise.all(toBeApplied.map(function (_ref14) {
1147
- var optionParams = _ref14.params,
1148
- files = _ref14.files;
1135
+ _context8.n = 3;
1136
+ return Promise.all(toBeApplied.map(function (_ref12) {
1137
+ var optionParams = _ref12.params,
1138
+ files = _ref12.files;
1149
1139
  // find model based on objectName
1150
1140
  var objectName = optionParams.objectName,
1151
1141
  _optionParams$materia = optionParams.material,
1152
1142
  material = _optionParams$materia === void 0 ? {} : _optionParams$materia,
1153
1143
  _optionParams$materia2 = optionParams.materials,
1154
1144
  materials = _optionParams$materia2 === void 0 ? [] : _optionParams$materia2;
1155
- var objects = objectName ? findAllObjectsWith(sceneContainer, function (_ref15) {
1156
- var name = _ref15.name;
1145
+ var objects = objectName ? findAllObjectsWith(sceneContainer, function (_ref13) {
1146
+ var name = _ref13.name;
1157
1147
  return name === objectName;
1158
1148
  }) : sceneContainer.children;
1159
1149
  var params = material.params;
@@ -1170,15 +1160,15 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1170
1160
  })
1171
1161
  };
1172
1162
  return Promise.all(objects.map(function (object) {
1173
- return _this7.applyCustomizations(object, item, imageLoader, {
1163
+ return _this8.applyCustomizations(object, item, imageLoader, {
1174
1164
  saveAndRestore: false
1175
1165
  });
1176
1166
  }));
1177
1167
  }));
1178
- case 22:
1179
- _context8.next = 24;
1168
+ case 3:
1169
+ _context8.n = 4;
1180
1170
  return this.initCustomizableMaterialsIfNeeded();
1181
- case 24:
1171
+ case 4:
1182
1172
  this.fixSceneScaling();
1183
1173
  this.setupGround();
1184
1174
  this.addLightsIfNeeded(sceneContainer);
@@ -1194,13 +1184,12 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1194
1184
  mixer.clipAction(animations[0]).play();
1195
1185
  this.startAnimation("builtin");
1196
1186
  }
1197
- case 31:
1198
- case "end":
1199
- return _context8.stop();
1187
+ case 5:
1188
+ return _context8.a(2);
1200
1189
  }
1201
1190
  }, _callee8, this);
1202
1191
  }));
1203
- function loadScene(_x12) {
1192
+ function loadScene(_x10) {
1204
1193
  return _loadScene.apply(this, arguments);
1205
1194
  }
1206
1195
  return loadScene;
@@ -1226,11 +1215,11 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1226
1215
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1227
1216
  var _camera$userData;
1228
1217
  var camera = _step4.value;
1229
- var position = camera.getWorldPosition(new _three.Vector3());
1230
- var dir = camera.getWorldDirection(new _three.Vector3());
1218
+ var position = camera.getWorldPosition(new Vector3());
1219
+ var dir = camera.getWorldDirection(new Vector3());
1231
1220
  var distance = position.distanceTo(center);
1232
1221
  var lookat = dir.multiplyScalar(distance).add(position);
1233
- var orientation = _three.Object3D.DEFAULT_UP;
1222
+ var orientation = Object3D.DEFAULT_UP;
1234
1223
  var fov = camera.fov || 45;
1235
1224
  var cameraView = {
1236
1225
  position: position,
@@ -1293,16 +1282,16 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1293
1282
  if (!this.relativeCameraViews["default"]) {
1294
1283
  this.relativeCameraViews["default"] = {
1295
1284
  position: this.defaultCameraPosition.clone(),
1296
- lookat: new _three.Vector3(0, 0, 0),
1297
- orientation: new _three.Vector3(0, 1, 0)
1285
+ lookat: new Vector3(0, 0, 0),
1286
+ orientation: new Vector3(0, 1, 0)
1298
1287
  };
1299
1288
  }
1300
1289
  this.cameraViews = this.calculateRelativeViews(this.relativeCameraViews, center, this.controls.maxDistance * 0.75);
1301
1290
  if (!this.relativeScreenshotViews["default"]) {
1302
1291
  this.relativeScreenshotViews["default"] = {
1303
1292
  position: this.defaultScreenshotPosition.clone(),
1304
- lookat: new _three.Vector3(0, 0, 0),
1305
- orientation: new _three.Vector3(0, 1, 0)
1293
+ lookat: new Vector3(0, 0, 0),
1294
+ orientation: new Vector3(0, 1, 0)
1306
1295
  };
1307
1296
  }
1308
1297
  this.screenshotViews = this.calculateRelativeViews(this.relativeScreenshotViews, center, (this.controls.minDistance + this.controls.maxDistance) * 0.5);
@@ -1329,7 +1318,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1329
1318
  return;
1330
1319
  }
1331
1320
  var box = this.getSceneContainerBox();
1332
- var center = box.getCenter(new _three.Vector3());
1321
+ var center = box.getCenter(new Vector3());
1333
1322
  var currentCameraName = this.currentCameraView;
1334
1323
  var previousCameraView = this.cameraViews[currentCameraName];
1335
1324
  this.setupRelativeCameras(center);
@@ -1428,7 +1417,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1428
1417
  var _this$sceneGround;
1429
1418
  var groundParent = (_this$sceneGround = this.sceneGround) === null || _this$sceneGround === void 0 ? void 0 : _this$sceneGround.parent;
1430
1419
  groundParent === null || groundParent === void 0 || groundParent.remove(this.sceneGround);
1431
- var box = new _three.Box3();
1420
+ var box = new Box3();
1432
1421
  this.sceneContainer.traverse(function (object) {
1433
1422
  if (object.isMesh) {
1434
1423
  box.expandByObject(object);
@@ -1447,7 +1436,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1447
1436
  hemiLight = this.hemiLight;
1448
1437
  var box = this.getSceneContainerBox();
1449
1438
  var fitOffset = 1.2;
1450
- var sphere = new _three.Sphere();
1439
+ var sphere = new Sphere();
1451
1440
  box.getBoundingSphere(sphere);
1452
1441
  if (sphere.radius < 0.001) {
1453
1442
  return;
@@ -1495,8 +1484,8 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1495
1484
  }, {
1496
1485
  key: "setActiveAnimation",
1497
1486
  value: function setActiveAnimation(animationName) {
1498
- var animation = this.animations.find(function (_ref16) {
1499
- var name = _ref16.name;
1487
+ var animation = this.animations.find(function (_ref14) {
1488
+ var name = _ref14.name;
1500
1489
  return name === animationName;
1501
1490
  });
1502
1491
  if (animation) {
@@ -1540,27 +1529,26 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1540
1529
  }, {
1541
1530
  key: "update",
1542
1531
  value: function () {
1543
- var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(configuration) {
1544
- var sceneData;
1545
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1546
- while (1) switch (_context9.prev = _context9.next) {
1532
+ var _update = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(configuration) {
1533
+ var sceneData, _t7;
1534
+ return _regenerator().w(function (_context9) {
1535
+ while (1) switch (_context9.n) {
1547
1536
  case 0:
1548
1537
  this._configuration = configuration;
1549
- sceneData = (0, _get2["default"])(configuration, "visualizationData.sceneData", false) || (0, _get2["default"])(configuration, "visualizationData.designViews[0].models.".concat(this._materialVariantPath), false);
1550
- _context9.t0 = sceneData;
1551
- if (!_context9.t0) {
1552
- _context9.next = 6;
1538
+ sceneData = get(configuration, "visualizationData.sceneData", false) || get(configuration, "visualizationData.designViews[0].models.".concat(this._materialVariantPath), false);
1539
+ _t7 = sceneData;
1540
+ if (!_t7) {
1541
+ _context9.n = 1;
1553
1542
  break;
1554
1543
  }
1555
- _context9.next = 6;
1544
+ _context9.n = 1;
1556
1545
  return this.loadSceneSync(sceneData);
1557
- case 6:
1558
- case "end":
1559
- return _context9.stop();
1546
+ case 1:
1547
+ return _context9.a(2);
1560
1548
  }
1561
1549
  }, _callee9, this);
1562
1550
  }));
1563
- function update(_x13) {
1551
+ function update(_x11) {
1564
1552
  return _update.apply(this, arguments);
1565
1553
  }
1566
1554
  return update;
@@ -1568,24 +1556,23 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1568
1556
  }, {
1569
1557
  key: "updateMaterial",
1570
1558
  value: function () {
1571
- var _updateMaterial = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1572
- var sceneData;
1573
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1574
- while (1) switch (_context10.prev = _context10.next) {
1559
+ var _updateMaterial = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
1560
+ var sceneData, _t8;
1561
+ return _regenerator().w(function (_context0) {
1562
+ while (1) switch (_context0.n) {
1575
1563
  case 0:
1576
- sceneData = (0, _get2["default"])(this._designAreaList, "[0].designView.models.".concat(this._materialVariantPath)) || (0, _get2["default"])(this._configuration, "visualizationData.designViews[0].models.".concat(this._materialVariantPath)) || false;
1577
- _context10.t0 = sceneData;
1578
- if (!_context10.t0) {
1579
- _context10.next = 5;
1564
+ sceneData = get(this._designAreaList, "[0].designView.models.".concat(this._materialVariantPath)) || get(this._configuration, "visualizationData.designViews[0].models.".concat(this._materialVariantPath)) || false;
1565
+ _t8 = sceneData;
1566
+ if (!_t8) {
1567
+ _context0.n = 1;
1580
1568
  break;
1581
1569
  }
1582
- _context10.next = 5;
1570
+ _context0.n = 1;
1583
1571
  return this.loadSceneSync(sceneData);
1584
- case 5:
1585
- case "end":
1586
- return _context10.stop();
1572
+ case 1:
1573
+ return _context0.a(2);
1587
1574
  }
1588
- }, _callee10, this);
1575
+ }, _callee0, this);
1589
1576
  }));
1590
1577
  function updateMaterial() {
1591
1578
  return _updateMaterial.apply(this, arguments);
@@ -1595,27 +1582,26 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1595
1582
  }, {
1596
1583
  key: "updateDesignAreaList",
1597
1584
  value: function () {
1598
- var _updateDesignAreaList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(designAreaList) {
1599
- var sceneData;
1600
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1601
- while (1) switch (_context11.prev = _context11.next) {
1585
+ var _updateDesignAreaList = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(designAreaList) {
1586
+ var sceneData, _t9;
1587
+ return _regenerator().w(function (_context1) {
1588
+ while (1) switch (_context1.n) {
1602
1589
  case 0:
1603
1590
  this._designAreaList = designAreaList;
1604
- sceneData = (0, _get2["default"])(designAreaList, "[0].designView.models.".concat(this._materialVariantPath));
1605
- _context11.t0 = sceneData;
1606
- if (!_context11.t0) {
1607
- _context11.next = 6;
1591
+ sceneData = get(designAreaList, "[0].designView.models.".concat(this._materialVariantPath));
1592
+ _t9 = sceneData;
1593
+ if (!_t9) {
1594
+ _context1.n = 1;
1608
1595
  break;
1609
1596
  }
1610
- _context11.next = 6;
1597
+ _context1.n = 1;
1611
1598
  return this.loadSceneSync(sceneData);
1612
- case 6:
1613
- case "end":
1614
- return _context11.stop();
1599
+ case 1:
1600
+ return _context1.a(2);
1615
1601
  }
1616
- }, _callee11, this);
1602
+ }, _callee1, this);
1617
1603
  }));
1618
- function updateDesignAreaList(_x14) {
1604
+ function updateDesignAreaList(_x12) {
1619
1605
  return _updateDesignAreaList.apply(this, arguments);
1620
1606
  }
1621
1607
  return updateDesignAreaList;
@@ -1623,7 +1609,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1623
1609
  }, {
1624
1610
  key: "exportGLTF",
1625
1611
  value: function exportGLTF() {
1626
- (0, _glTFExporter.exportGLTF)(this.sceneContainer);
1612
+ _exportGLTF(this.sceneContainer);
1627
1613
  }
1628
1614
  }, {
1629
1615
  key: "setupScreenshots",
@@ -1639,5 +1625,4 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1639
1625
  return function () {};
1640
1626
  }
1641
1627
  }]);
1642
- return Three3DScene;
1643
- }(_Three3D2.Three3D);
1628
+ }(Three3D);