redhotmagma-visualization 1.26.5 → 1.27.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redhotmagma-visualization",
3
- "version": "1.26.5",
3
+ "version": "1.27.2",
4
4
  "license": "UNLICENSED",
5
5
  "private": false,
6
6
  "main": "./lib/index.js",
@@ -29,7 +29,7 @@
29
29
  "lodash": "^4.17.21",
30
30
  "prop-types": "^15.7.2",
31
31
  "rimraf": "^3.0.2",
32
- "three": "^0.127.0",
32
+ "three": "^0.131.3",
33
33
  "uuid": "^3.4.0"
34
34
  },
35
35
  "devDependencies": {
@@ -113,6 +113,9 @@ const getImageSrc = imageNode =>
113
113
  imageNode.getAttribute("href") || imageNode.getAttribute("xlink:href");
114
114
 
115
115
  const applyOnChildNode = (imageCanvas, ctx, svgElement) => async node => {
116
+ if (node.getAttribute("visibility") === "hidden") {
117
+ return;
118
+ }
116
119
  if (node.tagName === "image") {
117
120
  if (getImageSrc(node).startsWith(SVG_DATA_URL_HDR)) {
118
121
  await applyOnEmbeddedSvg(node, imageCanvas, ctx, svgElement);
@@ -771,6 +771,22 @@ export class Three2D extends ThreeBase {
771
771
  }
772
772
  }
773
773
 
774
+ getScreenshotSize(targetSize) {
775
+ let width = get(targetSize, "width", 1024);
776
+ let height = get(targetSize, "height", 768);
777
+ const initialRatio = width / height;
778
+ const modelRatio = this._size.width / this._size.height;
779
+ if (modelRatio > initialRatio) {
780
+ height = width / modelRatio;
781
+ } else {
782
+ width = height * modelRatio;
783
+ }
784
+ return {
785
+ width,
786
+ height,
787
+ };
788
+ }
789
+
774
790
  async getScreenshots(callback, { designViewList, areaList, variantList, size }) {
775
791
  if (!this.renderer) {
776
792
  return callback({});
@@ -794,9 +810,6 @@ export class Three2D extends ThreeBase {
794
810
 
795
811
  const screenshots = {};
796
812
 
797
- const width = get(size, "width", 1024);
798
- const height = get(size, "height", 768);
799
-
800
813
  // store the original camera, variant and renderer size
801
814
  const origVariantPath = this._materialVariantPath;
802
815
  const origSize = new Vector2();
@@ -816,7 +829,6 @@ export class Three2D extends ThreeBase {
816
829
  };
817
830
 
818
831
  const camera = this.createCameraBase();
819
- setOrthographicCameraSize(camera, width, height);
820
832
  this._screenshotCamera = camera;
821
833
 
822
834
  const views = designViewList || designAreaList.map(({ designView }) => designView);
@@ -838,6 +850,9 @@ export class Three2D extends ThreeBase {
838
850
  updateMaterial: false,
839
851
  });
840
852
 
853
+ const { width, height } = this.getScreenshotSize(size);
854
+ setOrthographicCameraSize(camera, width, height);
855
+
841
856
  this.renderer.setSize(width, height);
842
857
  this.renderer.setPixelRatio(1);
843
858
  camera.zoom = this.getZoomForSize({ width, height });
@@ -120,9 +120,6 @@ export class Three2DLayers extends Three2D {
120
120
 
121
121
  const screenshots = {};
122
122
 
123
- const width = get(size, "width", 1024);
124
- const height = get(size, "height", 768);
125
-
126
123
  // store the original values for restoring afterwards
127
124
  const origDesignView = this.getCurrentDesignView();
128
125
  const origCamera = this.camera;
@@ -144,7 +141,6 @@ export class Three2DLayers extends Three2D {
144
141
  };
145
142
 
146
143
  const camera = this.createCameraBase();
147
- setOrthographicCameraSize(camera, width, height);
148
144
  this._screenshotCamera = camera;
149
145
 
150
146
  const views =
@@ -160,6 +156,10 @@ export class Three2DLayers extends Three2D {
160
156
 
161
157
  try {
162
158
  await this.updateView(view);
159
+
160
+ const { width, height } = this.getScreenshotSize(size);
161
+ setOrthographicCameraSize(camera, width, height);
162
+
163
163
  this.renderer.setSize(width, height);
164
164
  this.renderer.setPixelRatio(1);
165
165