@dreamcomposer/engine-types 0.0.79 → 0.0.81
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/Label.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Label = {
|
|
2
|
+
/**
|
|
3
|
+
* Unique identifier for the label.
|
|
4
|
+
*/
|
|
5
|
+
id: string;
|
|
6
|
+
/**
|
|
7
|
+
* Normalized coordinates within the layer texture. The origin is the top left corner of the texture. The bottom right corner is `(1, 1)`.
|
|
8
|
+
*
|
|
9
|
+
* If the coordinates are outside of the texture, or that part of the texture is not mapped to the geometry, the label will not be displayed.
|
|
10
|
+
*/
|
|
11
|
+
textureCoordinates: {
|
|
12
|
+
/** Normalized x-position. `0` represents the left edge of the image. `1` the right edge */
|
|
13
|
+
x: number;
|
|
14
|
+
/** Normalized y-position. `0` represents teh top edge of the image. `1` the bottom edge */
|
|
15
|
+
y: number;
|
|
16
|
+
};
|
|
17
|
+
/** The color of the connector lines in HEX format without alpha (e.g., #AD86A3). If `undefined` black is used */
|
|
18
|
+
lineColor?: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Label } from "../Label";
|
|
2
|
+
import { FromEngineMessage } from "../post-messages";
|
|
3
|
+
|
|
4
|
+
export type AnchorPosition = {
|
|
5
|
+
/** 3D world position in meters */
|
|
6
|
+
worldPosition: { x: number; y: number; z: number };
|
|
7
|
+
/** Normalized screen position, where top left corner is `(0,0)` and bottom right `(1,1)` */
|
|
8
|
+
screenPosition: { x: number; y: number };
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Is fired every frame to notify the embedder of the new screen position of the label.
|
|
13
|
+
*/
|
|
14
|
+
export interface LabelPositionChangedMessage
|
|
15
|
+
extends FromEngineMessage<"label-position-changed"> {
|
|
16
|
+
payload: {
|
|
17
|
+
label: Label;
|
|
18
|
+
/** The anchor position that is directly attached to the object */
|
|
19
|
+
objectAnchorPosition: AnchorPosition;
|
|
20
|
+
/** The floating anchor position where the text label will be displayed */
|
|
21
|
+
labelAnchorPosition: AnchorPosition;
|
|
22
|
+
/** Normalized value where `0` is directly in front of the camera and `1` at the far end */
|
|
23
|
+
depth: number;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
package/package.json
CHANGED
package/post-messages.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ import { ResetGeometryTransformMessage } from "./to-engine/ResetGeometryTransfor
|
|
|
49
49
|
import { PlaceGeometryOnGroundMessage } from "./to-engine/MoveGeometryToGroundMessage";
|
|
50
50
|
import { MouseEventMessage } from "./to-engine/MouseEventMessage";
|
|
51
51
|
import { SetBackgroundImageMessage } from "./to-engine/SetBackgroundImageMessage";
|
|
52
|
+
import { LabelPositionChangedMessage } from "./from-engine/LabelPositionChangedMessage";
|
|
53
|
+
import { SetLabelsMessage } from "./to-engine/SetLabelsMessage";
|
|
52
54
|
|
|
53
55
|
/**
|
|
54
56
|
* A message sent from the engine to the embedder.
|
|
@@ -85,7 +87,8 @@ export type FromEnginePostMessage =
|
|
|
85
87
|
| SetLoadingProgressMessage
|
|
86
88
|
| CameraPositionChangeMessage
|
|
87
89
|
| EnvironmentRotationChangedMessage
|
|
88
|
-
| GeometryTransformChangeMessage
|
|
90
|
+
| GeometryTransformChangeMessage
|
|
91
|
+
| LabelPositionChangedMessage;
|
|
89
92
|
|
|
90
93
|
export type ToEnginePostMessage =
|
|
91
94
|
| DownloadScreenshotMessage
|
|
@@ -124,6 +127,7 @@ export type ToEnginePostMessage =
|
|
|
124
127
|
| UpdateGeometryTransformMessage
|
|
125
128
|
| SetInitialGeometryTransformMessage
|
|
126
129
|
| ResetGeometryTransformMessage
|
|
127
|
-
| PlaceGeometryOnGroundMessage
|
|
130
|
+
| PlaceGeometryOnGroundMessage
|
|
131
|
+
| SetLabelsMessage;
|
|
128
132
|
|
|
129
133
|
export type PostMessage = FromEnginePostMessage | ToEnginePostMessage;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Label } from "../Label";
|
|
2
|
+
import { ToEngineMessage } from "../post-messages";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Sets the labels that should be displayed in the scene.
|
|
6
|
+
*
|
|
7
|
+
* The engine only renders the label connector lines and sends the label screen positions to the
|
|
8
|
+
* embedder via `label-position-changed` message. The embedder is responsible for rendering the
|
|
9
|
+
* labels.
|
|
10
|
+
*/
|
|
11
|
+
export interface SetLabelsMessage extends ToEngineMessage<"set-labels"> {
|
|
12
|
+
payload: Label[];
|
|
13
|
+
}
|