redhotmagma-visualization 1.28.3 → 1.29.1
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 +129 -0
- package/CommonUtils/Deferred.js +135 -0
- package/CommonUtils/Observable.js +126 -0
- package/CommonUtils/PropertyObserver.js +61 -0
- package/CommonUtils/SyncCurrentFunction.js +59 -0
- package/CommonUtils/SyncObservableEvent.js +19 -0
- package/CommonUtils/pointerEvent.js +415 -0
- package/Constants.js +23 -0
- package/DevApp.js +1049 -0
- package/ExposedModules.js +26 -0
- package/FallbackVisualization.js +26 -0
- package/PrintingEffects/ColorEmbossingEffect.js +58 -0
- package/PrintingEffects/DomingEffect.js +150 -0
- package/PrintingEffects/EmbossingEffect.js +65 -0
- package/PrintingEffects/EmbroideryEffect.js +541 -0
- package/PrintingEffects/EngravingEffect.js +65 -0
- package/PrintingEffects/PrintingEffects.js +117 -0
- package/PrintingEffects/PrintingEffectsUtils.js +53 -0
- package/PrintingEffects/resources/embroidery_multiply.jpg +0 -0
- package/PrintingEffects/resources/embroidery_screen.jpg +0 -0
- package/README.md +11 -4
- package/React/ReactBase.js +111 -0
- package/Three/Controls/OrbitControls.js +745 -0
- package/Three/Exporters/glTFExporter.js +48 -0
- package/Three/Loaders/ColladaLoader.js +2916 -0
- package/Three/Loaders/MTLLoader.js +449 -0
- package/Three/Loaders/OBJLoader.js +548 -0
- package/Three/Three2D.js +1790 -0
- package/Three/Three2DLayers.js +504 -0
- package/Three/Three3D.js +1412 -0
- package/Three/Three3DScene.js +1432 -0
- package/Three/ThreeBase.js +724 -0
- package/Utils/DesignArea/getDesignAreaCanvasSize.js +32 -0
- package/Utils/TextureBuilder/createTextureBuilder.js +334 -0
- package/Utils/TextureBuilder/textureBuilderFunctions.js +87 -0
- package/Utils/alignToElement.js +58 -0
- package/Utils/createAlphaMapFromAlphaChannel.js +50 -0
- package/Utils/createCache.js +46 -0
- package/Utils/createCanvas.js +29 -0
- package/Utils/createImageRepository.js +124 -0
- package/Utils/disposeMaterial.js +41 -0
- package/Utils/getImageSize.js +15 -0
- package/Utils/imagePreloader.js +76 -0
- package/Utils/initTextureCanvas.js +49 -0
- package/Utils/isMobileDevice.js +19 -0
- package/Utils/optimizeTextureImage.js +73 -0
- package/Utils/rememberCameraViewOffset.js +21 -0
- package/Utils/removeObject.js +22 -0
- package/Utils/restrictCameraMovement.js +45 -0
- package/Utils/setOrthographicCameraSize.js +16 -0
- package/Utils/updateFitSizeToElement.js +39 -0
- package/VisualizationContainer.js +279 -0
- package/VisualizationInterface.js +298 -0
- package/VisualizationProvider.js +38 -0
- package/__mocks__/exportedSample.svg +45 -0
- package/index.js +16 -0
- package/package.json +10 -70
- package/scripts/cpPublic.js +9 -12
- package/scripts/cpPublicLocal.js +30 -0
- package/src/CommonUtils/Observable.js +1 -0
- package/src/CommonUtils/pointerEvent.js +2 -1
- package/src/DevApp.js +2 -1
- package/src/FallbackVisualization.js +1 -5
- package/src/PrintingEffects/DomingEffect.js +1 -0
- package/src/PrintingEffects/EmbroideryEffect.js +3 -2
- package/src/React/ReactBase.js +1 -1
- package/src/Three/Controls/OrbitControls.js +2 -0
- package/src/Three/Loaders/ColladaLoader.js +111 -294
- package/src/Three/Loaders/MTLLoader.js +2 -0
- package/src/Three/Loaders/OBJLoader.js +2 -0
- package/src/Three/Three2D.js +18 -11
- package/src/Three/Three3D.js +9 -1
- package/src/Three/ThreeBase.js +14 -2
- package/src/Utils/DesignArea/getDesignAreaCanvasSize.js +1 -0
- package/src/Utils/TextureBuilder/createTextureBuilder.js +2 -0
- package/src/Utils/imagePreloader.js +1 -0
- package/src/Utils/initTextureCanvas.js +3 -0
- package/src/Utils/isMobileDevice.js +2 -0
- package/src/Utils/optimizeTextureImage.js +1 -0
- package/src/VisualizationContainer.js +3 -1
- package/src/VisualizationInterface.js +10 -1
- package/visualizationAdapterCreator.js +76 -0
- package/babel.config.js +0 -41
- package/scripts/cpPath.js +0 -151
- package/scripts/moveLibToPackageRoot.js +0 -44
- package/scripts/utils/fileSystem.js +0 -69
- package/scripts/utils/process.js +0 -19
- package/tsconfig.json +0 -22
package/src/Three/Three2D.js
CHANGED
|
@@ -48,8 +48,7 @@ const MIN_TEXTURE_SIZE = 2048;
|
|
|
48
48
|
const MAX_TEXTURE_SIZE = 2048;
|
|
49
49
|
|
|
50
50
|
const cameraZ = 100000;
|
|
51
|
-
const
|
|
52
|
-
const cameraFar = cameraZ - planeZ + 1000;
|
|
51
|
+
const getPlaneZ = overlayMode => (overlayMode ? 100 : -100000);
|
|
53
52
|
|
|
54
53
|
export const allowZooming = (zoom, originalZoom, minZoom, maxZoom) =>
|
|
55
54
|
(originalZoom > zoom && zoom >= minZoom) || (originalZoom < zoom && zoom <= maxZoom);
|
|
@@ -74,6 +73,7 @@ export class Three2D extends ThreeBase {
|
|
|
74
73
|
_redraw = null;
|
|
75
74
|
_modelBasePath = "";
|
|
76
75
|
_modelPath = null;
|
|
76
|
+
_overlayMode = false;
|
|
77
77
|
_imageRepository = createImageRepository(
|
|
78
78
|
createCache(20),
|
|
79
79
|
src =>
|
|
@@ -96,6 +96,10 @@ export class Three2D extends ThreeBase {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
setOverlayMode(mode) {
|
|
100
|
+
this._overlayMode = mode;
|
|
101
|
+
}
|
|
102
|
+
|
|
99
103
|
createRenderer() {
|
|
100
104
|
const renderer = new WebGLRenderer({
|
|
101
105
|
alpha: true,
|
|
@@ -111,7 +115,7 @@ export class Three2D extends ThreeBase {
|
|
|
111
115
|
const { redrawOnZoomChange = false, redrawDebounceWait = 100 } = options;
|
|
112
116
|
const camera = new OrthographicCamera();
|
|
113
117
|
camera.near = 0.01;
|
|
114
|
-
camera.far =
|
|
118
|
+
camera.far = cameraZ - getPlaneZ(this._overlayMode) + 1000;
|
|
115
119
|
camera.position.set(0, 0, cameraZ);
|
|
116
120
|
redrawOnZoomChange &&
|
|
117
121
|
observeProperty(camera, "zoom", debounce(this.redraw, redrawDebounceWait));
|
|
@@ -262,6 +266,7 @@ export class Three2D extends ThreeBase {
|
|
|
262
266
|
}
|
|
263
267
|
}
|
|
264
268
|
|
|
269
|
+
// eslint-disable-next-line no-unused-vars
|
|
265
270
|
setupDefaultControls(targetElement, options = {}) {
|
|
266
271
|
this.controls = {
|
|
267
272
|
enabled: true,
|
|
@@ -327,12 +332,14 @@ export class Three2D extends ThreeBase {
|
|
|
327
332
|
await this.observable.dispatch(EventTypes.MaterialUpdated, eventParams, true);
|
|
328
333
|
}
|
|
329
334
|
|
|
335
|
+
// eslint-disable-next-line no-unused-vars
|
|
330
336
|
async updateMaterial(targetObject = this.scene) {
|
|
331
337
|
return await this.updateView(this._currentDesignView);
|
|
332
338
|
}
|
|
333
339
|
|
|
334
340
|
async _getDrawingContext(
|
|
335
341
|
drawingFn,
|
|
342
|
+
// eslint-disable-next-line no-unused-vars
|
|
336
343
|
updateAlpha = false,
|
|
337
344
|
clearTexture = false,
|
|
338
345
|
materialName = undefined
|
|
@@ -370,12 +377,7 @@ export class Three2D extends ThreeBase {
|
|
|
370
377
|
}
|
|
371
378
|
}
|
|
372
379
|
|
|
373
|
-
async getDrawingContext(
|
|
374
|
-
drawingFn,
|
|
375
|
-
updateAlpha = false,
|
|
376
|
-
clearTexture = false,
|
|
377
|
-
materialName = undefined
|
|
378
|
-
) {
|
|
380
|
+
async getDrawingContext() {
|
|
379
381
|
this._redraw = this._getDrawingContext.bind(this, ...arguments);
|
|
380
382
|
if (!this._redrawPromise) {
|
|
381
383
|
window.cancelAnimationFrame(this._redrawFrame);
|
|
@@ -453,11 +455,11 @@ export class Three2D extends ThreeBase {
|
|
|
453
455
|
|
|
454
456
|
initModelWithTexture(tex) {
|
|
455
457
|
const { width, height } = tex.originalSize;
|
|
456
|
-
const planeMaterial = new MeshBasicMaterial({ map: tex });
|
|
458
|
+
const planeMaterial = new MeshBasicMaterial({ map: tex, transparent: true });
|
|
457
459
|
|
|
458
460
|
const planeGeometry = new PlaneGeometry(width, height, 1, 1);
|
|
459
461
|
const plane = new Mesh(planeGeometry, planeMaterial);
|
|
460
|
-
plane.position.z =
|
|
462
|
+
plane.position.z = getPlaneZ(this._overlayMode);
|
|
461
463
|
|
|
462
464
|
// remove the current model first
|
|
463
465
|
this.scene.remove(this._model);
|
|
@@ -608,6 +610,7 @@ export class Three2D extends ThreeBase {
|
|
|
608
610
|
|
|
609
611
|
const designViewIdentifier = designView && designView.identifier;
|
|
610
612
|
if (!designViewIdentifier) {
|
|
613
|
+
// eslint-disable-next-line no-console
|
|
611
614
|
console.log("No design view identifier! Skipping update.");
|
|
612
615
|
return;
|
|
613
616
|
}
|
|
@@ -647,6 +650,7 @@ export class Three2D extends ThreeBase {
|
|
|
647
650
|
const containerGroup = this.createObjectsForDesignAreas(availableDesignAreas);
|
|
648
651
|
|
|
649
652
|
this._containerGroup = containerGroup;
|
|
653
|
+
this._intersectionRoot = containerGroup;
|
|
650
654
|
this.scene && this.scene.add(containerGroup);
|
|
651
655
|
|
|
652
656
|
updateMaterial && (await this.dispatchMaterialUpdateEvent());
|
|
@@ -656,6 +660,7 @@ export class Three2D extends ThreeBase {
|
|
|
656
660
|
delete this._redraw; // remove the redraw function to prevent drawing on non-existing textures
|
|
657
661
|
this.scene && this.scene.remove(this._containerGroup);
|
|
658
662
|
removeObject(this._containerGroup);
|
|
663
|
+
this._intersectionRoot = null;
|
|
659
664
|
this._customizableMaterialKeys = [];
|
|
660
665
|
this._customizableMaterials = [];
|
|
661
666
|
this._materialMap.forEach(disposeMaterial);
|
|
@@ -709,6 +714,7 @@ export class Three2D extends ThreeBase {
|
|
|
709
714
|
}
|
|
710
715
|
|
|
711
716
|
if (!this._containerGroup) {
|
|
717
|
+
// eslint-disable-next-line no-console
|
|
712
718
|
console.log(`Container group is not available, skipping jump to view!`);
|
|
713
719
|
return false;
|
|
714
720
|
}
|
|
@@ -738,6 +744,7 @@ export class Three2D extends ThreeBase {
|
|
|
738
744
|
await this.updateView(designView);
|
|
739
745
|
|
|
740
746
|
if (!this._containerGroup) {
|
|
747
|
+
// eslint-disable-next-line no-console
|
|
741
748
|
console.log(`Container group is not available, skipping jump to view!`);
|
|
742
749
|
return false;
|
|
743
750
|
}
|
package/src/Three/Three3D.js
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
Texture,
|
|
10
10
|
Spherical,
|
|
11
11
|
Vector2,
|
|
12
|
-
Vector3,
|
|
13
12
|
} from "three";
|
|
14
13
|
import TWEEN from "@tweenjs/tween.js";
|
|
15
14
|
import first from "lodash/first";
|
|
@@ -168,6 +167,7 @@ export class Three3D extends ThreeBase {
|
|
|
168
167
|
}
|
|
169
168
|
const matches = ("" + obj.name).toLowerCase().match(/(.+)_(position|lookat)$/);
|
|
170
169
|
if (!matches) {
|
|
170
|
+
// eslint-disable-next-line no-console
|
|
171
171
|
console.warn(`Camera view object skipped: ${obj.name}`);
|
|
172
172
|
continue;
|
|
173
173
|
}
|
|
@@ -248,10 +248,12 @@ export class Three3D extends ThreeBase {
|
|
|
248
248
|
*/
|
|
249
249
|
return src => {
|
|
250
250
|
if (_src === src) {
|
|
251
|
+
// eslint-disable-next-line no-console
|
|
251
252
|
console.log("Material is already loaded: " + src);
|
|
252
253
|
return promise;
|
|
253
254
|
}
|
|
254
255
|
_src = src;
|
|
256
|
+
// eslint-disable-next-line no-console
|
|
255
257
|
console.log("Loading material: " + src);
|
|
256
258
|
promise = new Promise((resolve, reject) => {
|
|
257
259
|
const { path, fileName } = this.getPathAndFileName(src);
|
|
@@ -260,6 +262,7 @@ export class Three3D extends ThreeBase {
|
|
|
260
262
|
materialCreator => {
|
|
261
263
|
const textureLoadingManager = new LoadingManager(
|
|
262
264
|
() => {
|
|
265
|
+
// eslint-disable-next-line no-console
|
|
263
266
|
console.log("All textures have been lodaed.");
|
|
264
267
|
resolve(materialCreator);
|
|
265
268
|
},
|
|
@@ -287,6 +290,7 @@ export class Three3D extends ThreeBase {
|
|
|
287
290
|
false
|
|
288
291
|
);
|
|
289
292
|
if (!isTexture) {
|
|
293
|
+
// eslint-disable-next-line no-console
|
|
290
294
|
console.log("Materials do not contain any texture.");
|
|
291
295
|
resolve(materialCreator);
|
|
292
296
|
}
|
|
@@ -338,10 +342,12 @@ export class Three3D extends ThreeBase {
|
|
|
338
342
|
}
|
|
339
343
|
|
|
340
344
|
async updateMaterial(targetObject = this.scene, options = {}) {
|
|
345
|
+
// eslint-disable-next-line no-console
|
|
341
346
|
console.log("Updating materials...");
|
|
342
347
|
const { mtlPath } = this.getModelPaths();
|
|
343
348
|
|
|
344
349
|
if (!mtlPath) {
|
|
350
|
+
// eslint-disable-next-line no-console
|
|
345
351
|
console.log("Missing material path!");
|
|
346
352
|
return;
|
|
347
353
|
}
|
|
@@ -410,6 +416,7 @@ export class Three3D extends ThreeBase {
|
|
|
410
416
|
* @param {*} materialsObj
|
|
411
417
|
*/
|
|
412
418
|
findCustomizableMaterials(materialsObj) {
|
|
419
|
+
// eslint-disable-next-line no-console
|
|
413
420
|
console.log("Looking for customizable materials...");
|
|
414
421
|
for (let key of this._customizableMaterialKeys) {
|
|
415
422
|
const mat = materialsObj[key];
|
|
@@ -516,6 +523,7 @@ export class Three3D extends ThreeBase {
|
|
|
516
523
|
const viewNameSafe = ("" + viewName).toLowerCase();
|
|
517
524
|
const view = this.cameraViews[viewNameSafe];
|
|
518
525
|
if (!view) {
|
|
526
|
+
// eslint-disable-next-line no-console
|
|
519
527
|
console.error(`Camera view does not exist: ${viewNameSafe}`);
|
|
520
528
|
return;
|
|
521
529
|
}
|
package/src/Three/ThreeBase.js
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
Mesh,
|
|
4
4
|
Vector2,
|
|
5
5
|
BoxGeometry,
|
|
6
|
-
Material,
|
|
7
6
|
MeshBasicMaterial,
|
|
8
7
|
Raycaster,
|
|
9
8
|
AxesHelper,
|
|
@@ -24,6 +23,7 @@ import Deferred from "../CommonUtils/Deferred";
|
|
|
24
23
|
export const onProgress = xhr => {
|
|
25
24
|
if (xhr.lengthComputable) {
|
|
26
25
|
const percentComplete = (xhr.loaded / xhr.total) * 100;
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
27
|
console.log(percentComplete.toFixed(2) + "% downloaded");
|
|
28
28
|
}
|
|
29
29
|
};
|
|
@@ -104,6 +104,7 @@ export class ThreeBase extends VisualizationInterface {
|
|
|
104
104
|
* @param {number} width
|
|
105
105
|
* @param {number} height
|
|
106
106
|
*/
|
|
107
|
+
// eslint-disable-next-line no-unused-vars
|
|
107
108
|
updateCamera(width, height) {}
|
|
108
109
|
|
|
109
110
|
addToContainer(container) {
|
|
@@ -166,6 +167,7 @@ export class ThreeBase extends VisualizationInterface {
|
|
|
166
167
|
* @param {HTMLElement} targetElement
|
|
167
168
|
* @param {{}} options Custom options for the controls (see the OrbitControls.js file for details)
|
|
168
169
|
*/
|
|
170
|
+
// eslint-disable-next-line no-unused-vars
|
|
169
171
|
setupDefaultControls(targetElement, options = {}) {}
|
|
170
172
|
|
|
171
173
|
addAxesHelper() {
|
|
@@ -184,6 +186,7 @@ export class ThreeBase extends VisualizationInterface {
|
|
|
184
186
|
this.controls.enabled = enabled;
|
|
185
187
|
}
|
|
186
188
|
|
|
189
|
+
// eslint-disable-next-line no-unused-vars
|
|
187
190
|
updateMaterial(targetObject = this.scene) {}
|
|
188
191
|
|
|
189
192
|
/**
|
|
@@ -224,8 +227,11 @@ export class ThreeBase extends VisualizationInterface {
|
|
|
224
227
|
*/
|
|
225
228
|
getDrawingContext(
|
|
226
229
|
drawingFn,
|
|
230
|
+
// eslint-disable-next-line no-unused-vars
|
|
227
231
|
updateAlpha = false,
|
|
232
|
+
// eslint-disable-next-line no-unused-vars
|
|
228
233
|
clearTexture = false,
|
|
234
|
+
// eslint-disable-next-line no-unused-vars
|
|
229
235
|
materialName = undefined
|
|
230
236
|
) {}
|
|
231
237
|
|
|
@@ -344,7 +350,10 @@ export class ThreeBase extends VisualizationInterface {
|
|
|
344
350
|
);
|
|
345
351
|
raycaster.setFromCamera(mouse, this.camera);
|
|
346
352
|
|
|
347
|
-
const intersects = raycaster.intersectObjects(
|
|
353
|
+
const intersects = raycaster.intersectObjects(
|
|
354
|
+
this._intersectionRoot?.children || this.scene.children,
|
|
355
|
+
true
|
|
356
|
+
);
|
|
348
357
|
if (intersects.length > 0) {
|
|
349
358
|
const intersect = intersects[0]; // closest object
|
|
350
359
|
return {
|
|
@@ -379,6 +388,7 @@ export class ThreeBase extends VisualizationInterface {
|
|
|
379
388
|
event => {
|
|
380
389
|
event.preventDefault();
|
|
381
390
|
window.cancelAnimationFrame(_this._animationFrame);
|
|
391
|
+
// eslint-disable-next-line no-console
|
|
382
392
|
console.warn("WEBGL CONTEXT LOST");
|
|
383
393
|
},
|
|
384
394
|
false
|
|
@@ -390,6 +400,7 @@ export class ThreeBase extends VisualizationInterface {
|
|
|
390
400
|
if (_this._animationFrame) {
|
|
391
401
|
_this.animate();
|
|
392
402
|
}
|
|
403
|
+
// eslint-disable-next-line no-console
|
|
393
404
|
console.warn("WEGL CONTEXT RESTORED");
|
|
394
405
|
},
|
|
395
406
|
false
|
|
@@ -446,6 +457,7 @@ export class ThreeBase extends VisualizationInterface {
|
|
|
446
457
|
this._customizableMaterials = [];
|
|
447
458
|
this._isInitialized = false;
|
|
448
459
|
|
|
460
|
+
// eslint-disable-next-line no-console
|
|
449
461
|
console.info("Three instance has been successfully disposed.");
|
|
450
462
|
}
|
|
451
463
|
|
|
@@ -9,6 +9,7 @@ export const getDesignAreaCanvasSize = designArea => {
|
|
|
9
9
|
sourceObject = position;
|
|
10
10
|
}
|
|
11
11
|
if (!sourceObject) {
|
|
12
|
+
// eslint-disable-next-line no-console
|
|
12
13
|
console.error(
|
|
13
14
|
"Incomplete design area data, baseShape and position has to be set up correctly.",
|
|
14
15
|
designArea
|
|
@@ -26,6 +26,7 @@ export const createTextureBuilder = (textureImage, params = {}) => {
|
|
|
26
26
|
}) => {
|
|
27
27
|
const { baseShape, position } = designArea;
|
|
28
28
|
if (!baseShape || !position) {
|
|
29
|
+
// eslint-disable-next-line no-console
|
|
29
30
|
console.log("No design area provided.");
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
@@ -55,6 +56,7 @@ export const createTextureBuilder = (textureImage, params = {}) => {
|
|
|
55
56
|
break;
|
|
56
57
|
}
|
|
57
58
|
default: {
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
58
60
|
console.error(`Unknown baseShape type: ${type}. Texture update will be skipped.`);
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
@@ -8,14 +8,17 @@ export function createCanvasFromImage(image) {
|
|
|
8
8
|
|
|
9
9
|
export function initTextureCanvas(texture) {
|
|
10
10
|
if (!texture.image) {
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
11
12
|
console.warn("There is no image for the given texture.", texture);
|
|
12
13
|
}
|
|
13
14
|
if (!texture.originalImage || texture.image.nodeName !== "CANVAS") {
|
|
14
15
|
const originalImage = optimizeTextureImage(texture.image);
|
|
16
|
+
// eslint-disable-next-line no-console
|
|
15
17
|
console.log(`Creating canvas from texture: ${originalImage.src}`);
|
|
16
18
|
texture.image = createCanvasFromImage(originalImage);
|
|
17
19
|
texture.originalImage = originalImage;
|
|
18
20
|
} else {
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
19
22
|
console.log(`Texture for ${texture.originalImage.src} is already prepared, skipping.`);
|
|
20
23
|
}
|
|
21
24
|
}
|
|
@@ -29,6 +29,7 @@ export const optimizeTextureImage = (image, maxTextureSize = 2048, minTextureSiz
|
|
|
29
29
|
width = height * ratio;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// eslint-disable-next-line no-console
|
|
32
33
|
console.log(
|
|
33
34
|
"Optimizing texture image for better mipmaps:",
|
|
34
35
|
`${image.width}x${image.height} -> ${width}x${height}`
|
|
@@ -51,6 +51,7 @@ export class VisualizationContainer extends React.Component {
|
|
|
51
51
|
const { visualization } = this.props;
|
|
52
52
|
|
|
53
53
|
if (!visualization) {
|
|
54
|
+
// eslint-disable-next-line no-console
|
|
54
55
|
console.warn("Visualization component is not provided! Visualization will not be rendered.");
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
@@ -65,7 +66,7 @@ export class VisualizationContainer extends React.Component {
|
|
|
65
66
|
this.updateVisualization();
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
componentDidUpdate(prevProps
|
|
69
|
+
componentDidUpdate(prevProps) {
|
|
69
70
|
this.updateVisualization(prevProps);
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -161,6 +162,7 @@ export class VisualizationContainer extends React.Component {
|
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
export const VisualizationContainerSwitch = props => {
|
|
165
|
+
// eslint-disable-next-line react/prop-types
|
|
164
166
|
const { visualization, VisualizationContainerComponent, FallbackComponent } = props;
|
|
165
167
|
const Component = visualization ? VisualizationContainerComponent : FallbackComponent;
|
|
166
168
|
return <Component {...props} />;
|
|
@@ -22,8 +22,9 @@ export class VisualizationInterface {
|
|
|
22
22
|
* This function is called from the container component.
|
|
23
23
|
* It provides the opportunity to add any visualization element to the container, and do initial setup if needed.
|
|
24
24
|
* @param {HTMLElement} [container=<div>]
|
|
25
|
-
* @param {boolean} useDefaultSetup
|
|
25
|
+
* @param {boolean} [useDefaultSetup]
|
|
26
26
|
*/
|
|
27
|
+
// eslint-disable-next-line no-unused-vars
|
|
27
28
|
init(container, useDefaultSetup) {}
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -33,6 +34,7 @@ export class VisualizationInterface {
|
|
|
33
34
|
* This function should add the visualization element to the container, and do other updates if needed.
|
|
34
35
|
* @param container
|
|
35
36
|
*/
|
|
37
|
+
// eslint-disable-next-line no-unused-vars
|
|
36
38
|
addToContainer(container) {}
|
|
37
39
|
|
|
38
40
|
isInitialized() {
|
|
@@ -108,6 +110,7 @@ export class VisualizationInterface {
|
|
|
108
110
|
* @param {number} height
|
|
109
111
|
* @param {boolean} rerender
|
|
110
112
|
*/
|
|
113
|
+
// eslint-disable-next-line no-unused-vars
|
|
111
114
|
setSize({ width, height }, rerender = true) {}
|
|
112
115
|
|
|
113
116
|
/**
|
|
@@ -129,6 +132,7 @@ export class VisualizationInterface {
|
|
|
129
132
|
/**
|
|
130
133
|
* Handle updates of design area list if needed in the custom implementation
|
|
131
134
|
*/
|
|
135
|
+
// eslint-disable-next-line no-unused-vars
|
|
132
136
|
updateDesignAreaList(designAreaList) {}
|
|
133
137
|
|
|
134
138
|
/**
|
|
@@ -141,8 +145,11 @@ export class VisualizationInterface {
|
|
|
141
145
|
*/
|
|
142
146
|
getDrawingContext(
|
|
143
147
|
drawingFn,
|
|
148
|
+
// eslint-disable-next-line no-unused-vars
|
|
144
149
|
updateAlpha = false,
|
|
150
|
+
// eslint-disable-next-line no-unused-vars
|
|
145
151
|
clearTexture = false,
|
|
152
|
+
// eslint-disable-next-line no-unused-vars
|
|
146
153
|
materialName = undefined
|
|
147
154
|
) {}
|
|
148
155
|
|
|
@@ -161,6 +168,7 @@ export class VisualizationInterface {
|
|
|
161
168
|
|
|
162
169
|
onLoadError = url => {
|
|
163
170
|
const errorMessage = `Could not load file: ${url}`;
|
|
171
|
+
// eslint-disable-next-line no-console
|
|
164
172
|
console.error(errorMessage);
|
|
165
173
|
this.observable.dispatch(EventTypes.LoadError, {
|
|
166
174
|
url,
|
|
@@ -185,6 +193,7 @@ export class VisualizationInterface {
|
|
|
185
193
|
* @param {function} callback The callback function should get the generated screenshots in the first arg
|
|
186
194
|
* @param {object} options The options object to pass extra data
|
|
187
195
|
*/
|
|
196
|
+
// eslint-disable-next-line no-unused-vars
|
|
188
197
|
async getScreenshots(callback, options) {
|
|
189
198
|
callback && callback(null);
|
|
190
199
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAdapterConfig = exports.createVisualizationAdapter = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
11
|
+
|
|
12
|
+
var _ReactBase = require("./React/ReactBase");
|
|
13
|
+
|
|
14
|
+
var _Three2DLayers = require("./Three/Three2DLayers");
|
|
15
|
+
|
|
16
|
+
var _Three3DScene = require("./Three/Three3DScene");
|
|
17
|
+
|
|
18
|
+
var _Three2D = require("./Three/Three2D");
|
|
19
|
+
|
|
20
|
+
var _Three3D = require("./Three/Three3D");
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
+
|
|
24
|
+
var createVisualizationAdapter = function createVisualizationAdapter(adapterConfig, target) {
|
|
25
|
+
var cfg = adapterConfig[target];
|
|
26
|
+
|
|
27
|
+
if (!cfg) {
|
|
28
|
+
throw new Error("No adapter configuration for the following target: ".concat(target));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var Adapter = cfg.adapterClass;
|
|
32
|
+
|
|
33
|
+
if (Adapter) {
|
|
34
|
+
return new Adapter(cfg);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.createVisualizationAdapter = createVisualizationAdapter;
|
|
39
|
+
|
|
40
|
+
var createAdapterConfig = function createAdapterConfig(_ref) {
|
|
41
|
+
var host = _ref.host;
|
|
42
|
+
var overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
43
|
+
return (0, _merge["default"])({
|
|
44
|
+
"2dVariant": {
|
|
45
|
+
adapterClass: _Three2D.Three2D,
|
|
46
|
+
modelBasePath: host,
|
|
47
|
+
basePath: "".concat(host, "/images/item/view") // only for conventional urls
|
|
48
|
+
|
|
49
|
+
},
|
|
50
|
+
"2dLayer": {
|
|
51
|
+
adapterClass: _Three2DLayers.Three2DLayers,
|
|
52
|
+
modelBasePath: host
|
|
53
|
+
},
|
|
54
|
+
"3dVariant": {
|
|
55
|
+
adapterClass: _Three3DScene.Three3DScene,
|
|
56
|
+
modelBasePath: host
|
|
57
|
+
},
|
|
58
|
+
"3dScene": {
|
|
59
|
+
adapterClass: _Three3DScene.Three3DScene,
|
|
60
|
+
modelBasePath: host
|
|
61
|
+
},
|
|
62
|
+
"3d": {
|
|
63
|
+
// deprecated, only for backward compatibility
|
|
64
|
+
adapterClass: _Three3D.Three3D,
|
|
65
|
+
modelBasePath: host
|
|
66
|
+
},
|
|
67
|
+
"default": {
|
|
68
|
+
adapterClass: _ReactBase.ReactBase,
|
|
69
|
+
Component: function Component() {
|
|
70
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, "No visualization");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, overrides);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
exports.createAdapterConfig = createAdapterConfig;
|
package/babel.config.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
module.exports = function(api) {
|
|
2
|
-
const presets = [
|
|
3
|
-
"@babel/preset-env",
|
|
4
|
-
"@babel/preset-typescript",
|
|
5
|
-
"@babel/preset-react" // Transpile React components to JavaScript
|
|
6
|
-
];
|
|
7
|
-
|
|
8
|
-
const plugins = [
|
|
9
|
-
"@babel/plugin-proposal-class-properties",
|
|
10
|
-
"@babel/plugin-syntax-dynamic-import",
|
|
11
|
-
|
|
12
|
-
[
|
|
13
|
-
"module-resolver",
|
|
14
|
-
{
|
|
15
|
-
root: ["./src"]
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
const ignore = [];
|
|
21
|
-
|
|
22
|
-
if (api.env("development")) {
|
|
23
|
-
plugins.push("react-hot-loader/babel"); // Enables React code to work with HMR.
|
|
24
|
-
api.cache(true);
|
|
25
|
-
} else if (api.env("production")) {
|
|
26
|
-
ignore.push(
|
|
27
|
-
"**/__tests__", // ignore the whole test directory
|
|
28
|
-
"**/*.test.js", // ignore test files only
|
|
29
|
-
"**/__mocks__"
|
|
30
|
-
);
|
|
31
|
-
api.cache(false);
|
|
32
|
-
} else {
|
|
33
|
-
api.cache(true);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
presets,
|
|
38
|
-
plugins,
|
|
39
|
-
ignore
|
|
40
|
-
};
|
|
41
|
-
};
|