redhotmagma-visualization 1.56.2 → 1.56.4
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.
- package/CommonUtils/Deferred.js +4 -2
- package/CommonUtils/Observable.js +20 -11
- package/CommonUtils/SyncCurrentFunction.js +26 -18
- package/CommonUtils/SyncObservableEvent.js +3 -3
- package/DevApp.js +84 -73
- package/PrintingEffects/EmbroideryEffect.js +98 -82
- package/PrintingEffects/PrintingEffects.js +24 -14
- package/React/ReactBase.js +14 -13
- package/Three/Exporters/glTFExporter.js +1 -0
- package/Three/Three2D.js +311 -281
- package/Three/Three2DLayers.js +106 -93
- package/Three/Three3D.js +214 -196
- package/Three/Three3DScene.js +231 -209
- package/Three/ThreeBase.js +56 -42
- package/Utils/TextureBuilder/createTextureBuilder.js +67 -58
- package/Utils/createImageRepository.js +50 -33
- package/Utils/imagePreloader.js +24 -16
- package/VisualizationContainer.js +13 -11
- package/VisualizationInterface.js +33 -24
- package/index.js +1 -1
- package/package.json +2 -2
- package/visualizationAdapterCreator.js +2 -0
package/Three/Three3D.js
CHANGED
|
@@ -6,8 +6,15 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
|
6
6
|
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; } } }; }
|
|
7
7
|
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; } }
|
|
8
8
|
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; }
|
|
9
|
+
function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { "throw": 1, "return": 2, "break": 3, "continue": 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, "catch": function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
|
|
10
|
+
function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
|
|
11
|
+
function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
|
|
12
|
+
function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
|
|
13
|
+
function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
|
|
14
|
+
function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
|
|
9
15
|
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 }; })(); }
|
|
10
16
|
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); }
|
|
17
|
+
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
11
18
|
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); }
|
|
12
19
|
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); }); }; }
|
|
13
20
|
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; }
|
|
@@ -15,16 +22,15 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
15
22
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
16
23
|
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); } }
|
|
17
24
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
18
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
19
|
-
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); }
|
|
20
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
21
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
22
|
-
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; }
|
|
23
25
|
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); }
|
|
24
26
|
function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
|
|
25
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
26
27
|
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); }
|
|
27
28
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
29
|
+
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
|
|
30
|
+
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); }
|
|
31
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
32
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
33
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
28
34
|
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; }
|
|
29
35
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
30
36
|
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); }
|
|
@@ -52,15 +58,17 @@ export var MAX_DISTANCE_MULTIPLIER = 1.1;
|
|
|
52
58
|
export var MIN_DISTANCE_MULTIPLIER = 0.1;
|
|
53
59
|
export var DEFAULT_TEXTURE_SIZE = 2048;
|
|
54
60
|
export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
61
|
+
_inherits(Three3D, _ThreeBase);
|
|
62
|
+
var _super = _createSuper(Three3D);
|
|
55
63
|
function Three3D() {
|
|
56
64
|
var _this;
|
|
57
65
|
_classCallCheck(this, Three3D);
|
|
58
66
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
59
67
|
args[_key] = arguments[_key];
|
|
60
68
|
}
|
|
61
|
-
_this =
|
|
62
|
-
_defineProperty(_this, "DefaultCustomizableMaterialKey", "main_material");
|
|
63
|
-
_defineProperty(_this, "loadMaterial", function () {
|
|
69
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
70
|
+
_defineProperty(_assertThisInitialized(_this), "DefaultCustomizableMaterialKey", "main_material");
|
|
71
|
+
_defineProperty(_assertThisInitialized(_this), "loadMaterial", function () {
|
|
64
72
|
var _src;
|
|
65
73
|
var promise;
|
|
66
74
|
/**
|
|
@@ -112,8 +120,7 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
112
120
|
}());
|
|
113
121
|
return _this;
|
|
114
122
|
}
|
|
115
|
-
|
|
116
|
-
return _createClass(Three3D, [{
|
|
123
|
+
_createClass(Three3D, [{
|
|
117
124
|
key: "createRenderer",
|
|
118
125
|
value: function createRenderer() {
|
|
119
126
|
var renderer = new WebGLRenderer({
|
|
@@ -196,8 +203,8 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
196
203
|
*/
|
|
197
204
|
}, {
|
|
198
205
|
key: "loadModel",
|
|
199
|
-
value:
|
|
200
|
-
var _loadModel = _asyncToGenerator(/*#__PURE__*/
|
|
206
|
+
value: function () {
|
|
207
|
+
var _loadModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
201
208
|
var loadCameraViews,
|
|
202
209
|
rerender,
|
|
203
210
|
_this$getModelPaths,
|
|
@@ -205,14 +212,14 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
205
212
|
promises,
|
|
206
213
|
result,
|
|
207
214
|
_args = arguments;
|
|
208
|
-
return
|
|
209
|
-
while (1) switch (_context.
|
|
215
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
216
|
+
while (1) switch (_context.prev = _context.next) {
|
|
210
217
|
case 0:
|
|
211
218
|
loadCameraViews = _args.length > 0 && _args[0] !== undefined ? _args[0] : true;
|
|
212
219
|
rerender = _args.length > 1 && _args[1] !== undefined ? _args[1] : true;
|
|
213
220
|
_this$getModelPaths = this.getModelPaths(), objPath = _this$getModelPaths.objPath;
|
|
214
221
|
if (!objPath) {
|
|
215
|
-
_context.
|
|
222
|
+
_context.next = 14;
|
|
216
223
|
break;
|
|
217
224
|
}
|
|
218
225
|
promises = [this.loadObject("".concat(objPath, "/model.obj"))];
|
|
@@ -220,18 +227,21 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
220
227
|
promises.push(this.loadCameraViewsAdvanced("".concat(objPath, "/cameraviews.dae")));
|
|
221
228
|
}
|
|
222
229
|
this.onLoadStart();
|
|
223
|
-
_context.
|
|
230
|
+
_context.next = 9;
|
|
224
231
|
return Promise.all(promises);
|
|
225
|
-
case
|
|
226
|
-
result = _context.
|
|
232
|
+
case 9:
|
|
233
|
+
result = _context.sent;
|
|
227
234
|
this.onLoadFinished();
|
|
228
235
|
this.observable.dispatch(EventTypes.ModelLoaded);
|
|
229
236
|
if (rerender) {
|
|
230
237
|
this.render();
|
|
231
238
|
}
|
|
232
|
-
return _context.
|
|
233
|
-
case
|
|
234
|
-
return _context.
|
|
239
|
+
return _context.abrupt("return", result);
|
|
240
|
+
case 14:
|
|
241
|
+
return _context.abrupt("return", Promise.reject("Cannot load model, the item path is not defined!"));
|
|
242
|
+
case 15:
|
|
243
|
+
case "end":
|
|
244
|
+
return _context.stop();
|
|
235
245
|
}
|
|
236
246
|
}, _callee, this);
|
|
237
247
|
}));
|
|
@@ -257,11 +267,10 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
257
267
|
* @param {boolean} [setDefault=true] Jump to the default view immediately after the views are processed.
|
|
258
268
|
* @returns {Promise.<{}>}
|
|
259
269
|
*/
|
|
260
|
-
)
|
|
261
270
|
}, {
|
|
262
271
|
key: "loadCameraViews",
|
|
263
|
-
value:
|
|
264
|
-
var _loadCameraViews = _asyncToGenerator(/*#__PURE__*/
|
|
272
|
+
value: function () {
|
|
273
|
+
var _loadCameraViews = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(src) {
|
|
265
274
|
var setDefault,
|
|
266
275
|
group,
|
|
267
276
|
children,
|
|
@@ -273,76 +282,76 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
273
282
|
viewName,
|
|
274
283
|
viewParam,
|
|
275
284
|
pos,
|
|
276
|
-
_args2 = arguments
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
while (1) switch (_context2.p = _context2.n) {
|
|
285
|
+
_args2 = arguments;
|
|
286
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
287
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
280
288
|
case 0:
|
|
281
289
|
setDefault = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : true;
|
|
282
|
-
_context2.
|
|
290
|
+
_context2.next = 3;
|
|
283
291
|
return this.loadObject(src, false);
|
|
284
|
-
case
|
|
285
|
-
group = _context2.
|
|
292
|
+
case 3:
|
|
293
|
+
group = _context2.sent;
|
|
286
294
|
children = group.children;
|
|
287
295
|
if (!(children && children.length > 0)) {
|
|
288
|
-
_context2.
|
|
296
|
+
_context2.next = 37;
|
|
289
297
|
break;
|
|
290
298
|
}
|
|
291
299
|
views = {};
|
|
292
300
|
_iterator = _createForOfIteratorHelper(children);
|
|
293
|
-
_context2.
|
|
301
|
+
_context2.prev = 8;
|
|
294
302
|
_iterator.s();
|
|
295
|
-
case
|
|
303
|
+
case 10:
|
|
296
304
|
if ((_step = _iterator.n()).done) {
|
|
297
|
-
_context2.
|
|
305
|
+
_context2.next = 25;
|
|
298
306
|
break;
|
|
299
307
|
}
|
|
300
308
|
obj = _step.value;
|
|
301
309
|
if (obj instanceof Mesh) {
|
|
302
|
-
_context2.
|
|
310
|
+
_context2.next = 14;
|
|
303
311
|
break;
|
|
304
312
|
}
|
|
305
|
-
return _context2.
|
|
306
|
-
case
|
|
313
|
+
return _context2.abrupt("continue", 23);
|
|
314
|
+
case 14:
|
|
307
315
|
matches = ("" + obj.name).toLowerCase().match(/(.+)_(position|lookat)$/);
|
|
308
316
|
if (matches) {
|
|
309
|
-
_context2.
|
|
317
|
+
_context2.next = 18;
|
|
310
318
|
break;
|
|
311
319
|
}
|
|
312
320
|
// eslint-disable-next-line no-console
|
|
313
321
|
console.warn("Camera view object skipped: ".concat(obj.name));
|
|
314
|
-
return _context2.
|
|
315
|
-
case
|
|
322
|
+
return _context2.abrupt("continue", 23);
|
|
323
|
+
case 18:
|
|
316
324
|
viewName = matches[1];
|
|
317
325
|
viewParam = matches[2];
|
|
318
326
|
obj.geometry.computeBoundingSphere();
|
|
319
327
|
pos = obj.geometry.boundingSphere.center.clone();
|
|
320
328
|
views[viewName] = _objectSpread(_objectSpread({}, views[viewName]), {}, _defineProperty({}, viewParam, pos));
|
|
321
|
-
case
|
|
322
|
-
_context2.
|
|
329
|
+
case 23:
|
|
330
|
+
_context2.next = 10;
|
|
323
331
|
break;
|
|
324
|
-
case
|
|
325
|
-
_context2.
|
|
332
|
+
case 25:
|
|
333
|
+
_context2.next = 30;
|
|
326
334
|
break;
|
|
327
|
-
case
|
|
328
|
-
_context2.
|
|
329
|
-
|
|
330
|
-
_iterator.e(
|
|
331
|
-
case
|
|
332
|
-
_context2.
|
|
335
|
+
case 27:
|
|
336
|
+
_context2.prev = 27;
|
|
337
|
+
_context2.t0 = _context2["catch"](8);
|
|
338
|
+
_iterator.e(_context2.t0);
|
|
339
|
+
case 30:
|
|
340
|
+
_context2.prev = 30;
|
|
333
341
|
_iterator.f();
|
|
334
|
-
return _context2.
|
|
335
|
-
case
|
|
342
|
+
return _context2.finish(30);
|
|
343
|
+
case 33:
|
|
336
344
|
this.cameraViews = views;
|
|
337
345
|
if (setDefault) {
|
|
338
346
|
this.jumpToView("default", false);
|
|
339
347
|
}
|
|
340
348
|
this.setControlsDistanceMinMax();
|
|
341
|
-
return _context2.
|
|
342
|
-
case
|
|
343
|
-
|
|
349
|
+
return _context2.abrupt("return", views);
|
|
350
|
+
case 37:
|
|
351
|
+
case "end":
|
|
352
|
+
return _context2.stop();
|
|
344
353
|
}
|
|
345
|
-
}, _callee2, this, [[
|
|
354
|
+
}, _callee2, this, [[8, 27, 30, 33]]);
|
|
346
355
|
}));
|
|
347
356
|
function loadCameraViews(_x) {
|
|
348
357
|
return _loadCameraViews.apply(this, arguments);
|
|
@@ -356,11 +365,10 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
356
365
|
* @param {boolean} [setDefault=true] Jump to the default view immediately after the views are processed.
|
|
357
366
|
* @returns {Promise.<{}>}
|
|
358
367
|
*/
|
|
359
|
-
)
|
|
360
368
|
}, {
|
|
361
369
|
key: "loadCameraViewsAdvanced",
|
|
362
|
-
value:
|
|
363
|
-
var _loadCameraViewsAdvanced = _asyncToGenerator(/*#__PURE__*/
|
|
370
|
+
value: function () {
|
|
371
|
+
var _loadCameraViewsAdvanced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(src) {
|
|
364
372
|
var setDefault,
|
|
365
373
|
loader,
|
|
366
374
|
_this$getPathAndFileN2,
|
|
@@ -370,22 +378,23 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
370
378
|
scene,
|
|
371
379
|
views,
|
|
372
380
|
_args4 = arguments;
|
|
373
|
-
return
|
|
374
|
-
while (1) switch (_context4.
|
|
381
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
382
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
375
383
|
case 0:
|
|
376
384
|
setDefault = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : true;
|
|
377
385
|
loader = new ColladaLoader(this._loadingManager);
|
|
378
386
|
_this$getPathAndFileN2 = this.getPathAndFileName(src), path = _this$getPathAndFileN2.path, fileName = _this$getPathAndFileN2.fileName;
|
|
379
|
-
_context4.
|
|
387
|
+
_context4.next = 5;
|
|
380
388
|
return new Promise(function (resolve, reject) {
|
|
381
389
|
loader.setPath(path).load(fileName, /*#__PURE__*/function () {
|
|
382
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/
|
|
383
|
-
return
|
|
384
|
-
while (1) switch (_context3.
|
|
390
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(object) {
|
|
391
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
392
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
385
393
|
case 0:
|
|
386
394
|
resolve(object);
|
|
387
395
|
case 1:
|
|
388
|
-
|
|
396
|
+
case "end":
|
|
397
|
+
return _context3.stop();
|
|
389
398
|
}
|
|
390
399
|
}, _callee3);
|
|
391
400
|
}));
|
|
@@ -394,8 +403,8 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
394
403
|
};
|
|
395
404
|
}(), onProgress, reject);
|
|
396
405
|
});
|
|
397
|
-
case
|
|
398
|
-
_yield$Promise = _context4.
|
|
406
|
+
case 5:
|
|
407
|
+
_yield$Promise = _context4.sent;
|
|
399
408
|
scene = _yield$Promise.scene;
|
|
400
409
|
views = {};
|
|
401
410
|
scene.traverse(function (obj) {
|
|
@@ -416,7 +425,10 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
416
425
|
this.jumpToView("default", false);
|
|
417
426
|
}
|
|
418
427
|
this.setControlsDistanceMinMax();
|
|
419
|
-
return _context4.
|
|
428
|
+
return _context4.abrupt("return", views);
|
|
429
|
+
case 13:
|
|
430
|
+
case "end":
|
|
431
|
+
return _context4.stop();
|
|
420
432
|
}
|
|
421
433
|
}, _callee4, this);
|
|
422
434
|
}));
|
|
@@ -424,7 +436,7 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
424
436
|
return _loadCameraViewsAdvanced.apply(this, arguments);
|
|
425
437
|
}
|
|
426
438
|
return loadCameraViewsAdvanced;
|
|
427
|
-
}()
|
|
439
|
+
}()
|
|
428
440
|
}, {
|
|
429
441
|
key: "loadObject",
|
|
430
442
|
value:
|
|
@@ -444,19 +456,20 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
444
456
|
fileName = _this$getPathAndFileN3.fileName;
|
|
445
457
|
return new Promise(function (resolve, reject) {
|
|
446
458
|
objLoader.setPath(path).load(fileName, /*#__PURE__*/function () {
|
|
447
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/
|
|
448
|
-
return
|
|
449
|
-
while (1) switch (_context5.
|
|
459
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(object) {
|
|
460
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
461
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
450
462
|
case 0:
|
|
451
|
-
_context5.
|
|
463
|
+
_context5.next = 2;
|
|
452
464
|
return _this3.updateMaterial(object);
|
|
453
|
-
case
|
|
465
|
+
case 2:
|
|
454
466
|
if (addToScene) {
|
|
455
467
|
_this3.scene.add(object);
|
|
456
468
|
}
|
|
457
469
|
resolve(object);
|
|
458
|
-
case
|
|
459
|
-
|
|
470
|
+
case 4:
|
|
471
|
+
case "end":
|
|
472
|
+
return _context5.stop();
|
|
460
473
|
}
|
|
461
474
|
}, _callee5);
|
|
462
475
|
}));
|
|
@@ -469,14 +482,14 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
469
482
|
}, {
|
|
470
483
|
key: "dispatchMaterialUpdateEvent",
|
|
471
484
|
value: function () {
|
|
472
|
-
var _dispatchMaterialUpdateEvent = _asyncToGenerator(/*#__PURE__*/
|
|
485
|
+
var _dispatchMaterialUpdateEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
473
486
|
var options,
|
|
474
487
|
_options$screenshot,
|
|
475
488
|
screenshot,
|
|
476
489
|
eventParams,
|
|
477
490
|
_args6 = arguments;
|
|
478
|
-
return
|
|
479
|
-
while (1) switch (_context6.
|
|
491
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
492
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
480
493
|
case 0:
|
|
481
494
|
options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
|
482
495
|
_options$screenshot = options.screenshot, screenshot = _options$screenshot === void 0 ? false : _options$screenshot;
|
|
@@ -484,10 +497,11 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
484
497
|
variant: this._materialVariantPath,
|
|
485
498
|
screenshot: screenshot
|
|
486
499
|
}; // the redrawing of the areas can be synced if the event handler returns a Promise
|
|
487
|
-
_context6.
|
|
500
|
+
_context6.next = 5;
|
|
488
501
|
return this.observable.dispatch(EventTypes.MaterialUpdated, eventParams);
|
|
489
|
-
case
|
|
490
|
-
|
|
502
|
+
case 5:
|
|
503
|
+
case "end":
|
|
504
|
+
return _context6.stop();
|
|
491
505
|
}
|
|
492
506
|
}, _callee6, this);
|
|
493
507
|
}));
|
|
@@ -499,15 +513,15 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
499
513
|
}, {
|
|
500
514
|
key: "updateMaterial",
|
|
501
515
|
value: function () {
|
|
502
|
-
var _updateMaterial = _asyncToGenerator(/*#__PURE__*/
|
|
516
|
+
var _updateMaterial = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
503
517
|
var targetObject,
|
|
504
518
|
options,
|
|
505
519
|
_this$getModelPaths2,
|
|
506
520
|
mtlPath,
|
|
507
521
|
materialCreator,
|
|
508
522
|
_args7 = arguments;
|
|
509
|
-
return
|
|
510
|
-
while (1) switch (_context7.
|
|
523
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
524
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
511
525
|
case 0:
|
|
512
526
|
targetObject = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : this.scene;
|
|
513
527
|
options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
|
|
@@ -515,24 +529,27 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
515
529
|
console.log("Updating materials...");
|
|
516
530
|
_this$getModelPaths2 = this.getModelPaths(), mtlPath = _this$getModelPaths2.mtlPath;
|
|
517
531
|
if (mtlPath) {
|
|
518
|
-
_context7.
|
|
532
|
+
_context7.next = 7;
|
|
519
533
|
break;
|
|
520
534
|
}
|
|
521
535
|
// eslint-disable-next-line no-console
|
|
522
536
|
console.log("Missing material path!");
|
|
523
|
-
return _context7.
|
|
524
|
-
case
|
|
525
|
-
_context7.
|
|
537
|
+
return _context7.abrupt("return");
|
|
538
|
+
case 7:
|
|
539
|
+
_context7.next = 9;
|
|
526
540
|
return this.loadMaterial("".concat(mtlPath, "/materials.mtl"));
|
|
527
|
-
case
|
|
528
|
-
materialCreator = _context7.
|
|
541
|
+
case 9:
|
|
542
|
+
materialCreator = _context7.sent;
|
|
529
543
|
this.guessCustomizableMaterialNameIfNotSet(materialCreator.materials);
|
|
530
544
|
this.findCustomizableMaterials(materialCreator.materials);
|
|
531
545
|
this.applyMaterials(materialCreator.materials, targetObject);
|
|
532
|
-
_context7.
|
|
546
|
+
_context7.next = 15;
|
|
533
547
|
return this.dispatchMaterialUpdateEvent(options);
|
|
534
|
-
case
|
|
535
|
-
return _context7.
|
|
548
|
+
case 15:
|
|
549
|
+
return _context7.abrupt("return", materialCreator);
|
|
550
|
+
case 16:
|
|
551
|
+
case "end":
|
|
552
|
+
return _context7.stop();
|
|
536
553
|
}
|
|
537
554
|
}, _callee7, this);
|
|
538
555
|
}));
|
|
@@ -789,7 +806,7 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
789
806
|
}, {
|
|
790
807
|
key: "getScreenshots",
|
|
791
808
|
value: function () {
|
|
792
|
-
var _getScreenshots = _asyncToGenerator(/*#__PURE__*/
|
|
809
|
+
var _getScreenshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(callback) {
|
|
793
810
|
var _this5 = this;
|
|
794
811
|
var _ref3,
|
|
795
812
|
viewList,
|
|
@@ -822,32 +839,29 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
822
839
|
orientation,
|
|
823
840
|
target,
|
|
824
841
|
fov,
|
|
825
|
-
_args9 = arguments
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
_t4;
|
|
829
|
-
return _regenerator().w(function (_context9) {
|
|
830
|
-
while (1) switch (_context9.p = _context9.n) {
|
|
842
|
+
_args9 = arguments;
|
|
843
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
844
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
831
845
|
case 0:
|
|
832
846
|
_ref3 = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : {}, viewList = _ref3.viewList, variantList = _ref3.variantList, size = _ref3.size;
|
|
833
847
|
if (this.renderer) {
|
|
834
|
-
_context9.
|
|
848
|
+
_context9.next = 3;
|
|
835
849
|
break;
|
|
836
850
|
}
|
|
837
|
-
return _context9.
|
|
838
|
-
case
|
|
851
|
+
return _context9.abrupt("return", callback({}));
|
|
852
|
+
case 3:
|
|
839
853
|
if (!variantList) {
|
|
840
854
|
variantList = ["default"];
|
|
841
855
|
}
|
|
842
856
|
this._screenshottingInProgress = true;
|
|
843
857
|
this.endAnimation();
|
|
844
|
-
_context9.
|
|
858
|
+
_context9.next = 8;
|
|
845
859
|
return this.animationRunning();
|
|
846
|
-
case
|
|
847
|
-
_context9.
|
|
860
|
+
case 8:
|
|
861
|
+
_context9.next = 10;
|
|
848
862
|
return this.createTempOverlay();
|
|
849
|
-
case
|
|
850
|
-
removeTempOverlay = _context9.
|
|
863
|
+
case 10:
|
|
864
|
+
removeTempOverlay = _context9.sent;
|
|
851
865
|
restoreCameraViewOffset = rememberCameraViewOffset(this.camera); // store original state values
|
|
852
866
|
origVariantPath = this._materialVariantPath;
|
|
853
867
|
origPosition = this.camera.position.clone();
|
|
@@ -857,9 +871,9 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
857
871
|
this.renderer.getSize(origSize);
|
|
858
872
|
origPixelRatio = this.renderer.getPixelRatio();
|
|
859
873
|
restoreOriginalValues = /*#__PURE__*/function () {
|
|
860
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/
|
|
861
|
-
return
|
|
862
|
-
while (1) switch (_context8.
|
|
874
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
875
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
876
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
863
877
|
case 0:
|
|
864
878
|
_this5._screenshottingInProgress = false;
|
|
865
879
|
_this5.renderer.setSize(origSize.width, origSize.height);
|
|
@@ -868,13 +882,14 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
868
882
|
_this5.setCameraPosition(origPosition, origOrientation, origTarget);
|
|
869
883
|
restoreCameraViewOffset();
|
|
870
884
|
_this5._materialVariantPath = origVariantPath;
|
|
871
|
-
_context8.
|
|
885
|
+
_context8.next = 9;
|
|
872
886
|
return _this5.updateMaterial();
|
|
873
|
-
case
|
|
887
|
+
case 9:
|
|
874
888
|
_this5.render();
|
|
875
889
|
removeTempOverlay();
|
|
876
|
-
case
|
|
877
|
-
|
|
890
|
+
case 11:
|
|
891
|
+
case "end":
|
|
892
|
+
return _context8.stop();
|
|
878
893
|
}
|
|
879
894
|
}, _callee8);
|
|
880
895
|
}));
|
|
@@ -882,10 +897,10 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
882
897
|
return _ref4.apply(this, arguments);
|
|
883
898
|
};
|
|
884
899
|
}();
|
|
885
|
-
_context9.
|
|
900
|
+
_context9.next = 22;
|
|
886
901
|
return this.setupScreenshots();
|
|
887
|
-
case
|
|
888
|
-
restoreScreenshotSetup = _context9.
|
|
902
|
+
case 22:
|
|
903
|
+
restoreScreenshotSetup = _context9.sent;
|
|
889
904
|
// get the size from the size param, or use default values
|
|
890
905
|
width = (size === null || size === void 0 ? void 0 : size.width) || 1024;
|
|
891
906
|
height = (size === null || size === void 0 ? void 0 : size.height) || 768;
|
|
@@ -895,56 +910,56 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
895
910
|
return views[viewKey];
|
|
896
911
|
}) : Object.keys(views);
|
|
897
912
|
_iterator3 = _createForOfIteratorHelper(variantList);
|
|
898
|
-
_context9.
|
|
913
|
+
_context9.prev = 29;
|
|
899
914
|
_iterator3.s();
|
|
900
|
-
case
|
|
915
|
+
case 31:
|
|
901
916
|
if ((_step3 = _iterator3.n()).done) {
|
|
902
|
-
_context9.
|
|
917
|
+
_context9.next = 78;
|
|
903
918
|
break;
|
|
904
919
|
}
|
|
905
920
|
variant = _step3.value;
|
|
906
921
|
if (!this._abortScreenshotting) {
|
|
907
|
-
_context9.
|
|
922
|
+
_context9.next = 37;
|
|
908
923
|
break;
|
|
909
924
|
}
|
|
910
|
-
_context9.
|
|
925
|
+
_context9.next = 36;
|
|
911
926
|
return restoreOriginalValues();
|
|
912
|
-
case
|
|
913
|
-
return _context9.
|
|
914
|
-
case
|
|
927
|
+
case 36:
|
|
928
|
+
return _context9.abrupt("return", _context9.sent);
|
|
929
|
+
case 37:
|
|
915
930
|
data = {};
|
|
916
931
|
this.setMaterialVariantPath(variant);
|
|
917
|
-
_context9.
|
|
918
|
-
_context9.
|
|
932
|
+
_context9.prev = 39;
|
|
933
|
+
_context9.next = 42;
|
|
919
934
|
return this.updateMaterial(this.scene, {
|
|
920
935
|
screenshot: true
|
|
921
936
|
});
|
|
922
|
-
case
|
|
923
|
-
_context9.
|
|
937
|
+
case 42:
|
|
938
|
+
_context9.next = 47;
|
|
924
939
|
break;
|
|
925
|
-
case
|
|
926
|
-
_context9.
|
|
927
|
-
|
|
928
|
-
return _context9.
|
|
929
|
-
case
|
|
940
|
+
case 44:
|
|
941
|
+
_context9.prev = 44;
|
|
942
|
+
_context9.t0 = _context9["catch"](39);
|
|
943
|
+
return _context9.abrupt("continue", 76);
|
|
944
|
+
case 47:
|
|
930
945
|
_iterator4 = _createForOfIteratorHelper(viewKeyList);
|
|
931
|
-
_context9.
|
|
946
|
+
_context9.prev = 48;
|
|
932
947
|
_iterator4.s();
|
|
933
|
-
case
|
|
948
|
+
case 50:
|
|
934
949
|
if ((_step4 = _iterator4.n()).done) {
|
|
935
|
-
_context9.
|
|
950
|
+
_context9.next = 67;
|
|
936
951
|
break;
|
|
937
952
|
}
|
|
938
953
|
viewKey = _step4.value;
|
|
939
954
|
if (!this._abortScreenshotting) {
|
|
940
|
-
_context9.
|
|
955
|
+
_context9.next = 56;
|
|
941
956
|
break;
|
|
942
957
|
}
|
|
943
|
-
_context9.
|
|
958
|
+
_context9.next = 55;
|
|
944
959
|
return restoreOriginalValues();
|
|
945
|
-
case
|
|
946
|
-
return _context9.
|
|
947
|
-
case
|
|
960
|
+
case 55:
|
|
961
|
+
return _context9.abrupt("return", _context9.sent);
|
|
962
|
+
case 56:
|
|
948
963
|
view = views[viewKey];
|
|
949
964
|
position = view.position, orientation = view.orientation, target = view.lookat, fov = view.fov; // set the camera to the screenshot size
|
|
950
965
|
this.renderer.setPixelRatio(1);
|
|
@@ -954,48 +969,49 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
954
969
|
this.setCameraPosition(position, orientation, target, fov);
|
|
955
970
|
this.render();
|
|
956
971
|
data[viewKey] = this.renderer.domElement.toDataURL("image/png");
|
|
957
|
-
case
|
|
958
|
-
_context9.
|
|
972
|
+
case 65:
|
|
973
|
+
_context9.next = 50;
|
|
959
974
|
break;
|
|
960
|
-
case
|
|
961
|
-
_context9.
|
|
975
|
+
case 67:
|
|
976
|
+
_context9.next = 72;
|
|
962
977
|
break;
|
|
963
|
-
case
|
|
964
|
-
_context9.
|
|
965
|
-
|
|
966
|
-
_iterator4.e(
|
|
967
|
-
case
|
|
968
|
-
_context9.
|
|
978
|
+
case 69:
|
|
979
|
+
_context9.prev = 69;
|
|
980
|
+
_context9.t1 = _context9["catch"](48);
|
|
981
|
+
_iterator4.e(_context9.t1);
|
|
982
|
+
case 72:
|
|
983
|
+
_context9.prev = 72;
|
|
969
984
|
_iterator4.f();
|
|
970
|
-
return _context9.
|
|
971
|
-
case
|
|
985
|
+
return _context9.finish(72);
|
|
986
|
+
case 75:
|
|
972
987
|
screenshots[variant] = data;
|
|
973
|
-
case
|
|
974
|
-
_context9.
|
|
988
|
+
case 76:
|
|
989
|
+
_context9.next = 31;
|
|
975
990
|
break;
|
|
976
|
-
case
|
|
977
|
-
_context9.
|
|
991
|
+
case 78:
|
|
992
|
+
_context9.next = 83;
|
|
978
993
|
break;
|
|
979
|
-
case
|
|
980
|
-
_context9.
|
|
981
|
-
|
|
982
|
-
_iterator3.e(
|
|
983
|
-
case
|
|
984
|
-
_context9.
|
|
994
|
+
case 80:
|
|
995
|
+
_context9.prev = 80;
|
|
996
|
+
_context9.t2 = _context9["catch"](29);
|
|
997
|
+
_iterator3.e(_context9.t2);
|
|
998
|
+
case 83:
|
|
999
|
+
_context9.prev = 83;
|
|
985
1000
|
_iterator3.f();
|
|
986
|
-
return _context9.
|
|
987
|
-
case
|
|
988
|
-
_context9.
|
|
1001
|
+
return _context9.finish(83);
|
|
1002
|
+
case 86:
|
|
1003
|
+
_context9.next = 88;
|
|
989
1004
|
return restoreScreenshotSetup();
|
|
990
|
-
case
|
|
991
|
-
_context9.
|
|
1005
|
+
case 88:
|
|
1006
|
+
_context9.next = 90;
|
|
992
1007
|
return restoreOriginalValues();
|
|
993
|
-
case
|
|
1008
|
+
case 90:
|
|
994
1009
|
callback(screenshots);
|
|
995
|
-
case
|
|
996
|
-
|
|
1010
|
+
case 91:
|
|
1011
|
+
case "end":
|
|
1012
|
+
return _context9.stop();
|
|
997
1013
|
}
|
|
998
|
-
}, _callee9, this, [[
|
|
1014
|
+
}, _callee9, this, [[29, 80, 83, 86], [39, 44], [48, 69, 72, 75]]);
|
|
999
1015
|
}));
|
|
1000
1016
|
function getScreenshots(_x5) {
|
|
1001
1017
|
return _getScreenshots.apply(this, arguments);
|
|
@@ -1034,8 +1050,8 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
1034
1050
|
*/
|
|
1035
1051
|
}, {
|
|
1036
1052
|
key: "getDrawingContext",
|
|
1037
|
-
value:
|
|
1038
|
-
var _getDrawingContext = _asyncToGenerator(/*#__PURE__*/
|
|
1053
|
+
value: function () {
|
|
1054
|
+
var _getDrawingContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee0(drawingFn) {
|
|
1039
1055
|
var updateAlpha,
|
|
1040
1056
|
clearTexture,
|
|
1041
1057
|
materialName,
|
|
@@ -1052,21 +1068,21 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
1052
1068
|
tmpCanvas,
|
|
1053
1069
|
tmpCtx,
|
|
1054
1070
|
_args0 = arguments;
|
|
1055
|
-
return
|
|
1056
|
-
while (1) switch (_context0.
|
|
1071
|
+
return _regeneratorRuntime().wrap(function _callee0$(_context0) {
|
|
1072
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
1057
1073
|
case 0:
|
|
1058
1074
|
updateAlpha = _args0.length > 1 && _args0[1] !== undefined ? _args0[1] : false;
|
|
1059
1075
|
clearTexture = _args0.length > 2 && _args0[2] !== undefined ? _args0[2] : false;
|
|
1060
1076
|
materialName = _args0.length > 3 && _args0[3] !== undefined ? _args0[3] : undefined;
|
|
1061
1077
|
material = materialName ? this.findMaterialByName(materialName) : first(this._customizableMaterials);
|
|
1062
1078
|
if (!(!material || !material.map || !material.map.image)) {
|
|
1063
|
-
_context0.
|
|
1079
|
+
_context0.next = 7;
|
|
1064
1080
|
break;
|
|
1065
1081
|
}
|
|
1066
1082
|
// eslint-disable-next-line no-console
|
|
1067
1083
|
console.error("Cannot get drawing context for material: ".concat(materialName, "! Is it prepared already?"));
|
|
1068
|
-
return _context0.
|
|
1069
|
-
case
|
|
1084
|
+
return _context0.abrupt("return");
|
|
1085
|
+
case 7:
|
|
1070
1086
|
_this$getCanvasContex = this.getCanvasContextForTexture(material.map), ctx = _this$getCanvasContex.ctx, canvas = _this$getCanvasContex.canvas, originalImage = _this$getCanvasContex.originalImage, texture = _this$getCanvasContex.texture;
|
|
1071
1087
|
scaling = this.calculateTextureScaling(canvas);
|
|
1072
1088
|
getTextureBuilder = createTextureBuilder(originalImage, {
|
|
@@ -1078,29 +1094,30 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
1078
1094
|
ctx.drawImage(originalImage, 0, 0);
|
|
1079
1095
|
}
|
|
1080
1096
|
if (!(updateAlpha && material.alphaMap)) {
|
|
1081
|
-
_context0.
|
|
1097
|
+
_context0.next = 19;
|
|
1082
1098
|
break;
|
|
1083
1099
|
}
|
|
1084
1100
|
// create a temporary canvas
|
|
1085
1101
|
_createWorkingCanvas = createWorkingCanvas(canvas), _createWorkingCanvas2 = _slicedToArray(_createWorkingCanvas, 2), tmpCanvas = _createWorkingCanvas2[0], tmpCtx = _createWorkingCanvas2[1]; // do the drawing on a temporary canvas first, so we can get the alpha values
|
|
1086
|
-
_context0.
|
|
1102
|
+
_context0.next = 15;
|
|
1087
1103
|
return drawingFn(tmpCtx, getTextureBuilder);
|
|
1088
|
-
case
|
|
1104
|
+
case 15:
|
|
1089
1105
|
// copy the temp canvas on the diffuse map
|
|
1090
1106
|
ctx.drawImage(tmpCanvas, 0, 0);
|
|
1091
1107
|
this.updateAlphaMap(material.alphaMap, tmpCanvas);
|
|
1092
|
-
_context0.
|
|
1108
|
+
_context0.next = 21;
|
|
1093
1109
|
break;
|
|
1094
|
-
case
|
|
1095
|
-
_context0.
|
|
1110
|
+
case 19:
|
|
1111
|
+
_context0.next = 21;
|
|
1096
1112
|
return drawingFn(ctx, getTextureBuilder);
|
|
1097
|
-
case
|
|
1113
|
+
case 21:
|
|
1098
1114
|
texture.needsUpdate = true;
|
|
1099
1115
|
if (!this.isAnimating()) {
|
|
1100
1116
|
this.render();
|
|
1101
1117
|
}
|
|
1102
|
-
case
|
|
1103
|
-
|
|
1118
|
+
case 23:
|
|
1119
|
+
case "end":
|
|
1120
|
+
return _context0.stop();
|
|
1104
1121
|
}
|
|
1105
1122
|
}, _callee0, this);
|
|
1106
1123
|
}));
|
|
@@ -1108,7 +1125,7 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
1108
1125
|
return _getDrawingContext.apply(this, arguments);
|
|
1109
1126
|
}
|
|
1110
1127
|
return getDrawingContext;
|
|
1111
|
-
}()
|
|
1128
|
+
}()
|
|
1112
1129
|
}, {
|
|
1113
1130
|
key: "updateAlphaMap",
|
|
1114
1131
|
value: function updateAlphaMap(texture, srcCanvas) {
|
|
@@ -1173,7 +1190,8 @@ export var Three3D = /*#__PURE__*/function (_ThreeBase) {
|
|
|
1173
1190
|
if (this._cleanUpZoomHandler) {
|
|
1174
1191
|
this._cleanUpZoomHandler();
|
|
1175
1192
|
}
|
|
1176
|
-
|
|
1193
|
+
_get(_getPrototypeOf(Three3D.prototype), "dispose", this).call(this);
|
|
1177
1194
|
}
|
|
1178
1195
|
}]);
|
|
1196
|
+
return Three3D;
|
|
1179
1197
|
}(ThreeBase);
|