@dreamcomposer/engine-types 0.0.61 → 0.0.63
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/package.json
CHANGED
package/post-messages.d.ts
CHANGED
|
@@ -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";
|
|
@@ -47,6 +46,7 @@ import { GeometryTransformChangeMessage } from "./from-engine/GeometryTransformC
|
|
|
47
46
|
import { SetInitialGeometryTransformMessage } from "./to-engine/SetInitialGeometryTransformMessage";
|
|
48
47
|
import { ResetGeometryTransformMessage } from "./to-engine/ResetGeometryTransformMessage";
|
|
49
48
|
import { PlaceGeometryOnGroundMessage } from "./to-engine/MoveGeometryToGroundMessage";
|
|
49
|
+
import { MouseEventMessage } from "./to-engine/MouseEventMessage";
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* A message sent from the engine to the embedder.
|
|
@@ -61,16 +61,10 @@ export interface FromEngineMessage<Channel> {
|
|
|
61
61
|
*/
|
|
62
62
|
export interface ToEngineMessage<Channel> {
|
|
63
63
|
channel: Channel;
|
|
64
|
-
// /**
|
|
65
|
-
// * The nonce is a randomly generated string that is re-send by the engine in
|
|
66
|
-
// * the ack message.
|
|
67
|
-
// */
|
|
68
|
-
// nonce: string;
|
|
69
64
|
payload?: unknown;
|
|
70
65
|
}
|
|
71
66
|
|
|
72
67
|
export type FromEnginePostMessage =
|
|
73
|
-
| AckMessage
|
|
74
68
|
| CanvasImageUrlMessage
|
|
75
69
|
| DisplayLoadingUiMessage
|
|
76
70
|
| EngineReadyMessage
|
|
@@ -88,6 +82,7 @@ export type FromEnginePostMessage =
|
|
|
88
82
|
export type ToEnginePostMessage =
|
|
89
83
|
| DownloadScreenshotMessage
|
|
90
84
|
| HighlightLayerMessage
|
|
85
|
+
| MouseEventMessage
|
|
91
86
|
| ResetCameraPositionMessage
|
|
92
87
|
| RotateToVectorMessage
|
|
93
88
|
| UpdateCameraPositionMessage
|
|
@@ -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
|
+
}
|
|
@@ -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
|
}
|
|
@@ -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
|
-
}
|