three-cad-viewer 3.0.2 → 3.0.3
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/dist/three-cad-viewer.esm.js +56 -28
- package/dist/three-cad-viewer.esm.min.js +1 -1
- package/dist/three-cad-viewer.js +56 -28
- package/dist/three-cad-viewer.min.js +1 -1
- package/package.json +1 -1
- package/src/_version.js +1 -1
- package/src/display.js +7 -0
- package/src/viewer.js +48 -27
|
@@ -57632,6 +57632,13 @@ class Display {
|
|
|
57632
57632
|
this.cadView.appendChild(cadView);
|
|
57633
57633
|
}
|
|
57634
57634
|
|
|
57635
|
+
/**
|
|
57636
|
+
* Get the DOM canvas element
|
|
57637
|
+
*/
|
|
57638
|
+
getCanvas() {
|
|
57639
|
+
return this.cadView.children[this.cadView.children.length - 1];
|
|
57640
|
+
}
|
|
57641
|
+
|
|
57635
57642
|
/**
|
|
57636
57643
|
* Clear the Cad tree
|
|
57637
57644
|
*/
|
|
@@ -63190,7 +63197,7 @@ class Camera {
|
|
|
63190
63197
|
}
|
|
63191
63198
|
}
|
|
63192
63199
|
|
|
63193
|
-
const version = "3.0.
|
|
63200
|
+
const version = "3.0.3";
|
|
63194
63201
|
|
|
63195
63202
|
class Viewer {
|
|
63196
63203
|
/**
|
|
@@ -65650,35 +65657,56 @@ class Viewer {
|
|
|
65650
65657
|
* Note: Only the canvas will be shown, no tools and orientation marker
|
|
65651
65658
|
*/
|
|
65652
65659
|
pinAsPng = () => {
|
|
65653
|
-
const
|
|
65654
|
-
|
|
65655
|
-
|
|
65656
|
-
|
|
65657
|
-
|
|
65658
|
-
|
|
65659
|
-
|
|
65660
|
-
|
|
65661
|
-
|
|
65662
|
-
|
|
65663
|
-
|
|
65664
|
-
|
|
65665
|
-
|
|
65666
|
-
|
|
65667
|
-
|
|
65668
|
-
|
|
65669
|
-
|
|
65670
|
-
|
|
65660
|
+
const screenshot = this.getImage("screenshot");
|
|
65661
|
+
screenshot.then((data) => {
|
|
65662
|
+
var image = document.createElement("img");
|
|
65663
|
+
image.width = this.cadWidth;
|
|
65664
|
+
image.height = this.height;
|
|
65665
|
+
image.src = data.dataUrl;
|
|
65666
|
+
if (this.pinAsPngCallback == null) {
|
|
65667
|
+
// default, replace the elements of the container with the image
|
|
65668
|
+
for (var c of this.display.container.children) {
|
|
65669
|
+
this.display.container.removeChild(c);
|
|
65670
|
+
}
|
|
65671
|
+
this.display.container.appendChild(image);
|
|
65672
|
+
}
|
|
65673
|
+
});
|
|
65674
|
+
};
|
|
65675
|
+
|
|
65676
|
+
/**
|
|
65677
|
+
* Get the current canvas as png data.
|
|
65678
|
+
* @function
|
|
65679
|
+
* @param {string} taksId - and id to identify the screenshot
|
|
65680
|
+
* Note: Only the canvas will be shown, no tools and orientation marker
|
|
65681
|
+
*/
|
|
65682
|
+
getImage = (taskId) => {
|
|
65683
|
+
// canvas.toBlob can be very slow when anmation loop is off!
|
|
65684
|
+
const animationLoop = this.hasAnimationLoop;
|
|
65685
|
+
if (!animationLoop) {
|
|
65686
|
+
this.toggleAnimationLoop(true);
|
|
65687
|
+
}
|
|
65688
|
+
let result = new Promise((resolve, reject) => {
|
|
65689
|
+
const canvas = this.display.getCanvas();
|
|
65690
|
+
this.renderer.setViewport(0, 0, this.cadWidth, this.height);
|
|
65691
|
+
this.renderer.render(this.scene, this.camera.getCamera());
|
|
65692
|
+
canvas.toBlob((blob) => {
|
|
65693
|
+
let reader = new FileReader();
|
|
65694
|
+
reader.addEventListener(
|
|
65695
|
+
"load",
|
|
65696
|
+
() => {
|
|
65697
|
+
resolve({ task: taskId, dataUrl: reader.result });
|
|
65698
|
+
// set animation loop back to the stored value
|
|
65699
|
+
if (!animationLoop) {
|
|
65700
|
+
this.toggleAnimationLoop(false);
|
|
65671
65701
|
}
|
|
65672
|
-
|
|
65673
|
-
|
|
65674
|
-
|
|
65675
|
-
|
|
65676
|
-
|
|
65677
|
-
},
|
|
65678
|
-
false,
|
|
65679
|
-
);
|
|
65680
|
-
reader.readAsDataURL(blob);
|
|
65702
|
+
},
|
|
65703
|
+
false,
|
|
65704
|
+
);
|
|
65705
|
+
reader.readAsDataURL(blob);
|
|
65706
|
+
});
|
|
65681
65707
|
});
|
|
65708
|
+
|
|
65709
|
+
return result;
|
|
65682
65710
|
};
|
|
65683
65711
|
|
|
65684
65712
|
/**
|