redhotmagma-visualization 1.41.0 → 1.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AlignTargetProvider.js +50 -79
- package/CommonUtils/Deferred.js +11 -38
- package/CommonUtils/Observable.js +29 -48
- package/CommonUtils/PropertyObserver.js +10 -17
- package/CommonUtils/SyncCurrentFunction.js +33 -42
- package/CommonUtils/SyncObservableEvent.js +2 -6
- package/CommonUtils/pointerEvent.js +50 -98
- package/Constants.js +6 -6
- package/DevApp.js +187 -309
- package/ExposedModules.js +2 -9
- package/FallbackVisualization.js +4 -10
- package/PrintingEffects/ColorEmbossingEffect.js +15 -26
- package/PrintingEffects/DomingEffect.js +29 -52
- package/PrintingEffects/EmbossingEffect.js +17 -29
- package/PrintingEffects/EmbroideryEffect.js +251 -362
- package/PrintingEffects/EngravingEffect.js +17 -29
- package/PrintingEffects/PrintingEffects.js +44 -73
- package/PrintingEffects/PrintingEffectsUtils.js +1 -7
- package/React/ReactBase.js +15 -47
- package/Three/Controls/OrbitControls.js +105 -126
- package/Three/Exporters/glTFExporter.js +2 -6
- package/Three/Loaders/ColladaLoader.js +202 -550
- package/Three/Loaders/MTLLoader.js +33 -64
- package/Three/Loaders/OBJLoader.js +48 -80
- package/Three/Three2D.js +750 -1014
- package/Three/Three2DLayers.js +217 -341
- package/Three/Three3D.js +530 -800
- package/Three/Three3DScene.js +484 -780
- package/Three/ThreeBase.js +145 -230
- package/Utils/DesignArea/getDesignAreaCanvasSize.js +3 -11
- package/Utils/TextureBuilder/createTextureBuilder.js +133 -193
- package/Utils/TextureBuilder/textureBuilderFunctions.js +11 -27
- package/Utils/alignToElement.js +13 -24
- package/Utils/canvasBlur.js +27 -45
- package/Utils/createAlphaMapFromAlphaChannel.js +11 -21
- package/Utils/createBakedShadow.js +38 -42
- package/Utils/createCache.js +0 -4
- package/Utils/createCanvas.js +3 -9
- package/Utils/createImageRepository.js +63 -87
- package/Utils/disposeMaterial.js +4 -14
- package/Utils/getImageSize.js +1 -2
- package/Utils/imagePreloader.js +36 -48
- package/Utils/initTextureCanvas.js +6 -18
- package/Utils/isMobileDevice.js +3 -7
- package/Utils/optimizeTextureImage.js +13 -29
- package/Utils/rememberCameraViewOffset.js +8 -11
- package/Utils/removeObject.js +0 -4
- package/Utils/restrictCameraMovement.js +2 -12
- package/Utils/setLightShadow.js +3 -5
- package/Utils/setOrthographicCameraSize.js +0 -1
- package/Utils/updateFitSizeToElement.js +4 -9
- package/VisualizationContainer.js +37 -90
- package/VisualizationInterface.js +32 -67
- package/VisualizationProvider.js +5 -15
- package/index.js +2 -9
- package/package.json +6 -7
- package/scripts/cpPublicLocal.js +7 -2
- package/src/CommonUtils/Observable.js +1 -0
- package/src/CommonUtils/pointerEvent.js +17 -0
- package/src/Constants.js +2 -0
- package/src/DevApp.js +1 -2
- package/src/Three/Three2D.js +105 -1
- package/src/Three/ThreeBase.js +31 -3
- package/src/Utils/TextureBuilder/createTextureBuilder.js +12 -3
- package/src/VisualizationContainer.js +8 -2
- package/src/index.js +2 -3
- package/visualizationAdapterCreator.js +6 -23
|
@@ -4,78 +4,57 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.VisualizationInterface = void 0;
|
|
7
|
-
|
|
8
7
|
var _Observable = _interopRequireDefault(require("./CommonUtils/Observable"));
|
|
9
|
-
|
|
10
8
|
var _Constants = require("./Constants");
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
10
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
14
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
15
|
-
|
|
16
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
17
|
-
|
|
18
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
19
|
-
|
|
13
|
+
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); }
|
|
20
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var VisualizationInterface = /*#__PURE__*/function () {
|
|
15
|
+
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); } }
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
+
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; }
|
|
18
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
19
|
+
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); }
|
|
20
|
+
var VisualizationInterface = exports.VisualizationInterface = /*#__PURE__*/function () {
|
|
29
21
|
function VisualizationInterface() {
|
|
30
22
|
var _this = this;
|
|
31
|
-
|
|
32
23
|
var cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
33
|
-
|
|
34
24
|
_classCallCheck(this, VisualizationInterface);
|
|
35
|
-
|
|
36
25
|
_defineProperty(this, "_basePath", "");
|
|
37
|
-
|
|
38
26
|
_defineProperty(this, "_itemPath", "");
|
|
39
|
-
|
|
40
27
|
_defineProperty(this, "_materialVariantPath", "");
|
|
41
|
-
|
|
42
28
|
_defineProperty(this, "_isInitialized", false);
|
|
43
|
-
|
|
44
29
|
_defineProperty(this, "_screenshottingInProgress", false);
|
|
45
|
-
|
|
46
30
|
_defineProperty(this, "observable", new _Observable["default"](this));
|
|
47
|
-
|
|
48
31
|
_defineProperty(this, "dispatchErrorEvent", function (data) {
|
|
49
32
|
_this.observable.dispatch(_Constants.EventTypes.Error, data);
|
|
50
33
|
});
|
|
51
|
-
|
|
52
34
|
_defineProperty(this, "onLoadError", function (url) {
|
|
53
|
-
var errorMessage = "Could not load file: ".concat(url);
|
|
54
|
-
|
|
35
|
+
var errorMessage = "Could not load file: ".concat(url);
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
55
37
|
console.error(errorMessage);
|
|
56
|
-
|
|
57
38
|
_this.observable.dispatch(_Constants.EventTypes.LoadError, {
|
|
58
39
|
url: url,
|
|
59
40
|
screenshot: !!_this._screenshottingInProgress
|
|
60
41
|
});
|
|
61
42
|
});
|
|
62
|
-
|
|
63
43
|
_defineProperty(this, "onLoadStart", function () {
|
|
64
44
|
return _this.observable.dispatch(_Constants.EventTypes.LoadStart, {
|
|
65
45
|
screenshot: !!_this._screenshottingInProgress
|
|
66
46
|
});
|
|
67
47
|
});
|
|
68
|
-
|
|
69
48
|
_defineProperty(this, "onLoadFinished", function () {
|
|
70
49
|
return _this.observable.dispatch(_Constants.EventTypes.LoadFinished, {
|
|
71
50
|
screenshot: !!_this._screenshottingInProgress
|
|
72
51
|
});
|
|
73
52
|
});
|
|
74
|
-
|
|
75
53
|
if (cfg.basePath) {
|
|
76
54
|
this.setBasePath(cfg.basePath);
|
|
77
55
|
}
|
|
78
56
|
}
|
|
57
|
+
|
|
79
58
|
/**
|
|
80
59
|
* Initializes the visualization
|
|
81
60
|
* This function is called from the container component.
|
|
@@ -84,11 +63,10 @@ var VisualizationInterface = /*#__PURE__*/function () {
|
|
|
84
63
|
* @param {boolean} [useDefaultSetup]
|
|
85
64
|
*/
|
|
86
65
|
// eslint-disable-next-line no-unused-vars
|
|
87
|
-
|
|
88
|
-
|
|
89
66
|
_createClass(VisualizationInterface, [{
|
|
90
67
|
key: "init",
|
|
91
68
|
value: function init(container, useDefaultSetup) {}
|
|
69
|
+
|
|
92
70
|
/**
|
|
93
71
|
* Adds the visualization element to the container
|
|
94
72
|
* This function is called from the container component, when the visualization is already initialized.
|
|
@@ -97,7 +75,6 @@ var VisualizationInterface = /*#__PURE__*/function () {
|
|
|
97
75
|
* @param container
|
|
98
76
|
*/
|
|
99
77
|
// eslint-disable-next-line no-unused-vars
|
|
100
|
-
|
|
101
78
|
}, {
|
|
102
79
|
key: "addToContainer",
|
|
103
80
|
value: function addToContainer(container) {}
|
|
@@ -106,23 +83,23 @@ var VisualizationInterface = /*#__PURE__*/function () {
|
|
|
106
83
|
value: function isInitialized() {
|
|
107
84
|
return this._isInitialized;
|
|
108
85
|
}
|
|
86
|
+
|
|
109
87
|
/**
|
|
110
88
|
* Sets the base path for loading models
|
|
111
89
|
* @see getModelPaths
|
|
112
90
|
* @param {string} path
|
|
113
91
|
*/
|
|
114
|
-
|
|
115
92
|
}, {
|
|
116
93
|
key: "setBasePath",
|
|
117
94
|
value: function setBasePath(path) {
|
|
118
95
|
this._basePath = path;
|
|
119
96
|
}
|
|
97
|
+
|
|
120
98
|
/**
|
|
121
99
|
* Sets the item path for loading models
|
|
122
100
|
* @see getModelPaths
|
|
123
101
|
* @param {string} path
|
|
124
102
|
*/
|
|
125
|
-
|
|
126
103
|
}, {
|
|
127
104
|
key: "setItemPath",
|
|
128
105
|
value: function setItemPath(path) {
|
|
@@ -134,12 +111,12 @@ var VisualizationInterface = /*#__PURE__*/function () {
|
|
|
134
111
|
this.setItemPath(path);
|
|
135
112
|
return this.loadModel();
|
|
136
113
|
}
|
|
114
|
+
|
|
137
115
|
/**
|
|
138
116
|
* Sets the material variant path for loading models
|
|
139
117
|
* @see getModelPaths
|
|
140
118
|
* @param {string} path
|
|
141
119
|
*/
|
|
142
|
-
|
|
143
120
|
}, {
|
|
144
121
|
key: "setMaterialVariantPath",
|
|
145
122
|
value: function setMaterialVariantPath(path) {
|
|
@@ -151,12 +128,12 @@ var VisualizationInterface = /*#__PURE__*/function () {
|
|
|
151
128
|
this.setMaterialVariantPath(path);
|
|
152
129
|
return this.updateMaterial();
|
|
153
130
|
}
|
|
131
|
+
|
|
154
132
|
/**
|
|
155
133
|
* A helper function to split the given relative url to path and fileName parts
|
|
156
134
|
* @param {string|{path: string, fileName: string}} value
|
|
157
135
|
* @returns {{path: string, fileName: string}}
|
|
158
136
|
*/
|
|
159
|
-
|
|
160
137
|
}, {
|
|
161
138
|
key: "getPathAndFileName",
|
|
162
139
|
value: function getPathAndFileName(value) {
|
|
@@ -164,19 +141,17 @@ var VisualizationInterface = /*#__PURE__*/function () {
|
|
|
164
141
|
return value;
|
|
165
142
|
} else if (typeof value === "string") {
|
|
166
143
|
var matches = value.match(/(.*\/)?([^/]+)$/);
|
|
167
|
-
|
|
168
144
|
if (matches) {
|
|
169
145
|
return {
|
|
170
146
|
path: matches[1],
|
|
171
147
|
fileName: matches[2]
|
|
172
148
|
};
|
|
173
149
|
}
|
|
174
|
-
|
|
175
150
|
throw new Error("Could not match path and filename for the string: '".concat(value, "', is it a valid path?"));
|
|
176
151
|
}
|
|
177
|
-
|
|
178
152
|
throw new Error("Unknown path value type given in getPathAndFileName. " + "It should be a string or an object { path, fileName }");
|
|
179
153
|
}
|
|
154
|
+
|
|
180
155
|
/**
|
|
181
156
|
* Sets the canvas size
|
|
182
157
|
* @param {number} width
|
|
@@ -184,42 +159,42 @@ var VisualizationInterface = /*#__PURE__*/function () {
|
|
|
184
159
|
* @param {boolean} rerender
|
|
185
160
|
*/
|
|
186
161
|
// eslint-disable-next-line no-unused-vars
|
|
187
|
-
|
|
188
162
|
}, {
|
|
189
163
|
key: "setSize",
|
|
190
164
|
value: function setSize(_ref) {
|
|
191
165
|
var width = _ref.width,
|
|
192
|
-
|
|
166
|
+
height = _ref.height;
|
|
193
167
|
var rerender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
194
168
|
}
|
|
169
|
+
|
|
195
170
|
/**
|
|
196
171
|
* Loads the model from the pre-configured paths
|
|
197
172
|
* Implement this function to load resources and add them to the visualization.
|
|
198
173
|
* @see updateItemPath
|
|
199
174
|
* @see setItemPath
|
|
200
175
|
*/
|
|
201
|
-
|
|
202
176
|
}, {
|
|
203
177
|
key: "loadModel",
|
|
204
178
|
value: function loadModel() {}
|
|
179
|
+
|
|
205
180
|
/**
|
|
206
181
|
* Updates the material on the model
|
|
207
182
|
* Implement this function to load a material and apply it on the visualization object.
|
|
208
183
|
* @see updateMaterialVariantPath
|
|
209
184
|
* @see setMaterialVariantPath
|
|
210
185
|
*/
|
|
211
|
-
|
|
212
186
|
}, {
|
|
213
187
|
key: "updateMaterial",
|
|
214
188
|
value: function updateMaterial() {}
|
|
189
|
+
|
|
215
190
|
/**
|
|
216
191
|
* Handle updates of design area list if needed in the custom implementation
|
|
217
192
|
*/
|
|
218
193
|
// eslint-disable-next-line no-unused-vars
|
|
219
|
-
|
|
220
194
|
}, {
|
|
221
195
|
key: "updateDesignAreaList",
|
|
222
196
|
value: function updateDesignAreaList(designAreaList) {}
|
|
197
|
+
|
|
223
198
|
/**
|
|
224
199
|
* Calls the given drawing function for custom drawing implementations
|
|
225
200
|
* It provides the drawing context (among with other custom parameters if needed) in the callback function.
|
|
@@ -228,7 +203,6 @@ var VisualizationInterface = /*#__PURE__*/function () {
|
|
|
228
203
|
* @param {boolean} clearTexture Indicates that the texture has to be cleared before drawing
|
|
229
204
|
* @param {string|undefined} materialName Request for a specific material texture context
|
|
230
205
|
*/
|
|
231
|
-
|
|
232
206
|
}, {
|
|
233
207
|
key: "getDrawingContext",
|
|
234
208
|
value: function getDrawingContext(drawingFn) {
|
|
@@ -236,10 +210,10 @@ var VisualizationInterface = /*#__PURE__*/function () {
|
|
|
236
210
|
var clearTexture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
237
211
|
var materialName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
238
212
|
}
|
|
213
|
+
|
|
239
214
|
/**
|
|
240
215
|
* Redraw the visualization
|
|
241
216
|
*/
|
|
242
|
-
|
|
243
217
|
}, {
|
|
244
218
|
key: "render",
|
|
245
219
|
value: function render() {}
|
|
@@ -260,25 +234,20 @@ var VisualizationInterface = /*#__PURE__*/function () {
|
|
|
260
234
|
*/
|
|
261
235
|
// eslint-disable-next-line no-unused-vars
|
|
262
236
|
function () {
|
|
263
|
-
var _getScreenshots = _asyncToGenerator( /*#__PURE__*/
|
|
264
|
-
return
|
|
265
|
-
while (1) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
case "end":
|
|
272
|
-
return _context.stop();
|
|
273
|
-
}
|
|
237
|
+
var _getScreenshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(callback, options) {
|
|
238
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
239
|
+
while (1) switch (_context.prev = _context.next) {
|
|
240
|
+
case 0:
|
|
241
|
+
callback && callback(null);
|
|
242
|
+
case 1:
|
|
243
|
+
case "end":
|
|
244
|
+
return _context.stop();
|
|
274
245
|
}
|
|
275
246
|
}, _callee);
|
|
276
247
|
}));
|
|
277
|
-
|
|
278
248
|
function getScreenshots(_x, _x2) {
|
|
279
249
|
return _getScreenshots.apply(this, arguments);
|
|
280
250
|
}
|
|
281
|
-
|
|
282
251
|
return getScreenshots;
|
|
283
252
|
}()
|
|
284
253
|
/**
|
|
@@ -286,13 +255,9 @@ var VisualizationInterface = /*#__PURE__*/function () {
|
|
|
286
255
|
* The implementation has to free all the allocated resources including the removal of the element appended
|
|
287
256
|
* to the container, if there is any
|
|
288
257
|
*/
|
|
289
|
-
|
|
290
258
|
}, {
|
|
291
259
|
key: "dispose",
|
|
292
260
|
value: function dispose() {}
|
|
293
261
|
}]);
|
|
294
|
-
|
|
295
262
|
return VisualizationInterface;
|
|
296
|
-
}();
|
|
297
|
-
|
|
298
|
-
exports.VisualizationInterface = VisualizationInterface;
|
|
263
|
+
}();
|
package/VisualizationProvider.js
CHANGED
|
@@ -4,35 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.withVisualization = exports.VisualizationProvider = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
|
-
|
|
9
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
14
10
|
var VisualizationContext = /*#__PURE__*/_react["default"].createContext({
|
|
15
11
|
visualization: null
|
|
16
12
|
});
|
|
17
|
-
|
|
18
|
-
var VisualizationProvider = function VisualizationProvider(_ref) {
|
|
13
|
+
var VisualizationProvider = exports.VisualizationProvider = function VisualizationProvider(_ref) {
|
|
19
14
|
var visualization = _ref.visualization,
|
|
20
|
-
|
|
15
|
+
children = _ref.children;
|
|
21
16
|
return /*#__PURE__*/_react["default"].createElement(VisualizationContext.Provider, {
|
|
22
17
|
value: {
|
|
23
18
|
visualization: visualization
|
|
24
19
|
}
|
|
25
20
|
}, children);
|
|
26
21
|
};
|
|
27
|
-
|
|
28
|
-
exports.VisualizationProvider = VisualizationProvider;
|
|
29
|
-
|
|
30
|
-
var withVisualization = function withVisualization(Component) {
|
|
22
|
+
var withVisualization = exports.withVisualization = function withVisualization(Component) {
|
|
31
23
|
return function (props) {
|
|
32
24
|
return /*#__PURE__*/_react["default"].createElement(VisualizationContext.Consumer, null, function (state) {
|
|
33
25
|
return /*#__PURE__*/_react["default"].createElement(Component, _extends({}, state, props));
|
|
34
26
|
});
|
|
35
27
|
};
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
exports.withVisualization = withVisualization;
|
|
28
|
+
};
|
package/index.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("react-
|
|
4
|
-
|
|
5
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
6
|
-
|
|
3
|
+
var _client = require("react-dom/client");
|
|
7
4
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
|
|
9
5
|
var _DevApp = _interopRequireDefault(require("./DevApp"));
|
|
10
|
-
|
|
11
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
-
|
|
13
7
|
var container = document.createElement("div");
|
|
14
8
|
document.body.appendChild(container);
|
|
15
|
-
|
|
16
|
-
_reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(_DevApp["default"], null), container);
|
|
9
|
+
(0, _client.createRoot)(container).render( /*#__PURE__*/_react["default"].createElement(_DevApp["default"], null));
|
package/package.json
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redhotmagma-visualization",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@babel/polyfill": "^7.12.1",
|
|
9
|
-
"@configuratorware/scripts": "1.
|
|
9
|
+
"@configuratorware/scripts": "1.42.0",
|
|
10
10
|
"@tweenjs/tween.js": "^17.6.0",
|
|
11
11
|
"console-polyfill": "^0.3.0",
|
|
12
12
|
"css-element-queries": "^1.2.3",
|
|
13
|
+
"lodash": "^4.17.21",
|
|
13
14
|
"prop-types": "^15.7.2",
|
|
14
|
-
"react": "^16.14.0",
|
|
15
|
-
"react-dom": "^16.14.0",
|
|
16
15
|
"three": "^0.127.0",
|
|
17
16
|
"uuid": "^3.4.0"
|
|
18
17
|
},
|
|
19
18
|
"peerDependencies": {
|
|
20
|
-
"
|
|
19
|
+
"react": "^18.2.0 || ^16.14.0",
|
|
20
|
+
"react-dom": "^18.2.0 || ^16.14.0"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"copy-public": "node ./scripts/cpPublic.js",
|
|
24
24
|
"postinstall": "npm run copy-public"
|
|
25
|
-
}
|
|
26
|
-
"readme": "# redhotmagma-visualization\n\n## setup for development\n1. follow the \"preparation\", \"install\" and \"start development\" steps in frontend/README.md\n1. open the dev app in the browser: http://localhost:3003\n\n## development\n1. new features:\n - consider adding a demo to the dev app\n - write tests (if possible, interacting with the canvas element is not supported yet)\n1. CRs:\n - test the affected functionalities in the dev app\n - write tests and adjust existing ones if needed\n"
|
|
25
|
+
}
|
|
27
26
|
}
|
package/scripts/cpPublicLocal.js
CHANGED
|
@@ -18,13 +18,18 @@ const { cpDirDeep } = require("@configuratorware/scripts/utils/fileSystem");
|
|
|
18
18
|
|
|
19
19
|
const runnerPackagePublicDir = path.resolve(process.env.PNPM_SCRIPT_SRC_DIR, "public");
|
|
20
20
|
|
|
21
|
+
const src = path.resolve(__dirname, "../public");
|
|
22
|
+
|
|
23
|
+
if (src === runnerPackagePublicDir) {
|
|
24
|
+
console.log("Copying public content skipped due to identical target directory");
|
|
25
|
+
process.exit();
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
if (fs.existsSync(runnerPackagePublicDir)) {
|
|
22
29
|
console.log(
|
|
23
30
|
"\x1b[37m\x1b[42m%s\x1b[0m",
|
|
24
31
|
"Copying public content into the public directory of the local package"
|
|
25
32
|
);
|
|
26
33
|
|
|
27
|
-
const src = path.resolve(__dirname, "../public");
|
|
28
|
-
|
|
29
34
|
cpDirDeep(src, runnerPackagePublicDir, { testFn: src => /public\/(libs|hdr)/.test(src) });
|
|
30
35
|
}
|
|
@@ -144,6 +144,23 @@ export const createPointerEventListener = (element, name, fn) => {
|
|
|
144
144
|
};
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
+
export const createMouseMoveListener = (element, { onEnter, onMove, onLeave }) => {
|
|
148
|
+
const enterHandler = (...args) => {
|
|
149
|
+
onEnter && onEnter(...args);
|
|
150
|
+
onMove && element.addEventListener("mousemove", onMove);
|
|
151
|
+
};
|
|
152
|
+
const leaveHandler = (...args) => {
|
|
153
|
+
onLeave && onLeave(...args);
|
|
154
|
+
onMove && element.removeEventListener("mousemove", onMove);
|
|
155
|
+
};
|
|
156
|
+
element.addEventListener("mouseenter", enterHandler);
|
|
157
|
+
element.addEventListener("mouseleave", leaveHandler);
|
|
158
|
+
return () => {
|
|
159
|
+
element.removeEventListener("mouseenter", enterHandler);
|
|
160
|
+
element.removeEventListener("mouseleave", leaveHandler);
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
|
|
147
164
|
/**
|
|
148
165
|
* Helper function to get the distance of two points
|
|
149
166
|
* @param {number} x1
|
package/src/Constants.js
CHANGED
package/src/DevApp.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { hot } from "react-hot-loader/root";
|
|
2
1
|
import React, { Fragment, useEffect, useState } from "react";
|
|
3
2
|
import { VisualizationProvider } from "./VisualizationProvider";
|
|
4
3
|
import VisualizationContainer from "./VisualizationContainer";
|
|
@@ -772,4 +771,4 @@ const App = () => {
|
|
|
772
771
|
);
|
|
773
772
|
};
|
|
774
773
|
|
|
775
|
-
export default
|
|
774
|
+
export default App;
|
package/src/Three/Three2D.js
CHANGED
|
@@ -14,6 +14,9 @@ import {
|
|
|
14
14
|
Vector2,
|
|
15
15
|
Vector3,
|
|
16
16
|
WebGLRenderer,
|
|
17
|
+
BufferGeometry,
|
|
18
|
+
Float32BufferAttribute,
|
|
19
|
+
DoubleSide,
|
|
17
20
|
} from "three";
|
|
18
21
|
import TWEEN from "@tweenjs/tween.js";
|
|
19
22
|
import get from "lodash/get";
|
|
@@ -543,6 +546,10 @@ export class Three2D extends ThreeBase {
|
|
|
543
546
|
mat.side = BackSide;
|
|
544
547
|
}
|
|
545
548
|
|
|
549
|
+
if (get(designArea, "baseShape.type") === "Plane") {
|
|
550
|
+
mat.side = DoubleSide;
|
|
551
|
+
}
|
|
552
|
+
|
|
546
553
|
this._customizableMaterialKeys.push(mat.name);
|
|
547
554
|
this._customizableMaterials.push(mat);
|
|
548
555
|
this._materialMap.set(designArea.identifier, mat);
|
|
@@ -643,7 +650,12 @@ export class Three2D extends ThreeBase {
|
|
|
643
650
|
getModelPathFromDesignView(designView) {
|
|
644
651
|
const images = get(designView, "images");
|
|
645
652
|
const isImageArray = images instanceof Array;
|
|
646
|
-
if (
|
|
653
|
+
if (
|
|
654
|
+
images &&
|
|
655
|
+
!isImageArray &&
|
|
656
|
+
this._materialVariantPath &&
|
|
657
|
+
images.hasOwnProperty(this._materialVariantPath)
|
|
658
|
+
) {
|
|
647
659
|
return images[this._materialVariantPath];
|
|
648
660
|
} else if (images && !isImageArray && images.hasOwnProperty(this._itemPath)) {
|
|
649
661
|
return images[this._itemPath];
|
|
@@ -990,12 +1002,104 @@ export class Three2D extends ThreeBase {
|
|
|
990
1002
|
}
|
|
991
1003
|
}
|
|
992
1004
|
|
|
1005
|
+
const createGridGeometryBuffer = ({ width, height, baseShape }) => {
|
|
1006
|
+
const halfSizeX = 0.5 * width;
|
|
1007
|
+
const halfSizeY = 0.5 * height;
|
|
1008
|
+
|
|
1009
|
+
const points = baseShape?.points;
|
|
1010
|
+
|
|
1011
|
+
const { pA, pB, pC, pD } = points
|
|
1012
|
+
? {
|
|
1013
|
+
pA: new Vector2(points.pA.x, points.pA.y),
|
|
1014
|
+
pB: new Vector2(points.pB.x, points.pB.y),
|
|
1015
|
+
pC: new Vector2(points.pC.x, points.pC.y),
|
|
1016
|
+
pD: new Vector2(points.pD.x, points.pD.y),
|
|
1017
|
+
}
|
|
1018
|
+
: {
|
|
1019
|
+
pA: new Vector2(-halfSizeX, -halfSizeY),
|
|
1020
|
+
pB: new Vector2(halfSizeX, -halfSizeY),
|
|
1021
|
+
pC: new Vector2(halfSizeX, halfSizeY),
|
|
1022
|
+
pD: new Vector2(-halfSizeX, halfSizeY),
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
const pAD = new Vector2();
|
|
1026
|
+
const pBC = new Vector2();
|
|
1027
|
+
|
|
1028
|
+
const p = new Vector2();
|
|
1029
|
+
|
|
1030
|
+
const gridSize = 12;
|
|
1031
|
+
|
|
1032
|
+
const vertices = [];
|
|
1033
|
+
const normals = [];
|
|
1034
|
+
const uvs = [];
|
|
1035
|
+
const indices = [];
|
|
1036
|
+
|
|
1037
|
+
for (let i = 0; i <= gridSize; i++) {
|
|
1038
|
+
pAD.lerpVectors(pA, pD, i / gridSize);
|
|
1039
|
+
pBC.lerpVectors(pB, pC, i / gridSize);
|
|
1040
|
+
|
|
1041
|
+
for (let j = 0; j <= gridSize; j++) {
|
|
1042
|
+
p.lerpVectors(pAD, pBC, j / gridSize);
|
|
1043
|
+
|
|
1044
|
+
vertices.push(p.x, p.y, 0);
|
|
1045
|
+
normals.push(0, 0, 1);
|
|
1046
|
+
uvs.push(j / gridSize, i / gridSize);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
for (let i = 0; i < gridSize; i++) {
|
|
1051
|
+
for (let j = 0; j < gridSize; j++) {
|
|
1052
|
+
const a = i * (gridSize + 1) + (j + 1);
|
|
1053
|
+
const b = i * (gridSize + 1) + j;
|
|
1054
|
+
const c = (i + 1) * (gridSize + 1) + j;
|
|
1055
|
+
const d = (i + 1) * (gridSize + 1) + (j + 1);
|
|
1056
|
+
|
|
1057
|
+
// generate two faces (triangles) of a tile
|
|
1058
|
+
indices.push(d, b, a); // face one
|
|
1059
|
+
indices.push(d, c, b); // face two
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
const geometry = new BufferGeometry();
|
|
1064
|
+
geometry.setIndex(indices);
|
|
1065
|
+
geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
|
|
1066
|
+
geometry.setAttribute("normal", new Float32BufferAttribute(normals, 3));
|
|
1067
|
+
geometry.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
|
|
1068
|
+
|
|
1069
|
+
geometry.getControlPoints = () => ({
|
|
1070
|
+
pA,
|
|
1071
|
+
pB,
|
|
1072
|
+
pC,
|
|
1073
|
+
pD,
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
geometry.update = () => {
|
|
1077
|
+
vertices.length = 0;
|
|
1078
|
+
for (let i = 0; i <= gridSize; i++) {
|
|
1079
|
+
pAD.lerpVectors(pA, pD, i / gridSize);
|
|
1080
|
+
pBC.lerpVectors(pB, pC, i / gridSize);
|
|
1081
|
+
|
|
1082
|
+
for (let j = 0; j <= gridSize; j++) {
|
|
1083
|
+
p.lerpVectors(pAD, pBC, j / gridSize);
|
|
1084
|
+
vertices.push(p.x, p.y, 0);
|
|
1085
|
+
geometry.attributes.position.setXYZ((gridSize + 1) * i + j, p.x, p.y, 0);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
geometry.attributes.position.needsUpdate = true;
|
|
1089
|
+
};
|
|
1090
|
+
|
|
1091
|
+
return geometry;
|
|
1092
|
+
};
|
|
1093
|
+
|
|
993
1094
|
const createBaseShapeGeometry = designArea => {
|
|
994
1095
|
const { baseShape } = designArea;
|
|
995
1096
|
const { type } = baseShape;
|
|
996
1097
|
switch (type) {
|
|
997
1098
|
case "Plane": {
|
|
998
1099
|
const { width, height } = getDesignAreaCanvasSize(designArea);
|
|
1100
|
+
if (baseShape.useControlPoints) {
|
|
1101
|
+
return createGridGeometryBuffer({ width, height, baseShape });
|
|
1102
|
+
}
|
|
999
1103
|
return new PlaneGeometry(width, height, 1, 1);
|
|
1000
1104
|
}
|
|
1001
1105
|
case "Cylinder": {
|