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
package/src/Three/ThreeBase.js
CHANGED
|
@@ -11,7 +11,11 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import TWEEN from "@tweenjs/tween.js";
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
createMouseMoveListener,
|
|
16
|
+
createPointerHitListener,
|
|
17
|
+
getPointFromPointerEvent,
|
|
18
|
+
} from "../CommonUtils/pointerEvent";
|
|
15
19
|
import { VisualizationInterface } from "../VisualizationInterface";
|
|
16
20
|
import { EventTypes } from "../Constants";
|
|
17
21
|
import { removeObject } from "../Utils/removeObject";
|
|
@@ -114,6 +118,10 @@ export class ThreeBase extends VisualizationInterface {
|
|
|
114
118
|
this.setSize(size, false);
|
|
115
119
|
}
|
|
116
120
|
|
|
121
|
+
getContainer() {
|
|
122
|
+
return this._container;
|
|
123
|
+
}
|
|
124
|
+
|
|
117
125
|
/**
|
|
118
126
|
* Creates the paths for loading a model (object + material)
|
|
119
127
|
* @returns {{objPath: string, mtlPath: string}}
|
|
@@ -294,10 +302,14 @@ export class ThreeBase extends VisualizationInterface {
|
|
|
294
302
|
endAnimation = () => this.cameraTweenGroup.getAll().forEach(item => item.end());
|
|
295
303
|
|
|
296
304
|
render() {
|
|
297
|
-
if (this._disableRender) {
|
|
305
|
+
if (this._disableRender || !this._isInitialized) {
|
|
298
306
|
return;
|
|
299
307
|
}
|
|
300
|
-
|
|
308
|
+
try {
|
|
309
|
+
this.renderer && this.renderer.render(this.scene, this.camera);
|
|
310
|
+
} catch (e) {
|
|
311
|
+
console.error("Rendering failed with the following error:", e);
|
|
312
|
+
}
|
|
301
313
|
}
|
|
302
314
|
|
|
303
315
|
isAnimating() {
|
|
@@ -331,6 +343,22 @@ export class ThreeBase extends VisualizationInterface {
|
|
|
331
343
|
this.observable.dispatch(is ? EventTypes.Intersection : EventTypes.ClickAway, is);
|
|
332
344
|
}
|
|
333
345
|
});
|
|
346
|
+
|
|
347
|
+
createMouseMoveListener(element, {
|
|
348
|
+
onMove: evt => {
|
|
349
|
+
if (!this._hitTestEnabled) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const is = this.getIntersection(evt);
|
|
353
|
+
this.observable.dispatch(is ? EventTypes.HoverIn : EventTypes.HoverOut, is);
|
|
354
|
+
},
|
|
355
|
+
onLeave: () => {
|
|
356
|
+
if (!this._hitTestEnabled) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
this.observable.dispatch(EventTypes.HoverOut);
|
|
360
|
+
},
|
|
361
|
+
});
|
|
334
362
|
}
|
|
335
363
|
|
|
336
364
|
/**
|
|
@@ -37,9 +37,18 @@ export const createTextureBuilder = (textureImage, params = {}) => {
|
|
|
37
37
|
const { width, height, scaling } = calculateDesignAreaSize(designArea);
|
|
38
38
|
|
|
39
39
|
const effectCanvas = new EffectCanvas(width, height);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
try {
|
|
41
|
+
await drawToContext(effectCanvas.ctx, 0, 0, width, height, {
|
|
42
|
+
currentZoom,
|
|
43
|
+
});
|
|
44
|
+
} catch (e) {
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.error(
|
|
47
|
+
"Transfering design to the visualization failed due to the following error.",
|
|
48
|
+
e
|
|
49
|
+
);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
43
52
|
if (effect && effect !== "print") {
|
|
44
53
|
await effectCanvas.applyEffect(effect, {
|
|
45
54
|
getSvg,
|
|
@@ -108,19 +108,25 @@ export class VisualizationContainer extends React.Component {
|
|
|
108
108
|
const { autoDispose, visualization } = this.props;
|
|
109
109
|
autoDispose && visualization.dispose();
|
|
110
110
|
this.resizeSensor && this.resizeSensor.detach();
|
|
111
|
+
this.offObservers && this.offObservers();
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
initVisualization(container) {
|
|
114
115
|
const { visualization } = this.props;
|
|
115
116
|
visualization.init(container);
|
|
116
|
-
visualization.observable.on(
|
|
117
|
+
const offLoadError = visualization.observable.on(
|
|
117
118
|
VisualizationEventTypes.LoadError,
|
|
118
119
|
({ data: { screenshot } }) => !screenshot && this.setState({ broken: true })
|
|
119
120
|
);
|
|
120
|
-
visualization.observable.on(
|
|
121
|
+
const offLoadFinished = visualization.observable.on(
|
|
121
122
|
VisualizationEventTypes.LoadFinished,
|
|
122
123
|
({ data: { screenshot } }) => !screenshot && this.setState({ broken: false })
|
|
123
124
|
);
|
|
125
|
+
this.offObservers = () => {
|
|
126
|
+
offLoadError();
|
|
127
|
+
offLoadFinished();
|
|
128
|
+
delete this.offObservers;
|
|
129
|
+
};
|
|
124
130
|
}
|
|
125
131
|
|
|
126
132
|
onSizeChange = size => {
|
package/src/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import "react-
|
|
2
|
-
import ReactDOM from "react-dom";
|
|
1
|
+
import { createRoot } from "react-dom/client";
|
|
3
2
|
import React from "react";
|
|
4
3
|
|
|
5
4
|
import DevApp from "DevApp";
|
|
6
5
|
|
|
7
6
|
const container = document.createElement("div");
|
|
8
7
|
document.body.appendChild(container);
|
|
9
|
-
|
|
8
|
+
createRoot(container).render(<DevApp />);
|
|
@@ -3,41 +3,26 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.createVisualizationAdapter = exports.createAdapterConfig = void 0;
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
11
|
-
|
|
12
9
|
var _ReactBase = require("./React/ReactBase");
|
|
13
|
-
|
|
14
10
|
var _Three2DLayers = require("./Three/Three2DLayers");
|
|
15
|
-
|
|
16
11
|
var _Three3DScene = require("./Three/Three3DScene");
|
|
17
|
-
|
|
18
12
|
var _Three2D = require("./Three/Three2D");
|
|
19
|
-
|
|
20
13
|
var _Three3D = require("./Three/Three3D");
|
|
21
|
-
|
|
22
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
-
|
|
24
|
-
var createVisualizationAdapter = function createVisualizationAdapter(adapterConfig, target) {
|
|
15
|
+
var createVisualizationAdapter = exports.createVisualizationAdapter = function createVisualizationAdapter(adapterConfig, target) {
|
|
25
16
|
var cfg = adapterConfig[target];
|
|
26
|
-
|
|
27
17
|
if (!cfg) {
|
|
28
18
|
throw new Error("No adapter configuration for the following target: ".concat(target));
|
|
29
19
|
}
|
|
30
|
-
|
|
31
20
|
var Adapter = cfg.adapterClass;
|
|
32
|
-
|
|
33
21
|
if (Adapter) {
|
|
34
22
|
return new Adapter(cfg);
|
|
35
23
|
}
|
|
36
24
|
};
|
|
37
|
-
|
|
38
|
-
exports.createVisualizationAdapter = createVisualizationAdapter;
|
|
39
|
-
|
|
40
|
-
var createAdapterConfig = function createAdapterConfig(_ref) {
|
|
25
|
+
var createAdapterConfig = exports.createAdapterConfig = function createAdapterConfig(_ref) {
|
|
41
26
|
var host = _ref.host;
|
|
42
27
|
var overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
43
28
|
return (0, _merge["default"])({
|
|
@@ -45,14 +30,14 @@ var createAdapterConfig = function createAdapterConfig(_ref) {
|
|
|
45
30
|
adapterClass: _Three2D.Three2D,
|
|
46
31
|
modelBasePath: host,
|
|
47
32
|
basePath: "".concat(host, "/images/item/view") // only for conventional urls
|
|
48
|
-
|
|
49
33
|
},
|
|
34
|
+
|
|
50
35
|
"2dVariantOverlay": {
|
|
51
36
|
adapterClass: _Three2D.Three2D,
|
|
52
37
|
modelBasePath: host,
|
|
53
38
|
basePath: "".concat(host, "/images/item/view") // only for conventional urls
|
|
54
|
-
|
|
55
39
|
},
|
|
40
|
+
|
|
56
41
|
"2dLayer": {
|
|
57
42
|
adapterClass: _Three2DLayers.Three2DLayers,
|
|
58
43
|
modelBasePath: host
|
|
@@ -77,6 +62,4 @@ var createAdapterConfig = function createAdapterConfig(_ref) {
|
|
|
77
62
|
}
|
|
78
63
|
}
|
|
79
64
|
}, overrides);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
exports.createAdapterConfig = createAdapterConfig;
|
|
65
|
+
};
|