lythreeframe 1.0.31 → 1.0.32

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.
@@ -1665,7 +1665,12 @@ class Viewport {
1665
1665
  this.isRenderStateDirty = false;
1666
1666
  }
1667
1667
  renderAsImage(width = 1024, height = 1024) {
1668
- this.render();
1668
+ if (this.postProcessing) {
1669
+ this.postProcessing.render();
1670
+ }
1671
+ else { //console.log("render renderer");
1672
+ this.renderer.render(this.app.world.scene, this.app.camera);
1673
+ }
1669
1674
  const offscreenCanvas = document.createElement('canvas');
1670
1675
  offscreenCanvas.width = width;
1671
1676
  offscreenCanvas.height = height;
@@ -1673,7 +1678,12 @@ class Viewport {
1673
1678
  if (context) {
1674
1679
  context.drawImage(this.renderer.domElement, 0, 0, width, height);
1675
1680
  }
1676
- return offscreenCanvas.toDataURL('image/jpeg');
1681
+ if (!context) {
1682
+ throw Error("Can not create context");
1683
+ }
1684
+ const ret = offscreenCanvas.toDataURL('image/jpeg');
1685
+ offscreenCanvas.remove();
1686
+ return ret;
1677
1687
  }
1678
1688
  destroy() {
1679
1689
  var _a;
@@ -1663,7 +1663,12 @@ class Viewport {
1663
1663
  this.isRenderStateDirty = false;
1664
1664
  }
1665
1665
  renderAsImage(width = 1024, height = 1024) {
1666
- this.render();
1666
+ if (this.postProcessing) {
1667
+ this.postProcessing.render();
1668
+ }
1669
+ else { //console.log("render renderer");
1670
+ this.renderer.render(this.app.world.scene, this.app.camera);
1671
+ }
1667
1672
  const offscreenCanvas = document.createElement('canvas');
1668
1673
  offscreenCanvas.width = width;
1669
1674
  offscreenCanvas.height = height;
@@ -1671,7 +1676,12 @@ class Viewport {
1671
1676
  if (context) {
1672
1677
  context.drawImage(this.renderer.domElement, 0, 0, width, height);
1673
1678
  }
1674
- return offscreenCanvas.toDataURL('image/jpeg');
1679
+ if (!context) {
1680
+ throw Error("Can not create context");
1681
+ }
1682
+ const ret = offscreenCanvas.toDataURL('image/jpeg');
1683
+ offscreenCanvas.remove();
1684
+ return ret;
1675
1685
  }
1676
1686
  destroy() {
1677
1687
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",