@lingbi/studio 0.3.0 → 0.3.2
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 +37 -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,29 @@ 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
|
+
this.cancelScheduledRender();
|
|
31352
|
+
try {
|
|
31353
|
+
this.renderScene(false);
|
|
31354
|
+
} catch (error2) {
|
|
31355
|
+
return Promise.reject(
|
|
31356
|
+
new Error("The screenshot could not be rendered.", { cause: error2 })
|
|
31357
|
+
);
|
|
31358
|
+
}
|
|
31359
|
+
return new Promise((resolve, reject) => {
|
|
31360
|
+
this.canvas.toBlob((blob) => {
|
|
31361
|
+
if (blob === null) {
|
|
31362
|
+
reject(new Error("The screenshot could not be encoded."));
|
|
31363
|
+
return;
|
|
31364
|
+
}
|
|
31365
|
+
resolve(blob);
|
|
31366
|
+
}, "image/png");
|
|
31367
|
+
});
|
|
31368
|
+
}
|
|
31346
31369
|
assertNotDisposed() {
|
|
31347
31370
|
if (this.disposed) {
|
|
31348
31371
|
throw new Error("The renderer has been disposed.");
|
|
@@ -31520,13 +31543,20 @@ class Renderer {
|
|
|
31520
31543
|
return;
|
|
31521
31544
|
}
|
|
31522
31545
|
const animationActive = this.controller.updateAnimation(timestamp);
|
|
31523
|
-
this.
|
|
31524
|
-
this.renderer.render(this.scene, this.camera);
|
|
31525
|
-
this.renderViewCube();
|
|
31546
|
+
this.renderScene();
|
|
31526
31547
|
if (animationActive) {
|
|
31527
31548
|
this.requestRender();
|
|
31528
31549
|
}
|
|
31529
31550
|
}
|
|
31551
|
+
renderScene(includeViewCube = true) {
|
|
31552
|
+
if (includeViewCube) {
|
|
31553
|
+
this.viewCube.update(this.camera);
|
|
31554
|
+
}
|
|
31555
|
+
this.renderer.render(this.scene, this.camera);
|
|
31556
|
+
if (includeViewCube) {
|
|
31557
|
+
this.renderViewCube();
|
|
31558
|
+
}
|
|
31559
|
+
}
|
|
31530
31560
|
renderViewCube() {
|
|
31531
31561
|
const viewport = this.viewCube.getViewport();
|
|
31532
31562
|
const previousAutoClear = this.renderer.autoClear;
|
|
@@ -31694,6 +31724,10 @@ class Application {
|
|
|
31694
31724
|
this.assertNotDisposed();
|
|
31695
31725
|
this.getRenderer().resetCamera();
|
|
31696
31726
|
}
|
|
31727
|
+
takeScreenshot() {
|
|
31728
|
+
this.assertNotDisposed();
|
|
31729
|
+
return this.getRenderer().takeScreenshot();
|
|
31730
|
+
}
|
|
31697
31731
|
dispose() {
|
|
31698
31732
|
if (this.disposed) {
|
|
31699
31733
|
return;
|