lythreeframe 1.0.31 → 1.0.33
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/bundle.cjs.js
CHANGED
|
@@ -1664,16 +1664,31 @@ class Viewport {
|
|
|
1664
1664
|
}
|
|
1665
1665
|
this.isRenderStateDirty = false;
|
|
1666
1666
|
}
|
|
1667
|
-
renderAsImage(width = 1024, height = 1024) {
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1667
|
+
async renderAsImage(width = 1024, height = 1024) {
|
|
1668
|
+
return new Promise((resolve, reject) => {
|
|
1669
|
+
try {
|
|
1670
|
+
if (this.postProcessing) {
|
|
1671
|
+
this.postProcessing.render();
|
|
1672
|
+
}
|
|
1673
|
+
else {
|
|
1674
|
+
this.renderer.render(this.app.world.scene, this.app.camera);
|
|
1675
|
+
}
|
|
1676
|
+
const offscreenCanvas = document.createElement('canvas');
|
|
1677
|
+
offscreenCanvas.width = width;
|
|
1678
|
+
offscreenCanvas.height = height;
|
|
1679
|
+
const context = offscreenCanvas.getContext('2d');
|
|
1680
|
+
if (!context) {
|
|
1681
|
+
throw Error("Can not create context");
|
|
1682
|
+
}
|
|
1683
|
+
context.drawImage(this.renderer.domElement, 0, 0, width, height);
|
|
1684
|
+
const ret = offscreenCanvas.toDataURL('image/jpeg');
|
|
1685
|
+
offscreenCanvas.remove();
|
|
1686
|
+
resolve(ret);
|
|
1687
|
+
}
|
|
1688
|
+
catch (error) {
|
|
1689
|
+
reject(error);
|
|
1690
|
+
}
|
|
1691
|
+
});
|
|
1677
1692
|
}
|
|
1678
1693
|
destroy() {
|
|
1679
1694
|
var _a;
|
|
@@ -2162,8 +2177,8 @@ class ThreeJsApp {
|
|
|
2162
2177
|
// }
|
|
2163
2178
|
this.camera.updateProjectionMatrix();
|
|
2164
2179
|
}
|
|
2165
|
-
renderAsImage(width = 1024, height = 1024) {
|
|
2166
|
-
return this.viewport.renderAsImage(width, height);
|
|
2180
|
+
async renderAsImage(width = 1024, height = 1024) {
|
|
2181
|
+
return await this.viewport.renderAsImage(width, height);
|
|
2167
2182
|
}
|
|
2168
2183
|
}
|
|
2169
2184
|
|
package/dist/bundle.esm.js
CHANGED
|
@@ -1662,16 +1662,31 @@ class Viewport {
|
|
|
1662
1662
|
}
|
|
1663
1663
|
this.isRenderStateDirty = false;
|
|
1664
1664
|
}
|
|
1665
|
-
renderAsImage(width = 1024, height = 1024) {
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1665
|
+
async renderAsImage(width = 1024, height = 1024) {
|
|
1666
|
+
return new Promise((resolve, reject) => {
|
|
1667
|
+
try {
|
|
1668
|
+
if (this.postProcessing) {
|
|
1669
|
+
this.postProcessing.render();
|
|
1670
|
+
}
|
|
1671
|
+
else {
|
|
1672
|
+
this.renderer.render(this.app.world.scene, this.app.camera);
|
|
1673
|
+
}
|
|
1674
|
+
const offscreenCanvas = document.createElement('canvas');
|
|
1675
|
+
offscreenCanvas.width = width;
|
|
1676
|
+
offscreenCanvas.height = height;
|
|
1677
|
+
const context = offscreenCanvas.getContext('2d');
|
|
1678
|
+
if (!context) {
|
|
1679
|
+
throw Error("Can not create context");
|
|
1680
|
+
}
|
|
1681
|
+
context.drawImage(this.renderer.domElement, 0, 0, width, height);
|
|
1682
|
+
const ret = offscreenCanvas.toDataURL('image/jpeg');
|
|
1683
|
+
offscreenCanvas.remove();
|
|
1684
|
+
resolve(ret);
|
|
1685
|
+
}
|
|
1686
|
+
catch (error) {
|
|
1687
|
+
reject(error);
|
|
1688
|
+
}
|
|
1689
|
+
});
|
|
1675
1690
|
}
|
|
1676
1691
|
destroy() {
|
|
1677
1692
|
var _a;
|
|
@@ -2160,8 +2175,8 @@ class ThreeJsApp {
|
|
|
2160
2175
|
// }
|
|
2161
2176
|
this.camera.updateProjectionMatrix();
|
|
2162
2177
|
}
|
|
2163
|
-
renderAsImage(width = 1024, height = 1024) {
|
|
2164
|
-
return this.viewport.renderAsImage(width, height);
|
|
2178
|
+
async renderAsImage(width = 1024, height = 1024) {
|
|
2179
|
+
return await this.viewport.renderAsImage(width, height);
|
|
2165
2180
|
}
|
|
2166
2181
|
}
|
|
2167
2182
|
|
|
@@ -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(width?: number, height?: number): string
|
|
32
|
+
renderAsImage(width?: number, height?: number): Promise<string>;
|
|
33
33
|
}
|