lythreeframe 1.0.30 → 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;
@@ -2162,8 +2172,8 @@ class ThreeJsApp {
2162
2172
  // }
2163
2173
  this.camera.updateProjectionMatrix();
2164
2174
  }
2165
- renderAsImage() {
2166
- return this.viewport.renderAsImage();
2175
+ renderAsImage(width = 1024, height = 1024) {
2176
+ return this.viewport.renderAsImage(width, height);
2167
2177
  }
2168
2178
  }
2169
2179
 
@@ -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;
@@ -2160,8 +2170,8 @@ class ThreeJsApp {
2160
2170
  // }
2161
2171
  this.camera.updateProjectionMatrix();
2162
2172
  }
2163
- renderAsImage() {
2164
- return this.viewport.renderAsImage();
2173
+ renderAsImage(width = 1024, height = 1024) {
2174
+ return this.viewport.renderAsImage(width, height);
2165
2175
  }
2166
2176
  }
2167
2177
 
@@ -29,5 +29,5 @@ export declare class ThreeJsApp {
29
29
  destroy(): void;
30
30
  updateCamera(param: CameraParam): void;
31
31
  onWindowResize(width: number, height: number): void;
32
- renderAsImage(): string;
32
+ renderAsImage(width?: number, height?: number): string;
33
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",