@lingbi/studio 0.3.0 → 0.3.1
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/Application.d.ts +1 -0
- package/index.js +32 -3
- package/package.json +1 -1
package/Application.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class Application {
|
|
|
12
12
|
importObjResourceScene(source: ObjResourceSceneSource): Promise<ObjImportResult>;
|
|
13
13
|
importObjScene(source: ObjSceneSource): Promise<ObjImportResult>;
|
|
14
14
|
resetView(): void;
|
|
15
|
+
takeScreenshot(): Promise<Blob>;
|
|
15
16
|
dispose(): void;
|
|
16
17
|
private assertNotDisposed;
|
|
17
18
|
private getRenderer;
|
package/index.js
CHANGED
|
@@ -31343,6 +31343,28 @@ class Renderer {
|
|
|
31343
31343
|
this.controller.reset();
|
|
31344
31344
|
this.requestRender();
|
|
31345
31345
|
}
|
|
31346
|
+
takeScreenshot() {
|
|
31347
|
+
this.assertNotDisposed();
|
|
31348
|
+
if (this.contextLost) {
|
|
31349
|
+
return Promise.reject(new Error("The WebGL context is unavailable."));
|
|
31350
|
+
}
|
|
31351
|
+
try {
|
|
31352
|
+
this.renderScene();
|
|
31353
|
+
} catch (error2) {
|
|
31354
|
+
return Promise.reject(
|
|
31355
|
+
new Error("The screenshot could not be rendered.", { cause: error2 })
|
|
31356
|
+
);
|
|
31357
|
+
}
|
|
31358
|
+
return new Promise((resolve, reject) => {
|
|
31359
|
+
this.canvas.toBlob((blob) => {
|
|
31360
|
+
if (blob === null) {
|
|
31361
|
+
reject(new Error("The screenshot could not be encoded."));
|
|
31362
|
+
return;
|
|
31363
|
+
}
|
|
31364
|
+
resolve(blob);
|
|
31365
|
+
}, "image/png");
|
|
31366
|
+
});
|
|
31367
|
+
}
|
|
31346
31368
|
assertNotDisposed() {
|
|
31347
31369
|
if (this.disposed) {
|
|
31348
31370
|
throw new Error("The renderer has been disposed.");
|
|
@@ -31520,13 +31542,16 @@ class Renderer {
|
|
|
31520
31542
|
return;
|
|
31521
31543
|
}
|
|
31522
31544
|
const animationActive = this.controller.updateAnimation(timestamp);
|
|
31523
|
-
this.
|
|
31524
|
-
this.renderer.render(this.scene, this.camera);
|
|
31525
|
-
this.renderViewCube();
|
|
31545
|
+
this.renderScene();
|
|
31526
31546
|
if (animationActive) {
|
|
31527
31547
|
this.requestRender();
|
|
31528
31548
|
}
|
|
31529
31549
|
}
|
|
31550
|
+
renderScene() {
|
|
31551
|
+
this.viewCube.update(this.camera);
|
|
31552
|
+
this.renderer.render(this.scene, this.camera);
|
|
31553
|
+
this.renderViewCube();
|
|
31554
|
+
}
|
|
31530
31555
|
renderViewCube() {
|
|
31531
31556
|
const viewport = this.viewCube.getViewport();
|
|
31532
31557
|
const previousAutoClear = this.renderer.autoClear;
|
|
@@ -31694,6 +31719,10 @@ class Application {
|
|
|
31694
31719
|
this.assertNotDisposed();
|
|
31695
31720
|
this.getRenderer().resetCamera();
|
|
31696
31721
|
}
|
|
31722
|
+
takeScreenshot() {
|
|
31723
|
+
this.assertNotDisposed();
|
|
31724
|
+
return this.getRenderer().takeScreenshot();
|
|
31725
|
+
}
|
|
31697
31726
|
dispose() {
|
|
31698
31727
|
if (this.disposed) {
|
|
31699
31728
|
return;
|