@dreamcomposer/engine-types 0.0.60 → 0.0.62

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,12 @@
1
+ export interface GeometryTransform {
2
+ /**
3
+ * 3D world position of the origin of the object
4
+ * The origin of the object is always the bottom center
5
+ */
6
+ position: [number, number, number];
7
+ /**
8
+ * Euler angles in degree of the of the object.
9
+ * The rotation is around the object center.
10
+ */
11
+ rotation: [number, number, number];
12
+ }
@@ -0,0 +1,10 @@
1
+ import { GeometryTransform } from "../GeometryTransform";
2
+ import { FromEngineMessage } from "../post-messages";
3
+
4
+ /**
5
+ * Event object if the position or rotation of the geometry changed
6
+ */
7
+ export interface GeometryTransformChangeMessage
8
+ extends FromEngineMessage<"geometry-transform-change"> {
9
+ payload: GeometryTransform;
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamcomposer/engine-types",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "description": "The type definitions for messages from and to the engine",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -1,4 +1,3 @@
1
- import { AckMessage } from "./from-engine/AckMessage";
2
1
  import { CanvasImageUrlMessage } from "./from-engine/CanvasImageUrlMessage";
3
2
  import { EngineReadyMessage } from "./from-engine/EngineReadyMessage";
4
3
  import { KeyDownMessage } from "./from-engine/KeyDownMessage";
@@ -42,6 +41,12 @@ import { UpdateCameraPositionMessage } from "./to-engine/UpdateCameraPositionMes
42
41
  import { CameraPositionChangeMessage } from "./from-engine/CameraPositionChangeMessage";
43
42
  import { UpdateEnvironmentRotationMessage } from "./to-engine/UpdateEnvironmentRotationMessage";
44
43
  import { EnvironmentRotationChangedMessage } from "./from-engine/EnvironmentRotationChangedMessage";
44
+ import { UpdateGeometryTransformMessage } from "./to-engine/UpdateGeometryTransformMessage";
45
+ import { GeometryTransformChangeMessage } from "./from-engine/GeometryTransformChangeMessage";
46
+ import { SetInitialGeometryTransformMessage } from "./to-engine/SetInitialGeometryTransformMessage";
47
+ import { ResetGeometryTransformMessage } from "./to-engine/ResetGeometryTransformMessage";
48
+ import { PlaceGeometryOnGroundMessage } from "./to-engine/MoveGeometryToGroundMessage";
49
+ import { MouseEventMessage } from "./to-engine/MouseEventMessage";
45
50
 
46
51
  /**
47
52
  * A message sent from the engine to the embedder.
@@ -56,16 +61,10 @@ export interface FromEngineMessage<Channel> {
56
61
  */
57
62
  export interface ToEngineMessage<Channel> {
58
63
  channel: Channel;
59
- // /**
60
- // * The nonce is a randomly generated string that is re-send by the engine in
61
- // * the ack message.
62
- // */
63
- // nonce: string;
64
64
  payload?: unknown;
65
65
  }
66
66
 
67
67
  export type FromEnginePostMessage =
68
- | AckMessage
69
68
  | CanvasImageUrlMessage
70
69
  | DisplayLoadingUiMessage
71
70
  | EngineReadyMessage
@@ -77,11 +76,13 @@ export type FromEnginePostMessage =
77
76
  | PointerEventMessage
78
77
  | SetLoadingProgressMessage
79
78
  | CameraPositionChangeMessage
80
- | EnvironmentRotationChangedMessage;
79
+ | EnvironmentRotationChangedMessage
80
+ | GeometryTransformChangeMessage;
81
81
 
82
82
  export type ToEnginePostMessage =
83
83
  | DownloadScreenshotMessage
84
84
  | HighlightLayerMessage
85
+ | MouseEventMessage
85
86
  | ResetCameraPositionMessage
86
87
  | RotateToVectorMessage
87
88
  | UpdateCameraPositionMessage
@@ -110,6 +111,10 @@ export type ToEnginePostMessage =
110
111
  | RecenterSkeletonObjectsMessage
111
112
  | SetSkeletonStatesMessage
112
113
  | SetShadowPlaneVisibilityMessage
113
- | UpdateEnvironmentRotationMessage;
114
+ | UpdateEnvironmentRotationMessage
115
+ | UpdateGeometryTransformMessage
116
+ | SetInitialGeometryTransformMessage
117
+ | ResetGeometryTransformMessage
118
+ | PlaceGeometryOnGroundMessage;
114
119
 
115
120
  export type PostMessage = FromEnginePostMessage | ToEnginePostMessage;
@@ -0,0 +1,25 @@
1
+ import { ToEngineMessage } from "../post-messages";
2
+
3
+ /**
4
+ * Global mouse events from the embedder are sent to the engine to make sure
5
+ * that the engine can react to the correctly.
6
+ *
7
+ * E.g. when the user clicks and holds the mouse inside the iframe to rotate the
8
+ * model and then leaves the iframe with the mouse still pressed, the engine
9
+ * will not receive the corresponding mouseup event. This code will make sure
10
+ * that global mouse events are sent to the engine so that it can react
11
+ * accordingly.
12
+ */
13
+ export interface MouseEventMessage extends ToEngineMessage<"mouse-events"> {
14
+ payload: {
15
+ type: "mousedown" | "mouseup" | "mousemove";
16
+ /**
17
+ * The clientX coordinate, adjusted to the iframe's position.
18
+ */
19
+ clientX: number;
20
+ /**
21
+ * The clientY coordinate, adjusted to the iframe's position.
22
+ */
23
+ clientY: number;
24
+ };
25
+ }
@@ -0,0 +1,10 @@
1
+ import { ToEngineMessage } from "../post-messages";
2
+
3
+ /**
4
+ * Translates the geometry so its lowest part touches the ground.
5
+ * The current rotation of the object is not affected.
6
+ */
7
+ export interface PlaceGeometryOnGroundMessage
8
+ extends ToEngineMessage<"place-geometry-on-ground"> {
9
+ payload: { transitionDuration?: number };
10
+ }
@@ -0,0 +1,13 @@
1
+ import { GeometryTransform } from "../GeometryTransform";
2
+ import { ToEngineMessage } from "../post-messages";
3
+
4
+ /**
5
+ * Sets the geometry rotation and position to the initial transform values.
6
+ *
7
+ * If no initial transform was defined `{position: [0,0,0], rotation: [0,0,0]}`
8
+ * is used
9
+ */
10
+ export interface ResetGeometryTransformMessage
11
+ extends ToEngineMessage<"reset-geometry-transform"> {
12
+ payload: { transitionDuration?: number };
13
+ }
@@ -0,0 +1,12 @@
1
+ import { GeometryTransform } from "../GeometryTransform";
2
+ import { ToEngineMessage } from "../post-messages";
3
+
4
+ /**
5
+ * Defines the initial geometry rotation and position.
6
+ *
7
+ * The initial transform is used if the transform is reseted.
8
+ */
9
+ export interface SetInitialGeometryTransformMessage
10
+ extends ToEngineMessage<"set-initial-geometry-transform"> {
11
+ payload: { transform: GeometryTransform };
12
+ }
@@ -1,98 +1,102 @@
1
1
  import { ToEngineMessage } from "../post-messages";
2
2
 
3
+ export interface StageMapping {
4
+ /**
5
+ * The layer texture mapping
6
+ *
7
+ * If not provided only the surface material is visible by defaulting to `{x: -1, y: -1, width: 1, height: 1}`.
8
+ */
9
+ uvMapping?: {
10
+ /**
11
+ * The x position where the mapping begings.
12
+ *
13
+ * This is not a pixel value but a percentage (i.e., a value between `0`
14
+ * and `1`).
15
+ */
16
+ x: number;
17
+ /**
18
+ * The y position where the mapping begings.
19
+ *
20
+ * This is not a pixel value but a percentage (i.e., a value between `0`
21
+ * and `1`).
22
+ */
23
+ y: number;
24
+ /**
25
+ * The with of the mapping.
26
+ *
27
+ * This is not a pixel value but a percentage (i.e., a value between `0`
28
+ * and `1`).
29
+ */
30
+ width: number;
31
+ /**
32
+ * The height of the mapping.
33
+ *
34
+ * This is not a pixel value but a percentage (i.e., a value between `0`
35
+ * and `1`).
36
+ */
37
+ height: number;
38
+ };
39
+ /**
40
+ * The rotation of the mapping in degrees.
41
+ *
42
+ * Defaults to `0`.
43
+ */
44
+ rotation?: 0 | 90 | 180 | 270;
45
+ /**
46
+ * Defines if the stage should be visible or not.
47
+ *
48
+ * Defaults to `true`.
49
+ */
50
+ visible?: boolean;
51
+ /**
52
+ * Defines a sub area of the target geometry, where the stage will be displayed
53
+ *
54
+ * If no subMeshUVArea is defined, the whole area is used.
55
+ */
56
+ subMeshUVArea?: {
57
+ /**
58
+ * The x position where the target uv box begins.
59
+ *
60
+ * This is not a pixel value but a percentage (i.e., a value between `0`
61
+ * and `1`).
62
+ */
63
+ x: number;
64
+ /**
65
+ * The y position where the target uv box begins.
66
+ *
67
+ * This is not a pixel value but a percentage (i.e., a value between `0`
68
+ * and `1`).
69
+ */
70
+ y: number;
71
+ /**
72
+ * The width of target uv box
73
+ *
74
+ * This is not a pixel value but a percentage (i.e., a value between `0`
75
+ * and `1`).
76
+ */
77
+ width: number;
78
+ /**
79
+ * The height of target uv box
80
+ *
81
+ * This is not a pixel value but a percentage (i.e., a value between `0`
82
+ * and `1`).
83
+ */
84
+ height: number;
85
+ };
86
+ }
87
+
88
+ export interface StageMappings {
89
+ /**
90
+ * The name of the stage is the key and defined in the SetGeometryMessage.
91
+ */
92
+ [stageName: string]: StageMapping;
93
+ }
94
+
3
95
  /**
4
96
  * A message to set the stage mappings (i.e., how a texture is mapped to the
5
97
  * geometry).
6
98
  */
7
99
  export interface SetStageMappingsMessage
8
100
  extends ToEngineMessage<"set-stage-mappings"> {
9
- payload: {
10
- /**
11
- * The name of the stage is the key and defined in the SetGeometryMessage.
12
- */
13
- [stageName: string]: {
14
- /**
15
- * The layer texture mapping
16
- *
17
- * If not provided only the surface material is visible by defaulting to `{x: -1, y: -1, width: 1, height: 1}`.
18
- */
19
- uvMapping?: {
20
- /**
21
- * The x position where the mapping begings.
22
- *
23
- * This is not a pixel value but a percentage (i.e., a value between `0`
24
- * and `1`).
25
- */
26
- x: number;
27
- /**
28
- * The y position where the mapping begings.
29
- *
30
- * This is not a pixel value but a percentage (i.e., a value between `0`
31
- * and `1`).
32
- */
33
- y: number;
34
- /**
35
- * The with of the mapping.
36
- *
37
- * This is not a pixel value but a percentage (i.e., a value between `0`
38
- * and `1`).
39
- */
40
- width: number;
41
- /**
42
- * The height of the mapping.
43
- *
44
- * This is not a pixel value but a percentage (i.e., a value between `0`
45
- * and `1`).
46
- */
47
- height: number;
48
- };
49
- /**
50
- * The rotation of the mapping in degrees.
51
- *
52
- * Defaults to `0`.
53
- */
54
- rotation?: 0 | 90 | 180 | 270;
55
- /**
56
- * Defines if the stage should be visible or not.
57
- *
58
- * Defaults to `true`.
59
- */
60
- visible?: boolean;
61
- /**
62
- * Defines a sub area of the target geometry, where the stage will be displayed
63
- *
64
- * If no subMeshUVArea is defined, the whole area is used.
65
- */
66
- subMeshUVArea?: {
67
- /**
68
- * The x position where the target uv box begins.
69
- *
70
- * This is not a pixel value but a percentage (i.e., a value between `0`
71
- * and `1`).
72
- */
73
- x: number;
74
- /**
75
- * The y position where the target uv box begins.
76
- *
77
- * This is not a pixel value but a percentage (i.e., a value between `0`
78
- * and `1`).
79
- */
80
- y: number;
81
- /**
82
- * The width of target uv box
83
- *
84
- * This is not a pixel value but a percentage (i.e., a value between `0`
85
- * and `1`).
86
- */
87
- width: number;
88
- /**
89
- * The height of target uv box
90
- *
91
- * This is not a pixel value but a percentage (i.e., a value between `0`
92
- * and `1`).
93
- */
94
- height: number;
95
- };
96
- };
97
- };
101
+ payload: StageMappings;
98
102
  }
@@ -0,0 +1,12 @@
1
+ import { GeometryTransform } from "../GeometryTransform";
2
+ import { ToEngineMessage } from "../post-messages";
3
+
4
+ /**
5
+ * Translates and rotates the camera to a given values.
6
+ *
7
+ * The transform data can be partial information. In that case the other transform values are kept as is.
8
+ */
9
+ export interface UpdateGeometryTransformMessage
10
+ extends ToEngineMessage<"update-geometry-transform"> {
11
+ payload: { changes: Partial<GeometryTransform>; transitionDuration?: number };
12
+ }
@@ -1,24 +0,0 @@
1
- import { EngineState } from "../EngineState";
2
- import { FromEngineMessage } from "../post-messages";
3
-
4
- /**
5
- * Sent as a response for every message to the engine,
6
- */
7
- export interface AckMessage extends FromEngineMessage<"ack"> {
8
- /**
9
- * The state of the engine.
10
- */
11
- payload: EngineState;
12
- /**
13
- * The nonce that was sent with the message to the engine.
14
- *
15
- * Used to identify to what message the ack belongs.
16
- */
17
- nonce: string;
18
- /**
19
- * An error if the message to the engine could not be processed by the engine.
20
- */
21
- error?: {
22
- message: string;
23
- };
24
- }