@dreamcomposer/engine-types 2.2.0 → 3.0.0

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.
@@ -0,0 +1,44 @@
1
+ import { CameraPosition } from "./Camera";
2
+
3
+ /**
4
+ * Which camera a screenshot is taken through.
5
+ *
6
+ * - `"current"` shoots what the viewer shows, from the camera the user moved.
7
+ * - `"initial"` shoots the view the project opens with: the engine's default
8
+ * viewing angle, the object's center as the target, and the distance that
9
+ * fits the object into the image.
10
+ * - An explicit position shoots that pose. Anything left out of it is framed
11
+ * the way `"initial"` would frame it, so an empty object is `"initial"`.
12
+ *
13
+ * Everything but `"current"` is rendered through a second camera, so the
14
+ * camera on screen keeps its position and the viewer shows the same frame
15
+ * before and after.
16
+ */
17
+ export type ScreenshotCamera = "current" | "initial" | Partial<CameraPosition>;
18
+
19
+ /**
20
+ * What every screenshot request shares, whatever is done with the image
21
+ * afterwards.
22
+ */
23
+ export interface ScreenshotPayloadBase {
24
+ /**
25
+ * The width of the screenshot. Defaults to the width of the canvas.
26
+ */
27
+ width?: number;
28
+ /**
29
+ * The height of the screenshot. Defaults to the height of the canvas.
30
+ */
31
+ height?: number;
32
+ /**
33
+ * Which camera to shoot through. Defaults to `"current"`.
34
+ */
35
+ camera?: ScreenshotCamera;
36
+ /**
37
+ * A PNG image that is overlaid on top of the screenshot.
38
+ *
39
+ * It is drawn at the screenshot's own size, so it belongs to the framing the
40
+ * shot is taken in - pair it with the default camera rather than with a
41
+ * position the overlay was not captured for.
42
+ */
43
+ overlayPNG?: ImageBitmap;
44
+ }
@@ -0,0 +1,27 @@
1
+ import { FromEngineMessage } from "../post-messages";
2
+
3
+ /**
4
+ * The image of a `take-screenshot` message.
5
+ *
6
+ * It is sent before the ack of that message.
7
+ */
8
+ export interface ScreenshotImageMessage extends FromEngineMessage<"screenshot-image"> {
9
+ payload: {
10
+ /**
11
+ * The `requestId` of the `take-screenshot` message this image belongs to.
12
+ */
13
+ requestId: string;
14
+ /**
15
+ * The height of the image.
16
+ */
17
+ height: number;
18
+ /**
19
+ * The width of the image.
20
+ */
21
+ width: number;
22
+ /**
23
+ * The base64 encoded image in the PNG format, as a data URL.
24
+ */
25
+ data: string;
26
+ };
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamcomposer/engine-types",
3
- "version": "2.2.0",
3
+ "version": "3.0.0",
4
4
  "description": "The type definitions for messages from and to the engine",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -1,5 +1,4 @@
1
1
  import { AckMessage } from "./from-engine/AckMessage";
2
- import { CanvasImageUrlMessage } from "./from-engine/CanvasImageUrlMessage";
3
2
  import { EngineAliveMessage } from "./from-engine/EngineAliveMessage";
4
3
  import { EngineErrorMessage } from "./from-engine/EngineErrorMessage";
5
4
  import { EngineReadyMessage } from "./from-engine/EngineReadyMessage";
@@ -58,6 +57,8 @@ import { SetAnnotationTagsMessage } from "./to-engine/SetAnnotationTagsMessage";
58
57
  import { SetCustomRequestHeaders } from "./to-engine/SetCustomRequestHeaders";
59
58
  import { SetObjectForScaleMessage } from "./to-engine/SetObjectForScaleMessage";
60
59
  import { ExportSceneMessage } from "./to-engine/ExportSceneMessage";
60
+ import { ScreenshotImageMessage } from "./from-engine/ScreenshotImageMessage";
61
+ import { TakeScreenshotMessage } from "./to-engine/TakeScreenshotMessage";
61
62
 
62
63
  /**
63
64
  * A message sent from the engine to the embedder.
@@ -82,7 +83,6 @@ export interface ToEngineMessage<Channel> {
82
83
 
83
84
  export type FromEnginePostMessage =
84
85
  | AckMessage
85
- | CanvasImageUrlMessage
86
86
  | DisplayLoadingUiMessage
87
87
  | EngineAliveMessage
88
88
  | EngineErrorMessage
@@ -97,10 +97,12 @@ export type FromEnginePostMessage =
97
97
  | CameraPositionChangeMessage
98
98
  | EnvironmentRotationChangedMessage
99
99
  | GeometryTransformChangeMessage
100
- | AnnotationTagPositionChangedMessage;
100
+ | AnnotationTagPositionChangedMessage
101
+ | ScreenshotImageMessage;
101
102
 
102
103
  export type ToEnginePostMessage =
103
104
  | DownloadScreenshotMessage
105
+ | TakeScreenshotMessage
104
106
  | HighlightLayerMessage
105
107
  | MouseEventMessage
106
108
  | ResetCameraPositionMessage
@@ -1,20 +1,18 @@
1
+ import { ScreenshotPayloadBase } from "../Screenshot";
1
2
  import { ToEngineMessage } from "../post-messages";
2
3
 
3
- export interface ScreenshotPayload {
4
+ export interface ScreenshotPayload extends ScreenshotPayloadBase {
5
+ /**
6
+ * The name of the file to download the screenshot as.
7
+ */
4
8
  fileName: string;
5
- overlayPNG?: ImageBitmap;
6
- width?: number;
7
- height?: number;
8
9
  }
9
10
 
10
11
  /**
11
- * Downloads a high-resolution screenshot of the current scene.
12
+ * Downloads a screenshot of the scene.
12
13
  *
13
14
  * The download starts automatically once the screenshot has been rendered.
14
15
  */
15
16
  export interface DownloadScreenshotMessage extends ToEngineMessage<"download-screenshot"> {
16
- /**
17
- * An empty object.
18
- */
19
17
  payload: ScreenshotPayload;
20
18
  }
@@ -0,0 +1,18 @@
1
+ import { ScreenshotPayloadBase } from "../Screenshot";
2
+ import { ToEngineMessage } from "../post-messages";
3
+
4
+ export interface TakeScreenshotPayload extends ScreenshotPayloadBase {
5
+ /**
6
+ * An id that the engine echoes back in the `screenshot-image` message, so
7
+ * that an embedder with several screenshots in flight can tell them apart.
8
+ */
9
+ requestId: string;
10
+ }
11
+
12
+ /**
13
+ * Renders a screenshot of the scene and sends the image back
14
+ * in a `screenshot-image` message, which arrives before the ack of this one.
15
+ */
16
+ export interface TakeScreenshotMessage extends ToEngineMessage<"take-screenshot"> {
17
+ payload: TakeScreenshotPayload;
18
+ }
@@ -1,26 +0,0 @@
1
- import { FromEngineMessage, ToEngineMessage } from "../post-messages";
2
-
3
- /**
4
- * A screenshot of the canvas that is sent to the embedder when the heatmap
5
- * collection is stopped.
6
- *
7
- * The screenshot is used by the embedder to draw the heatmap over it.
8
- */
9
- // TODO: This should have another name to make it clear it's related to the
10
- // heat map collection.
11
- export interface CanvasImageUrlMessage extends FromEngineMessage<"canvas-image-url"> {
12
- payload: {
13
- /**
14
- * The height of the image.
15
- */
16
- height: number;
17
- /**
18
- * The width of the image.
19
- */
20
- width: number;
21
- /**
22
- * The base64 encoded image in the PNG format.
23
- */
24
- data: string;
25
- };
26
- }