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
package/scripts/cpPath.js DELETED
@@ -1,151 +0,0 @@
1
- /**
2
- * This script is created to copy specific files with their folder structure
3
- * usage: node copyWithFolder.js src dst [filterRegExp]
4
- * @author boda@redhotmagma.de
5
- */
6
-
7
- const fs = require("fs");
8
-
9
- let src = null;
10
- let dst = null;
11
- let reg = null;
12
-
13
- process.argv.forEach(function(val, index) {
14
- switch (index) {
15
- case 2:
16
- src = val;
17
- break;
18
- case 3:
19
- dst = val;
20
- break;
21
- case 4:
22
- reg = new RegExp(val);
23
- }
24
- });
25
-
26
- if (!src || !fs.existsSync(src)) {
27
- throw new Error("src must be an existing directory");
28
- }
29
- if (!dst || !fs.existsSync(dst)) {
30
- throw new Error("dst must be an existing directory");
31
- }
32
-
33
- function walk(path, cb) {
34
- try {
35
- const files = fs.readdirSync(path);
36
- for (const f of files) {
37
- const cf = path + "/" + f;
38
- const s = fs.lstatSync(cf);
39
- cb(cf);
40
- s.isDirectory() && walk(cf, cb);
41
- }
42
- } catch (e) {
43
- return;
44
- }
45
- }
46
-
47
- function copyWithParent(src, dst) {
48
- if (typeof dst === "function") {
49
- dst = dst(src);
50
- }
51
- createDirDeep(dst.replace(/\/[^/]+$/, ""));
52
- console.log(src + " -> " + dst);
53
- const fileExt = src.replace(/.+\.([\w]+)$/, "$1");
54
- switch (fileExt) {
55
- case "scss":
56
- fs.readFile(src, "utf8", function read(err, data) {
57
- if (err) {
58
- throw err;
59
- }
60
- const modifiedContent = prepareSassFile(src, data);
61
- fs.writeFile(dst, modifiedContent, "utf8", function write(err) {
62
- if (err) {
63
- throw err;
64
- }
65
- });
66
- });
67
- break;
68
- default:
69
- fs.createReadStream(src).pipe(fs.createWriteStream(dst));
70
- }
71
- }
72
-
73
- function prepareSassFile(src, content) {
74
- if (!content || !content.match) {
75
- console.log("Strange file: " + src);
76
- return content;
77
- }
78
- const replaceImports = content.match(/@import ['"][^.~].+/g);
79
- let output = content;
80
- if (replaceImports) {
81
- const pathUp =
82
- ".." +
83
- src
84
- .match(/src\/.+/)[0]
85
- .match(/\//g)
86
- .splice(1)
87
- .join("..");
88
- for (let i in replaceImports) {
89
- const pathToImport = replaceImports[i].replace(/@import ['"][/]?([^'"]+).*/, "$1");
90
- const resolverPath = pathUp + pathToImport;
91
-
92
- const srcPathDir = src.replace(/\/[^/]+$/, "/");
93
- const relativeImportPath = srcPathDir + pathToImport;
94
- const rootImportPath = srcPathDir + resolverPath;
95
-
96
- let resolveRootImport = false;
97
- try {
98
- fs.accessSync(relativeImportPath);
99
- } catch (err) {
100
- try {
101
- fs.accessSync(relativeImportPath + ".scss");
102
- } catch (err) {
103
- try {
104
- fs.accessSync(rootImportPath);
105
- resolveRootImport = true;
106
- } catch (err) {
107
- try {
108
- fs.accessSync(rootImportPath + ".scss");
109
- resolveRootImport = true;
110
- } catch (err) {
111
- throw "Cannot resolve import path: " + replaceImports[i] + " in " + src;
112
- }
113
- }
114
- }
115
- }
116
- if (resolveRootImport) {
117
- console.log("Resolved root import in " + src + ": " + pathToImport + " -> " + resolverPath);
118
- const resolvedImport = replaceImports[i].replace(
119
- /(@import ['"])[^'"]+(.*)/,
120
- "$1" + resolverPath + "$2"
121
- );
122
- output = output.replace(replaceImports[i], resolvedImport);
123
- }
124
- }
125
- }
126
- return output;
127
- }
128
-
129
- function createDirDeep(path) {
130
- const ps = path.split("/");
131
- let dir = ps.splice(0, 1);
132
- for (const p of ps) {
133
- dir = [dir, p].join("/");
134
- if (!fs.existsSync(dir)) {
135
- fs.mkdirSync(dir);
136
- }
137
- }
138
- }
139
-
140
- console.log(
141
- "\x1b[37m\x1b[42m%s\x1b[0m",
142
- "Copying files from " + src + " to " + dst + (reg ? " with filter: " + reg : " without filter")
143
- );
144
-
145
- walk(src, function(f) {
146
- if (reg === null || (reg && reg.test(f))) {
147
- copyWithParent(f, function(path) {
148
- return dst + path.replace(src, "");
149
- });
150
- }
151
- });
@@ -1,44 +0,0 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const rimraf = require("rimraf");
4
- const { isDependency } = require('./utils/process');
5
-
6
- function walk(dir, cb, cbAfter) {
7
- try {
8
- const files = fs.readdirSync(dir);
9
- for (const f of files) {
10
- const cf = path.resolve(dir, f);
11
- const s = fs.lstatSync(cf);
12
- cb && cb(cf);
13
- s.isDirectory() && walk(cf, cb, cbAfter);
14
- cbAfter && cbAfter(cf);
15
- }
16
- } catch (e) {
17
- return;
18
- }
19
- }
20
-
21
- if (isDependency()) {
22
- console.log(
23
- "\x1b[37m\x1b[42m%s\x1b[0m",
24
- "Moving content of lib into the root package directory"
25
- );
26
-
27
- const src = path.resolve(__dirname, "../", "lib");
28
- const dst = path.resolve(__dirname, "../");
29
- walk(src, function(file) {
30
- const relativePath = file.replace(src, "");
31
- const tp = path.resolve(dst + relativePath);
32
- if (fs.statSync(file).isFile()) {
33
- fs.createReadStream(file).pipe(fs.createWriteStream(tp));
34
- } else {
35
- fs.mkdirSync(tp);
36
- }
37
- });
38
-
39
- rimraf(src, function(err) {
40
- if (err) {
41
- console.log("Error occured while clearing the directory: " + src, err);
42
- }
43
- });
44
- }
@@ -1,69 +0,0 @@
1
- /* eslint no-console: 0 */
2
-
3
- /**
4
- * These utils are made to simplify more complex fs operations for the node scripts.
5
- *
6
- * @author boda@redhotmagma.de
7
- */
8
-
9
- const fs = require('fs');
10
- const path = require('path');
11
-
12
- function mkDirDeep(dst) {
13
- const ps = dst.split(/[/\\]/);
14
- let dir = ps.splice(0, 1);
15
- for (const p of ps) {
16
- dir = [dir, p].join('/');
17
- if (!fs.existsSync(dir)) {
18
- console.log('Create directory:', dir);
19
- fs.mkdirSync(dir);
20
- }
21
- }
22
- }
23
-
24
- function walkDir(dir, cb, cbAfter) {
25
- const files = fs.readdirSync(dir);
26
- for (const f of files) {
27
- const cf = dir + '/' + f;
28
- const s = fs.lstatSync(cf);
29
- cb && cb(cf);
30
- s.isDirectory() && walkDir(cf, cb, cbAfter);
31
- cbAfter && cbAfter(cf);
32
- }
33
- }
34
-
35
- function cpDirDeep(src, dst, testFn) {
36
- mkDirDeep(dst);
37
-
38
- walkDir(src, function(file) {
39
- const relativePath = file.replace(src, '');
40
- const tp = path.resolve(dst + relativePath);
41
- if (testFn && !testFn(file, tp)) {
42
- return;
43
- }
44
- if (fs.statSync(file).isFile()) {
45
- console.log('Copy file: ' + file + ' -> ' + tp);
46
- fs.createReadStream(file).pipe(fs.createWriteStream(tp));
47
- } else if (!fs.existsSync(tp)) {
48
- fs.mkdirSync(tp);
49
- }
50
- });
51
- }
52
-
53
- const testMatchers = {
54
- keepIfExists: matcher => (src, dst) => {
55
- if (!(matcher instanceof RegExp)) {
56
- throw new Error('matcher must be a RegExp!');
57
- }
58
- const result = !matcher.test(dst) || !fs.existsSync(dst);
59
- !result && console.log('Keep existing file: ' + dst + ' > keepIfExists: ' + matcher);
60
- return result;
61
- },
62
- };
63
-
64
- module.exports = {
65
- mkDirDeep,
66
- walkDir,
67
- cpDirDeep,
68
- testMatchers,
69
- };
@@ -1,19 +0,0 @@
1
- /**
2
- * These utils are made to simplify querying process information for the node scripts.
3
- *
4
- * @author boda@redhotmagma.de
5
- */
6
-
7
- /**
8
- * Checks if the current installation process is a dependency installation
9
- * @return {boolean}
10
- */
11
- function isDependency() {
12
- // if the path of the initial directory contains 'node_modules', it's probably installed as a dependency
13
- const { INIT_CWD } = process.env;
14
- return INIT_CWD.indexOf('node_modules') !== -1;
15
- }
16
-
17
- module.exports = {
18
- isDependency,
19
- };
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // Target latest version of ECMAScript.
4
- "target": "esnext",
5
- // Search under node_modules for non-relative imports.
6
- "moduleResolution": "node",
7
- // Process & infer types from .js files.
8
- "allowJs": true,
9
- // Don't emit; allow Babel to transform files.
10
- "noEmit": true,
11
- // Enable strictest settings like strictNullChecks & noImplicitAny.
12
- "strict": true,
13
- // Disallow features that require cross-file information for emit.
14
- "isolatedModules": true,
15
- // Import non-ES modules as default imports.
16
- "esModuleInterop": true
17
- },
18
- "include": [
19
- "./src",
20
- "./node_modules/redhotmagma-graphics-editor"
21
- ]
22
- }