redhotmagma-visualization 1.28.4 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/AlignTargetProvider.js +129 -0
  2. package/CommonUtils/Deferred.js +135 -0
  3. package/CommonUtils/Observable.js +126 -0
  4. package/CommonUtils/PropertyObserver.js +61 -0
  5. package/CommonUtils/SyncCurrentFunction.js +59 -0
  6. package/CommonUtils/SyncObservableEvent.js +19 -0
  7. package/CommonUtils/pointerEvent.js +415 -0
  8. package/Constants.js +23 -0
  9. package/DevApp.js +1049 -0
  10. package/ExposedModules.js +26 -0
  11. package/FallbackVisualization.js +26 -0
  12. package/PrintingEffects/ColorEmbossingEffect.js +58 -0
  13. package/PrintingEffects/DomingEffect.js +150 -0
  14. package/PrintingEffects/EmbossingEffect.js +65 -0
  15. package/PrintingEffects/EmbroideryEffect.js +541 -0
  16. package/PrintingEffects/EngravingEffect.js +65 -0
  17. package/PrintingEffects/PrintingEffects.js +117 -0
  18. package/PrintingEffects/PrintingEffectsUtils.js +53 -0
  19. package/PrintingEffects/resources/embroidery_multiply.jpg +0 -0
  20. package/PrintingEffects/resources/embroidery_screen.jpg +0 -0
  21. package/README.md +11 -4
  22. package/React/ReactBase.js +111 -0
  23. package/Three/Controls/OrbitControls.js +745 -0
  24. package/Three/Exporters/glTFExporter.js +48 -0
  25. package/Three/Loaders/ColladaLoader.js +2916 -0
  26. package/Three/Loaders/MTLLoader.js +449 -0
  27. package/Three/Loaders/OBJLoader.js +548 -0
  28. package/Three/Three2D.js +1790 -0
  29. package/Three/Three2DLayers.js +504 -0
  30. package/Three/Three3D.js +1412 -0
  31. package/Three/Three3DScene.js +1432 -0
  32. package/Three/ThreeBase.js +724 -0
  33. package/Utils/DesignArea/getDesignAreaCanvasSize.js +32 -0
  34. package/Utils/TextureBuilder/createTextureBuilder.js +334 -0
  35. package/Utils/TextureBuilder/textureBuilderFunctions.js +87 -0
  36. package/Utils/alignToElement.js +58 -0
  37. package/Utils/createAlphaMapFromAlphaChannel.js +50 -0
  38. package/Utils/createCache.js +46 -0
  39. package/Utils/createCanvas.js +29 -0
  40. package/Utils/createImageRepository.js +124 -0
  41. package/Utils/disposeMaterial.js +41 -0
  42. package/Utils/getImageSize.js +15 -0
  43. package/Utils/imagePreloader.js +76 -0
  44. package/Utils/initTextureCanvas.js +49 -0
  45. package/Utils/isMobileDevice.js +19 -0
  46. package/Utils/optimizeTextureImage.js +73 -0
  47. package/Utils/rememberCameraViewOffset.js +21 -0
  48. package/Utils/removeObject.js +22 -0
  49. package/Utils/restrictCameraMovement.js +45 -0
  50. package/Utils/setOrthographicCameraSize.js +16 -0
  51. package/Utils/updateFitSizeToElement.js +39 -0
  52. package/VisualizationContainer.js +279 -0
  53. package/VisualizationInterface.js +298 -0
  54. package/VisualizationProvider.js +38 -0
  55. package/__mocks__/exportedSample.svg +45 -0
  56. package/index.js +16 -0
  57. package/package.json +10 -70
  58. package/scripts/cpPublic.js +9 -12
  59. package/scripts/cpPublicLocal.js +30 -0
  60. package/src/CommonUtils/Observable.js +1 -0
  61. package/src/CommonUtils/pointerEvent.js +2 -1
  62. package/src/DevApp.js +2 -1
  63. package/src/FallbackVisualization.js +1 -5
  64. package/src/PrintingEffects/DomingEffect.js +1 -0
  65. package/src/PrintingEffects/EmbroideryEffect.js +3 -2
  66. package/src/React/ReactBase.js +1 -1
  67. package/src/Three/Controls/OrbitControls.js +2 -0
  68. package/src/Three/Loaders/ColladaLoader.js +111 -294
  69. package/src/Three/Loaders/MTLLoader.js +2 -0
  70. package/src/Three/Loaders/OBJLoader.js +2 -0
  71. package/src/Three/Three2D.js +18 -11
  72. package/src/Three/Three3D.js +9 -1
  73. package/src/Three/ThreeBase.js +14 -2
  74. package/src/Utils/DesignArea/getDesignAreaCanvasSize.js +1 -0
  75. package/src/Utils/TextureBuilder/createTextureBuilder.js +2 -0
  76. package/src/Utils/imagePreloader.js +1 -0
  77. package/src/Utils/initTextureCanvas.js +3 -0
  78. package/src/Utils/isMobileDevice.js +2 -0
  79. package/src/Utils/optimizeTextureImage.js +1 -0
  80. package/src/VisualizationContainer.js +3 -1
  81. package/src/VisualizationInterface.js +10 -1
  82. package/visualizationAdapterCreator.js +76 -0
  83. package/babel.config.js +0 -41
  84. package/scripts/cpPath.js +0 -151
  85. package/scripts/moveLibToPackageRoot.js +0 -44
  86. package/scripts/utils/fileSystem.js +0 -69
  87. package/scripts/utils/process.js +0 -19
  88. package/tsconfig.json +0 -22
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EffectCanvas = void 0;
7
+
8
+ var _EmbossingEffect = require("./EmbossingEffect");
9
+
10
+ var _EngravingEffect = require("./EngravingEffect");
11
+
12
+ var _DomingEffect = require("./DomingEffect");
13
+
14
+ var _EmbroideryEffect = require("./EmbroideryEffect");
15
+
16
+ var _createCanvas = require("../Utils/createCanvas");
17
+
18
+ var _ColorEmbossingEffect = require("./ColorEmbossingEffect");
19
+
20
+ 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); } }
21
+
22
+ 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); }); }; }
23
+
24
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
25
+
26
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
27
+
28
+ 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); }
29
+
30
+ 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; }
31
+
32
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
33
+
34
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
35
+
36
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
37
+
38
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
39
+
40
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
41
+
42
+ var EffectCanvas = /*#__PURE__*/function () {
43
+ function EffectCanvas(width, height) {
44
+ _classCallCheck(this, EffectCanvas);
45
+
46
+ var _createWorkingCanvas = (0, _createCanvas.createWorkingCanvas)({
47
+ width: width,
48
+ height: height
49
+ }),
50
+ _createWorkingCanvas2 = _slicedToArray(_createWorkingCanvas, 2),
51
+ canvas = _createWorkingCanvas2[0],
52
+ ctx = _createWorkingCanvas2[1];
53
+
54
+ this.canvas = canvas;
55
+ this.ctx = ctx;
56
+ }
57
+
58
+ _createClass(EffectCanvas, [{
59
+ key: "applyEffect",
60
+ value: function () {
61
+ var _applyEffect = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(effect) {
62
+ var options,
63
+ effectFn,
64
+ _args = arguments;
65
+ return regeneratorRuntime.wrap(function _callee$(_context) {
66
+ while (1) {
67
+ switch (_context.prev = _context.next) {
68
+ case 0:
69
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
70
+ effectFn = {
71
+ embossing: _EmbossingEffect.embossingEffect,
72
+ engraving: _EngravingEffect.engravingEffect,
73
+ doming: _DomingEffect.domingEffect,
74
+ embroidery: _EmbroideryEffect.embroideryEffect,
75
+ color_embossing: _ColorEmbossingEffect.colorEmbossingEffect
76
+ }[effect];
77
+ _context.t0 = effectFn;
78
+
79
+ if (!_context.t0) {
80
+ _context.next = 7;
81
+ break;
82
+ }
83
+
84
+ _context.next = 6;
85
+ return effectFn(this.canvas, options);
86
+
87
+ case 6:
88
+ _context.t0 = _context.sent;
89
+
90
+ case 7:
91
+ return _context.abrupt("return", _context.t0);
92
+
93
+ case 8:
94
+ case "end":
95
+ return _context.stop();
96
+ }
97
+ }
98
+ }, _callee, this);
99
+ }));
100
+
101
+ function applyEffect(_x) {
102
+ return _applyEffect.apply(this, arguments);
103
+ }
104
+
105
+ return applyEffect;
106
+ }()
107
+ }, {
108
+ key: "drawOn",
109
+ value: function drawOn(ctx) {
110
+ ctx.drawImage(this.canvas, 0, 0);
111
+ }
112
+ }]);
113
+
114
+ return EffectCanvas;
115
+ }();
116
+
117
+ exports.EffectCanvas = EffectCanvas;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getNewCanvas = getNewCanvas;
7
+ exports.createBackgroundCanvas = createBackgroundCanvas;
8
+ exports.createNegativeCanvas = createNegativeCanvas;
9
+ exports.createShadowCanvas = createShadowCanvas;
10
+
11
+ function getNewCanvas(width, height) {
12
+ var canvas = document.createElement("canvas");
13
+ canvas.width = width;
14
+ canvas.height = height;
15
+ return canvas;
16
+ }
17
+
18
+ function createBackgroundCanvas(baseCanvas, fillColor, canvasWidth, canvasHeight) {
19
+ var backgroundCanvas = getNewCanvas(canvasWidth, canvasHeight);
20
+ var backgroundContext = backgroundCanvas.getContext("2d");
21
+ backgroundContext.drawImage(baseCanvas, 0, 0);
22
+ backgroundContext.globalCompositeOperation = "source-in";
23
+ backgroundContext.fillStyle = fillColor;
24
+ backgroundContext.fillRect(0, 0, canvasWidth, canvasHeight);
25
+ return backgroundCanvas;
26
+ }
27
+
28
+ function createNegativeCanvas(baseCanvas, fillColor, canvasWidth, canvasHeight) {
29
+ var negativeCanvas = getNewCanvas(canvasWidth, canvasHeight);
30
+ var negativeContext = negativeCanvas.getContext("2d");
31
+ negativeContext.fillStyle = fillColor;
32
+ negativeContext.fillRect(0, 0, canvasWidth, canvasHeight);
33
+ negativeContext.globalCompositeOperation = "destination-out";
34
+ negativeContext.drawImage(baseCanvas, 0, 0);
35
+ return negativeCanvas;
36
+ }
37
+
38
+ function createShadowCanvas(baseCanvas, shadows, canvasWidth, canvasHeight) {
39
+ var shadowCanvas = getNewCanvas(canvasWidth, canvasHeight);
40
+ var shadowContext = shadowCanvas.getContext("2d");
41
+
42
+ for (var i = 0; i < shadows.length; i++) {
43
+ shadowContext.shadowOffsetX = shadows[i].offsetX;
44
+ shadowContext.shadowOffsetY = shadows[i].offsetY;
45
+ shadowContext.shadowColor = shadows[i].color;
46
+ shadowContext.shadowBlur = shadows[i].blur;
47
+ shadowContext.drawImage(baseCanvas, 0, 0);
48
+ }
49
+
50
+ shadowContext.globalCompositeOperation = "destination-out";
51
+ shadowContext.drawImage(baseCanvas, 0, 0);
52
+ return shadowCanvas;
53
+ }
package/README.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # redhotmagma-visualization
2
2
 
3
- ## Setup for Development
4
- 1. Install NodeJs `> 8.x`
5
- 2. `npm install`
6
- 3. `npm start`
3
+ ## setup for development
4
+ 1. follow the "preparation", "install" and "start development" steps in frontend/README.md
5
+ 1. open the dev app in the browser: http://localhost:3003
6
+
7
+ ## development
8
+ 1. new features:
9
+ - consider adding a demo to the dev app
10
+ - write tests (if possible, interacting with the canvas element is not supported yet)
11
+ 1. CRs:
12
+ - test the affected functionalities in the dev app
13
+ - write tests and adjust existing ones if needed
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ReactBase = void 0;
9
+
10
+ var _reactDom = _interopRequireDefault(require("react-dom"));
11
+
12
+ var _react = _interopRequireDefault(require("react"));
13
+
14
+ var _VisualizationInterface = require("../VisualizationInterface");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
+
18
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
+
20
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
21
+
22
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
23
+
24
+ function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } 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(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
25
+
26
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
27
+
28
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
29
+
30
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
31
+
32
+ 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); }; }
33
+
34
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
35
+
36
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
37
+
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
+
40
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
41
+
42
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
43
+
44
+ var NoComponent = function NoComponent() {
45
+ return null;
46
+ };
47
+ /**
48
+ * A base class for React based visualizations which renders the given Component in the container element
49
+ */
50
+
51
+
52
+ var ReactBase = /*#__PURE__*/function (_VisualizationInterfa) {
53
+ _inherits(ReactBase, _VisualizationInterfa);
54
+
55
+ var _super = _createSuper(ReactBase);
56
+
57
+ function ReactBase(cfg) {
58
+ var _this;
59
+
60
+ _classCallCheck(this, ReactBase);
61
+
62
+ _this = _super.call(this, cfg);
63
+
64
+ _defineProperty(_assertThisInitialized(_this), "_container", null);
65
+
66
+ _defineProperty(_assertThisInitialized(_this), "Component", NoComponent);
67
+
68
+ if (cfg.Component) {
69
+ _this.Component = cfg.Component;
70
+ }
71
+
72
+ return _this;
73
+ }
74
+
75
+ _createClass(ReactBase, [{
76
+ key: "init",
77
+ value: function init() {
78
+ var container = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.createElement("div");
79
+ this._isInitialized = true;
80
+ this._container = container;
81
+ this.render();
82
+ }
83
+ }, {
84
+ key: "addToContainer",
85
+ value: function addToContainer(container) {
86
+ this._container = container;
87
+ this.render();
88
+ }
89
+ }, {
90
+ key: "render",
91
+ value: function render() {
92
+ var Component = this.Component,
93
+ _container = this._container;
94
+
95
+ _reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(Component, null), _container);
96
+ }
97
+ }, {
98
+ key: "dispose",
99
+ value: function dispose() {
100
+ _get(_getPrototypeOf(ReactBase.prototype), "dispose", this).call(this);
101
+
102
+ if (this._container) {
103
+ _reactDom["default"].unmountComponentAtNode(this._container);
104
+ }
105
+ }
106
+ }]);
107
+
108
+ return ReactBase;
109
+ }(_VisualizationInterface.VisualizationInterface);
110
+
111
+ exports.ReactBase = ReactBase;